mirror of
https://github.com/gophish/gophish
synced 2024-11-14 16:27:23 +00:00
Initial commit - adding db migration as well as the logic to add the payload
This commit is contained in:
parent
da4d108908
commit
94e43fe557
7 changed files with 68 additions and 4 deletions
|
@ -1,11 +1,13 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/gophish/gophish/auth"
|
||||
|
@ -120,7 +122,12 @@ func PhishTracker(w http.ResponseWriter, r *http.Request) {
|
|||
// PhishHandler handles incoming client connections and registers the associated actions performed
|
||||
// (such as clicked link, etc.)
|
||||
func PhishHandler(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
Logger.Println(err)
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
id := r.Form.Get("rid")
|
||||
if id == "" {
|
||||
http.NotFound(w, r)
|
||||
|
@ -140,7 +147,32 @@ func PhishHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
Logger.Println(err)
|
||||
}
|
||||
c.AddEvent(models.Event{Email: rs.Email, Message: models.EVENT_CLICKED})
|
||||
switch {
|
||||
case r.Method == "GET":
|
||||
err = c.AddEvent(models.Event{Email: rs.Email, Message: models.EVENT_CLICKED})
|
||||
if err != nil {
|
||||
Logger.Println(err)
|
||||
}
|
||||
case r.Method == "POST":
|
||||
// If data was POST'ed, let's record it
|
||||
// Store the data in an event
|
||||
d := struct {
|
||||
Payload url.Values `json:"payload"`
|
||||
Browser map[string]string `json:"browser"`
|
||||
}{
|
||||
Payload: r.Form,
|
||||
}
|
||||
rj, err := json.Marshal(d)
|
||||
if err != nil {
|
||||
Logger.Println(err)
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
c.AddEvent(models.Event{Email: rs.Email, Message: models.EVENT_DATA_SUBMIT, Details: string(rj)})
|
||||
if err != nil {
|
||||
Logger.Println(err)
|
||||
}
|
||||
}
|
||||
w.Write([]byte(p.HTML))
|
||||
}
|
||||
|
||||
|
|
5
db/dbconf.yml
Normal file
5
db/dbconf.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
production:
|
||||
driver: sqlite3
|
||||
open: gophish.db
|
||||
dialect: sqlite3
|
||||
import: github.com/mattn/go-sqlite3
|
8
db/migrations/20160131153104_0.1.2_add_event_details.sql
Normal file
8
db/migrations/20160131153104_0.1.2_add_event_details.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
-- +goose Up
|
||||
-- SQL in section 'Up' is executed when this migration is applied
|
||||
ALTER TABLE events ADD COLUMN details BLOB;
|
||||
|
||||
-- +goose Down
|
||||
-- SQL section 'Down' is executed when this migration is rolled back
|
||||
|
|
@ -108,6 +108,7 @@ type Event struct {
|
|||
Email string `json:"email"`
|
||||
Time time.Time `json:"time"`
|
||||
Message string `json:"message"`
|
||||
Details string `json:"details"`
|
||||
}
|
||||
|
||||
// GetCampaigns returns the campaigns owned by the given user.
|
||||
|
|
|
@ -33,6 +33,7 @@ const (
|
|||
EVENT_SENDING_ERROR string = "Error Sending Email"
|
||||
EVENT_OPENED string = "Email Opened"
|
||||
EVENT_CLICKED string = "Clicked Link"
|
||||
EVENT_DATA_SUBMIT string = "Submitted Data"
|
||||
STATUS_SUCCESS string = "Success"
|
||||
STATUS_UNKNOWN string = "Unknown"
|
||||
ERROR string = "Error"
|
||||
|
|
8
static/css/main.css
vendored
8
static/css/main.css
vendored
|
@ -433,3 +433,11 @@ table.dataTable thead .sorting_desc:after {
|
|||
color:#999999;
|
||||
font-style:italic;
|
||||
}
|
||||
.timeline-event-details {
|
||||
font-size:16px;
|
||||
margin-top:5px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.timeline-event-details>.table-responsive{
|
||||
display:none;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,12 @@ var statuses = {
|
|||
label: "label-default",
|
||||
icon: "fa-times"
|
||||
},
|
||||
"Submitted Data":{
|
||||
slice: "ct-slice-donut-clicked",
|
||||
legend: "ct-legend-clicked",
|
||||
label: "label-danger",
|
||||
icon: "fa-exclamation"
|
||||
},
|
||||
"Unknown": {
|
||||
slice: "ct-slice-donut-error",
|
||||
legend: "ct-legend-error",
|
||||
|
@ -122,8 +128,11 @@ function renderTimeline(data) {
|
|||
' <div class="timeline-icon ' + statuses[event.message].label + '">' +
|
||||
' <i class="fa ' + statuses[event.message].icon + '"></i></div>' +
|
||||
' <div class="timeline-message">' + event.message +
|
||||
' <span class="timeline-date">' + moment(event.time).format('MMMM Do YYYY h:mm') + '</span></div>'
|
||||
results += '</div>'
|
||||
' <span class="timeline-date">' + moment(event.time).format('MMMM Do YYYY h:mm') + '</span>'
|
||||
if (event.details) {
|
||||
results += '<div class="timeline-event-details"><i class="fa fa-caret-right"></i> View Details</div>'
|
||||
}
|
||||
results += '</div></div>'
|
||||
}
|
||||
})
|
||||
results += '</div></div>'
|
||||
|
|
Loading…
Reference in a new issue