Skip to content

Commit

Permalink
update hotpatch server to have more descriptive text
Browse files Browse the repository at this point in the history
  • Loading branch information
breadchris committed Dec 15, 2021
1 parent ee9655e commit 6187edd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tools/log4shell/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ func hotpatchCommand(c *cli.Context) error {

log.Info().
Msg("Starting Log4Shell hotpatch LDAP and payload servers")
log.Info().Msgf("Once both servers have started, use payload string: '${jndi:ldap://%s:1389/a}' to hotpatch", ip)
log.Info().
Msgf("Once both servers have started, use payload string: '%s' to hotpatch your servers.", payload)

hotpatchServer.Start()
hotpatchPayloadServer.Start()

Expand Down
14 changes: 12 additions & 2 deletions tools/log4shell/patch/hotpatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,22 @@ func (s *HotpatchLDAPServer) Stop() {
func (s *HotpatchLDAPServer) createSearchResultEntry(req ldapmsg.SearchRequest) ldapmsg.SearchResultEntry {
resolvedJNDICodebase := ldapmsg.AttributeValue(s.payloadServerUrl)

payloadClassName := ldapmsg.AttributeValue("Log4ShellHotpatch")

payloadDescription := fmt.Sprintf(
"attempting to patch Log4Shell vulnerability with payload hosted on: %s/%s.class",
resolvedJNDICodebase,
payloadClassName,
)

classNameAttribute := ldapmsg.AttributeValue(payloadDescription)

e := ldapserver.NewSearchResultEntry("cn=log4shell-hotpatch, " + string(req.BaseObject()))
e.AddAttribute("cn", "log4shell-hotpatch")
e.AddAttribute("javaClassName", "attempting to patch Log4Shell vulnerability...")
e.AddAttribute("javaClassName", classNameAttribute)
e.AddAttribute("javaCodeBase", resolvedJNDICodebase)
e.AddAttribute("objectclass", "javaNamingReference")
e.AddAttribute("javaFactory", "Log4ShellHotpatch")
e.AddAttribute("javaFactory", payloadClassName)
return e
}

Expand Down
2 changes: 1 addition & 1 deletion tools/log4shell/util/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ParseHostAndPortFromUrlString(urlStr string) (host string, port int64, err
return
}

host = parsedUrl.Host
host = parsedUrl.Hostname()
port, err = strconv.ParseInt(parsedUrl.Port(), 10, 0)
return
}

0 comments on commit 6187edd

Please sign in to comment.