This commit is contained in:
Adrien MALINGREY 2023-04-14 17:06:19 +02:00
parent fbd0f19ced
commit 0027932ecd
2 changed files with 15 additions and 6 deletions

View File

@ -29,7 +29,6 @@ action = function(host, port)
local hostaddress = (host.name ~= '' and host.name) or host.ip local hostaddress = (host.name ~= '' and host.name) or host.ip
local path = "/" local path = "/"
local uri local uri
local answer
local favicon_relative_uri = "/favicon.ico" local favicon_relative_uri = "/favicon.ico"
local favicon local favicon
@ -44,12 +43,19 @@ action = function(host, port)
end end
uri = scheme.."://"..hostaddress..":"..port.number..path uri = scheme.."://"..hostaddress..":"..port.number..path
answer = http.get_url(uri) local answer = http.get_url(uri)
local info = {status=answer.status, ["status-line"]=answer["status-line"]}
if (answer and answer.status == 200) then if (answer and answer.status == 200) then
stdnse.debug1("[SUCCESS] Load page %s", uri) stdnse.debug1("[SUCCESS] Load page %s", uri)
favicon_relative_uri = parseIcon(answer.body) or "favicon.ico" -- Taken from http-title.nse by Diman Todorov
local title = string.match(answer.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")
if (title) then
info.title = title
end
stdnse.debug1("[INFO] Try favicon %s", favicon_relative_uri) stdnse.debug1("[INFO] Try favicon %s", favicon_relative_uri)
favicon_relative_uri = parseIcon(answer.body) or "favicon.ico"
else else
stdnse.debug1("[ERROR] Can't load page %s", uri) stdnse.debug1("[ERROR] Can't load page %s", uri)
end end
@ -59,11 +65,12 @@ action = function(host, port)
if (favicon and favicon.status == 200) then if (favicon and favicon.status == 200) then
stdnse.debug1("[SUCCESS] Load favicon %s", favicon_absolute_uri) stdnse.debug1("[SUCCESS] Load favicon %s", favicon_absolute_uri)
return {status=answer.status, ["status-line"]=answer["status-line"], favicon=favicon_absolute_uri} info.favicon = favicon_absolute_uri
else else
stdnse.debug1("[ERROR] Can't load favicon %s", favicon_absolute_uri) stdnse.debug1("[ERROR] Can't load favicon %s", favicon_absolute_uri)
return {status=answer.status, ["status-line"]=answer["status-line"]}
end end
return info
end end
--- function taken from http_favicon.nse by Vlatko Kosturjak --- function taken from http_favicon.nse by Vlatko Kosturjak

View File

@ -145,6 +145,7 @@
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="title"> <xsl:variable name="title">
<xsl:value-of select="$scannedPort/@portid"/> <xsl:value-of select="$scannedPort/@portid"/>
<xsl:text>/</xsl:text> <xsl:text>/</xsl:text>
<xsl:value-of select="$scannedPort/@protocol"/> <xsl:value-of select="$scannedPort/@protocol"/>
@ -152,9 +153,10 @@
<xsl:value-of select="$scannedPort/state/@state"/> <xsl:value-of select="$scannedPort/state/@state"/>
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/service/@name"/> <xsl:value-of select="$scannedPort/service/@name"/>
<xsl:if test="$scannedPort/script[@id='http-info']/elem[@key='status-line']"> <xsl:if test="$scannedPort/script[@id='http-info']">
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='status-line']"/> <xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='status-line']"/>
<xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='title']"/>
</xsl:if> </xsl:if>
</xsl:variable> </xsl:variable>
<xsl:choose> <xsl:choose>