python探测网站目录的gui程序

pyqt4写的界面 find_ui.py

#-*- coding: utf-8 -*-
from pyqt4 import qtcore, qtgui
try:
_fromutf8 = qtcore.qstring.fromutf8
except attributeerror:
def _fromutf8(s):
return s
try:
_encoding = qtgui.qapplication.unicodeutf8
def _translate(context, text, disambig):
return qtgui.qapplication.translate(context, text, disambig, _encoding)
except attributeerror:
def _translate(context, text, disambig):
return qtgui.qapplication.translate(context, text, disambig)
class ui_form(object):
def setupui(self, form):
form.setobjectname(_fromutf8(“form”))
form.resize(516, 467)
self.label = qtgui.qlabel(form)
self.label.setgeometry(qtcore.qrect(20, 10, 54, 16))
self.label.setobjectname(_fromutf8(“label”))
self.edit_address = qtgui.qlineedit(form)
self.edit_address.setgeometry(qtcore.qrect(80, 10, 351, 20))
self.edit_address.setobjectname(_fromutf8(“edit_address”))
self.button_search = qtgui.qpushbutton(form)
self.button_search.setgeometry(qtcore.qrect(440, 10, 61, 23))
self.button_search.setobjectname(_fromutf8(“button_search”))
self.text_all = qtgui.qtextedit(form)
self.text_all.setgeometry(qtcore.qrect(20, 40, 411, 261))
self.text_all.sethorizontalscrollbarpolicy(qtcore.qt.scrollbaralwaysoff)
self.text_all.setobjectname(_fromutf8(“text_all”))
self.label_2 = qtgui.qlabel(form)
self.label_2.setgeometry(qtcore.qrect(20, 320, 54, 12))
self.label_2.setobjectname(_fromutf8(“label_2”))
self.text_exist = qtgui.qtextedit(form)
self.text_exist.setgeometry(qtcore.qrect(20, 340, 411, 64))
self.text_exist.sethorizontalscrollbarpolicy(qtcore.qt.scrollbaralwaysoff)
self.text_exist.setobjectname(_fromutf8(“text_exist”))
self.label_3 = qtgui.qlabel(form)
self.label_3.setgeometry(qtcore.qrect(380, 310, 91, 20))
self.label_3.settext(_fromutf8(“”))
self.label_3.setobjectname(_fromutf8(“label_3”))
self.edit_add = qtgui.qlineedit(form)
self.edit_add.setgeometry(qtcore.qrect(20, 420, 411, 20))
self.edit_add.setobjectname(_fromutf8(“edit_add”))
self.button_add = qtgui.qpushbutton(form)
self.button_add.setgeometry(qtcore.qrect(440, 420, 71, 23))
self.button_add.setobjectname(_fromutf8(“button_add”))
self.label_4 = qtgui.qlabel(form)
self.label_4.setgeometry(qtcore.qrect(20, 440, 251, 16))
self.label_4.setobjectname(_fromutf8(“label_4”))
self.retranslateui(form)
qtcore.qmetaobject.connectslotsbyname(form)
def retranslateui(self, form):
form.setwindowtitle(_translate(“form”, “目录探测工具”, none))
self.label.settext(_translate(“form”, “网站地址:”, none))
self.button_search.settext(_translate(“form”, “探测”, none))
self.label_2.settext(_translate(“form”, “结果:”, none))
self.button_add.settext(_translate(“form”, “添加地址”, none))
self.label_4.settext(_translate(“form”, “例如:/admin/manager.asp 请以斜杠开始”, none))

2. 启动文件 start.py

#!/usr/local/bin/python
#coding=utf-8
import sys
import os
import time
import httplib
import re
from pyqt4 import qtcore, qtgui
from threading import thread
from find_ui import ui_form
class myform(qtgui.qmainwindow):
def __init__(self, parent=none):
qtgui.qwidget.__init__(self, parent)
self.ui = ui_form()
self.ui.setupui(self)
qtcore.qobject.connect(self.ui.button_search,qtcore.signal(“clicked()”), self.startthread)
qtcore.qobject.connect(self.ui.button_add,qtcore.signal(“clicked()”), self.addaddress)
def startsearch(self):
self.ui.label_3.settext(“”)
self.getaddress()
address=str(self.ui.edit_address.text())
self.accessaddesss(address)
def startthread(self):
t1=thread(target=self.startsearch,)
t1.start()
def getaddress(self):
try:
global addresslist
addresslist=[]
filepath=os.getcwd()+”\\address.txt”
# if not os.path.isfile(filepath):
# print ‘aaa’
# return 0
fileaddress=file(filepath,”r”)
for address_line in fileaddress.readlines():
if address_line not in addresslist:
addresslist.append(address_line)
pass
pass
pass
fileaddress.close()
except:
#self.ui.text_all.settext(‘aaa’)
self.ui.text_all.settext(u’打开文件错误’)
pass
finally:
#fileaddress.close()
pass
# print addresslist[0]
def accessaddesss(self,host):
try:
print host
print len(addresslist)
for oneaddress in addresslist:
print len(addresslist)
oneaddress=oneaddress.replace(“\n”,””)
print oneaddress
connection=httplib.httpconnection(host,80,timeout=10)
connection.request(“get”,oneaddress)
response=connection.getresponse()
result=response.reason
resultnum=response.status
if “ok” in result or “forbidden” in result:
getaddress=”http://”+host+oneaddress+”——“+str(resultnum)+”:”+result
self.ui.text_exist.append(getaddress)
else:
self.ui.text_all.append(“http://”+host+oneaddress+”——“+str(resultnum)+”:”+result)
connection.close()
except exception as e:
print e.message
self.ui.label_3.settext(u”探测完成”)
self.ui.label_3.colorcount()
def addaddress(self):
try:
filepath=os.getcwd()+”\\address.txt”
fileaddress=file(filepath,”a”)
newaddress=”\n”+str(self.ui.edit_add.text())
print newaddress
fileaddress.write(newaddress)
fileaddress.close()
except exception as e:
print e.message
if __name__ == “__main__”:
app = qtgui.qapplication(sys.argv)
myapp = myform()
myapp.show()
sys.exit(app.exec_())

3.address.txt 扫描地址名单文件,可以通过编辑改文件制定自己的规则,你懂的~~

/admin.php

/admin/

/administrator/

/moderator/

/webadmin/

/adminarea/

/bb-admin/

/adminlogin/

/test/login.jsp

/source/login.php

Posted in 未分类

发表评论