parent
b60fcfc9ca
commit
1e9f938248
11
autorecon.py
11
autorecon.py
|
@ -76,6 +76,7 @@ class Target:
|
||||||
|
|
||||||
target.running_tasks[tag]['processes'].append({'process': process, 'stderr': stderr, 'cmd': cmd})
|
target.running_tasks[tag]['processes'].append({'process': process, 'stderr': stderr, 'cmd': cmd})
|
||||||
|
|
||||||
|
# If process should block, sleep until stdout and stderr have finished.
|
||||||
if blocking:
|
if blocking:
|
||||||
while (not (stdout.ended and stderr.ended)):
|
while (not (stdout.ended and stderr.ended)):
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
@ -164,6 +165,7 @@ class Service:
|
||||||
|
|
||||||
target.running_tasks[tag]['processes'].append({'process': process, 'stderr': stderr, 'cmd': cmd})
|
target.running_tasks[tag]['processes'].append({'process': process, 'stderr': stderr, 'cmd': cmd})
|
||||||
|
|
||||||
|
# If process should block, sleep until stdout and stderr have finished.
|
||||||
if blocking:
|
if blocking:
|
||||||
while (not (stdout.ended and stderr.ended)):
|
while (not (stdout.ended and stderr.ended)):
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
@ -182,6 +184,7 @@ class CommandStreamReader(object):
|
||||||
self.outfile = outfile
|
self.outfile = outfile
|
||||||
self.ended = False
|
self.ended = False
|
||||||
|
|
||||||
|
# Read lines from the stream until it ends.
|
||||||
async def _read(self):
|
async def _read(self):
|
||||||
while True:
|
while True:
|
||||||
if self.stream.at_eof():
|
if self.stream.at_eof():
|
||||||
|
@ -195,6 +198,8 @@ class CommandStreamReader(object):
|
||||||
if self.target.autorecon.config['verbose'] >= 2:
|
if self.target.autorecon.config['verbose'] >= 2:
|
||||||
if line != '':
|
if line != '':
|
||||||
info('{bblue}[' + self.target.address + '/' + self.tag + ']{crst} ' + line.replace('{', '{{').replace('}', '}}'))
|
info('{bblue}[' + self.target.address + '/' + self.tag + ']{crst} ' + line.replace('{', '{{').replace('}', '}}'))
|
||||||
|
|
||||||
|
# Check lines for pattern matches.
|
||||||
for p in self.patterns:
|
for p in self.patterns:
|
||||||
matches = p.pattern.findall(line)
|
matches = p.pattern.findall(line)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
|
@ -215,6 +220,7 @@ class CommandStreamReader(object):
|
||||||
self.lines.append(line)
|
self.lines.append(line)
|
||||||
self.ended = True
|
self.ended = True
|
||||||
|
|
||||||
|
# Read a line from the stream cache.
|
||||||
async def readline(self):
|
async def readline(self):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -225,6 +231,7 @@ class CommandStreamReader(object):
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
|
||||||
|
# Read all lines from the stream cache.
|
||||||
async def readlines(self):
|
async def readlines(self):
|
||||||
lines = []
|
lines = []
|
||||||
while True:
|
while True:
|
||||||
|
@ -1637,8 +1644,9 @@ async def main():
|
||||||
port_scan_task_count = 0
|
port_scan_task_count = 0
|
||||||
for targ in autorecon.scanning_targets:
|
for targ in autorecon.scanning_targets:
|
||||||
for process_list in targ.running_tasks.values():
|
for process_list in targ.running_tasks.values():
|
||||||
|
# If we're not scanning ports, count ServiceScans instead.
|
||||||
if autorecon.config['force_services']:
|
if autorecon.config['force_services']:
|
||||||
if issubclass(process_list['plugin'].__class__, ServiceScan):
|
if issubclass(process_list['plugin'].__class__, ServiceScan): # TODO should we really count ServiceScans? Test...
|
||||||
port_scan_task_count += 1
|
port_scan_task_count += 1
|
||||||
else:
|
else:
|
||||||
if issubclass(process_list['plugin'].__class__, PortScan):
|
if issubclass(process_list['plugin'].__class__, PortScan):
|
||||||
|
@ -1678,6 +1686,7 @@ async def main():
|
||||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, terminal_settings)
|
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, terminal_settings)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# Capture Ctrl+C and cancel everything.
|
||||||
signal.signal(signal.SIGINT, cancel_all_tasks)
|
signal.signal(signal.SIGINT, cancel_all_tasks)
|
||||||
try:
|
try:
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
Loading…
Reference in New Issue