Skip to content

Instantly share code, notes, and snippets.

@ceramicskate0
Forked from superkojiman/bin2sc.py
Created March 23, 2020 01:14
Show Gist options
  • Select an option

  • Save ceramicskate0/7277c50c2a4bde47e6de2c3a435ea390 to your computer and use it in GitHub Desktop.

Select an option

Save ceramicskate0/7277c50c2a4bde47e6de2c3a435ea390 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