-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkarch.py
49 lines (44 loc) · 1.22 KB
/
workarch.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import datetime
import os
import threading
from celery import Celery
import urllib
import subprocess
#app = Celery('workarch', broker='amqp://admin:[email protected]//', backend='amqp://')
#RESULT = './result/'
app.config_from_object('config')
def execCmd(cmd):
print cmd
try:
print "命令%s开始运行%s" % (cmd, datetime.datetime.now())
#os.system(cmd)
rc=subprocess.call(cmd)
print rc
print "命令%s结束运行%s" % (cmd, datetime.datetime.now())
except Exception, e:
print '%s\t 运行失败,失败原因\r\n%s' % (cmd, e)
@app.task
def add(a, b):
print 'Start task'
time.sleep(3)
print 'Finish task'
return a + b
@app.task
def scandir(url, dict):
proto, rest = urllib.splittype(url)
domain, rest = urllib.splithost(rest)
print domain + " scan start!"
#file = RESULT + domain + '.subdomain.txt'
# subdomain=subdomain.replace('\n','')
cmd = ['dirb',url,dict]
#cmd = 'dirb ' + url + ' ' + dict
print cmd
# os.system(cmd)
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
th.join()
# subdomain=subdomains.readline()
print domain + " scan end!"