Skip to content

Instantly share code, notes, and snippets.

@iordic
Last active February 15, 2018 15:49
Show Gist options
  • Save iordic/40043f047e7f663ec1559579a63e7b54 to your computer and use it in GitHub Desktop.
Save iordic/40043f047e7f663ec1559579a63e7b54 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# BRONCO~1.WSF code deobfuscation
import sys
import os
def usage():
print "Usage: " + os.path.basename(sys.argv[0]) + " <file> <output_file>"
def main():
#print get_text(binarize(read_file(sys.argv[1])))
data = get_text(binarize(read_file(sys.argv[1])))
write_file(sys.argv[2], data)
def read_file(file):
""" Open the file with the raw value and load into a variable. """
with open(file, 'r') as r_file:
data = r_file.read().replace('\n', '')
r_file.close()
return data
def write_file(file, data):
""" Write result to an external file. """
with open(file, 'w') as w_file:
w_file.write(data)
w_file.close()
def binarize(data):
""" Converts simbols into digits and returns a string array
with binary values.
"""
result = data.replace('{', '0')
result = result.replace('}', '1')
result = result.split('_')
return result
def get_text(data_array):
""" Convert each array element into his char representation and
appends it into a variable. Then returns the complete text.
"""
result = ''
for element in data_array:
result = result + chr(int(element, 2))
return result
if __name__ == '__main__':
if len(sys.argv) < 3 or len(sys.argv) > 3:
usage()
else:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment