Last active
July 1, 2022 21:08
-
-
Save therealdreg/c5779d23cfd2d5596d3cb2db4a01ed8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
print("By Dreg, finding all C null-end-strings in a binary blob (string must be +2 bytes)") | |
patt = b'([\x20-\x7E]{2,})(?=\x00)' | |
blob = b'aa\x10bsssss\x01\x00dddooa\x00zzzzz\x00bb\x00' | |
print(str(patt)) | |
print(str(blob)) | |
for match in re.finditer(patt, blob): | |
print(match.span()) | |
print(match.group()) | |
print(blob[slice(*match.span())]) | |
print("-") | |
result = re.findall(patt, blob) | |
if result: | |
print("Search successful.") | |
print(result) | |
print("-") | |
else: | |
print("Search unsuccessful.") | |
python poc.py | |
By Dreg, finding all C null-end-strings in a binary blob (string must be +2 bytes) | |
b'([ -~]{2,})(?=\x00)' | |
b'aa\x10bsssss\x01\x00dddooa\x00zzzzz\x00bb\x00' | |
(11, 17) | |
b'dddooa' | |
b'dddooa' | |
- | |
(18, 23) | |
b'zzzzz' | |
b'zzzzz' | |
- | |
(24, 26) | |
b'bb' | |
b'bb' | |
- | |
Search successful. | |
[b'dddooa', b'zzzzz', b'bb'] | |
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment