nmap 請(qǐng)求修改ua (nmap發(fā)送http請(qǐng)求的多種方式)
前言
因掃描原因,在所有發(fā)出的請(qǐng)求中盡可能的添加ua,由其他業(yè)務(wù)判斷。
有業(yè)務(wù)反饋跑了幾年的nmap,有部分請(qǐng)求不帶ua。
但http.useragent并不能覆蓋所有的http請(qǐng)求,還有部分請(qǐng)求 "/"的不帶ua
一 http庫(kù) 設(shè)置http.useragent
默認(rèn)的nmap添加ua的做法是添加腳本參數(shù)
--script-args http.useragent="my user-agent"
具體生效位置
/usr/local/share/nmap/nselib/http.lua 或 /usr/share/nmap/nselib/http.lua
設(shè)置請(qǐng)求函數(shù)中 創(chuàng)建請(qǐng)求時(shí)的UA


調(diào)用方式
-- 引用
local http = require "http"
-- 請(qǐng)求
http.get( host, port, '/' )
生效范圍
使用http.get的一般是scripts中的腳本,如
/usr/local/share/nmap/scripts/couchdb-stats.nse

其他請(qǐng)求方式,http.useragent無(wú)法覆蓋到
二 nmap-service-probes 請(qǐng)求方式
nmap-service-probes發(fā)送預(yù)設(shè)的數(shù)據(jù)探針,匹配響應(yīng)的內(nèi)容來(lái)判斷服務(wù)類型。
探針內(nèi)容:Probe TCP GetRequest q|GET / HTTP/1.0\r\n\r\n|
請(qǐng)求 "/" 路徑,添加ua需要改為
Probe TCP GetRequest q|GET / HTTP/1.0\r\nUser-Agent: xxx\r\n|
三 comm socket請(qǐng)求
/usr/local/share/nmap/nselib/comm.lua 封裝了socket請(qǐng)求
腳本 skypev2-version.nse中調(diào)用該方法,發(fā)送http請(qǐng)求
if not result then
-- Have to send the probe ourselves.
status, result = comm.exchange(host, port,
"GET / HTTP/1.0\r\n\r\n", {bytes=26})
if (not status) then
return nil
end
end
四 rpc 請(qǐng)求
rpc-grind.nse
發(fā)的請(qǐng)求導(dǎo)致報(bào)錯(cuò),具體怎么發(fā)不詳細(xì)找了,這個(gè)請(qǐng)求比較難修改。
[06/Jul/2022 11:30:48] code 400, message Bad request version ('\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
[06/Jul/2022 11:30:48] "?(?m%? " 400 -

浙公網(wǎng)安備 33010602011771號(hào)