Proxychains bug fixes.
Removed UDP port scans from proxychains. Fixed bug where running nmap through proxychains as sudo wouldn't work.
This commit is contained in:
parent
49b2874390
commit
6cd6955a0d
14
autorecon.py
14
autorecon.py
|
@ -183,8 +183,8 @@ async def port_scan(plugin, target):
|
||||||
target.ports['tcp'] = ','.join(config['ports']['tcp'])
|
target.ports['tcp'] = ','.join(config['ports']['tcp'])
|
||||||
if config['ports']['udp']:
|
if config['ports']['udp']:
|
||||||
target.ports['udp'] = ','.join(config['ports']['udp'])
|
target.ports['udp'] = ','.join(config['ports']['udp'])
|
||||||
if plugin.type is None:
|
if plugin.specific_ports is False:
|
||||||
warn('Port scan {bblue}' + plugin.name + ' {green}(' + plugin.slug + '){rst} does not have a type set, and --ports was used. Skipping.')
|
warn('Port scan {bblue}' + plugin.name + ' {green}(' + plugin.slug + '){rst} cannot be used to scan specific ports, and --ports was used. Skipping.')
|
||||||
return {'type':'port', 'plugin':plugin, 'result':[]}
|
return {'type':'port', 'plugin':plugin, 'result':[]}
|
||||||
else:
|
else:
|
||||||
if plugin.type == 'tcp' and not config['ports']['tcp']:
|
if plugin.type == 'tcp' and not config['ports']['tcp']:
|
||||||
|
@ -278,7 +278,7 @@ async def service_scan(plugin, service):
|
||||||
addressv6 = '[' + addressv6 + ']'
|
addressv6 = '[' + addressv6 + ']'
|
||||||
ipaddressv6 = '[' + ipaddressv6 + ']'
|
ipaddressv6 = '[' + ipaddressv6 + ']'
|
||||||
|
|
||||||
if config['proxychains']:
|
if config['proxychains'] and protocol == 'tcp':
|
||||||
nmap_extra += ' -sT'
|
nmap_extra += ' -sT'
|
||||||
|
|
||||||
tag = service.tag() + '/' + plugin.slug
|
tag = service.tag() + '/' + plugin.slug
|
||||||
|
@ -391,6 +391,9 @@ async def scan_target(target):
|
||||||
match = re.search('(?P<protocol>(tcp|udp))\/(?P<port>\d+)\/(?P<service>[\w\-\/]+)\/(?P<secure>secure|insecure)', forced_service)
|
match = re.search('(?P<protocol>(tcp|udp))\/(?P<port>\d+)\/(?P<service>[\w\-\/]+)\/(?P<secure>secure|insecure)', forced_service)
|
||||||
if match:
|
if match:
|
||||||
protocol = match.group('protocol')
|
protocol = match.group('protocol')
|
||||||
|
if config['proxychains'] and protocol == 'udp':
|
||||||
|
error('The service ' + forced_service + ' uses UDP and --proxychains is enabled. Skipping.')
|
||||||
|
continue
|
||||||
port = int(match.group('port'))
|
port = int(match.group('port'))
|
||||||
service = match.group('service')
|
service = match.group('service')
|
||||||
secure = True if match.group('secure') == 'secure' else False
|
secure = True if match.group('secure') == 'secure' else False
|
||||||
|
@ -408,6 +411,9 @@ async def scan_target(target):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
for plugin in target.autorecon.plugin_types['port']:
|
for plugin in target.autorecon.plugin_types['port']:
|
||||||
|
if config['proxychains'] and plugin.type == 'udp':
|
||||||
|
continue
|
||||||
|
|
||||||
plugin_tag_set = set(plugin.tags)
|
plugin_tag_set = set(plugin.tags)
|
||||||
|
|
||||||
matching_tags = False
|
matching_tags = False
|
||||||
|
@ -503,7 +509,7 @@ async def scan_target(target):
|
||||||
addressv6 = '[' + addressv6 + ']'
|
addressv6 = '[' + addressv6 + ']'
|
||||||
ipaddressv6 = '[' + ipaddressv6 + ']'
|
ipaddressv6 = '[' + ipaddressv6 + ']'
|
||||||
|
|
||||||
if config['proxychains']:
|
if config['proxychains'] and protocol == 'tcp':
|
||||||
nmap_extra += ' -sT'
|
nmap_extra += ' -sT'
|
||||||
|
|
||||||
service_match = False
|
service_match = False
|
||||||
|
|
|
@ -95,6 +95,7 @@ class PortScan(Plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.type = None
|
self.type = None
|
||||||
|
self.specific_ports = False
|
||||||
|
|
||||||
async def run(self, target):
|
async def run(self, target):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -307,6 +308,12 @@ class AutoRecon(object):
|
||||||
fail('Error: the plugin "' + plugin.name + '" in ' + filename + ' needs either a "manual" function, a "run" coroutine, or both.', file=sys.stderr)
|
fail('Error: the plugin "' + plugin.name + '" in ' + filename + ' needs either a "manual" function, a "run" coroutine, or both.', file=sys.stderr)
|
||||||
|
|
||||||
if issubclass(plugin.__class__, PortScan):
|
if issubclass(plugin.__class__, PortScan):
|
||||||
|
if plugin.type is None:
|
||||||
|
fail('Error: the PortScan plugin "' + plugin.name + '" in ' + filename + ' requires a type (either tcp or udp).')
|
||||||
|
else:
|
||||||
|
plugin.type = plugin.type.lower()
|
||||||
|
if plugin.type not in ['tcp', 'udp']:
|
||||||
|
fail('Error: the PortScan plugin "' + plugin.name + '" in ' + filename + ' has an invalid type (should be tcp or udp).')
|
||||||
self.plugin_types["port"].append(plugin)
|
self.plugin_types["port"].append(plugin)
|
||||||
elif issubclass(plugin.__class__, ServiceScan):
|
elif issubclass(plugin.__class__, ServiceScan):
|
||||||
self.plugin_types["service"].append(plugin)
|
self.plugin_types["service"].append(plugin)
|
||||||
|
|
|
@ -51,10 +51,11 @@ class Target:
|
||||||
addressv6 = '[' + addressv6 + ']'
|
addressv6 = '[' + addressv6 + ']'
|
||||||
ipaddressv6 = '[' + ipaddressv6 + ']'
|
ipaddressv6 = '[' + ipaddressv6 + ']'
|
||||||
|
|
||||||
|
plugin = inspect.currentframe().f_back.f_locals['self']
|
||||||
|
|
||||||
if config['proxychains']:
|
if config['proxychains']:
|
||||||
nmap_extra += ' -sT'
|
nmap_extra += ' -sT'
|
||||||
|
|
||||||
plugin = inspect.currentframe().f_back.f_locals['self']
|
|
||||||
cmd = e(cmd)
|
cmd = e(cmd)
|
||||||
tag = plugin.slug
|
tag = plugin.slug
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ class Service:
|
||||||
addressv6 = '[' + addressv6 + ']'
|
addressv6 = '[' + addressv6 + ']'
|
||||||
ipaddressv6 = '[' + ipaddressv6 + ']'
|
ipaddressv6 = '[' + ipaddressv6 + ']'
|
||||||
|
|
||||||
if config['proxychains']:
|
if config['proxychains'] and protocol == 'tcp':
|
||||||
nmap_extra += ' -sT'
|
nmap_extra += ' -sT'
|
||||||
|
|
||||||
plugin = inspect.currentframe().f_back.f_locals['self']
|
plugin = inspect.currentframe().f_back.f_locals['self']
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from autorecon.plugins import PortScan
|
from autorecon.plugins import PortScan
|
||||||
from autorecon.io import info, error
|
from autorecon.io import info, error
|
||||||
|
from autorecon.config import config
|
||||||
import os, re
|
import os, re
|
||||||
|
|
||||||
class QuickTCPPortScan(PortScan):
|
class QuickTCPPortScan(PortScan):
|
||||||
|
@ -9,17 +10,23 @@ class QuickTCPPortScan(PortScan):
|
||||||
self.name = 'Top TCP Ports'
|
self.name = 'Top TCP Ports'
|
||||||
self.description = 'Performs an Nmap scan of the top 1000 TCP ports.'
|
self.description = 'Performs an Nmap scan of the top 1000 TCP ports.'
|
||||||
self.type = 'tcp'
|
self.type = 'tcp'
|
||||||
|
self.specific_ports = True
|
||||||
self.tags = ['default', 'default-port-scan']
|
self.tags = ['default', 'default-port-scan']
|
||||||
self.priority = 0
|
self.priority = 0
|
||||||
|
|
||||||
async def run(self, target):
|
async def run(self, target):
|
||||||
|
if config['proxychains']:
|
||||||
|
traceroute_os = ''
|
||||||
|
else:
|
||||||
|
traceroute_os = ' -A --osscan-guess'
|
||||||
|
|
||||||
if target.ports:
|
if target.ports:
|
||||||
if target.ports['tcp']:
|
if target.ports['tcp']:
|
||||||
process, stdout, stderr = await target.execute('nmap {nmap_extra} -A --osscan-guess --version-all -p ' + target.ports['tcp'] + ' -oN "{scandir}/_custom_ports_tcp_nmap.txt" -oX "{scandir}/xml/_custom_ports_tcp_nmap.xml" {address}', blocking=False)
|
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sV -sC --version-all' + traceroute_os + ' -p ' + target.ports['tcp'] + ' -oN "{scandir}/_custom_ports_tcp_nmap.txt" -oX "{scandir}/xml/_custom_ports_tcp_nmap.xml" {address}', blocking=False)
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
process, stdout, stderr = await target.execute('nmap {nmap_extra} -A --osscan-guess --version-all -oN "{scandir}/_quick_tcp_nmap.txt" -oX "{scandir}/xml/_quick_tcp_nmap.xml" {address}', blocking=False)
|
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sV -sC --version-all' + traceroute_os + ' -oN "{scandir}/_quick_tcp_nmap.txt" -oX "{scandir}/xml/_quick_tcp_nmap.xml" {address}', blocking=False)
|
||||||
services = await target.extract_services(stdout)
|
services = await target.extract_services(stdout)
|
||||||
await process.wait()
|
await process.wait()
|
||||||
return services
|
return services
|
||||||
|
@ -30,12 +37,19 @@ class AllTCPPortScan(PortScan):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.name = 'All TCP Ports'
|
self.name = 'All TCP Ports'
|
||||||
self.description = 'Performs an Nmap scan of all TCP ports.'
|
self.description = 'Performs an Nmap scan of all TCP ports.'
|
||||||
|
self.type = 'tcp'
|
||||||
self.tags = ['default', 'default-port-scan', 'long']
|
self.tags = ['default', 'default-port-scan', 'long']
|
||||||
|
|
||||||
async def run(self, target):
|
async def run(self, target):
|
||||||
if target.ports: # Don't run this plugin if there are custom ports.
|
if target.ports: # Don't run this plugin if there are custom ports.
|
||||||
return []
|
return []
|
||||||
process, stdout, stderr = await target.execute('nmap {nmap_extra} -A --osscan-guess --version-all -p- -oN "{scandir}/_full_tcp_nmap.txt" -oX "{scandir}/xml/_full_tcp_nmap.xml" {address}', blocking=False)
|
|
||||||
|
if config['proxychains']:
|
||||||
|
traceroute_os = ''
|
||||||
|
else:
|
||||||
|
traceroute_os = ' -A --osscan-guess'
|
||||||
|
|
||||||
|
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sV -sC --version-all' + traceroute_os + ' -p- -oN "{scandir}/_full_tcp_nmap.txt" -oX "{scandir}/xml/_full_tcp_nmap.xml" {address}', blocking=False)
|
||||||
services = []
|
services = []
|
||||||
while True:
|
while True:
|
||||||
line = await stdout.readline()
|
line = await stdout.readline()
|
||||||
|
@ -58,6 +72,7 @@ class Top100UDPPortScan(PortScan):
|
||||||
self.name = 'Top 100 UDP Ports'
|
self.name = 'Top 100 UDP Ports'
|
||||||
self.description = 'Performs an Nmap scan of the top 100 UDP ports.'
|
self.description = 'Performs an Nmap scan of the top 100 UDP ports.'
|
||||||
self.type = 'udp'
|
self.type = 'udp'
|
||||||
|
self.specific_ports = True
|
||||||
self.tags = ['default', 'default-port-scan', 'long']
|
self.tags = ['default', 'default-port-scan', 'long']
|
||||||
|
|
||||||
async def run(self, target):
|
async def run(self, target):
|
||||||
|
@ -65,11 +80,11 @@ class Top100UDPPortScan(PortScan):
|
||||||
if os.getuid() == 0:
|
if os.getuid() == 0:
|
||||||
if target.ports:
|
if target.ports:
|
||||||
if target.ports['udp']:
|
if target.ports['udp']:
|
||||||
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sU -A --version-all -p ' + target.ports['udp'] + ' -oN "{scandir}/_custom_ports_udp_nmap.txt" -oX "{scandir}/xml/_custom_ports_udp_nmap.xml" {address}', blocking=False)
|
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sU -A --osscan-guess -p ' + target.ports['udp'] + ' -oN "{scandir}/_custom_ports_udp_nmap.txt" -oX "{scandir}/xml/_custom_ports_udp_nmap.xml" {address}', blocking=False)
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sU -A --version-all --top-ports 100 -oN "{scandir}/_top_100_udp_nmap.txt" -oX "{scandir}/xml/_top_100_udp_nmap.xml" {address}', blocking=False)
|
process, stdout, stderr = await target.execute('nmap {nmap_extra} -sU -A --top-ports 100 -oN "{scandir}/_top_100_udp_nmap.txt" -oX "{scandir}/xml/_top_100_udp_nmap.xml" {address}', blocking=False)
|
||||||
services = []
|
services = []
|
||||||
while True:
|
while True:
|
||||||
line = await stdout.readline()
|
line = await stdout.readline()
|
||||||
|
|
Loading…
Reference in New Issue