https
This commit is contained in:
parent
81652e25c9
commit
80dc329353
@ -32,28 +32,28 @@ action = function(host, port)
|
|||||||
local scheme = ""
|
local scheme = ""
|
||||||
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 favicon_relative_uri = "/favicon.ico"
|
local favicon_relative_uri = "/favicon.ico"
|
||||||
local favicon
|
local favicon
|
||||||
|
|
||||||
|
stdnse.debug1("port", port.service)
|
||||||
if (port.service == "ssl") then
|
if (port.service == "ssl") then
|
||||||
scheme = "https"
|
scheme = "https"
|
||||||
else
|
else
|
||||||
scheme = port.service
|
scheme = port.service
|
||||||
end
|
end
|
||||||
|
stdnse.debug1("scheme", scheme)
|
||||||
|
|
||||||
if(stdnse.get_script_args('http-get.path')) then
|
if(stdnse.get_script_args('http-get.path')) then
|
||||||
path = stdnse.get_script_args('http-info.path')
|
path = stdnse.get_script_args('http-info.path')
|
||||||
end
|
end
|
||||||
|
|
||||||
uri = scheme.."://"..hostaddress..":"..port.number..path
|
stdnse.debug1("Try to download %s", path)
|
||||||
stdnse.debug1("Try to download %s", uri)
|
local answer = http.get(hostaddress, port, path)
|
||||||
local answer = http.get_url(uri, {})
|
|
||||||
|
|
||||||
local output = {status=answer.status, ["status-line"]=answer["status-line"]}
|
local output = {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", path)
|
||||||
-- Taken from http-title.nse by Diman Todorov
|
-- Taken from http-title.nse by Diman Todorov
|
||||||
local title = string.match(answer.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")
|
local title = string.match(answer.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")
|
||||||
if (title) then
|
if (title) then
|
||||||
@ -62,17 +62,16 @@ action = function(host, port)
|
|||||||
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_relative_uri
|
favicon_relative_uri = parseIcon(answer.body) or favicon_relative_uri
|
||||||
else
|
else
|
||||||
stdnse.debug1("[ERROR] Can't load page %s", uri)
|
stdnse.debug1("[ERROR] Can't load page %s", path)
|
||||||
end
|
end
|
||||||
|
|
||||||
favicon_absolute_uri = scheme.."://"..hostaddress..":"..port.number..favicon_relative_uri
|
favicon = http.get(hostaddress, port, favicon_relative_uri)
|
||||||
favicon = http.get_url(favicon_absolute_uri, {})
|
|
||||||
|
|
||||||
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_relative_uri)
|
||||||
output.favicon = favicon_absolute_uri
|
output.favicon = favicon_relative_uri
|
||||||
else
|
else
|
||||||
stdnse.debug1("[ERROR] Can't load favicon %s", favicon_absolute_uri)
|
stdnse.debug1("[ERROR] Can't load favicon %s", favicon_relative_uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
@ -45,7 +45,14 @@
|
|||||||
</xsl:if>
|
</xsl:if>
|
||||||
<xsl:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
|
<xsl:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="service/@name"/>
|
<xsl:choose>
|
||||||
|
<xsl:when test="service/@name='http' and service/@tunnel='ssl'">
|
||||||
|
<xsl:text>https</xsl:text>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="service/@name"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
<xsl:text>://</xsl:text>
|
<xsl:text>://</xsl:text>
|
||||||
<xsl:value-of select="$hostAddress"/>
|
<xsl:value-of select="$hostAddress"/>
|
||||||
<xsl:text>:</xsl:text>
|
<xsl:text>:</xsl:text>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user