Skip to content

Instantly share code, notes, and snippets.

@iamtutu
Forked from superkojiman/bin2sc.py
Created May 10, 2017 18:22
Show Gist options
  • Save iamtutu/e8cf741779402a52bbe553b2dcb6802e to your computer and use it in GitHub Desktop.
Save iamtutu/e8cf741779402a52bbe553b2dcb6802e 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