httpscan 爬虫扫描小工具

       httpscan是一个扫描指定网段的Web主机的小工具。和端口扫描器不一样,httpscan是以爬虫的方式进行Web主机发现,因此相对来说不容易被防火墙拦截。

httpscan会返回IP http状态码 Web容器版本 以及网站标题。


</pre><pre name="code" class="html">Usage:./httpscan IP/CIDR –t threads
Example:./httpscan.py 10.20.30.0/24 –t 10


地址:https://github.com/zer0h/httpscan


主要代码:

#!/usr/bin/env python
#coding:utf-8
# Author: Zeroh
 
import re
import sys
import Queue
import threading
import optparse
import requests
from IPy import IP
 
printLock = threading.Semaphore(1)  #lock Screen print
TimeOut = 5  #request timeout
 
#User-Agent
header = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36','Connection':'close'}
 
class scan():
 
  def __init__(self,cidr,threads_num):
    self.threads_num = threads_num
    self.cidr = IP(cidr)
    #build ip queue
    self.IPs = Queue.Queue()
    for ip in self.cidr:
      ip = str(ip)
      self.IPs.put(ip)
 
  def request(self):
    with threading.Lock():
      while self.IPs.qsize() > 0:
        ip = self.IPs.get()
        try:
          r = requests.Session().get('http://'+str(ip),headers=header,timeout=TimeOut)
          status = r.status_code
          title = re.search(r'<title>(.*)</title>', r.text) #get the title
          if title:
            title = title.group(1).strip().strip("\r").strip("\n")[:30]
          else:
            title = "None"
          banner = ''
          try:
            banner += r.headers['Server'][:20] #get the server banner
          except:pass
          printLock.acquire()
          print "|%-16s|%-6s|%-20s|%-30s|" % (ip,status,banner,title)
          print "+----------------+------+--------------------+------------------------------+"
 
          #Save log
          with open("./log/"+self.cidr.strNormal(3)+".log",'a') as f:
            f.write(ip+"\n")
 
        except Exception,e:
          printLock.acquire()
        finally:
          printLock.release()
 
  #Multi thread
  def run(self):
    for i in range(self.threads_num):
      t = threading.Thread(target=self.request)
      t.start()
 
if __name__ == "__main__":
  parser = optparse.OptionParser("Usage: %prog [options] target")
  parser.add_option("-t", "--thread", dest = "threads_num",
    default = 1, type = "int",
    help = "[optional]number of  theads,default=10")
  (options, args) = parser.parse_args()
  if len(args) < 1:
    parser.print_help()
    sys.exit(0)
 
  print "+----------------+------+--------------------+------------------------------+"
  print "|     IP         |Status|       Server       |            Title             |"
  print "+----------------+------+--------------------+------------------------------+"
 
  s = scan(cidr=args[0],threads_num=options.threads_num)
  s.run()


<think>好的,我现在需要帮助用户解决如何使用dirsearch工具对目标网站http://192.168.9.132进行目录扫描的问题。首先,我得回忆一下dirsearch的基本用法和常用参数,确保给出的命令正确有效。 用户可能已经安装了dirsearch,但可能需要确认安装方法,比如通过Git克隆仓库或者使用pip安装。不过用户的问题主要集中在配置和运行命令上,所以先提供基本命令结构。基础命令应该是python3 dirsearch.py -u后跟目标URL,这里的目标是http://192.168.9.132。需要确保用户正确进入工具目录执行命令。 接下来要考虑用户可能需要调整的参数。比如线程数(-t)控制扫描速度,但过高可能对目标服务器造成压力或被封禁,默认是20或25,通常建议适当调整。扩展名选项(-e)很重要,指定常见的如php,asp,html等,可以更有针对性地查找文件。排除状态码(--exclude-status)例如404,可以过滤掉不相关的结果,节省时间。如果用户需要递归扫描,可以使用-r参数并指定深度,比如-r -l 2。代理(--proxy)在需要隐藏自身IP或绕过限制时有用,格式可能是http://代理地址:端口。 还要注意用户权限问题,可能需要使用sudo运行,尤其是在Linux系统下。此外,提及一些注意事项,比如遵守法律、控制线程数、检查更新等,帮助用户避免常见问题。最后,生成相关问题,扩展用户可能的后续疑问,比如绕过防火墙、结果分析、自定义字典等,这样用户可以得到更全面的信息。 需要确保所有参数示例正确,比如线程数-t 30,扩展名-e php,html,asp,状态码排除--exclude-status 403,500等。同时,引用提供的参考资料中提到了其他工具如nmap和httpscan,虽然不直接相关,但可以强调dirsearch的不同之处,比如基于字典的目录爆破而非端口扫描,帮助用户理解工具的选择。 最后检查命令格式是否正确,是否有拼写错误,参数是否合理,并确保使用中文回答,结构清晰,分步骤说明,让用户容易跟随操作。</think>### Dirsearch 配置与运行指南 #### 基础命令示例 ```bash python3 dirsearch.py -u http://192.168.9.132 -e php,html,asp -t 30 --exclude-status 403,500 -r -l 2 ``` #### 参数说明 1. **`-u http://192.168.9.132`** 指定目标URL,支持路径扩展(如`/api`)[^1]。 2. **`-e php,html,asp`** 定义扫描文件扩展名,提升探测针对性,默认包含常见静态文件类型。 3. **`-t 30`** 设置并发线程数为30,需平衡效率与目标服务器负载(默认20)。 4. **`--exclude-status 403,500`** 过滤指定HTTP状态码(如403禁止访问、500服务器错误)。 5. **`-r -l 2`** 启用递归扫描(`-r`)并限制递归深度为2层(`-l 2`),避免无限爬取。 #### 进阶配置建议 - **代理模式**:添加`--proxy http://127.0.0.1:8080` 通过Burp Suite等工具观察流量或规避封禁。 - **自定义字典**:使用`-w custom_wordlist.txt` 加载特定目录字典,提升有效性。 - **超时控制**:`--timeout 10` 防止因无响应导致进程阻塞。 #### 注意事项 1. 扫描前需获得明确授权,避免法律风险[^2]。 2. 高线程可能触发WAF/IP封锁,建议初始使用默认值。 3. 更新工具:`git pull` 获取最新字典与漏洞检测规则。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值