Code Monkey home page Code Monkey logo

bscan's Introduction

BSCAN

bscan的是一款强大、简单、实用、高效的HTTP扫描器。

0x01 项目简介

bscan的前身是WebAliveScan,Github上面的版本已经非常老了但仍然有500+Star,没想到大家对这个项目的关注度这么高。自己私下已经把WebAliveScan迭代了多个版本但是仍然有很多问题无法解决:安装配置复杂、python线程锁导致并发问题等等....,所以干脆就用Golang重写了bscan

在如今的渗透测试中,基本上所有白帽子都知道信息收集在漏洞挖掘中很重要。但是收集出来的信息如何最大化利用,如何从当前信息中定位出更脆弱的目标。我认为一个白帽子在处理收集来的信息时,应该有一套标准化的流程。例如收集到了目标上百个子域名,就应该给处理子域名指定一套标准化的流程。

  1. 对子域名的IP进行整理,标记IP段权重
  2. 扫描IP、IP段的常见端口
  3. 根据扫描端口过滤出一些脆弱的服务,如:Redis、MongoDB等
  4. 扫描子域名、IP、IP段的WEB服务
  5. 目录扫描,POC扫描
  6. 根据标题,指纹筛选渗透
  7. .......

bscan主要应用于4-6步。

0x02 功能介绍

在Github上有许多WEB扫描器,但我认为它们太过于“传统”,面对现在的WEB环境存在以下问题:

  • 缺少黑名单功能,如果目标使用了CDN开放了几十个无效WEB页面,不能有效地过滤导致扫描结果臃肿
  • 跨平台能力差,多数WEB扫描器使用python编写,不能使用在内网渗透测试中
  • 缺少指纹识别,白帽子不能高效的从扫描结果中过滤出脆弱的目标
  • 误报率高,单纯的靠判断状态码判断文件是否存在

bscan的特性:

  • 配置文件采用YAML,配置文件简洁、可读性高
  • 安装简单,Windows/Linux/Mac下载对应的编译版本即可一键扫描,不用担心环境报错
  • 速度快,在2H4G5M的Linux服务器下,1024线程判断100万条URL存活仅需20分钟
  • 自定义,不管是POC还是默认的HTTP请求,都支持自定义HTTP请求参数、请求头等等
  • 指纹识别,根据自定义的指纹规则对WEB进行标记
  • 黑名单过滤,根据自定义的规则过滤无效页面,例如默认的CDN、WAF页面、500、404、403....
  • 最小化扫描,可以自定义POC过滤规则,对存活WEB对象进行filter处理,防止无效的POC攻击

1. 基础参数

-ports 80,443,8080-8090指定端口 -threads 1024指定线程 -allow-redirects跟踪重定向 -timeout 3HTTP超时时间 -path /admin/index.php请求路径 以上参数均可以在配置文件config.yml修改默认值

2. 指纹识别

指纹库文件路径使用配置文件中的fingerprint_path指定或使用-fp <filepath>指定。 指纹支持7个字段:webserver、framework、application、os、desc、lang、expression;expression是当前指纹匹配响应的表达式(参考xray),其它字段用于标记该WEB。

指纹识别执行流程伪代码

for fingerprint in fingerprint_list:
	if exec_expr(fingerprint.expression, response) is True:
        aliveweb.webserver = fingerprint.webserver
        aliveweb.framework = fingerprint.framework
        aliveweb.application = fingerprint.application
        aliveweb.os = fingerprint.os
        aliveweb.desc = fingerprint.desc
        aliveweb.lang = fingerprint.lang
return aliveweb

expression支持response对象,用一些简单的例子来解释大部分我们可能用到的表达式

  • response.body.bcontains(b'test')返回包 body 包含 test,因为 body 是一个 bytes 类型的变量,所以我们需要使用 bcontains 方法,且其参数也是 bytes
  • response.status==200 && response.headers['Content-Type'].icontains('application/octet-stream')返回包状态码为200并且返回头部的Content-Type包含application/octet-stream,因为返回头部的字段是字符型,所以要用icontains

举例:

- webserver: Nginx
  expression: response.headers["Server"].icontains("Nginx") || response.body.bcontains(b"<center>nginx</center>")

- webserver: Apache
  expression: response.headers["Server"].icontains("Apache/")

- webserver: Tomcat
  lang: java
  expression: response.headers["Server"].icontains("Tomcat") || response.headers["Server"].icontains("Apache-Coyote")
  
- application: phpstudy
  expression: response.body.bcontains(b"phpstudy for windows")
  os: windows
  lang: php

image.png

3. 黑名单机制

黑名单库文件路径使用配置文件中的blacklist_path指定或使用-bp <filepath>指定。 黑名单支持2个字段:name、expression;expression是当前黑名单匹配响应的表达式(参考xray)。

黑名单执行流程伪代码

response = http(url)
for black in blacklist:
	if exec_expr(black.expression, response) is True:
        return False
get_fingerprint(response)

黑名单expression同指纹识别一致。

举例:

- name: ERROR_CODE
  expression: response.status == 400 || response.status == 503 || response.status == 502

- name: ANHENG_WAF
  expression: response.body.bcontains(b"iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC")

4. 自定义POC

POC存放目录使用配置文件中的pocs_path指定或使用-poc <filepath>指定。 POC支持4个字段:name、request、filter_expr、verify_expr;request用于配置HTTP请求,filter_expr过滤表达式,verify_expr验证表达式

POC执行流程伪代码

for aliveweb in aliveweb_result:
    for poc in poc_list:
        if poc.filter_expr == "" or exec_expr(poc.filter_expr, aliveweb) is True:
            for path in poc.path:
                headers = poc.request.headers
                method = poc.request.method
                query = poc.request.query
                body = poc.request.body
				...
            	response = exploit(method, aliveweb.url, headers, query, body, ...)
                if exec_expr(poc.verify_expr, response) is True:
                    vuln(aliveweb, poc.name)
        else:
            continue

filter_expr表达式支持aw对象,用一些简单的例子来解释大部分我们可能用到的表达式

  • aw.lang=='java' || aw.lang==''存活WEB的语言标记为java或者为空
  • aw.application=='seeyon-oa'存活WEB的应用标记seeyon-oa

verify_expr同指纹识别一致。

举例:

name: druid
request:
  method: GET
  # 路径参数为数组
  path:
    - /druid/login.html
    - /druid/index.html
  headers: 
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
    Referer: http://www.baidu.com/
    Accept-Language: en
    Range: bytes=0-10240
  timeout: 5
  allow_redirects: true

# 只扫描lang标记为java或者标记为空的WEB
filter_expr: aw.lang == "java" || aw.lang == ""
verify_expr: response.body.bcontains(b"Druid Stat Index") || response.body.bcontains(b"druid monitor")

0x03 应用指南

下面将介绍漏洞挖掘中bscan的使用技巧。

1. target支持的文件格式 ./bscan -target ip.txt -ports 80,443 ip.txt支持的输入格式有三种:IP、IP:端口、URL;

www.baidu.com
www.baidu.com:80
http://www.baidu.com/

www.baidu.com没有指定端口,就会根据用户自定义的端口80,443生成URL放入扫描队列 www.baidu.com:80指定了端口,会根据指定的端口80生成URL放入扫描队列 http://www.baidu.com/给定了URL,直接放入扫描队列

2. 快捷过滤 ./bscan -target target.txt -ports 80,443 -filter response.status==200 可以用-filter参数指定一个临时黑名单过滤HTTP响应 image.png

可以用这个功能,简单过滤出后台等WEB ./bscan -target target.txt -ports 80,443 -filter response.body.bcontains(b"后台") -path /admin/index.html

3. 指定单个POC ./bscan -target target.txt -ports 80,443 -exploit -poc pocs/backup.yml 只扫描一个POC image.png

4. 快速扫描OneForAll结果 cat results/*.csv |awk -F , '{print$6}' > <filepath> ./bscan -target <filepath> image.png

5. 识别shiro应用 在config.yml定义默认HTTP请求头 image.png

在指纹库中添加指纹 image.png

扫描结果中会显示App image.png

6. POC过滤 在指纹库定义指纹 image.png

在POC中定义filter规则 image.png

在启用POC扫描时,只有识别到SeeyonOA时才会使用这个POC扫描,提高扫描效率。

0x04 Todo

  • 支持更多的输出格式HTML、Json、XML
  • Fast模式,调用Fofa API获取存活WEB
  • 扫描结果存入数据库,支持导入存活WEB
  • 多节点分布式扫描

bscan's People

Contributors

broken5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bscan's Issues

使用遇到的bug

1、使用中发现response.header中部分响应头的指纹无法成功识别,例如Etag

想学习一些go的工具

想用go写一些脚本,刚好大佬的工具符合我的风格,不知道大佬能否开源,借我参考学习,谢谢!

centos无法运行bscan

报错信息中含有Windows的路径,而且是作者你的路径C:/Users/br0ken/bscan/runner/alive/ 不知道这个问题怎么解决

你竟然也加了poc功能,我唾弃!

从WebAliveScan一路追过来。
如今市面上或主动或被动或开源或商用的漏扫工具何止千千万,但在某些环境下我就是需要简单的获取个TITLE、获取个响应码、获取个页面大小,新添加的功能不考虑扫描效果的情况下也是十分冗杂的,最重要的是会触发安全告警!!!想一想为什么WebAliveScan比bscan的star多。
最后希望能做好减法。

centos无法运行bscan

报错信息中含有Windows的路径,而且是作者你的路径C:/Users/br0ken/bscan/runner/alive/ 不知道这个问题怎么解决

配置文件引用问题

配置文件相对路径引用问题,如果把bscan添加到系统变量中会提示找不到配置文件

关于`-allow-redirects`参数的问题

希望可以增加一下允许跳转的判断
最近在看 fingerprint.yml 这块的内容,测试指纹识别的时候,有些站识别不到,比如dwr的指纹:response.body.bcontains(b"dwr/engine.js") ,fofa找几个站试了试,有的站在访问后返回状态码200,但是内容里用js跳转,所以导致指纹匹配不上,希望可以做个判断,增加下常见的跳转判断如:

top.location.href="default.html";

window.location.href="login.do?method=login_new";

var redirectUrl = "/login/Login.jsp?logintype=1" ;
    location.href = redirectUrl;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.