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

Function service_scan

autorecon/main.py:334–456  ·  view source on GitHub ↗
(plugin, service)

Source from the content-addressed store, hash-verified

332 return {'type':'port', 'plugin':plugin, 'result':result}
333
334async def service_scan(plugin, service):
335 semaphore = service.target.autorecon.service_scan_semaphore
336
337 if not config['force_services']:
338 semaphore = await get_semaphore(service.target.autorecon)
339
340 plugin_pending = True
341
342 while plugin_pending:
343 global_plugin_count = 0
344 target_plugin_count = 0
345
346 if plugin.max_global_instances and plugin.max_global_instances > 0:
347 async with service.target.autorecon.lock:
348 # Count currently running plugin instances.
349 for target in service.target.autorecon.scanning_targets:
350 for task in target.running_tasks.values():
351 if plugin == task['plugin']:
352 global_plugin_count += 1
353 if global_plugin_count >= plugin.max_global_instances:
354 break
355 if global_plugin_count >= plugin.max_global_instances:
356 break
357 if global_plugin_count >= plugin.max_global_instances:
358 await asyncio.sleep(1)
359 continue
360
361 if plugin.max_target_instances and plugin.max_target_instances > 0:
362 async with service.target.lock:
363 # Count currently running plugin instances.
364 for task in service.target.running_tasks.values():
365 if plugin == task['plugin']:
366 target_plugin_count += 1
367 if target_plugin_count >= plugin.max_target_instances:
368 break
369 if target_plugin_count >= plugin.max_target_instances:
370 await asyncio.sleep(1)
371 continue
372
373 # If we get here, we can run the plugin.
374 plugin_pending = False
375
376 async with semaphore:
377 # Create variables for fformat references.
378 address = service.target.address
379 addressv6 = service.target.address
380 ipaddress = service.target.ip
381 ipaddressv6 = service.target.ip
382 scandir = service.target.scandir
383 protocol = service.protocol
384 port = service.port
385 name = service.name
386
387 if not config['no_port_dirs']:
388 scandir = os.path.join(scandir, protocol + str(port))
389 os.makedirs(scandir, exist_ok=True)
390 os.makedirs(os.path.join(scandir, 'xml'), exist_ok=True)
391

Callers 1

scan_targetFunction · 0.85

Calls 9

infoFunction · 0.90
cprintFunction · 0.90
warnFunction · 0.90
errorFunction · 0.90
get_semaphoreFunction · 0.85
calculate_elapsed_timeFunction · 0.85
tagMethod · 0.80
readlineMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected