This is a developer reference. For a high-level description of BBOT events including a full list of event types, see Events
make_event
make_event(data, event_type=None, parent=None, context=None, module=None, scan=None, tags=None, confidence=100, dummy=False, internal=None)
Creates and returns a new event object or modifies an existing one.
This function serves as a factory for creating new event objects, either by generating a new Event
object or by updating an existing event with additional metadata. If data
is already an event,
it updates the event based on the additional parameters provided.
Parameters:
-
data
(Union[str, dict, BaseEvent]
) –The primary data for the event or an existing event object.
-
event_type
(str
, default:None
) –Type of the event, e.g., 'IP_ADDRESS'. Auto-detected if not provided.
-
parent
(BaseEvent
, default:None
) –Parent event leading to this event's discovery.
-
context
(str
, default:None
) –Description of circumstances leading to event's discovery.
-
module
(str
, default:None
) –Module that discovered the event.
-
scan
(Scan
, default:None
) –BBOT Scan object associated with the event.
-
scans
(List[Scan]
) –Multiple BBOT Scan objects, primarily used for unserialization.
-
tags
(Union[str, List[str]]
, default:None
) –Descriptive tags for the event, as a list or a single string.
-
confidence
(int
, default:100
) –Confidence level for the event, on a scale of 1-100. Defaults to 100.
-
dummy
(bool
, default:False
) –Disables data validations if set to True. Defaults to False.
-
internal
(Any
, default:None
) –Makes the event internal if set to True. Defaults to None.
Returns:
-
BaseEvent
–A new or updated event object.
Raises:
-
ValidationError
–Raised when there's an error in event data or type sanitization.
Examples:
If inside a module, e.g. from within its handle_event()
:
>>> self.make_event("1.2.3.4", parent=event)
IP_ADDRESS("1.2.3.4", module=portscan, tags={'ipv4', 'distance-1'})
If you're outside a module but you have a scan object:
>>> scan.make_event("1.2.3.4", parent=scan.root_event)
IP_ADDRESS("1.2.3.4", module=None, tags={'ipv4', 'distance-1'})
If you're outside a scan and just messing around:
>>> from bbot.core.event.base import make_event
>>> make_event("1.2.3.4", dummy=True)
IP_ADDRESS("1.2.3.4", module=None, tags={'ipv4'})
Note
When working within a module's handle_event()
, use the instance method
self.make_event()
instead of calling this function directly.
Source code in bbot/core/event/base.py
1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 |
|
event_from_json
event_from_json(j, siem_friendly=False)
Creates an event object from a JSON dictionary.
This function deserializes a JSON dictionary to create a new event object, using the make_event
function
for the actual object creation. It sets additional attributes such as the timestamp and scope distance
based on the input JSON.
Parameters:
-
j
(Dict
) –JSON dictionary containing the event attributes. Must include keys "data" and "type".
Returns:
-
BaseEvent
–A new event object initialized with attributes from the JSON dictionary.
Raises:
-
ValidationError
–Raised when the JSON dictionary is missing required fields.
Note
The function assumes that the input JSON dictionary is valid and may raise exceptions if required keys are missing. Make sure to validate the JSON input beforehand.
Source code in bbot/core/event/base.py
1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 |
|
BaseEvent
Represents a piece of data discovered during a BBOT scan.
An Event contains various attributes that provide metadata about the discovered data. The attributes assist in understanding the context of the Event and facilitate further filtering and querying. Events are integral in the construction of visual graphs and are the cornerstone of data exchange between BBOT modules.
You can inherit from this class when creating a new event type. However, it's not always necessary. You only need to subclass if you want to layer additional functionality on top of the base class.
Attributes:
-
type
(str
) –Specifies the type of the event, e.g.,
IP_ADDRESS
,DNS_NAME
. -
id
(str
) –An identifier for the event (event type + sha1 hash of data). NOT universally unique.
-
uuid
(UUID
) –A universally unique identifier for the event.
-
data
(str or dict
) –The main data for the event, e.g., a URL or IP address.
-
data_graph
(str
) –Representation of
self.data
for graph nodes (e.g. Neo4j). -
data_human
(str
) –Representation of
self.data
for human output. -
data_id
(str
) –Representation of
self.data
used to calculate the event's ID (and ultimately its hash, which is used for deduplication) -
data_json
(str
) –Representation of
self.data
to be used in JSON serialization. -
host
(str, IPvXAddress, or IPvXNetwork
) –The associated IP address or hostname for the event
-
host_stem
(str
) –An abbreviated representation of hostname that removes the TLD, e.g. "www.evilcorp". Used by the word cloud.
-
port
(int or None
) –The port associated with the event, if applicable, else None.
-
words
(set
) –A list of relevant keywords extracted from the event. Used by the word cloud.
-
scope_distance
(int
) –Indicates how many hops the event is from the main scope; 0 means in-scope.
-
web_spider_distance
(int
) –The spider distance from the web root, specific to web crawling.
-
scan
(Scanner
) –The scan object that generated the event.
-
timestamp
(datetime
) –The time at which the data was discovered.
-
resolved_hosts
(list of str
) –List of hosts to which the event data resolves, applicable for URLs and DNS names.
-
parent
(BaseEvent
) –The parent event that led to the discovery of this event.
-
parent_id
(str
) –The
id
attribute of the parent event. -
parent_uuid
(str
) –The
uuid
attribute of the parent event. -
tags
(set of str
) –Descriptive tags for the event, e.g.,
mx-record
,in-scope
. -
module
(BaseModule
) –The module that discovered the event.
-
module_sequence
(str
) –The sequence of modules that participated in the discovery.
Examples:
{
"type": "URL",
"id": "URL:017ec8e5dc158c0fd46f07169f8577fb4b45e89a",
"data": "http://www.blacklanternsecurity.com/",
"web_spider_distance": 0,
"scope_distance": 0,
"scan": "SCAN:4d786912dbc97be199da13074699c318e2067a7f",
"timestamp": 1688526222.723366,
"resolved_hosts": ["185.199.108.153"],
"parent": "OPEN_TCP_PORT:cf7e6a937b161217eaed99f0c566eae045d094c7",
"tags": ["in-scope", "distance-0", "dir", "ip-185-199-108-153", "status-301", "http-title-301-moved-permanently"],
"module": "httpx",
"module_sequence": "httpx"
}
Source code in bbot/core/event/base.py
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 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
|
pretty_string
property
pretty_string
A human-friendly representation of the event's data. Used for graph representation.
If the event's data is a dictionary, the function will try to return a JSON-formatted string. Otherwise, it will use smart_decode to convert the data into a string representation.
Override if necessary.
Returns:
-
str
–The graphical representation of the event's data.
module_sequence
property
module_sequence
Get a human-friendly string that represents the sequence of modules responsible for generating this event.
Includes the names of omitted parent events to provide a complete view of the module sequence leading to this event.
Returns:
-
str
–The module sequence in human-friendly format.
__init__
__init__(data, event_type, parent=None, context=None, module=None, scan=None, tags=None, confidence=100, timestamp=None, _dummy=False, _internal=None)
Initializes an Event object with the given parameters.
In most cases, you should use make_event()
instead of instantiating this class directly.
make_event()
is much friendlier, and can auto-detect the event type for you.
Attributes:
-
data
((str, dict)
) –The primary data for the event.
-
event_type
(str
) –Type of the event, e.g., 'IP_ADDRESS'.
-
parent
(BaseEvent
) –Parent event that led to this event's discovery. Defaults to None.
-
module
(str
) –Module that discovered the event. Defaults to None.
-
scan
(Scan
) –BBOT Scan object. Required unless _dummy is True. Defaults to None.
-
tags
(list of str
) –Descriptive tags for the event. Defaults to None.
-
confidence
(int
) –Confidence level for the event, on a scale of 1-100. Defaults to 100.
-
timestamp
(datetime
) –Time of event discovery. Defaults to current UTC time.
-
_dummy
(bool
) –If True, disables certain data validations. Defaults to False.
-
_internal
(Any
) –If specified, makes the event internal. Defaults to None.
Raises:
-
ValidationError
–If either
scan
orparent
are not specified and_dummy
is False.
Source code in bbot/core/event/base.py
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 |
|
json
json(mode='json', siem_friendly=False)
Serializes the event object to a JSON-compatible dictionary.
By default, it includes attributes such as 'type', 'id', 'data', 'scope_distance', and others that are present. Additional specific attributes can be serialized based on the mode specified.
Parameters:
-
mode
(str
, default:'json'
) –Specifies the data serialization mode. Default is "json". Other options include "graph", "human", and "id".
-
siem_friendly
(bool
, default:False
) –Whether to format the JSON in a way that's friendly to SIEM ingestion by Elastic, Splunk, etc. This ensures the value of "data" is always the same type (a dictionary).
Returns:
-
dict
–JSON-serializable dictionary representation of the event object.
Source code in bbot/core/event/base.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
|
from_json
staticmethod
from_json(j)
Convenience shortcut to create an Event object from a JSON-compatible dictionary.
Calls the event_from_json()
function to deserialize the event.
Parameters:
-
j
(dict
) –The JSON-compatible dictionary containing event data.
Returns:
-
Event
–The deserialized Event object.
Source code in bbot/core/event/base.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
|