MCPcopy Create free account
hub / github.com/blacklanternsecurity/bbot / Scanner

Class Scanner

bbot/scanner/scanner.py:25–1364  ·  view source on GitHub ↗

A class representing a single BBOT scan Examples: Create scan with multiple targets: >>> my_scan = Scanner("evilcorp.com", "1.2.3.0/24", modules=["portscan", "sslcert", "httpx"]) Create scan with custom config: >>> config = {"http_proxy": "http://127.0.0.1:8080"

Source from the content-addressed store, hash-verified

23
24
25class Scanner:
26 """A class representing a single BBOT scan
27
28 Examples:
29 Create scan with multiple targets:
30 >>> my_scan = Scanner("evilcorp.com", "1.2.3.0/24", modules=["portscan", "sslcert", "httpx"])
31
32 Create scan with custom config:
33 >>> config = {"http_proxy": "http://127.0.0.1:8080", "modules": {"portscan": {"top_ports": 2000}}}
34 >>> my_scan = Scanner("www.evilcorp.com", modules=["portscan", "httpx"], config=config)
35
36 Start the scan, iterating over events as they're discovered (synchronous):
37 >>> for event in my_scan.start():
38 >>> print(event)
39
40 Start the scan, iterating over events as they're discovered (asynchronous):
41 >>> async for event in my_scan.async_start():
42 >>> print(event)
43
44 Start the scan without consuming events (synchronous):
45 >>> my_scan.start_without_generator()
46
47 Start the scan without consuming events (asynchronous):
48 >>> await my_scan.async_start_without_generator()
49
50 Attributes:
51 status (str): Status of scan, representing its current state. It can take on the following string values, each of which is mapped to an integer code in `_status_codes`:
52 ```markdown
53 - "NOT_STARTED" (0): Initial status before the scan starts.
54 - "STARTING" (1): Status when the scan is initializing.
55 - "RUNNING" (2): Status when the scan is in progress.
56 - "FINISHING" (3): Status when the scan is in the process of finalizing.
57 - "CLEANING_UP" (4): Status when the scan is cleaning up resources.
58 - "ABORTING" (5): Status when the scan is in the process of being aborted.
59 - "ABORTED" (6): Status when the scan has been aborted.
60 - "FAILED" (7): Status when the scan has encountered a failure.
61 - "FINISHED" (8): Status when the scan has successfully completed.
62 ```
63 _status_code (int): The numerical representation of the current scan status, stored for internal use. It is mapped according to the values in `_status_codes`.
64 target (Target): Target of scan (alias to `self.preset.target`).
65 preset (Preset): The main scan Preset in its baked form.
66 config (omegaconf.dictconfig.DictConfig): BBOT config (alias to `self.preset.config`).
67 whitelist (Target): Scan whitelist (by default this is the same as `target`) (alias to `self.preset.whitelist`).
68 blacklist (Target): Scan blacklist (this takes ultimate precedence) (alias to `self.preset.blacklist`).
69 helpers (ConfigAwareHelper): Helper containing various reusable functions, regexes, etc. (alias to `self.preset.helpers`).
70 output_dir (pathlib.Path): Output directory for scan (alias to `self.preset.output_dir`).
71 name (str): Name of scan (alias to `self.preset.scan_name`).
72 dispatcher (Dispatcher): Triggers certain events when the scan `status` changes.
73 modules (dict): Holds all loaded modules in this format: `{"module_name": Module()}`.
74 stats (ScanStats): Holds high-level scan statistics such as how many events have been produced and consumed by each module.
75 home (pathlib.Path): Base output directory of the scan (default: `~/.bbot/scans/<scan_name>`).
76 running (bool): Whether the scan is currently running.
77 stopping (bool): Whether the scan is currently stopping.
78 stopped (bool): Whether the scan is currently stopped.
79 aborting (bool): Whether the scan is aborted or currently aborting.
80
81 Notes:
82 - The status is read-only once set to "ABORTING" until it transitions to "ABORTED."

Callers 15

scanMethod · 0.90
_mainFunction · 0.90
scanFunction · 0.90
startFunction · 0.90
test_bloom_filterFunction · 0.90
run_bbot_multiprocessFunction · 0.90
test_regex_helperFunction · 0.90
test_eventsFunction · 0.90
test_event_confidenceFunction · 0.90
test_event_closest_hostFunction · 0.90
test_event_magicFunction · 0.90

Calls

no outgoing calls

Tested by 15

startFunction · 0.72
test_bloom_filterFunction · 0.72
run_bbot_multiprocessFunction · 0.72
test_regex_helperFunction · 0.72
test_eventsFunction · 0.72
test_event_confidenceFunction · 0.72
test_event_closest_hostFunction · 0.72
test_event_magicFunction · 0.72
test_mobile_appFunction · 0.72
test_filesystemFunction · 0.72
test_event_hashingFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…