当前位置:编程学习 > python >>

python简单实现网站目录扫描器

在OSC看到的一个网站目录扫描的源码,适合python新手学习,当然功能不是很强大 
 
 
#!/usr/local/bin/python
#-*- coding: UTF-8 -*-
#QQ29295842     python  网络安全编程群 138612676    希望认识更多的朋友
#BLOG  http://hi.baidu.com/alalmn
import sys, os, time, httplib
import re
list_http=[]  #http数组
 
def open_httptxt():  #打开TXT文本写入数组
    try:
        passlist = []
        list_passlist=[]
        xxx = file('http.txt', 'r')
        for xxx_line in xxx.readlines():
            #past.append(xxx_line)
            passlist.append(xxx_line)
        xxx.close()
 
        for i in passlist:  #python 列表去重
            if i not in list_passlist:
                list_passlist.append(i)
 
        E = 0 #得到list的第一个元素
        while E < len(list_passlist):
            #print list_passlist[E]
            past.append(list_passlist[E])  #添加到数组里
            E = E + 1
    except:
        return 0
 
def pst_http(host):   #获取是否开放  #pst_http("127.0.0.1")
    try:
        for admin in past:
            admin = admin.replace("\n","")
            connection = httplib.HTTPConnection(host,80,timeout=10)
            connection.request("GET",admin)
            response = connection.getresponse()
            #print "%s %s %s" % (admin, response.status, response.reason)
            #/admin-login.php   ,错误404  ,Not Found   /moderator/ 404 File Not Found
            data=response.reason
            if "OK" in data or "Forbidden" in data:
                SQLdata="http://"+host+admin+"---%s %s"%(response.status, response.reason)
                print SQLdata
            else:
                print "http://"+host+admin+"----"+data
            connection.close()
        return 1
    except:
        pass
        return 0
 
if __name__=='__main__':
    print u"=============2.0  python写的web路径扫描工具============="
    global  past  #声明全局变量
    past = []
    open_httptxt()  #打开TXT文本写入数组
    pst_http("blog.csdn.net")  
 
补充:综合编程 , 安全编程 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,