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

Option to Raise FILESYSTEM and WEBSCREENSHOT with base64 blobs #1438

Merged
merged 5 commits into from
Jun 13, 2024

Conversation

nicpenning
Copy link
Contributor

Draft code things

@nicpenning
Copy link
Contributor Author

FYI - Needs work and is not currently functioning or well thought out.

@TheTechromancer
Copy link
Collaborator

It's a good start. Tomorrow I'll see if I can pitch in and get it working.

@TheTechromancer
Copy link
Collaborator

TheTechromancer commented Jun 5, 2024

@nicpenning are you able to allow edits from maintainers?

image

@nicpenning
Copy link
Contributor Author

nicpenning commented Jun 5, 2024

image

Looks like I already had that set.

image

@nicpenning nicpenning marked this pull request as ready for review June 5, 2024 18:14
@TheTechromancer
Copy link
Collaborator

Okay, I made a few changes:

  • Added global file_blobs and folder_blobs options
  • Wrote tests
  • Added feature for both WEBSCREENSHOT and FILESYSTEM

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 98.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 92%. Comparing base (eeae1cb) to head (e8a45e0).

Files Patch % Lines
bbot/core/event/base.py 98% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           stable   #1438   +/-   ##
======================================
- Coverage      92%     92%   -0%     
======================================
  Files         321     321           
  Lines       20685   20749   +64     
======================================
+ Hits        19014   19057   +43     
- Misses       1671    1692   +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nicpenning
Copy link
Contributor Author

Phenomenal!

@TheTechromancer TheTechromancer changed the base branch from stable to dev June 6, 2024 00:16
@TheTechromancer TheTechromancer changed the title Trying raise FILESYSTEM with b64 encodings + filedownload using it Option to Raise FILESYSTEM and WESCREENSHOT with base64 blobs Jun 6, 2024
@nicpenning
Copy link
Contributor Author

Please let me know how I can test with custom/flag options, and I can run do some trial runs to see how it shakes out.

@TheTechromancer
Copy link
Collaborator

TheTechromancer commented Jun 7, 2024

Please let me know how I can test

@nicpenning you can test like this:

bbot -t evilcorp.com -c file_blobs=true folder_blobs=true

This will automatically attach binary blobs to any WEBSCREENSHOT and FILESYSTEM events. Do be aware that if the FILESYSTEM event is a folder (i.e. a git repo), the blob contains a compressed tar.gz archive.

codebase_event = self.make_event(
{"path": str(repo_path)}, "FILESYSTEM", tags=["git", "folder"], source=event
)
codebase_event = self.make_event({"path": str(repo_path)}, "FILESYSTEM", tags=["git"], source=event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the folder tag here will stop the unstructured module from crawling the folder

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tag will still be there, only now it's added automatically during the creation of the event.

@TheTechromancer
Copy link
Collaborator

@nicpenning have you got a chance to test?

@nicpenning
Copy link
Contributor Author

Not yet, but I will test as soon as I can! My initial test didn't work but I might not have had my config options or code updated properly.

@nicpenning
Copy link
Contributor Author

So far works great! Only downside is that the blob event that gets emitted to the console takes up a lot of lines (like 600K and in some cases I imagine it could be millions). It is bearable, but makes it more difficult to watch the scans progression using the default output.

Going to test the strict options to ensure I only get blobs for the appropriate scope.

@nicpenning
Copy link
Contributor Author

So does FILESYSTEM == filedownload?

I get all of the screenshots as PNGs in the output.ndjson but never the filedownload but shouldn't I need to set that configuration for the filedownload to use the blob feature? It doesn't seem the pdf, docx, etc.. that are in the filedownload directory are in the event at all (not just missing the blob).

Running this command bbot -t evilcorp.com -c file_blobs=true folder_blobs=true output_modules.http.siem_friendly=true modules.filedownload.base_64_encoded_file=true -m filedownload httpx gowitness

{"type": "WEBSCREENSHOT", "id": "WEBSCREENSHOT:4ec4b0a8e3ce89c7a85d9bb9b81d91dd652cccea", "data": {"filename": "/home/yams/.bbot/scans/heightened_jeremy/gowitness/screenshots/https-evilcorp.com.png", "url": "https://evilcorp.com/inside-evilcorp", "blob": "iVBORw0KG..."}

TL:DR - Screenshots seem to work, but the FILESYSTEM / filedownload module does not emit an event (so blob definitely does not exist).

@nicpenning
Copy link
Contributor Author

Here is a real world example: bbot -t "https://eicar.org/download-anti-malware-testfile/" -c file_blobs=true folder_blobs=true output_modules.http.siem_friendly=true modules.filedownload.base_64_encoded_file=true -m filedownload httpx gowitness

Files downloaded, but none are in the events (output.ndjson).
image

Otherwise, everything else is working as expected.

@TheTechromancer
Copy link
Collaborator

Hmm I think this branch needs merged with the latest dev, so it includes this PR:

Screenshot_20240612-223535.png

@TheTechromancer TheTechromancer changed the title Option to Raise FILESYSTEM and WESCREENSHOT with base64 blobs Option to Raise FILESYSTEM and WEBSCREENSHOT with base64 blobs Jun 13, 2024
@TheTechromancer
Copy link
Collaborator

I'm going to go ahead and merge this. We can make tweaks in a followup PR if needed.

@nicpenning
Copy link
Contributor Author

Sounds great

@TheTechromancer TheTechromancer merged commit 92834ea into blacklanternsecurity:dev Jun 13, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants