JS代码混淆
jsobfuscate
python
# apt install -y npm
# npm install -g js-obfuscator
import subprocess
import base64
with open('blah.js','r') as fp:
text = fp.read()
def getUglifyJs(jscode):
jsCM = ''
try:
jscode_b64 = base64.b64encode(jscode.encode()).decode()
command = f'echo {jscode_b64} | base64 -d | jsobfuscate'
with subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) as proc:
jsCM = proc.stdout.read().decode().strip()
except:
pass
return jsCM
print(getUglifyJs(text))
uglifyjs
python
# apt install -y npm
# npm i uglify-js -g
import subprocess
import base64
with open('blah.js','r') as fp:
text = fp.read()
def getUglifyJs(jscode):
jsCM = ''
try:
jscode_b64 = base64.b64encode(jscode.encode()).decode()
command = f'echo {jscode_b64} | base64 --decode | uglifyjs -c -m'
with subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) as proc:
jsCM = proc.stdout.read().decode().strip()
except:
pass
return jsCM
print(getUglifyJs(text))