Update the TCP server and HTTP server mixins

This commit is contained in:
Spencer McIntyre 2022-02-24 17:13:53 -05:00
parent 2e4f04a804
commit 0ab97b858f
2 changed files with 11 additions and 35 deletions

View File

@ -118,31 +118,17 @@ module Exploit::Remote::HttpServer
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.
self.service = Rex::ServiceManager.start(
Rex::Proto::Http::Server,
opts['ServerPort'].to_i,
opts['ServerHost'],
(opts['ServerPort'] || bindport).to_i,
opts['ServerHost'] || bindhost,
datastore['SSL'], # XXX: Should be in opts, need to test this
{
'Msf' => framework,
'MsfExploit' => self,
},
opts['Comm'],
opts['Comm'] || _determine_server_comm(opts['ServerHost'] || bindhost),
datastore['SSLCert'],
datastore['SSLCompression'],
datastore['SSLCipher'],
@ -172,19 +158,10 @@ module Exploit::Remote::HttpServer
print_status("Intentionally using insecure SSL compression. Your operating system might not respect this!")
end
print_status("Using URL: #{proto}://#{srvhost_addr}#{uopts['Path']}")
print_status("Using URL: #{proto}://#{opts['ServerHost']}:#{opts['ServerPort']}#{uopts['Path']}")
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_robots_resource if datastore['SendRobots']
add_resource(uopts)
end
def add_robots_resource

View File

@ -26,7 +26,6 @@ module Exploit::Remote::TcpServer
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 ]),
OptString.new('SSLCipher', [ false, 'String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"']),
Opt::SSLVersion
@ -56,11 +55,11 @@ module Exploit::Remote::TcpServer
#
def start_service(opts = {})
begin
comm = _determine_server_comm(srvhost)
comm = _determine_server_comm(bindhost)
self.service = Rex::Socket::TcpServer.create({
'LocalHost' => srvhost,
'LocalPort' => srvport,
'LocalHost' => bindhost,
'LocalPort' => bindport,
'SSL' => ssl,
'SSLCert' => ssl_cert,
'SSLCipher' => ssl_cipher,
@ -92,7 +91,7 @@ module Exploit::Remote::TcpServer
print_line(" ")
print_error("Could not start the TCP server: #{e}.")
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." +
"Please run the framework as root to use this module."
)
@ -107,8 +106,8 @@ module Exploit::Remote::TcpServer
end
via = via_string(comm)
hoststr = Rex::Socket.is_ipv6?(srvhost) ? "[#{srvhost}]" : srvhost
print_status("Started service listener on #{hoststr}:#{srvport} #{via}")
hoststr = Rex::Socket.is_ipv6?(bindhost) ? "[#{bindhost}]" : bindhost
print_status("Started service listener on #{hoststr}:#{bindport} #{via}")
end
#