Skip to content

Instantly share code, notes, and snippets.

@byt3bl33d3r
Created September 13, 2015 12:12
Show Gist options
  • Save byt3bl33d3r/3d0b7885ae9642919dc2 to your computer and use it in GitHub Desktop.
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)
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