-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMasscanxml.py
73 lines (55 loc) · 1.57 KB
/
Masscanxml.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import xml.dom.minidom
from Tools import *
import threading
#from Tools import *
class XmlModel:
"""docstring for ClassName"""
#root=None;
iplist=[]
def __init__(self, url):
dom=xml.dom.minidom.parse(url)
self.root=dom.documentElement
addresslist =self.root.getElementsByTagName('address')
for x in addresslist:
XmlModel.iplist.append(x.getAttribute("addr"))
def GetXmlInfo(self):
nmaprun =int(self.root.getAttribute("start"));
finished=int(self.root.getElementsByTagName("finished")[0].getAttribute("time"));
print "messcan starttime:",localtime(nmaprun),"messcan endtime:",localtime(finished)
class FileWirt:
"""docstring for FileWirt"""
def __init__(self, arg):
#super(FileWirt, self).__init__()
self.arg = arg
class ThreadMan:
"""docstring for ThreadMan"""
def __init__(self,threadNum,iplist):
self.iplist=iplist;
self.threadNum =threadNum;
self.index=0
self.lock=threading.Lock();
def StartThreading(self):
# global index
#print self.index
while self.index<len(self.iplist):
self.lock.acquire()
ip=self.iplist[self.index]
# print ip
thisindex=self.index=self.index+1
# print "ssss"
self.lock.release()
title=GetHtmlTitle(ip)
FilePrint(str(thisindex)+" "+ip,title)
def StartThread(self):
print "StartThread start",self.threadNum
#GetXml()
threads=[]
for x in xrange(0,self.threadNum):
t=threading.Thread(target=self.StartThreading);
threads.append(t)
for t in threads:
t.start()
for t in threads:
t.join()
if __name__ == '__main__':
ThreadMan(1,["127.0.0.1"]).StartThread()