Created
March 27, 2022 23:50
-
-
Save sh1dow3r/2684cb05ab8f60392bfc389b6d266716 to your computer and use it in GitHub Desktop.
ASPX Webshell De de-obfuscator
This file contains hidden or 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
import argparse | |
import re | |
def convert_to_str(match_obj): | |
if match_obj.group() is not None: | |
return match_obj.group().encode('utf_8').decode('unicode_escape') | |
def deobfuscated(filename): | |
with open(filename) as myfile: | |
for line in myfile: | |
words = line.split() | |
for word in words: | |
cond = re.findall(r"(\\u[a-zA-Z0-9]{4})", word) | |
if cond: | |
#print("BEFORE", word) | |
line = re.sub(r"(\\u[a-zA-Z0-9]{4})",convert_to_str ,line) | |
#print("AFTER", word) | |
filename_no_ext = filename.split(".")[0] | |
filename_ext = filename.split(".")[1] | |
deobf_filename = filename_no_ext + "_clean." + filename_ext | |
with open(deobf_filename, "w+") as f1: | |
f1.write(line) | |
f1.close() | |
def main(): | |
parser = argparse.ArgumentParser(description='Deobfuscate file using unicode algorithm') | |
parser.add_argument('-f',"--file", action='store',help='Path to the obfuscated file') | |
args = parser.parse_args() | |
deobfuscated(args.file) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment