37,737
社区成员
发帖
与我相关
我的任务
分享def LoadPlugin(self):
print "\33[33mStart Plugin scan,please wait...\33[0m"
self.count = 0;
PluginThread=[]
ExistList = []
self.PluginQueue = Queue(maxsize = 10000)
linecount = len(open('./loopholes_plugin.txt','rU').readlines())
Plugin_Path = "http://{0}".format(self.url)
if(os.path.exists(r'./loopholes_plugin.txt')):
file = open(r'./loopholes_plugin.txt','r')
for line in file:
PluginList = line.strip()
self.PluginQueue.put(PluginList)
file.close()
self.PluginQueue.cancel_join_thread()
else:
print " file does not exist!"
start = time.time()
for count in range(5):
t = threading.Thread(target = self.PluginScan,args = (linecount,ExistList))
t.setDaemon(True)
t.start()
PluginThread.append(t)
for i in PluginThread:
i.join()
print ""
for j in ExistList:
print "\33[31m%s\33[0m" %j
end = time.time()
#print "Plugin_Scan_Time: %f s" % (end - start)
def PluginScan(self,linecount,ExistList):
thread = threading.current_thread()
while 1:
Plugin_Path = self.url
if(not self.PluginQueue.empty()):
PluginDir = self.PluginQueue.get()
else:
break
Plugin_Path = "%s/wp-content/plugins/%s/" %(Plugin_Path,PluginDir)
try:
Plugin_re = requests.get(Plugin_Path,headers = HEADERS)
if(Plugin_re.status_code == 200 or Plugin_re.status_code == 403):
ExistList.append(PluginDir)
Plugin_Path = self.url
except:
print "\33[31mconnect fail\33[0m"
break
self.count+=1
sys.stdout.write('Current full schedule:'+str(str(self.count)+'/'+str(linecount))+"\r")
sys.stdout.flush()