Using Python to create a graphical program for getting a Web site Directory

Source: Internet
Author: User
1.PYQT4-Written interface find_ui.py

#-*-coding:utf-8-*-from PyQt4 import Qtcore, Qtgui try: _fromutf8 = QtCore.QString.fromUtf8except attributeerror:def _fromutf8 (s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate (context, text, disambig): R Eturn 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 (), (+), Self.label.setObjectName) (_fromutf8 ("label")) Self.edit_address = QTGUI.QL Ineedit (Form) self.edit_address.setGeometry (Qtcore.qrect (+, 351,)) Self.edit_address.setObjectName (_fromutf 8 ("edit_address")) Self.button_search = Qtgui.qpushbutton (Form) self.button_search.setGeometry (Qtcore.qrect (440, 10 , Self.button_sear))Ch.setobjectname (_fromutf8 ("Button_search")) Self.text_all = Qtgui.qtextedit (Form) self.text_all.setGeometry ( Qtcore.qrect (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 ( Self.label_2.setObjectName (_fromutf8 ("label_2")) Self.text_exist = Qtgui.qtextedit (Form) self.t Ext_exist.setgeometry (Qtcore.qrect (340, 411, Max)) 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, a) self.label_3.setText (_fromutf8 ("")) Self.label_3.s Etobjectname (_fromutf8 ("Label_3")) Self.edit_add = Qtgui.qlineedit (Form) self.edit_add.setGeometry (Qtcore.qrect (20 , 420, 411, ()) 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 (251, Max)) Self.label_4.setObjectName (_fromutf8 ("Label_4")) Self.retranslateui (Form) Qtcore . Qmetaobject.connectslotsbyname (Form) def retranslateui (self, form): Form.setwindowtitle (_translate ("form", "Directory Probing tool" , none)) Self.label.setText (_translate ("form", "website address:", None)) Self.button_search.setText (_translate ("form", "Probe", N One) Self.label_2.setText (_translate ("form", "Result:", none)) Self.button_add.setText (_translate ("form", "Add Address", none) ) Self.label_4.setText (_translate ("Form", "For example:/admin/manager.asp, start with a slash", None))


2. Boot file start.py

#!/usr/local/bin/python#coding=utf-8 import sysimport osimport timeimport httplibimport refrom PyQt4 import QtCore, Qtguifrom 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.A Ppend (address_line) Pass pass pass Fileaddress.close () except: #self. Ui.text_all. SetText (' AAA ') self.ui.text_all.setText (U ' open file error ') Pass finally: #fileAddress. Close () Pass # PRI NT Addresslist[0] def accessaddesss (self,host): Try:print Host Print len (AddressList) for Oneaddres        s 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 (getaddr Ess) 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 "probe complete") self.ui.la Bel_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.qappli Cation (sys.argv) MyApp = MyForm () myapp.show () Sys.exit (App.exec_ ())


3.address.txt Scan Address List file, you can edit the file to make your own rules, you know ~ ~

The code is as follows:

/admin.php

/admin/

/administrator/

/moderator/

/webadmin/

/adminarea/

/bb-admin/

/adminlogin/

/test/login.jsp

/source/login.php

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.