Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev --> Stable (2.01) #1650

Merged
merged 199 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
0354266
Bump pyjwt from 2.8.0 to 2.9.0
dependabot[bot] Aug 5, 2024
a223a82
Bump pyzmq from 26.0.3 to 26.1.0
dependabot[bot] Aug 5, 2024
402404d
Bump black from 24.4.2 to 24.8.0
dependabot[bot] Aug 5, 2024
b9c5de5
Add `raw_text` to excavate and change unstructured discovery context
domwhewell-sage Aug 6, 2024
98b0b3b
Add tests and stop newlines from printing in debug logs
domwhewell-sage Aug 6, 2024
430a631
Include test.notreal and localhost in tests
domwhewell-sage Aug 6, 2024
bc0dfb6
Bump mkdocs-material from 9.5.26 to 9.5.31
dependabot[bot] Aug 6, 2024
8b80e54
Fix unstructured
domwhewell-sage Aug 7, 2024
a40da6a
Make `RAW_TEXT` a dict event
domwhewell-sage Aug 7, 2024
0b490f6
Revert "Make `RAW_TEXT` a dict event"
domwhewell-sage Aug 7, 2024
0fe898e
Add a check to ensure event is a `dict`
domwhewell-sage Aug 7, 2024
6072230
Add service_record function
colin-stubbs Aug 7, 2024
46cac6c
Fix black formatting requirement
colin-stubbs Aug 7, 2024
32cdcbc
Test *almost* all Excavate rules
domwhewell-sage Aug 7, 2024
3b67328
Fix final_url not defined error
domwhewell-sage Aug 7, 2024
3e6109b
lint
domwhewell-sage Aug 7, 2024
2a1fed4
Increase scope distance
domwhewell-sage Aug 7, 2024
52d53f5
Closes #1642
domwhewell-sage Aug 9, 2024
d797767
Lint
domwhewell-sage Aug 9, 2024
45c45c3
make dnsbrute active
invalid-email-address Aug 11, 2024
f068227
fixing tests
invalid-email-address Aug 11, 2024
bc5cbf0
Merge pull request #1644 from domwhewell-sage/deleted_forks
TheTechromancer Aug 11, 2024
9c9d87c
more work on tests
invalid-email-address Aug 11, 2024
3ccf409
Merge branch 'dev' into dependabot/pip/dev/pyjwt-2.9.0
TheTechromancer Aug 11, 2024
a023d2f
Merge pull request #1632 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 11, 2024
f1871e9
Merge pull request #1630 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 11, 2024
cdfc484
Merge pull request #1633 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 11, 2024
6d26204
allow version updater to trigger tests
invalid-email-address Aug 12, 2024
50d85cd
Bump lxml from 5.2.2 to 5.3.0
dependabot[bot] Aug 12, 2024
661b3ff
Bump pytest-httpserver from 1.0.11 to 1.1.0
dependabot[bot] Aug 12, 2024
b5d51b6
Merge branch 'dev' into service-record
TheTechromancer Aug 12, 2024
88ab7c8
relocate common SRV records, add tests
invalid-email-address Aug 12, 2024
098f0c1
fix conflict
invalid-email-address Aug 12, 2024
2559686
reimplement event confidence
invalid-email-address Aug 12, 2024
ba359d0
update docs
invalid-email-address Aug 12, 2024
898c47a
flake
invalid-email-address Aug 12, 2024
64b6072
fix tests
invalid-email-address Aug 12, 2024
70eba73
add path attribute to findings/vulns, accept blank host
invalid-email-address Aug 12, 2024
ad55c2e
comment tests
invalid-email-address Aug 12, 2024
fa51cff
Merge pull request #1652 from blacklanternsecurity/fix-version-updater
TheTechromancer Aug 13, 2024
b40cef2
fix description
invalid-email-address Aug 13, 2024
5babb1b
Merge branch 'dev' into closest-host-option
TheTechromancer Aug 13, 2024
3b0640f
Merge branch 'dev' into event-confidence
TheTechromancer Aug 13, 2024
7f07783
Merge branch 'stable' into dnsbrute-active
TheTechromancer Aug 13, 2024
692dae3
Merge branch 'dev' into service-record
TheTechromancer Aug 13, 2024
2df980a
Tagged modules with `code-enum`
domwhewell-sage Aug 14, 2024
1220598
Merge pull request #1659 from domwhewell-sage/add-code-enum-tags
TheTechromancer Aug 14, 2024
f6c533a
better engine debugging
invalid-email-address Aug 14, 2024
fbf1a0f
pin unstructured version
invalid-email-address Aug 15, 2024
5ce846f
blacked
invalid-email-address Aug 15, 2024
a4bea60
Merge pull request #1661 from blacklanternsecurity/fix-unstructured
TheTechromancer Aug 15, 2024
a40a0f7
Merge branch 'dev' into engine-debug
TheTechromancer Aug 15, 2024
1d1c1ad
Merge branch 'dev' into closest-host-option
TheTechromancer Aug 15, 2024
820048b
Merge branch 'dev' into event-confidence
TheTechromancer Aug 15, 2024
c39294c
Merge branch 'dev' into dnsbrute-active
TheTechromancer Aug 15, 2024
7b59164
Merge branch 'dev' into service-record
TheTechromancer Aug 15, 2024
8c9440a
Update nuclei
web-flow Aug 16, 2024
3a57829
Update trufflehog
web-flow Aug 16, 2024
9e9fa0b
remove debugging message
invalid-email-address Aug 16, 2024
c39d561
new commit hash
invalid-email-address Aug 16, 2024
4c9fbdf
Merge pull request #1663 from blacklanternsecurity/fix-unstructured
TheTechromancer Aug 16, 2024
a0cb8b1
Merge branch 'dev' into engine-debug
TheTechromancer Aug 16, 2024
35a737b
Merge branch 'dev' into closest-host-option
TheTechromancer Aug 16, 2024
ad19b95
Merge branch 'dev' into event-confidence
TheTechromancer Aug 16, 2024
a17966e
Merge branch 'dev' into dnsbrute-active
TheTechromancer Aug 16, 2024
d2c78c6
Merge branch 'dev' into service-record
TheTechromancer Aug 16, 2024
690f8c2
Merge branch 'dev' into dependabot/pip/dev/pyjwt-2.9.0
TheTechromancer Aug 16, 2024
43b5b53
Merge branch 'dev' into update-nuclei
TheTechromancer Aug 16, 2024
f6e8d3e
Merge branch 'dev' into update-trufflehog
TheTechromancer Aug 16, 2024
ef115c4
Merge branch 'dev' into dependabot/pip/dev/pytest-httpserver-1.1.0
TheTechromancer Aug 16, 2024
4279621
Merge branch 'dev' into dependabot/pip/dev/lxml-5.3.0
TheTechromancer Aug 16, 2024
cac50df
Merge pull request #1646 from blacklanternsecurity/update-trufflehog
TheTechromancer Aug 16, 2024
16d367b
Merge pull request #1645 from blacklanternsecurity/update-nuclei
TheTechromancer Aug 16, 2024
1eb8362
Merge pull request #1629 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 16, 2024
51afff0
Merge pull request #1654 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 16, 2024
bc56830
Merge pull request #1653 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 16, 2024
f8f0115
Merge pull request #1660 from blacklanternsecurity/engine-debug
TheTechromancer Aug 16, 2024
9250fa5
Merge pull request #1656 from blacklanternsecurity/closest-host-option
TheTechromancer Aug 16, 2024
1198d9b
Merge branch 'dev' into excavate_raw_text
domwhewell-sage Aug 16, 2024
b59dfd9
Merge branch 'dev' into event-confidence
TheTechromancer Aug 16, 2024
207563c
Merge pull request #1640 from colin-stubbs/service-record
TheTechromancer Aug 16, 2024
ae639ff
Merge branch 'dev' into dnsbrute-active
TheTechromancer Aug 16, 2024
acb77de
support usernames as targets
invalid-email-address Aug 16, 2024
5c985aa
Only add url to `FINDING` event if it exists in the source_event
domwhewell-sage Aug 16, 2024
c48a5c6
Add the parents path to the `FINDING` / `VULNERABILITY`
domwhewell-sage Aug 16, 2024
703d048
Merge pull request #1655 from blacklanternsecurity/event-confidence
TheTechromancer Aug 16, 2024
4abd67c
Get the url from the event dict
domwhewell-sage Aug 16, 2024
b03df80
Check if parent data is a dictionary
domwhewell-sage Aug 16, 2024
698d2fe
Merge pull request #1665 from blacklanternsecurity/username-targets
TheTechromancer Aug 16, 2024
3172528
Merge pull request #1649 from blacklanternsecurity/dnsbrute-active
TheTechromancer Aug 16, 2024
121462c
Improved tests and fixed parent event
domwhewell-sage Aug 16, 2024
48aae2e
Made changes to test. *crosses fingers
domwhewell-sage Aug 16, 2024
6b4217b
D'oh
domwhewell-sage Aug 16, 2024
4df4d4a
Correct tests for `URL_UNVERIFIED` events
domwhewell-sage Aug 16, 2024
672c790
bro, do you even unit test?
domwhewell-sage Aug 16, 2024
e735daa
better host inheritance
invalid-email-address Aug 16, 2024
3b1b7f8
fix httpx memory leak
invalid-email-address Aug 16, 2024
aa1e93c
better caching
invalid-email-address Aug 16, 2024
ac08e5f
Merge pull request #1667 from blacklanternsecurity/fix-httpx-memory-leak
TheTechromancer Aug 16, 2024
01d9b8f
update unstructured to use pypi
invalid-email-address Aug 17, 2024
92dc6a5
Merge remote-tracking branch 'upstream/better-host-inheritance' into …
domwhewell-sage Aug 17, 2024
147579d
Remove getting parent.path in excavate as the `FINDING` does that for us
domwhewell-sage Aug 17, 2024
8048e70
if there is an event host from `HTTP_RESPONSE` then set this in the e…
domwhewell-sage Aug 17, 2024
a0a8f32
clean up
invalid-email-address Aug 17, 2024
62846a0
fix version
invalid-email-address Aug 17, 2024
2688bae
update readme
invalid-email-address Aug 17, 2024
5fa774a
Merge pull request #1636 from domwhewell-sage/excavate_raw_text
TheTechromancer Aug 17, 2024
a2a9afc
Merge pull request #1669 from blacklanternsecurity/fix-unstructured
TheTechromancer Aug 17, 2024
7520e93
Bump mkdocstrings-python from 1.10.3 to 1.10.8
dependabot[bot] Aug 19, 2024
a9a849b
Bump cachetools from 5.3.3 to 5.5.0
dependabot[bot] Aug 19, 2024
940a727
Bump mike from 2.1.2 to 2.1.3
dependabot[bot] Aug 19, 2024
373058c
Enhance github workflows to download any workflow artifacts aswell
domwhewell-sage Aug 20, 2024
ec66fb5
Merge pull request #1683 from domwhewell-sage/artipacked
TheTechromancer Aug 20, 2024
7bfbb29
Added RawV2 to trufflehog output
domwhewell-sage Aug 20, 2024
06fe2a9
Add a test for the RawV2 result
domwhewell-sage Aug 20, 2024
c1415cc
Update test_module_trufflehog.py
TheTechromancer Aug 20, 2024
1e04373
Merge pull request #1687 from domwhewell-sage/enhance_trufflehog_output
TheTechromancer Aug 21, 2024
73739ca
Split out the owner from the repository URL and use that as the conta…
domwhewell-sage Aug 21, 2024
ff53e24
Forgot to update the test
domwhewell-sage Aug 21, 2024
d5a881b
More test corrections
domwhewell-sage Aug 21, 2024
ad6de81
removed unnecessary `self.output_dir`
domwhewell-sage Aug 21, 2024
ab53ff0
Merge pull request #1690 from domwhewell-sage/small-git-clone-patch
TheTechromancer Aug 21, 2024
4b1ba22
Merge pull request #1677 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 22, 2024
c4b425c
Merge branch 'dev' into dependabot/pip/dev/cachetools-5.5.0
TheTechromancer Aug 22, 2024
0e1c426
Merge pull request #1676 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 22, 2024
82a0bea
Merge branch 'dev' into dependabot/pip/dev/mkdocstrings-python-1.10.8
TheTechromancer Aug 23, 2024
40b034b
fixing web_parameters appearing when no modules listening
liquidsec Aug 24, 2024
696ab91
optimize generate_templist
liquidsec Aug 24, 2024
2e88ac4
fixing excavate header parameter test
liquidsec Aug 24, 2024
16fc5fa
Merge pull request #1695 from blacklanternsecurity/excavate-unsolicte…
liquidsec Aug 24, 2024
0e33cd9
variable cleanup
liquidsec Aug 24, 2024
0a9caa5
Merge pull request #1696 from blacklanternsecurity/ffuf-optimize-gene…
liquidsec Aug 25, 2024
08ad1ba
Bump cloudcheck from 5.0.1.415 to 5.0.1.515
dependabot[bot] Aug 26, 2024
45cf8a5
Bump pyzmq from 26.1.0 to 26.2.0
dependabot[bot] Aug 26, 2024
74de67a
Bump pytest-asyncio from 0.23.8 to 0.24.0
dependabot[bot] Aug 26, 2024
0749c15
Bump idna from 3.7 to 3.8
dependabot[bot] Aug 26, 2024
5bac76a
Bump werkzeug from 3.0.3 to 3.0.4
dependabot[bot] Aug 26, 2024
54a499f
Bump mkdocs-material from 9.5.31 to 9.5.33
dependabot[bot] Aug 26, 2024
335c44e
Merge pull request #1700 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
7339ad7
Merge pull request #1702 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
8be1cfe
Merge pull request #1704 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
d56a680
Merge pull request #1705 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
15496ec
Merge pull request #1706 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
c08f19e
Merge pull request #1703 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
748bea7
Merge pull request #1675 from blacklanternsecurity/dependabot/pip/dev…
TheTechromancer Aug 26, 2024
9522dd2
better engine debugging
invalid-email-address Aug 19, 2024
063d027
more debugging
invalid-email-address Aug 19, 2024
be2ae32
high water marks
invalid-email-address Aug 19, 2024
be9179a
better engine debug
invalid-email-address Aug 19, 2024
4ac5a72
fix queue draining bug
invalid-email-address Aug 19, 2024
3b219e8
more debugging
invalid-email-address Aug 19, 2024
24c2fa7
update unstructured
invalid-email-address Aug 20, 2024
844b684
fix web proxy
invalid-email-address Aug 20, 2024
70a7cff
fix ffuf tests
invalid-email-address Aug 20, 2024
ba31de5
cache asn queries
invalid-email-address Aug 20, 2024
0b82e2f
fix asn bug
invalid-email-address Aug 20, 2024
196e87f
increase interval
invalid-email-address Aug 21, 2024
ee21c85
debug logging
invalid-email-address Aug 21, 2024
a9aa2ba
fix excavate bug
invalid-email-address Aug 22, 2024
e4ca715
don't keep client tasks
invalid-email-address Aug 23, 2024
f7a748e
fix bug
invalid-email-address Aug 23, 2024
5e981ff
blacked
invalid-email-address Aug 23, 2024
429b234
delete some code
invalid-email-address Aug 23, 2024
798a1fa
blacked
invalid-email-address Aug 23, 2024
09ec45d
remove debug messages
invalid-email-address Aug 23, 2024
b845132
fix bug with queue draining
invalid-email-address Aug 23, 2024
b55b79d
remove unneeded debug statements
invalid-email-address Aug 24, 2024
3de844b
fix unstructured bug
invalid-email-address Aug 26, 2024
0a40790
fix path bug
invalid-email-address Aug 26, 2024
01b4136
fix unstructured???
invalid-email-address Aug 26, 2024
d3922c2
fix tests
invalid-email-address Aug 26, 2024
f652f73
Update command.py
TheTechromancer Aug 27, 2024
6a55178
Merge pull request #1708 from blacklanternsecurity/fix-path-bug
TheTechromancer Aug 27, 2024
18d365f
removed fix for https://github.com/blacklanternsecurity/bbot/issues/1…
invalid-email-address Aug 27, 2024
98c0dea
Merge pull request #1678 from blacklanternsecurity/better-engine-debu…
TheTechromancer Aug 27, 2024
42669c8
bump version
invalid-email-address Aug 27, 2024
5662568
Merge pull request #1710 from blacklanternsecurity/bump-version
TheTechromancer Aug 27, 2024
f2c5400
more optimization
invalid-email-address Aug 27, 2024
d367d34
fix typo
invalid-email-address Aug 27, 2024
cd132c1
fix tests
invalid-email-address Aug 27, 2024
659b82b
Merge pull request #1711 from blacklanternsecurity/ffuf-optimization
TheTechromancer Aug 27, 2024
fb14be5
Release notes contained new lines so was not setting the GITHUB varia…
domwhewell-sage Aug 28, 2024
873814e
Set release notes as heading
domwhewell-sage Aug 28, 2024
89d5069
Merge branch 'dev' into patch_version_updated
domwhewell-sage Aug 28, 2024
efe642d
Merge pull request #1714 from domwhewell-sage/patch_version_updated
TheTechromancer Aug 28, 2024
15b4b36
fix tablesort
invalid-email-address Aug 28, 2024
50ca824
bump baddns, lower dnswalk timeout settings
liquidsec Aug 28, 2024
c9c7ab7
fix tag error
invalid-email-address Aug 28, 2024
dfdcfbf
Merge branch 'dev' into baddns-dnswalk-settings
liquidsec Aug 28, 2024
26a60de
matching value with bbot default
liquidsec Aug 28, 2024
50da5f1
Merge pull request #1717 from blacklanternsecurity/fix-event-tags
TheTechromancer Aug 28, 2024
8ccc1d7
Merge pull request #1716 from blacklanternsecurity/fix-tablesort
TheTechromancer Aug 28, 2024
64e6a5a
Merge pull request #1718 from blacklanternsecurity/baddns-dnswalk-set…
liquidsec Aug 28, 2024
34663e3
Filter out already processed events from trufflehog
domwhewell-sage Aug 29, 2024
adc3140
Use Path instead of os
domwhewell-sage Aug 29, 2024
c09bc0e
Add an option to trufflehog to allow users to specify their own custo…
domwhewell-sage Aug 29, 2024
cf263e1
Changed option description
domwhewell-sage Aug 29, 2024
465020b
Merge pull request #1720 from domwhewell-sage/trufflehog-fix
TheTechromancer Aug 29, 2024
26cba49
Merge pull request #1722 from domwhewell-sage/add-trufflehog-option
TheTechromancer Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/version_updater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ jobs:
response = requests.get('https://api.github.com/repos/projectdiscovery/nuclei/releases/latest')
version = response.json()['tag_name'].lstrip('v')
release_notes = response.json()['body']
os.system(f"echo 'latest_version={version}' >> $GITHUB_ENV")
os.system(f"echo 'release_notes={release_notes}' >> $GITHUB_ENV")
with open(os.getenv('GITHUB_ENV'), 'a') as env_file:
env_file.write(f"latest_version={version}\n")
env_file.write(f"release_notes<<EOF\n{release_notes}\nEOF\n")
shell: python
- name: Get current version
id: get-current-version
Expand All @@ -44,13 +45,13 @@ jobs:
if: steps.update-version.outcome == 'success'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.BBOT_DOCS_UPDATER_PAT }}
commit-message: "Update nuclei"
title: "Update nuclei to ${{ env.latest_version }}"
body: |
This PR uses https://api.github.com/repos/projectdiscovery/nuclei/releases/latest to obtain the latest version of nuclei and update the version in bbot/modules/deadly/nuclei.py."

Release notes:
# Release notes:
${{ env.release_notes }}
branch: "update-nuclei"
committer: GitHub <[email protected]>
Expand Down Expand Up @@ -78,8 +79,9 @@ jobs:
response = requests.get('https://api.github.com/repos/trufflesecurity/trufflehog/releases/latest')
version = response.json()['tag_name'].lstrip('v')
release_notes = response.json()['body']
os.system(f"echo 'latest_version={version}' >> $GITHUB_ENV")
os.system(f"echo 'release_notes={release_notes}' >> $GITHUB_ENV")
with open(os.getenv('GITHUB_ENV'), 'a') as env_file:
env_file.write(f"latest_version={version}\n")
env_file.write(f"release_notes<<EOF\n{release_notes}\nEOF\n")
shell: python
- name: Get current version
id: get-current-version
Expand All @@ -94,13 +96,13 @@ jobs:
if: steps.update-version.outcome == 'success'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.BBOT_DOCS_UPDATER_PAT }}
commit-message: "Update trufflehog"
title: "Update trufflehog to ${{ env.latest_version }}"
body: |
This PR uses https://api.github.com/repos/trufflesecurity/trufflehog/releases/latest to obtain the latest version of trufflehog and update the version in bbot/modules/trufflehog.py.

Release notes:
# Release notes:
${{ env.release_notes }}
branch: "update-trufflehog"
committer: GitHub <[email protected]>
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Passive API sources plus a recursive DNS brute-force with target-specific subdom
```bash
# find subdomains of evilcorp.com
bbot -t evilcorp.com -p subdomain-enum

# passive sources only
bbot -t evilcorp.com -p subdomain-enum -rf passive
```

<!-- BBOT SUBDOMAIN-ENUM PRESET EXPANDABLE -->
Expand Down
258 changes: 170 additions & 88 deletions bbot/core/engine.py

Large diffs are not rendered by default.

102 changes: 75 additions & 27 deletions bbot/core/event/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(
scan=None,
scans=None,
tags=None,
confidence=5,
confidence=100,
timestamp=None,
_dummy=False,
_internal=None,
Expand All @@ -146,7 +146,7 @@ def __init__(
scan (Scan, optional): BBOT Scan object. Required unless _dummy is True. Defaults to None.
scans (list of Scan, optional): BBOT Scan objects, used primarily when unserializing an Event from the database. Defaults to None.
tags (list of str, optional): Descriptive tags for the event. Defaults to None.
confidence (int, optional): Confidence level for the event, on a scale of 1-10. Defaults to 5.
confidence (int, optional): Confidence level for the event, on a scale of 1-100. Defaults to 100.
timestamp (datetime, optional): Time of event discovery. Defaults to current UTC time.
_dummy (bool, optional): If True, disables certain data validations. Defaults to False.
_internal (Any, optional): If specified, makes the event internal. Defaults to None.
Expand Down Expand Up @@ -237,6 +237,27 @@ def __init__(
def data(self):
return self._data

@property
def confidence(self):
return self._confidence

@confidence.setter
def confidence(self, confidence):
self._confidence = min(100, max(1, int(confidence)))

@property
def cumulative_confidence(self):
"""
Considers the confidence of parent events. This is useful for filtering out speculative/unreliable events.

E.g. an event with a confidence of 50 whose parent is also 50 would have a cumulative confidence of 25.

A confidence of 100 will reset the cumulative confidence to 100.
"""
if self._confidence == 100 or self.parent is None or self.parent is self:
return self._confidence
return int(self._confidence * self.parent.cumulative_confidence / 100)

@property
def resolved_hosts(self):
if is_ip(self.host):
Expand Down Expand Up @@ -359,7 +380,7 @@ def discovery_path(self):
This event's full discovery context, including those of all its parents
"""
parent_path = []
if self.parent is not None and self != self.parent:
if self.parent is not None and self.parent is not self:
parent_path = self.parent.discovery_path
return parent_path + [[self.id, self.discovery_context]]

Expand Down Expand Up @@ -387,6 +408,10 @@ def tags(self, tags):
def add_tag(self, tag):
self._tags.add(tagify(tag))

def add_tags(self, tags):
for tag in set(tags):
self.add_tag(tag)

def remove_tag(self, tag):
with suppress(KeyError):
self._tags.remove(tagify(tag))
Expand Down Expand Up @@ -461,10 +486,10 @@ def scope_distance(self, scope_distance):
self.remove_tag("in-scope")
self.add_tag(f"distance-{new_scope_distance}")
self._scope_distance = new_scope_distance
# apply recursively to parent events
parent_scope_distance = getattr(self.parent, "scope_distance", None)
if parent_scope_distance is not None and self != self.parent:
self.parent.scope_distance = scope_distance + 1
# apply recursively to parent events
parent_scope_distance = getattr(self.parent, "scope_distance", None)
if parent_scope_distance is not None and self.parent is not self:
self.parent.scope_distance = new_scope_distance + 1

@property
def scope_description(self):
Expand Down Expand Up @@ -869,7 +894,7 @@ def __hash__(self):

def __str__(self):
max_event_len = 80
d = str(self.data)
d = str(self.data).replace("\n", "\\n")
return f'{self.type}("{d[:max_event_len]}{("..." if len(d) > max_event_len else "")}", module={self.module}, tags={self.tags})'

def __repr__(self):
Expand Down Expand Up @@ -923,19 +948,40 @@ def _host(self):
return make_ip_type(parsed.hostname)


class DictPathEvent(DictEvent):
_path_keywords = ["path", "filename"]
class ClosestHostEvent(DictHostEvent):
# if a host/path/url isn't specified, this event type grabs it from the closest parent
# inherited by FINDING and VULNERABILITY
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not self.host:
for parent in self.get_parents(include_self=True):
# inherit closest URL
if not "url" in self.data:
parent_url = getattr(parent, "parsed_url", None)
if parent_url is not None:
self.data["url"] = parent_url.geturl()
# inherit closest path
if not "path" in self.data and isinstance(parent.data, dict):
parent_path = parent.data.get("path", None)
if parent_path is not None:
self.data["path"] = parent_path
# inherit closest host
if parent.host:
self.data["host"] = str(parent.host)
break
# die if we still haven't found a host
if not self.host:
raise ValueError("No host was found in event parents. Host must be specified!")


class DictPathEvent(DictEvent):
def sanitize_data(self, data):
new_data = dict(data)
file_blobs = getattr(self.scan, "_file_blobs", False)
folder_blobs = getattr(self.scan, "_folder_blobs", False)
for path_keyword in self._path_keywords:
blob = None
try:
data_path = Path(data[path_keyword])
except KeyError:
continue
blob = None
try:
data_path = Path(data["path"])
if data_path.is_file():
self.add_tag("file")
if file_blobs:
Expand All @@ -945,10 +991,10 @@ def sanitize_data(self, data):
self.add_tag("folder")
if folder_blobs:
blob = self._tar_directory(data_path)
else:
continue
if blob:
new_data["blob"] = base64.b64encode(blob).decode("utf-8")
except KeyError:
pass
if blob:
new_data["blob"] = base64.b64encode(blob).decode("utf-8")

return new_data

Expand Down Expand Up @@ -1300,7 +1346,7 @@ def redirect_location(self):
return location


class VULNERABILITY(DictHostEvent):
class VULNERABILITY(ClosestHostEvent):
_always_emit = True
_quick_emit = True
severity_colors = {
Expand All @@ -1316,10 +1362,11 @@ def sanitize_data(self, data):
return data

class _data_validator(BaseModel):
host: str
host: Optional[str] = None
severity: str
description: str
url: Optional[str] = None
path: Optional[str] = None
_validate_url = field_validator("url")(validators.validate_url)
_validate_host = field_validator("host")(validators.validate_host)
_validate_severity = field_validator("severity")(validators.validate_severity)
Expand All @@ -1328,14 +1375,15 @@ def _pretty_string(self):
return f'[{self.data["severity"]}] {self.data["description"]}'


class FINDING(DictHostEvent):
class FINDING(ClosestHostEvent):
_always_emit = True
_quick_emit = True

class _data_validator(BaseModel):
host: str
host: Optional[str] = None
description: str
url: Optional[str] = None
path: Optional[str] = None
_validate_url = field_validator("url")(validators.validate_url)
_validate_host = field_validator("host")(validators.validate_host)

Expand Down Expand Up @@ -1464,7 +1512,7 @@ def make_event(
scan=None,
scans=None,
tags=None,
confidence=5,
confidence=100,
dummy=False,
internal=None,
):
Expand All @@ -1484,7 +1532,7 @@ def make_event(
scan (Scan, optional): BBOT Scan object associated with the event.
scans (List[Scan], optional): Multiple BBOT Scan objects, primarily used for unserialization.
tags (Union[str, List[str]], optional): Descriptive tags for the event, as a list or a single string.
confidence (int, optional): Confidence level for the event, on a scale of 1-10. Defaults to 5.
confidence (int, optional): Confidence level for the event, on a scale of 1-100. Defaults to 100.
dummy (bool, optional): Disables data validations if set to True. Defaults to False.
internal (Any, optional): Makes the event internal if set to True. Defaults to None.

Expand Down Expand Up @@ -1613,7 +1661,7 @@ def event_from_json(j, siem_friendly=False):
"event_type": event_type,
"scans": j.get("scans", []),
"tags": j.get("tags", []),
"confidence": j.get("confidence", 5),
"confidence": j.get("confidence", 100),
"context": j.get("discovery_context", None),
"dummy": True,
}
Expand Down
21 changes: 18 additions & 3 deletions bbot/core/helpers/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import logging
import traceback
from signal import SIGINT
from subprocess import CompletedProcess, CalledProcessError
from subprocess import CompletedProcess, CalledProcessError, SubprocessError

from .misc import smart_decode, smart_encode
from .misc import smart_decode, smart_encode, which

log = logging.getLogger("bbot.core.helpers.command")

Expand Down Expand Up @@ -182,7 +182,11 @@ async def _spawn_proc(self, *command, **kwargs):
>>> _spawn_proc("ls", "-l", input="data")
(<Process ...>, "data", ["ls", "-l"])
"""
command, kwargs = self._prepare_command_kwargs(command, kwargs)
try:
command, kwargs = self._prepare_command_kwargs(command, kwargs)
except SubprocessError as e:
log.warning(e)
return None, None, None
_input = kwargs.pop("input", None)
if _input is not None:
if kwargs.get("stdin") is not None:
Expand Down Expand Up @@ -276,6 +280,17 @@ def _prepare_command_kwargs(self, command, kwargs):
command = command[0]
command = [str(s) for s in command]

if not command:
raise SubprocessError("Must specify a command")

# use full path of binary, if not already specified
binary = command[0]
if not "/" in binary:
binary_full_path = which(binary)
if binary_full_path is None:
raise SubprocessError(f'Command "{binary}" was not found')
command[0] = binary_full_path

env = kwargs.get("env", os.environ)
if sudo and os.geteuid() != 0:
self.depsinstaller.ensure_root()
Expand Down
3 changes: 2 additions & 1 deletion bbot/core/helpers/dns/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self, parent_helper):
self.parent_helper = parent_helper
self.config = self.parent_helper.config
self.dns_config = self.config.get("dns", {})
super().__init__(server_kwargs={"config": self.config})
engine_debug = self.config.get("engine", {}).get("debug", False)
super().__init__(server_kwargs={"config": self.config}, debug=engine_debug)

# resolver
self.timeout = self.dns_config.get("timeout", 5)
Expand Down
Loading
Loading