nmap http status script

This commit is contained in:
Adrien MALINGREY 2023-04-10 21:26:53 +02:00
parent 72a9c62d4a
commit a552a3cc06
4 changed files with 34 additions and 12 deletions

View File

@ -6,8 +6,6 @@ local stdnse = require "stdnse"
local string = require "string"
local url = require "url"
local openssl = stdnse.silent_require "openssl"
description = [[
Gets the favicon url ("favorites icon").
@ -43,22 +41,15 @@ categories = {"default", "discovery", "safe"}
portrule = shortport.http
action = function(host, port)
local md5sum,answer
local answer
local match
local status, favicondb
local status
local result
local favicondbfile="nselib/data/favicon-db"
local index, icon
local root = ""
local url
local hostname = host.targetname or (host.name ~= "" and host.name) or host.ip
status, favicondb = datafiles.parse_file( favicondbfile, {["^%s*([^%s#:]+)[%s:]+"] = "^%s*[^%s#:]+[%s:]+(.*)"})
if not status then
stdnse.debug1("Could not open file: %s", favicondbfile )
return
end
if(stdnse.get_script_args('favicon.root')) then
root = stdnse.get_script_args('favicon.root')
end

25
http-status.nse Normal file
View File

@ -0,0 +1,25 @@
local shortport = require "shortport"
description = [[
Get root page and return status code
]]
---
-- @usage nmap -p80 --script http-status.nse <target>
--
-- @output
-- 404
---
categories = {"discovery", "intrusive"}
author = "Adrien Malingrey"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
portrule = shortport.http
local http = require "http"
action = function(host, port)
return http.get( host, port, "/" ).status
end

View File

@ -132,6 +132,12 @@
</xsl:when>
<xsl:when test="$scannedPort/service/@name='ftp' or $scannedPort/service/@name='ssh' or $scannedPort/service/@name='http' or $scannedPort/service/@name='https'">
<a class="ui primary mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$scannedPort/script[@id='http-status']>=400">ui red mini button</xsl:when>
<xsl:otherwise>ui primary mini button</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</xsl:when>

View File

@ -46,7 +46,7 @@ foreach (scandir("./site/") as $file) {
$targets = join(array_keys($targets), " ");
$services = join(array_keys($services), ",");
exec("nmap -v -Pn -p $services --script smb-enum-shares.nse,http-errors,./http-favicon-url.nse --script-args=httpspider.maxpagecount=1 -oX 'scans/$site.xml' $targets\n");
exec("nmap -v -Pn -p $services --script smb-enum-shares.nse,./http-status.nse,./http-favicon-url.nse --script-args=httpspider.maxpagecount=1 -oX 'scans/$site.xml' $targets\n");
}
};