Skip to content

Instantly share code, notes, and snippets.

@jasperla
Created June 6, 2020 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasperla/15b2758612d8b06c5f2ee18ecc4da08e to your computer and use it in GitHub Desktop.
Save jasperla/15b2758612d8b06c5f2ee18ecc4da08e to your computer and use it in GitHub Desktop.
#!/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