Word Cloud
These are helpers related to BBOT's Word Cloud, a mechanism for storing target-specific keywords that are useful for custom wordlists, etc.
Note that these helpers can be invoked directly from self.helpers
, e.g.:
self.helpers.word_cloud
DNSMutator
Bases: Mutator
DNS-specific mutator used by the dnsbrute_mutations
module to generate target-specific subdomain mutations.
This class extends the Mutator base class to add DNS-specific logic for generating subdomain mutations based on input words. It utilizes custom word extraction patterns and a wordninja model trained on DNS-specific data.
Examples:
>>> s = Scanner("www1.evilcorp.com", "www-test.evilcorp.com")
>>> s.start_without_generator()
>>> s.helpers.word_cloud.dns_mutator.mutations("word")
[
"word",
"word-test",
"word1",
"wordtest",
"www-word",
"wwwword"
]
Source code in bbot/core/helpers/wordcloud.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
|
Mutator
Bases: dict
Base class for generating mutations from a list of words. It accumulates words and produces mutations from them.
Source code in bbot/core/helpers/wordcloud.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
|
WordCloud
Bases: dict
WordCloud is a specialized dictionary-like class for storing and aggregating words extracted from various data sources such as DNS names and URLs. The class is intended to facilitate the generation of target-specific wordlists and mutations.
The WordCloud class can be accessed and manipulated like a standard Python dictionary. It also offers additional methods for generating mutations based on the words it contains.
Attributes:
-
parent_helper
–The parent helper object that provides necessary utilities.
-
devops_mutations
–A set containing common devops-related mutations, loaded from a file.
-
dns_mutator
–An instance of the DNSMutator class for generating DNS-based mutations.
Examples:
>>> s = Scanner("www1.evilcorp.com", "www-test.evilcorp.com")
>>> s.start_without_generator()
>>> print(s.helpers.word_cloud)
{
"evilcorp": 2,
"ec": 2,
"www1": 1,
"evil": 2,
"www": 2,
"w1": 1,
"corp": 2,
"1": 1,
"wt": 1,
"test": 1,
"www-test": 1
}
>>> s.helpers.word_cloud.mutations(["word"], cloud=True, numbers=0, devops=False, letters=False)
[
[
"1",
"word"
],
[
"corp",
"word"
],
[
"ec",
"word"
],
[
"evil",
"word"
],
...
]
>>> s.helpers.word_cloud.dns_mutator.mutations("word")
[
"word",
"word-test",
"word1",
"wordtest",
"www-word",
"wwwword"
]
Source code in bbot/core/helpers/wordcloud.py
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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
absorb_event
absorb_event(event)
Absorbs an event from a BBOT scan into the word cloud.
This method updates the word cloud by extracting words from the given event. It aims to avoid including PTR (Pointer) records, as they tend to produce unhelpful mutations in the word cloud.
Parameters:
-
event
(Event
) –The event object containing the words to be absorbed into the word cloud.
Source code in bbot/core/helpers/wordcloud.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
absorb_word
absorb_word(word, wordninja=True)
Absorbs a word into the word cloud after splitting it using a word extraction algorithm.
This method splits the input word into smaller meaningful words using word extraction, and then adds each of them to the word cloud. The splitting is done using a predefined algorithm in the parent helper.
Parameters:
-
word
(str
) –The word to be split and absorbed into the word cloud.
-
wordninja
(bool
, default:True
) –If True, word extraction is enabled. Defaults to True.
Examples:
>>> self.helpers.word_cloud.absorb_word("blacklantern")
>>> print(self.helpers.word_cloud)
{
"blacklantern": 1,
"black": 1,
"bl": 1,
"lantern": 1
}
Source code in bbot/core/helpers/wordcloud.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
add_word
add_word(word, lowercase=True)
Adds a word to the word cloud.
This method updates the word cloud by adding a given word. If the word already exists in the cloud, its frequency count is incremented by 1. Optionally, the word can be converted to lowercase before adding.
Parameters:
-
word
(str
) –The word to be added to the word cloud.
-
lowercase
(bool
, default:True
) –If True, the word will be converted to lowercase before adding. Defaults to True.
Examples:
>>> self.helpers.word_cloud.add_word("Example")
>>> self.helpers.word_cloud.add_word("example")
>>> print(self.helpers.word_cloud)
{'example': 2}
Source code in bbot/core/helpers/wordcloud.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
get_number_mutations
get_number_mutations(base, n=5, padding=2)
Generates mutations of a base string by modifying the numerical parts or appending numbers.
This method detects existing numbers in the base string and tries incrementing and decrementing them within a specified range. It also appends numbers at the end or after each word to generate more mutations.
Parameters:
-
base
(str
) –The base string to generate mutations from.
-
n
(int
, default:5
) –The range of numbers to use for incrementing/decrementing. Defaults to 5.
-
padding
(int
, default:2
) –Zero-pad numbers up to this length. Defaults to 2.
Returns:
-
set
–A set of mutated strings based on the base input.
Examples:
>>> self.helpers.word_cloud.get_number_mutations("www2-test", n=2)
{
"www0-test",
"www1-test",
"www2-test",
"www2-test0",
"www2-test00",
"www2-test01",
"www2-test1",
"www3-test",
"www4-test"
}
Source code in bbot/core/helpers/wordcloud.py
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 |
|
json
json(limit=None)
Returns the word cloud as a sorted OrderedDict, optionally truncated to the top limit
entries.
Parameters:
-
limit
(int
, default:None
) –The maximum number of entries to include in the returned OrderedDict. If None, all entries are included.
Returns:
-
OrderedDict
–A dictionary sorted by word frequencies, potentially truncated to the top
limit
entries.
Examples:
>>> self.helpers.word_cloud.update({"apple": 5, "banana": 2, "cherry": 8})
>>> self.helpers.word_cloud.json(limit=2)
OrderedDict([('cherry', 8), ('apple', 5)])
Source code in bbot/core/helpers/wordcloud.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
load
load(filename=None)
Loads a word cloud from a file. The file can be either a standard wordlist with one entry per line or a .tsv (tab-separated) file where the first row is the count and the second row is the associated entry.
Parameters:
-
filename
(str
, default:None
) –The path to the file from which to load the word cloud. If None, uses a default filename.
Source code in bbot/core/helpers/wordcloud.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
mutations
mutations(words, devops=True, cloud=True, letters=True, numbers=5, number_padding=2, substitute_numbers=True)
Generate various mutations for the given list of words based on different criteria.
Yields tuples of strings which can be joined on the desired delimiter, e.g. "-" or "_".
Parameters:
-
words
(Union[str, Iterable[str]]
) –A single word or list of words to mutate.
-
devops
(bool
, default:True
) –Whether to include devops-related mutations.
-
cloud
(bool
, default:True
) –Whether to include mutations from the word cloud.
-
letters
(bool
, default:True
) –Whether to include letter-based mutations.
-
numbers
(int
, default:5
) –The maximum numeric mutations to include.
-
number_padding
(int
, default:2
) –Padding for numeric mutations.
-
substitute_numbers
(bool
, default:True
) –Whether to substitute numbers in mutations.
Yields:
-
tuple
–A tuple containing each of the mutation segments.
Source code in bbot/core/helpers/wordcloud.py
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 |
|
save
save(filename=None, limit=None)
Saves the word cloud to a file. The cloud can optionally be truncated to the top limit
entries.
Parameters:
-
filename
(str
, default:None
) –The path to the file where the word cloud will be saved. If None, uses a default filename.
-
limit
(int
, default:None
) –The maximum number of entries to save to the file. If None, all entries are saved.
Returns:
-
tuple
–A tuple containing a boolean indicating success or failure, and the resolved filename.
Examples:
>>> self.helpers.word_cloud.update({"apple": 5, "banana": 2, "cherry": 8})
>>> self.helpers.word_cloud.save(filename="word_cloud.txt", limit=2)
(True, Path('word_cloud.txt'))
Source code in bbot/core/helpers/wordcloud.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
truncate
truncate(limit)
Truncates the word cloud dictionary to retain only the top limit
entries based on their occurrence frequencies.
Parameters:
-
limit
(int
) –The maximum number of entries to retain in the word cloud.
Examples:
>>> self.helpers.word_cloud.update({"apple": 5, "banana": 2, "cherry": 8})
>>> self.helpers.word_cloud.truncate(2)
>>> self.helpers.word_cloud
{'cherry': 8, 'apple': 5}
Source code in bbot/core/helpers/wordcloud.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|