当前位置: 首页 > 科技观察

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

时间:2023-03-14 23:28:02 科技观察

如果我们有几十万个网站需要检查,怎么实现呢?人工检查?当然不是,这是很不现实的,只有自动化才是正确的选择,那么如何实现自动化呢?针对几十个网站的目标,如果需要扫描所有网站,那么扫描每个网站的时间会比较长,而且其中难免会有很多无效网站。如果我们能够排除无效网站,那么我们就可以节省扫描时间,从而提高检测效率。自动化检测离不开自动化工具。今天给大家分享一个命令行版的http工具集httpx。项目地址:https://github.com/projectdiscovery/httpx这个工具是用go语言写的,安装方法也比较简单,需要提前安装好go环境,需要替换成安装完成后国内代理,否则安装时会出现连接超时问题。安装命令如下:goget-vgithub.com/projectdiscovery/httpx/cmd/httpxWindows安装报错,然后执行以下命令,然后安装:goenv-wGOSUMDB=off安装完成后,查看帮助信息:[root@vultrguest~]#httpx-hUsageofhttpx:-Hvalue#自定义header,如UA、cookie等CustomHeader-allowvalueAllowlistip/cidr-bodystringContenttosendinbodywithHTTPrequest-cdn#根据页面返回的header,判断是否有是cdnCheckifdomain'sipbelongstknownCDN(akamai,cloudflare,..)-cnameOutputfirstcname-content-length#输出返回包的长度Extractscontent-length-输出网站的内容类型Extractscontent-type-csp-probeSendHTTPprobesontheextractedCSPdomains-debugDebugmode-denyvalueDenylistip/cidr-exclude-cdnSkipfullportscansforCDNs(onlychecksfor80,443)-extract-regexstringExtractRegex-fcstring#过滤掉某些状态码的网站,比如404-Filteruscode,等等filter-regexstringFilterRegex-filter-stringstringFilterString-flstringFiltercontentenlength-follow-host-redirectsOnlyfollowredirectsonthesamehost-follow-redirectsFollowRedirects-http-proxystring#设置请求代理HTTPProxy,eghttp://127.0.0.1:8080-http2HTTP2probe-include-chainShowRawHTTPChainInOutput(-jsononly)-include-responseShowRawHTTPResponseInOutput(-jsononly)-ip#输出域名对应的IPOutputtargetip-jsonJSONOutput-lstringFilecontainingdomains-locationExtractslocationheader-match-regexstringMatchRegex-match-stringstringMatchstring-mcstringMatchstatuscode-methodDisplayrequestmethod-mlstringMatchcontentlength-no-colorNoColor-no-fallbackIfHTTPSonport443issuccessfulondefaultconfiguration,probesalsoport80forHTTP-no-fallback-schemeThetoolwillrespectandattempttheschemespecifiedintheurl(ifHTTPSisspecifiednoHTTPisattempted)-ostringFiletowriteoutputto(optional)-pathstringRequestpath/file(example'/api')-pathsstringCommandseparatedpathsorfilecontainingonepathperline(example'/api/v1,/apiv2')-pipelineHTTP1.1Pipeline-portsvalueportsrange(nmapsyntax:eg1,2-10,11)-probeDisplayprobestatus-random-agentUserandomlyselectedHTTPUser-Agentheadervalue(defaulttrue)-rate-limitintMaximumrequeststosendpersecond(default150)-requeststringFilecontainingrawrequest-response-in-jsonShowRawHTTPResponseInOutput(-jsononly)(deprecated)-response-size-to-readintMaxresponsesizetoreadinbytes(default2response47)(default2response47)-size-to-saveintMaxresponsesizetosaveinbytes(default-unlimited)(default2147483647)-response-timeOutputtheresponsetime-resumeResumescanusingresume.cfg-retriesintNumberofretries-silentSilentmode-srSaveresponsetofile(default'output')-srdstringSaveresponsedirectory(default"output")-s??tatsEnablestatisticonkeypress(terminalmaybecomeunresponsivetilltheend)-status-codeExtractsstatuscode-store-chainSavechaintofile(默认'输出')-tech-detectPerformwappalyzerbasedtechnologydetection-threadsintNumberofthreads(默认50)-timeoutintTimeoutinseconds(默认5)-titleExtractstitle-tls-grabPerformTLSdatagrabbing-tls-probeSendHTTPprobesontheextractedTLSdomains-unsafeSendrawrequestsskippinggolangnormalization-verboseVerboseMode-versionShowversionofhttpx-vhostCheckforVHOSTs-vhost-inputGetalistofvhostsasinput-web-serverExtractsserverheader-websocketPrintsoutiftheserverexposesawebsocket-xstringRequestMethods,useALLtocheckallverbs()使用场景一:检查网站是否存活将网站列表保存为一个文本,比如:最简单的命令,无需加Anyparameter:typedomain.txt|httpx(windows)/catdomain.txt|httpx(Linux)orhttpx-ldomain.txtInaccessiblewebsitesarenotdisplayedintheresults:thistoolwilllookbetterwhenusedunderlinux,ifIfwewanttodisplaythewebsitesthatfailtoconnect,wecanusethecommand:httpx-ldomain.txt-silent-probeUsescenario2:ObtainthewebsiteTitle,statuscode,etc.ByobtainingthewebsiteTitleandstatuscode,youcanexcludealargenumberofabnormalwebsites,suchas404,500andotherstatuscodes,andmanydomainnamespointtothesamewebsite,andthenalargenumberofrepeatedwebsitedomainnamescanberemovedthroughthewebsitetitle,therebyimprovingtheefficiencyofdetectionhttpx-ldomain.txt-title-tech-detect-status-code对于大量无法访问的网站,默认超时时间为5秒。如果想提高速度,可以更改超时时间,例如:httpx-ldomain.txt-title-tech-detect-status-code-timeout2当target比较多的时候,可以结合多线程技术,使用参数-threads:httpx-ldomain.txt-title-tech-detect-status-code-timeout2-threads30如果还想获取目标网络的服务器信息,可以使用-web-server参数:httpx-ldomain2.txt-title-tech-detect-status-code-threads30-web-server使用场景三:当我们收集了很多域名,并没有生成网站链接时,以域名为目标获取网站信息,httpx一般可以检测建立在域名上的网站信息,比如下面的域名:一般使用命令获取标题:httpx-ldomain2.txt-title-tech-detect-status-code-timeout2-threads30本文总结简单使用httpx。工具的好坏主要取决于用户面临的问题和需求。在你需要的时候,它是提高效率的好帮手。当你不需要它的时候,它是个好帮手。它只是一个工具。对于大量目标的状态检测和信息收集,httpx是个好帮手。这几天的实战训练营,也可以用到这个工具。当然,如果你有编码基础,你可以通过编写脚本来实现自己的目标,更加高效和高度可定制,满足你的各种需求。公共工具有些缺陷。笔者不可能考虑到所有的情况,而且在使用的时候,目标太多了,就会出现各种bug,参加过训练营的小伙伴都或多或少的体验过。