• nmap 请求修改ua (nmap发送http请求的多种方式)


    前言
    因扫描原因,在所有发出的请求中尽可能的添加ua,由其他业务判断。
    有业务反馈跑了几年的nmap,有部分请求不带ua。
    但http.useragent并不能覆盖所有的http请求,还有部分请求 "/"的不带ua

    一 http库 设置http.useragent

    默认的nmap添加ua的做法是添加脚本参数

    --script-args http.useragent="my user-agent"
    

    具体生效位置

    /usr/local/share/nmap/nselib/http.lua 或 /usr/share/nmap/nselib/http.lua
    设置请求函数中 创建请求时的UA

    调用方式

    -- 引用
    local http = require "http"  
    -- 请求
    http.get( host, port, '/' )
    

    生效范围

    使用http.get的一般是scripts中的脚本,如
    /usr/local/share/nmap/scripts/couchdb-stats.nse

    其他请求方式,http.useragent无法覆盖到

    二 nmap-service-probes 请求方式

    nmap-service-probes发送预设的数据探针,匹配响应的内容来判断服务类型。
    探针内容:Probe TCP GetRequest q|GET / HTTP/1.0\r\n\r\n|
    请求 "/" 路径,添加ua需要改为
    Probe TCP GetRequest q|GET / HTTP/1.0\r\nUser-Agent: xxx\r\n|

    三 comm socket请求

    /usr/local/share/nmap/nselib/comm.lua 封装了socket请求

    脚本 skypev2-version.nse中调用该方法,发送http请求

      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 请求

    rpc-grind.nse
    发的请求导致报错,具体怎么发不详细找了,这个请求比较难修改。

    [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 -
    
  • 相关阅读:
    emacs 集成astyle
    git reflog
    rpm 打包的时候 不进行strip
    gmock
    如何对正在运行的进程,进行heap profile
    linux性能压测工具
    默认宏定义
    gdb fabs错误输出
    基于Clang的缓存型C++编译器Zapcc
    grep 多行 正则匹配
  • 原文地址:https://www.cnblogs.com/huim/p/16450192.html
Copyright © 2020-2023  润新知