MCPcopy Index your code
hub / github.com/AutoRecon/AutoRecon / scan_target

Function scan_target

autorecon/main.py:472–852  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

470 raise Exception(cprint('Error: Report plugin {bblue}' + plugin.name + ' {green}(' + plugin.slug + '){rst} produced an exception:\n\n' + error_text, color=Fore.RED, char='!', printmsg=False))
471
472async def scan_target(target):
473 os.makedirs(os.path.abspath(config['output']), exist_ok=True)
474
475 if config['single_target']:
476 basedir = os.path.abspath(config['output'])
477 else:
478 basedir = os.path.abspath(os.path.join(config['output'], target.address))
479 os.makedirs(basedir, exist_ok=True)
480
481 target.basedir = basedir
482
483 scandir = os.path.join(basedir, 'scans')
484 target.scandir = scandir
485 os.makedirs(scandir, exist_ok=True)
486
487 os.makedirs(os.path.join(scandir, 'xml'), exist_ok=True)
488
489 if not config['only_scans_dir']:
490 exploitdir = os.path.join(basedir, 'exploit')
491 os.makedirs(exploitdir, exist_ok=True)
492
493 lootdir = os.path.join(basedir, 'loot')
494 os.makedirs(lootdir, exist_ok=True)
495
496 reportdir = os.path.join(basedir, 'report')
497 os.makedirs(reportdir, exist_ok=True)
498
499 open(os.path.join(reportdir, 'local.txt'), 'a').close()
500 open(os.path.join(reportdir, 'proof.txt'), 'a').close()
501
502 screenshotdir = os.path.join(reportdir, 'screenshots')
503 os.makedirs(screenshotdir, exist_ok=True)
504 else:
505 reportdir = scandir
506
507 target.reportdir = reportdir
508
509 pending = []
510
511 heartbeat = asyncio.create_task(start_heartbeat(target, period=config['heartbeat']))
512
513 services = []
514 if config['force_services']:
515 forced_services = [x.strip().lower() for x in config['force_services']]
516
517 for forced_service in forced_services:
518 match = re.search('(?P<protocol>(tcp|udp))\/(?P<port>\d+)\/(?P<service>[\w\-]+)(\/(?P<secure>secure|insecure))?', forced_service)
519 if match:
520 protocol = match.group('protocol')
521 if config['proxychains'] and protocol == 'udp':
522 error('The service ' + forced_service + ' uses UDP and --proxychains is enabled. Skipping.', verbosity=2)
523 continue
524 port = int(match.group('port'))
525 service = match.group('service')
526 secure = True if match.group('secure') == 'secure' else False
527 service = Service(protocol, port, service, secure)
528 service.target = target
529 services.append(service)

Callers 1

runFunction · 0.85

Calls 14

full_tagMethod · 0.95
tagMethod · 0.95
errorFunction · 0.90
ServiceClass · 0.90
infoFunction · 0.90
warnFunction · 0.90
cprintFunction · 0.90
eFunction · 0.90
start_heartbeatFunction · 0.85
port_scanFunction · 0.85
service_scanFunction · 0.85
generate_reportFunction · 0.85

Tested by

no test coverage detected