写了一个wordpress目录检测的脚本,但是有时候会出现死循环不知道是什么原因

面包加火腿 2016-05-19 03:43:05
代码入下,求大牛帮看一下
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()

会有县城不退出,有时候就会一直死循环。
...全文
94 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,737

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧