This repository was archived by the owner on May 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathscan.py
More file actions
executable file
·57 lines (47 loc) · 1.43 KB
/
scan.py
File metadata and controls
executable file
·57 lines (47 loc) · 1.43 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
#!/usr/bin/env python
from multiprocessing import Process, Queue
from Queue import Empty
import sys
import subprocess
import time
def scan(rank, host):
cmd = "OPENSSL=/usr/local/ssl/bin/openssl timeout 60 ./sslfacts.sh {0} > tmp/{1:0>8d}-{0}.txt".format(host,int(rank))
#cmd = "./sslfacts.sh {0} > tmp/{1:0>8d}-{0}.txt".format(host,int(rank))
print cmd
returncode = subprocess.call(cmd, shell=True)
if returncode != 0:
cmd = "echo FAIL >> tmp/{0:0>8d}-{1}.txt".format(rank, host)
subprocess.call(cmd, shell=True)
print "FAIL"
def worker(q):
try:
while True:
msg = q.get(block=True, timeout=1)
scan(*msg)
except Empty:
print "Working done, exiting"
if __name__ == '__main__':
count = 0
start = 0
stop = 10000
num_workers = 4
q = Queue()
with open('./top-1m.csv', 'r') as fd:
for line in fd:
count += 1
if count < start:
continue
if count > stop:
break
rankstr,host = line.strip().split(',')
rank = int(rankstr)
q.put( (rank, host) )
if not host.startswith('www'):
q.put( (rank, 'www.' + host) )
workers = [ Process(target=worker, args=(q,)) for i in range(num_workers) ]
# start them
for w in workers:
w.start()
# wait for them to finish
for w in workers:
w.join()