NMAP使用哪种类型的正则表达式?

时间:2017-01-13 18:18:40

标签: regex nmap

尝试使用Nmap扫描Robtex数据库:

nmap --script http-robtex-reverse-ip <target>

但是自从Robtex更新了他的网站以来,Nmap脚本已不再适用了。

新的Robtex html结构是这样的:

    <div class="xsha">
        <div>
            <div>
                <h3>
                    <span id="sharedn.b446331/_ma">Pointing to this IP number</span>
                </h3>
            </div>
            <ol class="xbul">
                <li>domain1</li>
<li>domain2</li>
<li>domain3</li>
<li>domain...</li>
            </ol>
        </div>
    </div>

我已更改了我的Nmap脚本,但它无效。

function parse_robtex_response(data)
  local data = data:match("<span id=\"sharedn\">.-<ol.->(.-)</ol>")
  local result = {}
  if data then
    for domain in data:gmatch("<li[^>]*>(.-)</li>") do
      domain = domain:gsub("<[^>]+>","")
      table.insert(result, domain)
    end
  end
  return result
end

prerule = function() return stdnse.get_script_args("http-robtex-reverse-ip.host") ~= nil end

action = function(host, port)

  local target = stdnse.get_script_args("http-robtex-reverse-ip.host")
  local ip = ipOps.ip_to_str(target)
  if ( not(ip) or #ip ~= 4 ) then
    return stdnse.format_output(false, "The argument \"http-robtex-reverse-ip.host\" did not contain a valid IPv4 address")
  end

  local link = "/ip-lookup/"..target..""
  local htmldata = http.get("www.robtex.com", 443, link, {any_af=true})
  local domains = parse_robtex_response(htmldata.body)
  if ( #domains > 0 ) then
    return stdnse.format_output(true, domains)
  end
end

如何解决此问题?

1 个答案:

答案 0 :(得分:2)

下次我们更改网页时,这可能会再次破裂。不要刮擦我们的网站,最好使用全新的免费API(https://www.robtex.com/api/)。 它更安全,更快速,更容易解析。

相关问题