Skip to content
This repository has been archived by the owner on Aug 7, 2020. It is now read-only.

Fixed Freeze on 401 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NSE/http-screenshot.nse
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ local shortport = require "shortport"

local stdnse = require "stdnse"

-- Added HTTP to detect response code to abort on 401
local http = require "http"

portrule = shortport.http

action = function(host, port)
Expand All @@ -47,6 +50,13 @@ action = function(host, port)
prefix = "https"
end

local answer = http.get(host, port, "/", { bypass_cache = true })

if answer.status == 401 then
result = "Page requires authentication (401). Aborting Script"
return stdnse.format_output(true, result)
end

-- Execute the shell command wkhtmltoimage-i386 <url> <filename>
local cmd = "wkhtmltoimage-i386 -n " .. prefix .. "://" .. host.ip .. ":" .. port.number .. " " .. filename .. " 2> /dev/null >/dev/null"

Expand Down