-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (47 loc) · 1.7 KB
/
main.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
#-*- coding: utf-8 -*-
#!/usr/bin/python
import paramiko
import threading
def ssh2(ip,username,passwd,cmd):
print cmd
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,22,username,passwd,timeout=5)
for m in cmd:
stdin, stdout, stderr = ssh.exec_command(m)
# stdin.write("Y") #简单交互,输入 ‘Y’
out = stdout.readlines()
#屏幕输出
for o in out:
print o,
print '%s\tOK\n'%(ip)
ssh.close()
except :
print '%s\tError\n'%(ip)
if __name__=='__main__':
taskpars = [
['http://192.168.200.130:5555', './dict/common.txt'],
['http://192.168.200.130:5555', './dict/jsp.txt'],
['http://192.168.200.130:5555', './dict/asp.txt'],
['http://192.168.200.130:5555', './dict/php.txt'],
]
taskips = [
['192.168.200.130', 'root', 'xiaodong'],
['192.168.200.138', 'root', 'xiaodong'],
['192.168.200.140', 'root', 'xiaodong'],
]
#cmd = ['cd /home/celery/pentest/','']#你要执行的命令列表
taskcmd = 'python /root/distributedPentest/task.py'
TASKJOBS=len(taskips)
order=TASKJOBS-1
for tp in taskpars:
taskcmd=taskcmd+' '+tp[0]+' '+tp[1]
print taskcmd
a=threading.Thread(target=ssh2,args=(taskips[order][0],taskips[order][1],taskips[order][2],['cd /root/distributedPentest',taskcmd]))#ip,username,password,
a.start()
#a.join()
taskcmd = 'python /root/distributedPentest/task.py'
order=order-1
if order==-1:
order = TASKJOBS - 1