Web
These are helpers for making various web requests.
Note that these helpers can be invoked directly from self.helpers, e.g.:
self.helpers.request("https://www.evilcorp.com")
WebHelper
Main utility class for managing HTTP operations in BBOT. Uses blasthttp (Rust) as the HTTP engine for all requests, downloads, and wordlist retrieval.
All requests go through the shared blasthttp client on the parent helper,
which supports global rate limiting via web.http_rate_limit.
Attributes:
-
parent_helper(object) –The parent helper object containing scan configurations.
-
http_debug(bool) –Flag to indicate whether HTTP debugging is enabled.
-
ssl_verify_target(bool) –Whether to verify SSL for target-directed traffic (default False).
-
ssl_verify_infrastructure(bool) –Whether to verify SSL for non-target traffic (default True).
Examples:
Basic web request:
>>> response = await self.helpers.request("https://www.evilcorp.com")
Download file:
>>> filename = await self.helpers.download("https://www.evilcorp.com/passwords.docx")
Download wordlist (cached for 30 days by default):
>>> filename = await self.helpers.wordlist("https://www.evilcorp.com/wordlist.txt")
Source code in bbot/core/helpers/web/web.py
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 403 404 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 450 451 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 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | |
client
property
client
The shared rate-limited blasthttp client for target-directed traffic.
beautifulsoup
beautifulsoup(
markup,
features="html.parser",
builder=None,
parse_only=None,
from_encoding=None,
exclude_encodings=None,
element_classes=None,
**kwargs,
)
Naviate, Search, Modify, Parse, or PrettyPrint HTML Content. More information at https://beautiful-soup-4.readthedocs.io/en/latest/
Parameters:
-
markup–A string or a file-like object representing markup to be parsed.
-
features–Desirable features of the parser to be used. This may be the name of a specific parser ("lxml", "lxml-xml", "html.parser", or "html5lib") or it may be the type of markup to be used ("html", "html5", "xml"). Defaults to 'html.parser'.
-
builder–A TreeBuilder subclass to instantiate (or instance to use) instead of looking one up based on
features. -
parse_only–A SoupStrainer. Only parts of the document matching the SoupStrainer will be considered.
-
from_encoding–A string indicating the encoding of the document to be parsed.
Returns:
-
soup–An instance of the BeautifulSoup class
Todo
- Write tests for this function
Examples:
>>> soup = self.helpers.beautifulsoup(event.body, "html.parser")
Perform an html parse of the 'markup' argument and return a soup instance
>>> email_type = soup.find(type="email")
Searches the soup instance for all occurrences of the passed in argument
Source code in bbot/core/helpers/web/web.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
download
async
download(url, **kwargs)
Asynchronous function for downloading files from a given URL. Supports caching with an optional time period in hours via the "cache_hrs" keyword argument. In case of successful download, returns the full path of the saved filename. If the download fails, returns None.
Parameters:
-
url(str) –The URL of the file to download.
-
filename(str) –The filename to save the downloaded file as. If not provided, will generate based on URL.
-
max_size(str or int) –Maximum filesize as a string ("5MB") or integer in bytes.
-
cache_hrs(float) –The number of hours to cache the downloaded file. A negative value disables caching. Defaults to -1.
-
method(str) –The HTTP method to use for the request, defaults to 'GET'.
-
raise_error(bool) –Whether to raise exceptions for HTTP connect, timeout errors. Defaults to False.
-
**kwargs–Additional keyword arguments to pass to request().
Returns:
-
–
Path or None: The full path of the downloaded file as a Path object if successful, otherwise None.
Examples:
>>> filepath = await self.helpers.download("https://www.evilcorp.com/passwords.docx", cache_hrs=24)
Source code in bbot/core/helpers/web/web.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 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 | |
is_http_wildcard_host
async
is_http_wildcard_host(scheme, host, port)
Detect whether a host returns the same response regardless of URL path.
Probes two random paths and the root URL via HttpCompare. Cached per (scheme, host, port); 3 HTTP requests on first call, instant thereafter.
Returns:
-
–
HttpCompare -- host is a wildcard responder (cached baseline).
-
–
False -- host distinguishes responses by path.
-
–
None -- probe failed after retry; treat as unknown.
Source code in bbot/core/helpers/web/web.py
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
request
async
request(*args, **kwargs)
Asynchronous function for making HTTP requests, intended to be the most basic web request function used widely across BBOT and within this helper class. Handles various exceptions and timeouts that might occur during the request.
This function automatically respects the scan's global timeout, proxy, headers, etc. Headers you specify will be merged with the scan's. Your arguments take ultimate precedence, meaning you can override the scan's values if you want.
Parameters:
-
url(str) –The URL to send the request to.
-
method(str) –The HTTP method to use for the request. Defaults to 'GET'.
-
headers(dict) –Dictionary of HTTP headers to send with the request.
-
params(dict) –Dictionary, list of tuples, or bytes to send in the query string.
-
cookies(dict) –Dictionary or CookieJar object containing cookies.
-
json(Any) –A JSON serializable Python object to send in the body.
-
data(dict) –Dictionary, list of tuples, or bytes to send in the body.
-
body(str) –Raw string body to send (not URL-encoded).
-
auth(tuple) –Auth tuple to enable Basic/Digest/Custom HTTP auth.
-
timeout(float) –The maximum time to wait for the request to complete.
-
proxy(str) –HTTP proxy URL.
-
allow_redirects(bool) –Enables or disables redirection. Defaults to None.
-
raise_error(bool) –Whether to raise exceptions for HTTP connect, timeout errors. Defaults to False.
-
ssl_verify(bool) –Override SSL certificate verification for this request. Defaults to ssl_verify_target for target traffic; pass ssl_verify_infrastructure for API/infra calls.
-
request_target(str) –Override the HTTP request-line target.
-
resolve_ip(str) –Connect TCP to this IP instead of DNS resolution.
-
ignore_bbot_global_settings(bool) –Skip User-Agent/header/cookie merging.
Raises:
-
WebError–If raise_error is True and the request fails.
Returns:
-
–
Response or None: The HTTP response object.
Examples:
>>> response = await self.helpers.request("https://www.evilcorp.com")
>>> response = await self.helpers.request("https://api.evilcorp.com/", method="POST", data="stuff")
Note
If the web request fails, it will return None unless raise_error is True.
Source code in bbot/core/helpers/web/web.py
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 | |
request_batch_stream
async
request_batch_stream(urls, threads=10, **kwargs)
Request multiple URLs in parallel via blasthttp's native Rust batch engine, yielding each response as soon as it completes (completion order, not input order).
Applies the same header/cookie/proxy/timeout logic as request() — each
entry is translated into a blasthttp.BatchConfig and dispatched through
blasthttp.request_batch_stream. A slow request no longer blocks faster
peers behind it, and Python work overlaps with in-flight HTTP I/O.
Each entry in urls can be:
- A plain URL string (uses shared **kwargs for all requests)
- A (url, per_request_kwargs) tuple for per-request options
- A (url, per_request_kwargs, tracker) tuple to attach arbitrary
tracking data that is yielded alongside the response
Yields:
-
–
When entries are plain strings:
(url, response) -
–
When any entry includes a tracker:
(url, response, tracker)
Parameters:
-
urls–URLs to visit — strings or
(url, kwargs[, tracker])tuples. -
threads(int, default:10) –Concurrency passed to blasthttp. Defaults to 10.
-
**kwargs–Default keyword arguments (same as
request()). Overridden by per-request kwargs when entries are tuples.
Examples:
Simple (shared kwargs)::
async for url, response in self.helpers.request_batch_stream(urls, headers={"X-Test": "Test"}):
...
Per-request kwargs with tracker::
reqs = [("http://example.com", {"method": "POST"}, "my-tracker")]
async for url, response, tracker in self.helpers.request_batch_stream(reqs):
...
Source code in bbot/core/helpers/web/web.py
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 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
response_to_json
response_to_json(response)
Convert web response to JSON object, to a JSON-serializable dict.
Source code in bbot/core/helpers/web/web.py
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | |
wordlist
async
wordlist(
path, lines=None, zip=False, zip_filename=None, **kwargs
)
Asynchronous function for retrieving wordlists, either from a local path or a URL. Allows for optional line-based truncation and caching. Returns the full path of the wordlist file or a truncated version of it.
Also accepts a list of paths/URLs, in which case all wordlists are fetched and merged into a single deduplicated file before being returned.
Parameters:
-
path(str | list) –The local or remote path of the wordlist, or a list of paths/URLs to merge into a single deduplicated wordlist.
-
lines(int, default:None) –Number of lines to read from the wordlist. If specified, will return a truncated wordlist with this many lines.
-
zip(bool, default:False) –Whether to unzip the file after downloading. Defaults to False.
-
zip_filename(str, default:None) –The name of the file to extract from the ZIP archive. Required if zip is True.
-
cache_hrs(float) –Number of hours to cache the downloaded wordlist. Defaults to 720 hours (30 days) for remote wordlists.
-
**kwargs–Additional keyword arguments to pass to the 'download' function for remote wordlists.
Returns:
-
Path–The full path of the wordlist (or its truncated version) as a Path object.
Raises:
-
WordlistError–If the path is invalid or the wordlist could not be retrieved or found.
Examples:
Fetching full wordlist
>>> wordlist_path = await self.helpers.wordlist("https://www.evilcorp.com/wordlist.txt")
Fetching and truncating to the first 100 lines
>>> wordlist_path = await self.helpers.wordlist("/root/rockyou.txt", lines=100)
Merging multiple wordlists into one
>>> wordlist_path = await self.helpers.wordlist(["/custom.txt", "https://example.com/wordlist.txt"])
Source code in bbot/core/helpers/web/web.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |