Created
September 13, 2015 12:12
-
-
Save byt3bl33d3r/3d0b7885ae9642919dc2 to your computer and use it in GitHub Desktop.
Converts raw shellcode to a PowerShell compatible byte array (helpful when using custom shellcode with Invoke-Shellcode.ps1)
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
import sys | |
ps_shellcode = '@(' | |
with open(sys.argv[1], 'rb') as shellcode: | |
byte = shellcode.read(1) | |
while byte != '': | |
ps_shellcode += '0x{}, '.format(byte.encode('hex')) | |
byte = shellcode.read(1) | |
ps_shellcode = ps_shellcode[:-2] #get rid of the last whitespace and comma | |
ps_shellcode += ')' | |
print ps_shellcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment