Skip to content

Instantly share code, notes, and snippets.

@multiplex3r
Created August 31, 2017 02:33
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 multiplex3r/468eb3d277317ac0c2a868281fe66c5c to your computer and use it in GitHub Desktop.
Save multiplex3r/468eb3d277317ac0c2a868281fe66c5c to your computer and use it in GitHub Desktop.
Shellcode encoder
#!/usr/bin/env python
import sys
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
shellcode = "your"
shellcode += "shellcode"
shellcode += "here"
key = []
key.append(0xDE)
key.append(0xAD)
key.append(0xBE)
key.append(0xEF)
out = []
for i in range(0, len(shellcode)):
b1 = ord(shellcode[i]) ^ key[i % 4]
out.append(b1)
for line in chunks(out, 16):
b = ''.join(["\\x{0:02x}".format(c) for c in line])
sys.stdout.write('\n"{0}"'.format(b))
sys.stdout.write(';\n')
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment