Lucene search

K

broadcast-pc-duo NSE Script

🗓️ 18 Dec 2011 09:38:33Reported by Patrik KarlssonType 
nmap
 nmap
🔗 nmap.org👁 76 Views

Discovers PC-DUO remote control hosts and gateways on LAN using special broadcast UDP probe

Show more
Related
Code
ReporterTitlePublishedViews
Family
Nmap
iscsi-brute NSE Script
10 Dec 201023:20
nmap
Nmap
snmp-win32-software NSE Script
16 Feb 201009:15
nmap
Nmap
stun-info NSE Script
16 Mar 201211:36
nmap
Nmap
socks-open-proxy NSE Script
12 Jun 200923:23
nmap
Nmap
sip-brute NSE Script
9 May 201118:00
nmap
Nmap
snmp-sysdescr NSE Script
6 Nov 200802:52
nmap
Nmap
smb-vuln-cve-2017-7494 NSE Script
10 Jun 201703:29
nmap
Nmap
pop3-ntlm-info NSE Script
8 Jan 201616:06
nmap
Nmap
servicetags NSE Script
22 Feb 201104:32
nmap
Nmap
sip-enum-users NSE Script
9 May 201118:00
nmap
Rows per page
local coroutine = require "coroutine"
local nmap = require "nmap"
local os = require "os"
local stdnse = require "stdnse"
local table = require "table"

description = [[
Discovers PC-DUO remote control hosts and gateways running on a LAN by sending a special broadcast UDP probe.
]]

---
-- @usage
-- nmap --script broadcast-pc-duo
--
-- @output
-- Pre-scan script results:
-- | broadcast-pc-duo:
-- |   PC-Duo Gateway Server
-- |     10.0.200.113 - WIN2K3SRV-1
-- |   PC-Duo Hosts
-- |_    10.0.200.113 - WIN2K3SRV-1
--
-- @args broadcast-pc-duo.timeout specifies the amount of seconds to sniff
--       the network interface. (default varies according to timing. -T3 = 5s)

author = "Patrik Karlsson"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = { "broadcast", "safe" }

local TIMEOUT = stdnse.parse_timespec(stdnse.get_script_args("broadcast-pc-duo.timeout"))

prerule = function() return ( nmap.address_family() == "inet") end

-- Sends a UDP probe to the server and processes the response
-- @param probe table containing a pc-duo probe
-- @param responses table containing the responses
local function udpProbe(probe, responses)

  local condvar = nmap.condvar(responses)
  local socket = nmap.new_socket("udp")
  socket:set_timeout(500)

  for i=1,2 do
    local status = socket:sendto(probe.host, probe.port, probe.data)
    if ( not(status) ) then
      return stdnse.format_output(false, "Failed to send broadcast request")
    end
  end

  local timeout = TIMEOUT or ( 20 / ( nmap.timing_level() + 1 ) )
  local stime = os.time()
  local hosts = {}

  repeat
    local status, data = socket:receive()
    if ( status ) then
      local srvname = data:match(probe.match)
      if ( srvname ) then
        local status, _, _, rhost, _ = socket:get_info()
        if ( not(status) ) then
          socket:close()
          return false, "Failed to get socket information"
        end
        -- avoid duplicates
        hosts[rhost] = srvname
      end
    end
  until( os.time() - stime > timeout )
  socket:close()

  local result = {}
  for ip, name in pairs(hosts) do
    table.insert(result, ("%s - %s"):format(ip,name))
  end

  if ( #result > 0 ) then
    result.name = probe.topic
    table.insert(responses, result)
  end

  condvar "signal"
end

action = function()

  -- PC-Duo UDP probes
  local probes = {
    -- PC-Duo Host probe
    {
      host = { ip = "255.255.255.255" },
      port = { number = 1505, protocol = "udp" },
      data =  stdnse.fromhex("00808008ff00"),
      match= "^.........(%w*)\0",
      topic= "PC-Duo Hosts"
    },
    -- PC-Duo Gateway Server probe
    {
      host = { ip = "255.255.255.255" },
      port = { number = 2303, protocol = "udp" },
      data =  stdnse.fromhex("20908008ff00"),
      match= "^.........(%w*)\0",
      topic= "PC-Duo Gateway Server"
    },
  }

  local threads, responses = {}, {}
  local condvar = nmap.condvar(responses)

  -- start a thread for each probe
  for _, p in ipairs(probes) do
    local th = stdnse.new_thread( udpProbe, p, responses )
    threads[th] = true
  end

  -- wait until the probes are all done
  repeat
    for thread in pairs(threads) do
      if coroutine.status(thread) == "dead" then
        threads[thread] = nil
      end
    end
    if ( next(threads) ) then
      condvar "wait"
    end
  until next(threads) == nil

  table.sort(responses, function(a,b) return a.name < b.name end)
  -- did we get any responses
  if ( #responses > 0 ) then
    return stdnse.format_output(true, responses)
  end
end

Transform Your Security Services

Elevate your offerings with Vulners' advanced Vulnerability Intelligence. Contact us for a demo and discover the difference comprehensive, actionable intelligence can make in your security strategy.

Book a live demo
18 Dec 2011 09:33Current
9.3High risk
Vulners AI Score9.3
EPSS0.973
76
.json
Report