Skip to content

Instantly share code, notes, and snippets.

@superkojiman
Created April 22, 2014 03:15
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save superkojiman/11164279 to your computer and use it in GitHub Desktop.
Save superkojiman/11164279 to your computer and use it in GitHub Desktop.
Convert bin to shellcode.
#!/usr/bin/env python
import sys
if __name__ == "__main__":
if len(sys.argv) < 2:
print "usage: %s file.bin\n" % (sys.argv[0],)
sys.exit(0)
shellcode = "\""
ctr = 1
maxlen = 15
for b in open(sys.argv[1], "rb").read():
shellcode += "\\x" + b.encode("hex")
if ctr == maxlen:
shellcode += "\" +\n\""
ctr = 0
ctr += 1
shellcode += "\""
print shellcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment