local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" local table = require "table" description = [[ Extracts a list of published applications from the ICA Browser service. ]] --- -- @usage sudo ./nmap -sU --script=citrix-enum-apps -p 1604 -- -- @output -- PORT STATE SERVICE -- 1604/udp open unknown -- 1604/udp open unknown -- | citrix-enum-apps: -- | Notepad -- | iexplorer -- |_ registry editor -- -- Version 0.2 -- Created 11/24/2009 - v0.1 - created by Patrik Karlsson -- Revised 11/25/2009 - v0.2 - fixed multiple packet response bug author = "Patrik Karlsson" license = "Same as Nmap--See https://nmap.org/book/man-legal.html" categories = {"discovery","safe"} portrule = shortport.portnumber(1604, "udp") -- process the response from the server -- @param response string, complete server response -- @return string row delimited with \n containing all published applications function process_pa_response(response) local packet_len, pos = string.unpack("#query) -- process the first response pa_list = process_pa_response( packet ) -- -- the byte at offset 31 in the response has a really magic function -- if it is set to zero (0) we have more response packets to process -- if it is set to one (1) we have arrived at the last packet of our journey -- while packet:sub(31,31) ~= "\x01" do packet = try( socket:receive() ) local tmp_table = process_pa_response( packet ) for _,v in pairs(tmp_table) do table.insert(pa_list, v) end end -- set port to open if #pa_list>0 then nmap.set_port_state(host, port, "open") end socket:close() return stdnse.format_output(true, pa_list) end