Module Halberd.crew
Work crew pattern of parallel scanners
Overview
A work crew is instantiated passing a ScanTask object as a
parameter, thus defining the target and the way the scanning should
be done. After the initialization of the work crew it can be used to
scan the target and get the obtained clues back.
>>> crew = WorkCrew(scantask)
>>> clues = crew.scan()
Requirements
These are the features that the WorkCrew must provide:
-
There are 3 different types of consumers:
-
Controller thread (Performs timing + error-checking).
-
Local scanning thread.
-
Remote scanning thread.
-
We need a way to signal:
-
When a fatal error has happened.
-
When the user has pressed Control-C
Types of scanning threads
The WorkCrew object spawns different kinds of threads. Here's a
brief summary of what they do:
-
Manager: Detects when the time for performing the scan has
expired and notifies the rest of the threads. This code is
executed in the main thread in order to be able to appropriately
catch signals, etc.
-
Scanner: Performs a load-balancer scan from the current
machine.
The following is a diagram showing the way it works:
.--> Manager --.
| |
+--> Scanner --+
.----------. .----------. | | .-------.
IN --> | ScanTask |->-| WorkCrew |--+--> Scanner --+->-| Clues |--> OUT
`----------' `----------' | | `-------'
+--> Scanner --+
| |
`--> Scanner --'
Classes |
WorkCrew |
Pool of scanners working in parallel. |
BaseScanner |
Base class for load balancer scanning threads. |
Manager |
Performs management tasks during the scan. |
Scanner |
Scans the target host from the local machine. |
ScanState |
Shared state among scanner threads. |