diff --git a/controllers/route.go b/controllers/route.go index 5276811f..78a466e7 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -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)) } diff --git a/db/dbconf.yml b/db/dbconf.yml new file mode 100644 index 00000000..819cc99a --- /dev/null +++ b/db/dbconf.yml @@ -0,0 +1,5 @@ +production: + driver: sqlite3 + open: gophish.db + dialect: sqlite3 + import: github.com/mattn/go-sqlite3 diff --git a/db/migrations/20160131153104_0.1.2_add_event_details.sql b/db/migrations/20160131153104_0.1.2_add_event_details.sql new file mode 100644 index 00000000..e8cc90f1 --- /dev/null +++ b/db/migrations/20160131153104_0.1.2_add_event_details.sql @@ -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 + diff --git a/models/campaign.go b/models/campaign.go index f4706913..b813d456 100644 --- a/models/campaign.go +++ b/models/campaign.go @@ -109,6 +109,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. diff --git a/models/models.go b/models/models.go index e4907f8d..6d4e50ce 100644 --- a/models/models.go +++ b/models/models.go @@ -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_SENDING string = "Sending" STATUS_UNKNOWN string = "Unknown" diff --git a/static/css/main.css b/static/css/main.css index 4c6c4656..64c02f39 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -433,3 +433,18 @@ 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; +} +.timeline-event-details{ + margin-top: 10px; + margin-bottom: 10px; +} +.timeline-event-table{ + display:none; +} diff --git a/static/js/app/campaign_results.js b/static/js/app/campaign_results.js index 74f01bc2..efddfd36 100644 --- a/static/js/app/campaign_results.js +++ b/static/js/app/campaign_results.js @@ -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", @@ -83,14 +89,16 @@ function exportAsCSV(scope) { exportHTML = $("#exportButton").html() var csvScope = null switch (scope) { - case "results": - csvScope = campaign.results - break; - case "events": - csvScope = campaign.timeline - break; + case "results": + csvScope = campaign.results + break; + case "events": + csvScope = campaign.timeline + break; + } + if (!csvScope) { + return } - if (!csvScope){return} $("#exportButton").html('') var csvString = Papa.unparse(csvScope, {}) var csvData = new Blob([csvString], { @@ -128,8 +136,26 @@ function renderTimeline(data) { '
' + ' ' - results += '' + ' ' + moment(event.time).format('MMMM Do YYYY h:mm') + '' + if (event.details) { + results += 'Parameter | Value(s) |
---|---|
' + param + ' | ' + results += '' + details.payload[param] + ' | ' + results += '