Skip to content

Instantly share code, notes, and snippets.

@burdenless
Last active August 29, 2015 13:57
Show Gist options
  • Save burdenless/9508023 to your computer and use it in GitHub Desktop.
Save burdenless/9508023 to your computer and use it in GitHub Desktop.
Decodes and inflates Base64 encoded strings/binaries
#!/usr/bin/env python
#
# Developed by Pendrak0n
#
# Capabilities: Decodes & decompresses Base64 encoded text and saves to a file
# Use Case: Decode binaries that have been compressed and encoded with Base64 to avoid detection
#
import re
import zlib
def decode(filename, ciphertxt):
string = re.sub('\s', '', ciphertxt) ## Remove whitespace characters
plain = string.decode('base64', 'strict') ## Decode the Base64
data = zlib.decompress(plain, -15) ## Inflate string
file = open(filename, 'w+') ## Write to new file
file.write(data)
file.close()
print '[+] Binary string decoded and inflated to original executable!'
def main():
cipher = raw_input('Base64 Encoded binary:\n> ')
file = raw_input('Name to give new executable (including extension):\n> ')
decode(file, cipher)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment