Skip to content

Instantly share code, notes, and snippets.

@gquere
Created February 12, 2021 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gquere/10d4b8275e569fa1e66b7c9411ab1785 to your computer and use it in GitHub Desktop.
Save gquere/10d4b8275e569fa1e66b7c9411ab1785 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import re
import random
import base64
with open(sys.argv[1], "rb") as f:
lines = f.readlines()
obfuscated_lines = b""
for line in lines:
matches = re.findall(b'"[^"]*"', line)
for match in matches:
replace = b'$([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("' + base64.b64encode(match[1:-1]) + b'")))'
line = line.replace(match, replace)
obfuscated_lines += line
with open(sys.argv[1] + '.obfu', 'wb+') as f:
f.write(obfuscated_lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment