Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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