Update the TCP server and HTTP server mixins
This commit is contained in:
parent
2e4f04a804
commit
0ab97b858f
|
@ -118,31 +118,17 @@ module Exploit::Remote::HttpServer
|
||||||
|
|
||||||
check_dependencies
|
check_dependencies
|
||||||
|
|
||||||
comm = datastore['ListenerComm']
|
|
||||||
if (comm.to_s == "local")
|
|
||||||
comm = ::Rex::Socket::Comm::Local
|
|
||||||
else
|
|
||||||
comm = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# Default the server host and port to what is required by the mixin.
|
|
||||||
opts = {
|
|
||||||
'ServerHost' => datastore['SRVHOST'],
|
|
||||||
'ServerPort' => datastore['SRVPORT'],
|
|
||||||
'Comm' => comm
|
|
||||||
}.update(opts)
|
|
||||||
|
|
||||||
# Start a new HTTP server service.
|
# Start a new HTTP server service.
|
||||||
self.service = Rex::ServiceManager.start(
|
self.service = Rex::ServiceManager.start(
|
||||||
Rex::Proto::Http::Server,
|
Rex::Proto::Http::Server,
|
||||||
opts['ServerPort'].to_i,
|
(opts['ServerPort'] || bindport).to_i,
|
||||||
opts['ServerHost'],
|
opts['ServerHost'] || bindhost,
|
||||||
datastore['SSL'], # XXX: Should be in opts, need to test this
|
datastore['SSL'], # XXX: Should be in opts, need to test this
|
||||||
{
|
{
|
||||||
'Msf' => framework,
|
'Msf' => framework,
|
||||||
'MsfExploit' => self,
|
'MsfExploit' => self,
|
||||||
},
|
},
|
||||||
opts['Comm'],
|
opts['Comm'] || _determine_server_comm(opts['ServerHost'] || bindhost),
|
||||||
datastore['SSLCert'],
|
datastore['SSLCert'],
|
||||||
datastore['SSLCompression'],
|
datastore['SSLCompression'],
|
||||||
datastore['SSLCipher'],
|
datastore['SSLCipher'],
|
||||||
|
@ -172,19 +158,10 @@ module Exploit::Remote::HttpServer
|
||||||
print_status("Intentionally using insecure SSL compression. Your operating system might not respect this!")
|
print_status("Intentionally using insecure SSL compression. Your operating system might not respect this!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print_status("Using URL: #{proto}://#{srvhost_addr}#{uopts['Path']}")
|
||||||
|
|
||||||
print_status("Using URL: #{proto}://#{opts['ServerHost']}:#{opts['ServerPort']}#{uopts['Path']}")
|
add_robots_resource if datastore['SendRobots']
|
||||||
|
|
||||||
if opts['ServerHost'] == '0.0.0.0'
|
|
||||||
print_status("Local IP: #{proto}://#{Rex::Socket.source_address('1.2.3.4')}:#{opts['ServerPort']}#{uopts['Path']}")
|
|
||||||
end
|
|
||||||
|
|
||||||
if datastore['SendRobots']
|
|
||||||
add_robots_resource
|
|
||||||
end
|
|
||||||
|
|
||||||
add_resource(uopts)
|
add_resource(uopts)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_robots_resource
|
def add_robots_resource
|
||||||
|
|
|
@ -26,7 +26,6 @@ module Exploit::Remote::TcpServer
|
||||||
|
|
||||||
register_advanced_options(
|
register_advanced_options(
|
||||||
[
|
[
|
||||||
OptString.new('ListenerComm', [ false, 'The specific communication channel to use for this service']),
|
|
||||||
OptBool.new('SSLCompression', [ false, 'Enable SSL/TLS-level compression', false ]),
|
OptBool.new('SSLCompression', [ false, 'Enable SSL/TLS-level compression', false ]),
|
||||||
OptString.new('SSLCipher', [ false, 'String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"']),
|
OptString.new('SSLCipher', [ false, 'String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"']),
|
||||||
Opt::SSLVersion
|
Opt::SSLVersion
|
||||||
|
@ -56,11 +55,11 @@ module Exploit::Remote::TcpServer
|
||||||
#
|
#
|
||||||
def start_service(opts = {})
|
def start_service(opts = {})
|
||||||
begin
|
begin
|
||||||
comm = _determine_server_comm(srvhost)
|
comm = _determine_server_comm(bindhost)
|
||||||
|
|
||||||
self.service = Rex::Socket::TcpServer.create({
|
self.service = Rex::Socket::TcpServer.create({
|
||||||
'LocalHost' => srvhost,
|
'LocalHost' => bindhost,
|
||||||
'LocalPort' => srvport,
|
'LocalPort' => bindport,
|
||||||
'SSL' => ssl,
|
'SSL' => ssl,
|
||||||
'SSLCert' => ssl_cert,
|
'SSLCert' => ssl_cert,
|
||||||
'SSLCipher' => ssl_cipher,
|
'SSLCipher' => ssl_cipher,
|
||||||
|
@ -92,7 +91,7 @@ module Exploit::Remote::TcpServer
|
||||||
print_line(" ")
|
print_line(" ")
|
||||||
print_error("Could not start the TCP server: #{e}.")
|
print_error("Could not start the TCP server: #{e}.")
|
||||||
print_error(
|
print_error(
|
||||||
"This module is configured to use a privileged TCP port (#{srvport}). " +
|
"This module is configured to use a privileged TCP port (#{bindport}). " +
|
||||||
"On Unix systems, only the root user account is allowed to bind to privileged ports." +
|
"On Unix systems, only the root user account is allowed to bind to privileged ports." +
|
||||||
"Please run the framework as root to use this module."
|
"Please run the framework as root to use this module."
|
||||||
)
|
)
|
||||||
|
@ -107,8 +106,8 @@ module Exploit::Remote::TcpServer
|
||||||
end
|
end
|
||||||
|
|
||||||
via = via_string(comm)
|
via = via_string(comm)
|
||||||
hoststr = Rex::Socket.is_ipv6?(srvhost) ? "[#{srvhost}]" : srvhost
|
hoststr = Rex::Socket.is_ipv6?(bindhost) ? "[#{bindhost}]" : bindhost
|
||||||
print_status("Started service listener on #{hoststr}:#{srvport} #{via}")
|
print_status("Started service listener on #{hoststr}:#{bindport} #{via}")
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue