mirror of
https://github.com/nmap/nmap.git
synced 2026-08-27 11:55:27 +00:00
Merge db105fa9f8 into 271cabb86a
This commit is contained in:
commit
3fe5d2ce3d
1 changed files with 50 additions and 0 deletions
50
scripts/pjlink.nse
Normal file
50
scripts/pjlink.nse
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
local nmap = require "nmap"
|
||||
local shortport = require "shortport"
|
||||
local stdnse = require "stdnse"
|
||||
|
||||
description = [[
|
||||
Detects availability of the PJLink protocol used
|
||||
to monitor and control projectors and monitors.
|
||||
Sends a specific PJLink 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({4352}, "pjlink")
|
||||
|
||||
action = function(host, port)
|
||||
local socket = nmap.new_socket()
|
||||
local status, err
|
||||
local output
|
||||
|
||||
status, err = socket:connect(host, port)
|
||||
|
||||
-- Connect to the target host and port
|
||||
status, err = socket:connect(host, port)
|
||||
if not status then
|
||||
return "Failed to connect: " .. err
|
||||
end
|
||||
|
||||
-- Receive the response
|
||||
local lines
|
||||
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("^PJLINK 0") then
|
||||
output = "PJLink device detected: No authentication required."
|
||||
elseif lines:match("^PJLINK 1") then
|
||||
output = "PJLink device detected: Authentication required."
|
||||
else
|
||||
output = "No valid PJLink response detected."
|
||||
end
|
||||
|
||||
return output
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue