-
Notifications
You must be signed in to change notification settings - Fork 4
/
http-screenshot.nse
43 lines (27 loc) · 1.3 KB
/
http-screenshot.nse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
description = [[
Gets a screenshot from the host
]]
author = "Ryan Linn <rlinn at trustwave.com>, Tudor Enache"
license = "GPLv2"
categories = {"discovery", "safe"}
-- Updated the NSE Script imports and variable declarations
local shortport = require "shortport"
local stdnse = require "stdnse"
-- Process services that are either running on 80, 443 or ones that are classified as http(s)
portrule = shortport.port_or_service({80,443},{"http","https"})
action = function(host, port)
-- Check to see if ssl is enabled, if it is, this will be set to "ssl"
local service_prefix = port.service
-- Screenshots will be called screenshot-namp-<IP>:<port>.png
local filename = "screenshot-nmap-" .. service_prefix .. host.ip .. ":" .. port.number .. ".png"
-- Execute the shell command timeout 10 wkhtmltoimage <url> <filename>
local cmd = "timeout 10 wkhtmltoimage --height 768 -n " .. service_prefix .. "://" .. host.ip .. ":" .. port.number .. " " .. filename .. " 2>/dev/null >/dev/null"
local ret = os.execute(cmd)
-- If the command was successful, print the saved message, otherwise print the fail message
local result = "failed (verify wkhtmltoimage is in your path)"
if ret then
result = "Saved to " .. filename
end
-- Return the output message
return stdnse.format_output(true, result)
end