Last active
August 29, 2015 13:57
-
-
Save burdenless/9508023 to your computer and use it in GitHub Desktop.
Decodes and inflates Base64 encoded strings/binaries
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 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