Target
A class representing a target. Can contain an unlimited number of hosts, IP or IP ranges, URLs, etc.
Attributes:
-
make_in_scope
(bool
) –Specifies whether to mark contained events as in-scope.
-
scan
(Scan
) –Reference to the Scan object that instantiated the Target.
-
_events
(dict
) –Dictionary mapping hosts to events related to the target.
-
strict_scope
(bool
) –Flag indicating whether to consider child domains in-scope. If set to True, only the exact hosts specified and not their children are considered part of the target.
Examples:
Basic usage
>>> target = Target(scan, "evilcorp.com", "1.2.3.0/24")
>>> len(target)
257
>>> list(t.events)
[
DNS_NAME("evilcorp.com", module=TARGET, tags={'domain', 'distance-1', 'target'}),
IP_RANGE("1.2.3.0/24", module=TARGET, tags={'ipv4', 'distance-1', 'target'})
]
>>> "www.evilcorp.com" in target
True
>>> "1.2.3.4" in target
True
>>> "4.3.2.1" in target
False
>>> "https://admin.evilcorp.com" in target
True
>>> "bob@evilcorp.com" in target
True
Event correlation
>>> target.get("www.evilcorp.com")
DNS_NAME("evilcorp.com", module=TARGET, tags={'domain', 'distance-1', 'target'})
>>> target.get("1.2.3.4")
IP_RANGE("1.2.3.0/24", module=TARGET, tags={'ipv4', 'distance-1', 'target'})
Target comparison
>>> target2 = Targets(scan, "www.evilcorp.com")
>>> target2 == target
False
>>> target2 in target
True
>>> target in target2
False
Notes
- Targets are only precise down to the individual host. Ports and protocols are not considered in scope calculations.
- If you specify "https://evilcorp.com:8443" as a target, all of evilcorp.com (including subdomains and other ports and protocols) will be considered part of the target
- If you do not want to include child subdomains, use
strict_scope=True
Source code in bbot/scanner/target.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
events
property
events
A generator property that yields all events in the target.
Yields:
-
–
Event object: One of the Event objects stored in the
_events
dictionary.
Examples:
>>> target = Target(scan, "example.com")
>>> for event in target.events:
... print(event)
Notes
- This property is read-only.
- Iterating over this property gives you one event at a time from the
_events
dictionary.
__init__
__init__(
scan, *targets, strict_scope=False, make_in_scope=False
)
Initialize a Target object.
Parameters:
-
scan
(Scan
) –Reference to the Scan object that instantiated the Target.
-
*targets
–One or more targets (e.g., domain names, IP ranges) to be included in this Target.
-
strict_scope
(bool
, default:False
) –Flag to control whether only the exact hosts are considered in-scope. Defaults to False.
-
make_in_scope
(bool
, default:False
) –Flag to control whether contained events are marked as in-scope. Defaults to False.
Attributes:
-
scan
(Scan
) –Reference to the Scan object.
-
strict_scope
(bool
) –Flag to control in-scope conditions. If True, only exact hosts are considered.
Notes
- If you are instantiating a target from within a BBOT module, use
self.helpers.make_target()
instead. (this removes the need to pass in a scan object.) - The strict_scope flag can be set to restrict scope calculation to only exactly-matching hosts and not their child subdomains.
- Each target is processed and stored as an
Event
in the '_events' dictionary.
Source code in bbot/scanner/target.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
add_target
add_target(t, event_type=None)
Add a target or merge events from another Target object into this Target.
Parameters:
-
t
–The target to be added. It can be either a string, an event object, or another Target object.
Attributes Modified
_events (dict): The dictionary is updated to include the new target's events.
Examples:
>>> target.add_target('example.com')
Notes
- If
t
is of the same class as this Target, all its events are merged. - If
t
is an event, it is directly added to_events
. - If
make_in_scope
is True, the scope distance of the event is set to 0.
Source code in bbot/scanner/target.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
copy
copy()
Creates and returns a copy of the Target object, including a shallow copy of the _events
attribute.
Returns:
-
Target
–A new Target object with the same
scan
andstrict_scope
attributes as the original. A shallow copy of the_events
dictionary is made.
Examples:
>>> original_target = Target(scan, "example.com")
>>> copied_target = original_target.copy()
>>> copied_target is original_target
False
>>> copied_target == original_target
True
>>> copied_target in original_target
True
>>> original_target in copied_target
True
Notes
- The
scan
object reference is kept intact in the copied Target object.
Source code in bbot/scanner/target.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
get
get(host)
Gets the event associated with the specified host from the target's _events
dictionary.
Parameters:
-
host
(Event, Target, or str
) –The hostname, IP, URL, or event to look for.
Returns:
-
–
Event or None: Returns the Event object associated with the given host if it exists, otherwise returns None.
Examples:
>>> target = Target(scan, "evilcorp.com", "1.2.3.0/24")
>>> target.get("www.evilcorp.com")
DNS_NAME("evilcorp.com", module=TARGET, tags={'domain', 'distance-1', 'target'})
>>> target.get("1.2.3.4")
IP_RANGE("1.2.3.0/24", module=TARGET, tags={'ipv4', 'distance-1', 'target'})
Notes
- The method returns the first event that matches the given host.
- If
strict_scope
is False, it will also consider parent domains and IP ranges.
Source code in bbot/scanner/target.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|