暴力破解目录和文件位置

import urllib2
import threading
import Queue
import urllib

threads = 50
target_url = "http://testphp.vulnweb.com"
wodlist_file='../wingware/DirBuster/directory-list-2.3-small.txt'
resume = None
user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101Firefox/19.0"

def build_wordlist(wordlist_file):
    fd = open(wordlist_file,"rb")
    raw_words=fd.readlines()
    fd.close()
    
    found_resume=False
    words = Queue.Queue()
    
    for word in raw_words:
        word=word.rstrip()
        if resume is not None:
            if found_resume:
                words.put(word)
            else:
                if word == resume:
                    found_resume = True
                    print "Resuming wordlist from: %s" % resume
        else:
            words.put(word)
       
    return words

def dir_bruter(word_queue,extensions=None):
    while not word_queue.empty():
        attempt = word_queue.get()
        attempt_list = []
        
        if "." not in attempt:
            attempt_list.append("/%s/" % attempt)
        else:
            attempt_list.append("/%s" % attempt)
            
        if extensions:
            for extension in extensions:
                attempt_list.append("/%s%s" % (attempt,extension))
                
        for brute in attempt_list:
            url="%s%s" % (target_url,urllib.quote(brute))
            try:
                headers={}
                headers["User-Agent"] =  user_agent
                r = urllib2.Request(url,headers=headers)
                
                response = urllib2.urlopen(r)
                if len(response.read()):
                    print "[%d] => %s" % (response.code,url)
                
            except urllib2.URLError,e:
                if hasattr(e,'code') and e.code!=404:
                    print "!!! %d => %s" %(e.code,url)


word_queue = build_wordlist(wodlist_file)
extensions=[".html",".bak",".cs",".xls",".asp",".config"]
for i in range(threads):
    t = threading. Thread(target=dir_bruter,args=(word_queue,extensions))

    t.start()

---------------------------------------------------------------------------------------------------------------

wodlist_file显示到字典在https://www.owasp.org/index.php/Category:OWASP_DirBuster_Project 下载  需要翻墙

文件上传暴力破解黑名单后缀名是一种攻击方式,攻击者尝试上传被服务器列入黑名单的文件类型。这种攻击的目的是绕过服务器对文件类型的过滤,上传可能存在安全风险的文件。 下面是一些防御措施来防止文件上传暴力破解黑名单后缀名的攻击: 1. 使用白名单而非黑名单:将文件上传过滤机制从黑名单(禁止上传某些文件类型)改为白名单(只允许上传某些受信任的文件类型)。这样可以确保只有预期的文件类型被上传。 2. 对文件进行完整性检查:在接收到上传的文件后,对其进行完整性检查,以确保文件没有被篡改或包含恶意内容。可以通过校验文件的哈希值或进行病毒扫描来验证文件的完整性。 3. 限制文件上传大小:设置合理的上传文件大小限制,防止攻击者通过上传大型文件来耗尽服务器资源或进行其他恶意行为。 4. 验证文件类型:除了通过文件扩展名验证外,还应该通过检查文件的内容类型(MIME类型)来验证文件类型的合法性。这可以防止攻击者通过伪造文件扩展名来绕过检查。 5. 安全审计:定期审计文件上传功能的安全性,检查是否存在漏洞或配置错误。 通过以上防御措施,可以有效减少文件上传暴力破解黑名单后缀名的风险。同时,还应保持对最新的安全威胁和漏洞的了解,并及时更新和修复系统中的安全问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值