From 67b0a6ba4928b73672dd127c9d99bea99aea131b Mon Sep 17 00:00:00 2001 From: Jaroslav Svoboda Date: Tue, 13 May 2025 16:01:34 +0200 Subject: [PATCH] ESC/VP.net detector --- scripts/escvpnet.nse | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 scripts/escvpnet.nse diff --git a/scripts/escvpnet.nse b/scripts/escvpnet.nse new file mode 100644 index 000000000..4c74a4636 --- /dev/null +++ b/scripts/escvpnet.nse @@ -0,0 +1,59 @@ +local nmap = require "nmap" +local shortport = require "shortport" +local stdnse = require "stdnse" + +description = [[ +Detects availability of the ESC/VP.net protocol used to +monitor and control Epson projectors. +Sends a specific ESC/VP.net message and parses the response. +]] + +author = "Jaroslav Svoboda" +license = "Same as Nmap--See https://nmap.org/book/man-legal.html" +categories = {"discovery", "safe"} + +portrule = shortport.port_or_service({3629}, "escvpnet") + +action = function(host, port) + local socket = nmap.new_socket() + local status, err + local output + + -- Define the ESC/VP.net message + local message = "ESC/VP.net\x10\x01\x00\x00\x00\x00" + + -- Try to connect to the target + status, err = socket:connect(host, port) + if not status then + return "Failed to connect: " .. err + else + stdnse.print_debug(1, "Connected to " .. host.ip .. ":" .. port.number) + end + + -- Send the ESC/VP.net message + status, err = socket:send(message) + if not status then + socket:close() + return "Failed to send message: " .. err + else + stdnse.print_debug(1, "Command sent: " .. stdnse.tohex(message)) + end + + -- Receive the response + local status, lines = socket:receive_lines(1) + if not status then + socket:close() + return "Failed to receive response: " .. lines + end + + socket:close() + + stdnse.print_debug(1, "Raw response received: " .. stdnse.tohex(lines)) + if lines:match("^ESC/VP.net") then + output = "ESC/VP.net device detected" + else + output = "No valid ESC/VP.net response detected." + end + + return output +end