命令行版 HTTP 工具集,自动化检查网站状态

系统 Linux 自动化
自动化检测,离不开自动化的工具,今天来为大家分享一款命令行版的 HTTP 工具集 httpx 。

如果我们有几十万个网站需要检测,该如何实现?手工检测吗?当然不行,这是非常不现实的,只有自动化才是正确的选择,那么如何自动化实现?

对于几十个网站的目标,如果要对所有网站进行扫描,每一个网站的扫描都需要比较长的时间,而且,其中难免有很多无效网站,如果我们可以将无效网站排除,那么我们就可以节省扫描的时间,从而提升检测效率。

自动化检测,离不开自动化的工具,今天来为大家分享一款命令行版的 HTTP 工具集 httpx,项目地址:

https://github.com/projectdiscovery/httpx

该工具使用 go 语言编写,安装方式也比较简单,需要提前安装 go 环境,安装完成之后需要换成国内的代理,否则安装的时候,会出现连接超时的问题,安装命令如下: 

  1. go get -v github.com/projectdiscovery/httpx/cmd/httpx 

Windows 下安装时报错,然后执行下面的命令之后,再进行安装就可以了:

  1. go env -w GOSUMDB=off 

安装完成之后,查看帮助信息: 

  1. [root@vultrguest ~]# httpx -h  
  2. Usage of httpx:  
  3.   -H value                # 自定义 header,比如 UA、cookie 等 
  4.       Custom Header      
  5.    -allow value            
  6.       Allowlist ip/cidr 
  7.   -body string       
  8.        Content to send in body with HTTP request 
  9.    -cdn                   # 根据页面返回 header,判断是否存在 cdn 
  10.       Check if domain's ip belongs to known CDN (akamai, cloudflare, ..) 
  11.    -cname  
  12.       Output first cname  
  13.   -content-length         # 输出返回包的长度  
  14.       Extracts content length  
  15.   -content-type           # 输出网站的内容类型  
  16.       Extracts content-type  
  17.   -csp-probe  
  18.       Send HTTP probes on the extracted CSP domains  
  19.   -debug  
  20.       Debug mode  
  21.   -deny value  
  22.       Denylist ip/cidr  
  23.   -exclude-cdn  
  24.       Skip full port scans for CDNs (only checks for 80,443)  
  25.   -extract-regex string  
  26.       Extract Regex  
  27.   -fc string              # 过滤掉某些状态码的网站,比如 404、500 等  
  28.       Filter status code  
  29.   -filter-regex string  
  30.       Filter Regex  
  31.   -filter-string string  
  32.       Filter String  
  33.   -fl string  
  34.       Filter content length  
  35.   -follow-host-redirects  
  36.       Only follow redirects on the same host  
  37.   -follow-redirects  
  38.       Follow Redirects  
  39.   -http-proxy string      # 设置请求代理  
  40.       HTTP Proxy, eg http://127.0.0.1:8080  
  41.   -http2  
  42.       HTTP2 probe  
  43.   -include-chain  
  44.       Show Raw HTTP Chain In Output (-json only)  
  45.   -include-response  
  46.       Show Raw HTTP Response In Output (-json only)  
  47.   -ip                     # 输出域名对应的 IP  
  48.       Output target ip  
  49.   -json  
  50.       JSON Output  
  51.   -l string  
  52.       File containing domains  
  53.   -location  
  54.       Extracts location header  
  55.   -match-regex string  
  56.       Match Regex  
  57.   -match-string string  
  58.       Match string  
  59.   -mc string  
  60.       Match status code  
  61.   -method  
  62.       Display request method  
  63.   -ml string  
  64.       Match content length  
  65.   -no-color  
  66.       No Color  
  67.   -no-fallback  
  68.       If HTTPS on port 443 is successful on default configuration, probes also port 80 for HTTP  
  69.   -no-fallback-scheme  
  70.       The tool will respect and attempt the scheme specified in the url (if HTTPS is specified no HTTP is attempted)  
  71.   -o string  
  72.       File to write output to (optional)  
  73.   -path string  
  74.       Request path/file (example '/api')  
  75.   -paths string  
  76.       Command separated paths or file containing one path per line (example '/api/v1,/apiv2')  
  77.   -pipeline  
  78.       HTTP1.1 Pipeline 
  79.    -ports value  
  80.       ports range (nmap syntax: eg 1,2-10,11)  
  81.   -probe  
  82.       Display probe status  
  83.   -random-agent  
  84.       Use randomly selected HTTP User-Agent header value (default true)  
  85.   -rate-limit int  
  86.       Maximum requests to send per second (default 150)  
  87.   -request string  
  88.       File containing raw request  
  89.   -response-in-json  
  90.       Show Raw HTTP Response In Output (-json only) (deprecated)  
  91.   -response-size-to-read int  
  92.       Max response size to read in bytes (default - unlimited) (default 2147483647)  
  93.   -response-size-to-save int  
  94.       Max response size to save in bytes (default - unlimited) (default 2147483647)  
  95.   -response-time  
  96.       Output the response time  
  97.   -resume  
  98.       Resume scan using resume.cfg  
  99.   -retries int  
  100.       Number of retries  
  101.   -silent  
  102.       Silent mode  
  103.   -sr  
  104.       Save response to file (default 'output')  
  105.   -srd string  
  106.       Save response directory (default "output")  
  107.   -stats  
  108.       Enable statistic on keypress (terminal may become unresponsive till the end)  
  109.   -status-code  
  110.       Extracts status code  
  111.   -store-chain  
  112.       Save chain to file (default 'output')  
  113.   -tech-detect  
  114.       Perform wappalyzer based technology detection  
  115.   -threads int  
  116.       Number of threads (default 50)  
  117.   -timeout int  
  118.       Timeout in seconds (default 5)  
  119.   -title  
  120.       Extracts title  
  121.   -tls-grab  
  122.       Perform TLS data grabbing  
  123.   -tls-probe  
  124.       Send HTTP probes on the extracted TLS domains  
  125.   -unsafe  
  126.       Send raw requests skipping golang normalization  
  127.   -verbose  
  128.       Verbose Mode  
  129.   -version  
  130.       Show version of httpx  
  131.   -vhost  
  132.       Check for VHOSTs  
  133.   -vhost-input  
  134.       Get a list of vhosts as input  
  135.   -web-server  
  136.       Extracts server header  
  137.   -websocket  
  138.       Prints out if the server exposes a websocket  
  139.   -x string  
  140.       Request Methods, use ALL to check all verbs () 

使用场景一:检查网站是否存活

将网站列表保存为一个文本,比如:

最简单的命令,无需加任何参数:

  1. type domain.txt | httpx (windows)/ cat domain.txt | httpx (Linux) 

或者

  1. httpx -l domain.txt  

无法访问的网站,在结果中未进行显示:

这个工具在 linux 下使用显示会比较好看,如果我们想要显示连接失败的网站,可以使用命令:

  1. httpx -l domain.txt -silent -probe 

使用场景二:获取网站 Title 、状态码等

通过获取网站的 Title 和状态码,可以排除大量非正常网站,比如 404、500 等状态码,还有很多域名指向同一个网站,然后通过网站标题可以去掉大量重复的网站域名,从而提升检测的效率。

  1. httpx -l domain.txt -title -tech-detect -status-code 

对于有大量无法访问网站的情况,默认的超时时间是 5 秒,想要提升速度,可以将超时时间,比如:

  1. httpx -l domain.txt -title -tech-detect -status-code -timeout 2 

目标多的情况下,可以结合多线程技术,使用参数 -threads:

  1. httpx -l domain.txt -title -tech-detect -status-code -timeout 2 -threads 30 

如果还想获取目标网的服务器信息,可以使用 -web-server 参数:

  1. httpx -l domain2.txt -title -tech-detect -status-code -threads 30 -web-server 

使用场景三:使用域名作为目标,获取网站信息

当我们收集了很多域名,并没有生成网站的链接,httpx 通用可以检测域名上搭建的网站信息,比如下面的域名:

通用使用获取 title 的命令:

  1. httpx -l domain2.txt -title -tech-detect -status-code -timeout 2 -threads 30 

总结

本文对 httpx 做了一个简单的使用,工具好坏主要与使用者面临的问题和需求决定,当你需要时,它是一个提效的好帮手,当你不需要时,他不过就是个工具而已,对于大量目标的状态检测和信息收集,httpx 是个不错的帮手,在这几天的实战训练营中,这个工具也是可以使用的,当然,如果自己有编码基础,写脚本来实现自己的目标,更高效且高度自定义化,满足自己的各种需求,公开的工具多少是有缺陷的,作者不可能把所有状况都考虑到,而且在使用的时候,目标过多的情况下,会出现各种各样的 bug,参与训练营的小伙伴,多少都体验多了。 

责任编辑:庞桂玉 来源: 黑客技术与网络安全
相关推荐

2021-04-01 13:25:46

Node命令工具

2020-12-11 06:44:16

命令行工具开发

2020-12-10 16:16:08

工具代码开发

2023-06-09 07:45:29

Kuberneteskubectl

2022-02-21 11:24:14

代码工具开发

2010-11-24 17:12:17

MySQL命令行

2013-12-09 14:29:13

OpenStack命令行工具API

2011-01-18 19:11:26

Postfix命令行

2022-04-09 10:02:59

HTTPLInux开源

2022-02-17 18:21:47

工具HTTPie客户端

2023-03-14 07:39:13

返回值编写命令行工具

2018-05-04 09:15:35

PythonPlumbum命令行

2019-08-27 10:32:01

Linux操作系统Windows

2013-11-15 09:43:15

JDK工具

2013-05-21 14:58:08

系统监视glances开源

2020-09-18 14:27:26

GitHub代码开发者

2016-08-12 14:18:49

Javascriptnode命令行

2017-09-01 15:00:49

LinuxMac网站备份

2017-06-15 10:32:56

OracleDBV命令行工具

2018-07-05 08:30:54

Python命令行工具shell
点赞
收藏

51CTO技术栈公众号