mirror of https://github.com/gophish/gophish
Added initial functionality to allow arbitrary events
parent
b684fb4ebd
commit
c8abed4896
|
@ -112,6 +112,7 @@ func (ps *PhishingServer) registerRoutes() {
|
||||||
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fileServer))
|
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fileServer))
|
||||||
router.HandleFunc("/track", ps.TrackHandler)
|
router.HandleFunc("/track", ps.TrackHandler)
|
||||||
router.HandleFunc("/robots.txt", ps.RobotsHandler)
|
router.HandleFunc("/robots.txt", ps.RobotsHandler)
|
||||||
|
router.HandleFunc("/arbevent", ps.ArbitraryEventHandler)
|
||||||
router.HandleFunc("/{path:.*}/track", ps.TrackHandler)
|
router.HandleFunc("/{path:.*}/track", ps.TrackHandler)
|
||||||
router.HandleFunc("/{path:.*}/report", ps.ReportHandler)
|
router.HandleFunc("/{path:.*}/report", ps.ReportHandler)
|
||||||
router.HandleFunc("/report", ps.ReportHandler)
|
router.HandleFunc("/report", ps.ReportHandler)
|
||||||
|
@ -126,6 +127,32 @@ func (ps *PhishingServer) registerRoutes() {
|
||||||
ps.server.Handler = phishHandler
|
ps.server.Handler = phishHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ArbitraryEventHandler deals with arbitrary events - for example opening Word documents, secondary links, etc
|
||||||
|
func (ps *PhishingServer) ArbitraryEventHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
r, err := setupContext(r)
|
||||||
|
if err != nil {
|
||||||
|
// Log the error if it wasn't something we can safely ignore
|
||||||
|
if err != ErrInvalidRequest && err != ErrCampaignComplete {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rs := ctx.Get(r, "result").(models.Result)
|
||||||
|
d := ctx.Get(r, "details").(models.EventDetails)
|
||||||
|
|
||||||
|
err = rs.HandleArbitraryEvent(d)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
} else {
|
||||||
|
|
||||||
|
w.Write([]byte("Event received"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TrackHandler tracks emails as they are opened, updating the status for the given Result
|
// TrackHandler tracks emails as they are opened, updating the status for the given Result
|
||||||
func (ps *PhishingServer) TrackHandler(w http.ResponseWriter, r *http.Request) {
|
func (ps *PhishingServer) TrackHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
r, err := setupContext(r)
|
r, err := setupContext(r)
|
||||||
|
|
|
@ -40,25 +40,26 @@ const InitialAdminPassword = "GOPHISH_INITIAL_ADMIN_PASSWORD"
|
||||||
const InitialAdminApiToken = "GOPHISH_INITIAL_ADMIN_API_TOKEN"
|
const InitialAdminApiToken = "GOPHISH_INITIAL_ADMIN_API_TOKEN"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CampaignInProgress string = "In progress"
|
CampaignInProgress string = "In progress"
|
||||||
CampaignQueued string = "Queued"
|
CampaignQueued string = "Queued"
|
||||||
CampaignCreated string = "Created"
|
CampaignCreated string = "Created"
|
||||||
CampaignEmailsSent string = "Emails Sent"
|
CampaignEmailsSent string = "Emails Sent"
|
||||||
CampaignComplete string = "Completed"
|
CampaignComplete string = "Completed"
|
||||||
EventSent string = "Email Sent"
|
EventSent string = "Email Sent"
|
||||||
EventSendingError string = "Error Sending Email"
|
EventSendingError string = "Error Sending Email"
|
||||||
EventOpened string = "Email Opened"
|
EventOpened string = "Email Opened"
|
||||||
EventClicked string = "Clicked Link"
|
EventClicked string = "Clicked Link"
|
||||||
EventDataSubmit string = "Submitted Data"
|
EventDataSubmit string = "Submitted Data"
|
||||||
EventReported string = "Email Reported"
|
EventReported string = "Email Reported"
|
||||||
EventProxyRequest string = "Proxied request"
|
EventArbitraryEvent string = "Arbitrary Event"
|
||||||
StatusSuccess string = "Success"
|
EventProxyRequest string = "Proxied request"
|
||||||
StatusQueued string = "Queued"
|
StatusSuccess string = "Success"
|
||||||
StatusSending string = "Sending"
|
StatusQueued string = "Queued"
|
||||||
StatusUnknown string = "Unknown"
|
StatusSending string = "Sending"
|
||||||
StatusScheduled string = "Scheduled"
|
StatusUnknown string = "Unknown"
|
||||||
StatusRetry string = "Retrying"
|
StatusScheduled string = "Scheduled"
|
||||||
Error string = "Error"
|
StatusRetry string = "Retrying"
|
||||||
|
Error string = "Error"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Flash is used to hold flash information for use in templates.
|
// Flash is used to hold flash information for use in templates.
|
||||||
|
|
|
@ -3,6 +3,7 @@ package models
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
@ -135,6 +136,24 @@ func (r *Result) HandleFormSubmit(details EventDetails) error {
|
||||||
return db.Save(r).Error
|
return db.Save(r).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HandleArbitraryEvent updates a Result with an arbitrary event (e.g Word document opened, secondary link clicked)
|
||||||
|
func (r *Result) HandleArbitraryEvent(details EventDetails) error {
|
||||||
|
|
||||||
|
EventTitle := details.Payload.Get("title")
|
||||||
|
|
||||||
|
if EventTitle == "" {
|
||||||
|
return errors.New("No title supplied for arbitrary event")
|
||||||
|
}
|
||||||
|
|
||||||
|
event, err := r.createEvent(EventArbitraryEvent, details)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r.Status = EventTitle
|
||||||
|
r.ModifiedDate = event.Time
|
||||||
|
return db.Save(r).Error
|
||||||
|
}
|
||||||
|
|
||||||
// HandleEmailReport updates a Result in the case where they report a simulated
|
// HandleEmailReport updates a Result in the case where they report a simulated
|
||||||
// phishing email using the HTTP handler.
|
// phishing email using the HTTP handler.
|
||||||
func (r *Result) HandleEmailReport(details EventDetails) error {
|
func (r *Result) HandleEmailReport(details EventDetails) error {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue