Created
July 12, 2015 16:46
-
-
Save gabemarshall/788e692d581ddb5bf0aa to your computer and use it in GitHub Desktop.
Powerhell
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
#!/usr/bin/env python | |
# | |
# Powerhell | |
# | |
# by Gabe Marshall | |
# base64 encodes command line argument to Windows PowerShell | |
# | |
# Heavily influenced by Carol Perez's ps_encoder script (https://github.com/darkoperator/powershell_scripts/blob/master/ps_encoder.py) | |
import base64 | |
import sys | |
import re | |
import os | |
def ps_encode(input): | |
command = "" | |
for character in (input): | |
# insert nullbyte for each character | |
command += character + "\x00" | |
command = base64.b64encode(command) | |
return command | |
try: | |
code = sys.argv[1] | |
except: | |
sys.exit("Ex: powerhell.py '(Powershell Cmdlet or script)") | |
print("powershell -nop -noni -win hidden -enc %s" % ps_encode(code)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment