Created
November 17, 2021 14:36
-
-
Save maycon/c06586486841e3f62fb564f862a9a350 to your computer and use it in GitHub Desktop.
Decode AngularJS File
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
#!/bin/env python3 | |
import sys | |
import string | |
import re | |
import jsbeautifier | |
if len(sys.argv) != 2: | |
print ("Use: {} <angular-js-file>".format(sys.argv[0])) | |
sys.exit(0) | |
js_file = sys.argv[1] | |
with open(js_file) as f: | |
data = f.read() | |
data = jsbeautifier.beautify(data) | |
data = re.sub("\\\\x[a-f0-9][a-f0-9]", lambda m: bytes.fromhex(m.group()[2:]).decode("iso-8859-1"), data) | |
data = re.sub("\\\\u00[a-f0-9][a-f0-9]", lambda m: bytes.fromhex(m.group()[4:]).decode('iso-8859-1'), data) | |
with open(js_file, "w") as f: | |
f.write(data) |
It replaces the original file, so make sure to backup it before running it. ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use it: