hostscan

簡介

自動化Host碰撞工具,幫助紅隊快速擴展網絡邊界,獲取更多目標點

背景

很多時候,訪問目標網站時,使用其真實IP無法訪問,只有域名才能訪問到后端業務服務。這是因為反代服務器(如nginx)配置了禁止直接IP訪問。

nginx后面的業務有時是隱藏的:

  1. 不開放到外網的業務,如測試業務
  2. 原來DNS解析到外網,但是后來刪除了A記錄(nginx后的業務沒刪除,轉移到了內網訪問)

怎么訪問這些隱藏的業務呢?這就需要今天的主角登場了--Host碰撞技術

使用示例

./hostscan -d test.com -i 127.0.0.1:3333
./hostscan -D input/hosts.txt -I input/ips.txt -O out/output.txt -T 5 -t 10

使用說明

請下載release中對應平臺的版本運行

注意

  • 默認并發數為3, 如果網絡環境良好,請適當調大以增加速度,最高可以設置成rlimit數值
  • 默認UserAgent使用的是golang-hostscan/xxxx,可能留存掃描痕跡,可以使用參數'-U'來使用隨機UA
  • 現已支持輸入大文件的支持,無需擔心OOM
hostscan --help/ )( \ /  \ / ___)(_  _)/ ___) / __) / _\ (  ( \) __ ((  O )\___ \  )(  \___ \( (__ /    \/    /\_)(_/ \__/ (____/ (__) (____/ \___)\_/\_/\_)__)        Usage of hostscan:  -D string        Hosts in file to test  -I string        Nginx Ip in file to test  -O string        Output File (default "result.txt")  -T int        Thread for Http connection. (default 3)  -U    Open to send random UserAgent to avoid bot detection.  -d string        Host to test  -i string        Nginx IP  -t int        Timeout for Http connection. (default 5)  -v    Show hostscan version

運行截圖

使用的測試環境是下一小節中介紹的

Host 碰撞成功

碰撞返回 400

測試環境

Docker

docker pull vultarget/host_collisiondocker run -it -p 3333:8080 --rm vultarget/host_collision

Nginx 配置

反代服務器 (核心)

server {listen  8080  default_server;server_name _;return 400;}server {listen  8080;server_name test.com;
location / {proxy_pass http://127.0.0.1:80;proxy_redirect off;proxy_set_header Host $host:$server_port;proxy_set_header X-Real-IP $remote_addr;root    html;index   index.html  index.htm;    }access_log logs/test.com.log;}

第一個server表示 host為空時,會返回400

第二個server表示 nginx會根據傳入的host進行服務轉發,訪問test.com訪問的業務為 127.0.0.1:80 上的服務

示例業務

server {listen       80;server_name  localhost;
location / {root   /usr/share/nginx/html;index  index.html index.htm;    }
error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;    }}

簡單的nginx初始頁面