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

non-json base64 decoding #63

Open
bryant-smith opened this issue Apr 10, 2023 · 0 comments
Open

non-json base64 decoding #63

bryant-smith opened this issue Apr 10, 2023 · 0 comments

Comments

@bryant-smith
Copy link
Contributor

Base64 decoding similar to what Suricata has.

Suricata's implementation:
base64_decode:bytes <value>, offset <value>, relative;

Instead of using the number of bytes to capture and an offset something similar to the meta_content would work nicely. Knowing the exact offset and length can be difficult to determine and be accurate. The addition of a length to capture can be great option as we may not need to capture all 1000 bytes but only the first 100. We can use an ending delimiter or stop at the first non-base64 character.

Full Capture: Ending Delimiter
base64_capture:"powershell -enc|20|%sagan%|20|";
content:"hello"; base64_data; base64_contains; base64_nocase;

Full Capture: Non-base64 Character
base64_capture:"powershell -enc|20|%sagan%", "rfc4648";
content:"hello"; base64_data; base64_contains; base64_nocase;

Partial Capture:
base64_capture:"powershell -enc|20|%sagan%", 100;
content:"hello"; base64_data; base64_contains; base64_nocase;

Sample Log:
HostApplication=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Enc aGVsbG8gd29ybGQK EngineVersion=

Suricata Documentation:
https://suricata.readthedocs.io/en/suricata-6.0.10/rules/base64-keywords.html?highlight=base64#base64-keywords

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

No branches or pull requests

1 participant