Created
June 6, 2020 12:33
-
-
Save jasperla/15b2758612d8b06c5f2ee18ecc4da08e 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 argparse | |
# Using mona.py to find the badbytes with unicode: | |
# !mona cmp -r $REG -f c:\all_chars_unicode.bin | |
# then use 'xxd -s $offset all_chars.bin' to find the actual byte matching the offset. | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--unicode', '-u', action='store_true') | |
args = parser.parse_args() | |
all_chars = '' | |
bad_chars = [0x00] | |
for i in range(0x00, 0xFF+1): | |
if i not in bad_chars: | |
all_chars += chr(i) | |
if args.unicode: | |
print('[*] Writing all_chars_unicode.bin') | |
with open("all_chars_unicode.bin", "w", encoding='utf-16le') as f: | |
f.write(all_chars) | |
else: | |
print('[*] Writing all_chars.bin') | |
with open("all_chars.bin", "wb") as f: | |
f.write(bytes(all_chars, 'charmap')) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment