Skip to content

Instantly share code, notes, and snippets.

@maycon
Created November 17, 2021 14:36
Show Gist options
  • Save maycon/c06586486841e3f62fb564f862a9a350 to your computer and use it in GitHub Desktop.
Save maycon/c06586486841e3f62fb564f862a9a350 to your computer and use it in GitHub Desktop.
Decode AngularJS File
#!/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)
@maycon
Copy link
Author

maycon commented Nov 17, 2021

To use it:

for js in unpack/base/assets/www/app/assets/js/*.js; do
   echo "> $js";
   python3 decode.py "$js";
done;

@maycon
Copy link
Author

maycon commented Nov 17, 2021

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