Waraxe IT Security Portal  
  Login or Register
::  Home  ::  Search  ::  Your Account  ::  Forums  ::   Waraxe Advisories  ::  Tools  ::
June 23, 2024
Menu
 Home
 Logout
 Discussions
 Forums
 Members List
 IRC chat
 Tools
 Base64 coder
 MD5 hash
 CRC32 checksum
 ROT13 coder
 SHA-1 hash
 URL-decoder
 Sql Char Encoder
 Affiliates
 y3dips ITsec
 Md5 Cracker
 User Manuals
 AlbumNow
 Content
 Content
 Sections
 FAQ
 Top
 Info
 Feedback
 Recommend Us
 Search
 Journal
 Your Account



User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9145

People Online:
Visitors: 427
Members: 0
Total: 427
PacketStorm News
·301 Moved Permanently

read more...
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> Sql injection -> Injectable?
Post new topic  Reply to topic View previous topic :: View next topic 
Injectable?
PostPosted: Fri Jan 13, 2006 7:25 am Reply with quote
e-rased
Beginner
Beginner
 
Joined: Jan 13, 2006
Posts: 2




There's a popular mod-addon out for IBStore(Invision Power Board mod) called Transactions Mod...I looked the source over and some of the sql query values aren't checked or sanitized...Can anyone look it over and tell me what you could do with it? I imagine union would be of use but I'm new to exploits...

Code:

<?php



$idx = new trans;

class trans
{
    var $output     = "";
    var $page_title = "";
    var $nav        = array();
    var $html       = "";
   

    function trans()
    {
global $ibforums, $forums, $DB, $std, $print, $skin_universal;

        $ibforums->lang = $std->load_words($ibforums->lang, 'lang_trans', $ibforums->lang_id );
        $this->html = $std->load_template('skin_trans');
        $this->base_url = $ibforums->base_url;

       
       //// $this->output = $this->html->test();


////Here we build the transactions page.
////right here i'm checking to see if the $_GET[] vars are defined. if they aren't, i define them.

      if ( ! isset( $ibforums->input['method'] ) )
      {
         $ibforums->input['method'] = "global";
         $method = "global";
      }
      else
      {
         $method =  $ibforums->input['method'];
      }

      if ( ! isset( $ibforums->input['current'] ) )
      {
         $ibforums->input['current'] = "0";
         $current = 0;
      }
      else
      {
         $current =  $ibforums->input['current'];
      }
///We're done checking our get vars.
///Here i'm going to switch() on the case of $method

switch($method){

   case "global";
      $sql_count = "SELECT * from ipb_store_logs";

      ////get the number of rows
      $total_rows = mysql_num_rows($therows= mysql_query($sql_count));

      ////get the total amount of pages, round up
      $totalpages = floor($total_rows/50);

      ////total items
      $totalled_items = $totalpages * 50;
      ////the current page number
      $curpage =  ceil(($current) / 50);


      $the_tmp .= "<br />";
      $the_tmp .= "<form action=\"index.php?act=trans&method=search\" method=\"GET\">Search for a user's transactions:
<input type=\"hidden\" value=\"trans\" name=\"act\">
<input type=\"hidden\" value=\"search\" name=\"method\">
<input type=\"text\" name=\"user\" value=\"$user\"><input type=\"submit\" value=\"Search\"></form>";
      $the_tmp .= "<center>";
      $the_tmp .= "<br />";


      ///Before pages
      $thetmpshow = $curpage + 1;
      $the_tmp .= "<b>Current: $thetmpshow</b><br />";
      $the_tmp .=  "<a href=\"index.php?act=trans&current=0\"><<[</a> ";
      $page_min = $curpage - 11;
      if($page_min<0){
         $page_min = 0;
         $page_num = 1;
      }
      elseif($page_min>0){
         $page_min = $page_min - 1;
         if($page_min==0){
            $page_num = 1;
         }
         else{
            $page_num = $page_min+1;
         }
      }
      $itmp = ($page_min*50);

      while($itmp<($curpage*50)  AND $page_num>$page_min) {
         $the_tmp .=  "<a href=\"index.php?act=trans&current=$itmp\"> $page_num</a> ";
         $itmp = $itmp + 50;
         $page_num = $page_num + 1;
      }

      $the_tmp .= "<b>$thetmpshow</b> ";

      ///after pages

      $page_max = $curpage + 11;

      if($page_max>$totalpages){
         $page_max = $totalpages;
      }
      $page_num = $curpage + 1;
      $items_max = $pages_max * 50;
      $itmp = $page_num * 50;
      if($curpage<$totalpages){
          while($page_num < $page_max) {
            $page_num = $page_num  + 1;
            $the_tmp .=  "<a href=\"index.php?act=trans&current=$itmp\">$page_num</a> ";
            $itmp = $itmp + 50;
         }
      }
      $the_tmp .= "<a href=\"check.php?current=$totalled_items\">]>></a>";
      $the_tmp .=  "</center>";

      $the_tmp .=  "<br />";


      $query = "SELECT * FROM ipb_store_logs ORDER by lid DESC LIMIT $current, 50";

      $pigfuck = mysql_query($query);



      $the_tmp .=  "<br><br>";

      $the_tmp .= "<div align=\"right\"></div>";
      $the_tmp .= "<table border=\"1\" width=\"100%\" Cellpaddinng=\"2\">";
      $the_tmp .= "<th width=\"5%\" nowrap>ID</th>";
      $the_tmp .= "<th width=\"50%\" nowrap>Message</th>";
      $the_tmp .= "<th width=\"10%\" nowrap>Username</th>";
      $the_tmp .= "<th width=\"10%\" nowrap>Action</th>";
      $the_tmp .= "<th width=\"25%\">Time</th>";


      while($query_data = mysql_fetch_array($pigfuck)) {
         $lid = $query_data["lid"];
         $lmessage = $query_data["lmessage"];
         $luserid = $query_data["luserid"];
         $ltype = $query_data["ltype"];
         $ltime = $query_data["ltime"];


            $midgettoss = date('r',$ltime);
            $midgettoss = str_replace(',','',$midgettoss);
            $midgettoss = explode("-", $midgettoss);


         if($ltype == "donate_m"){
            $ltype = "Donated";
         }

         if($ltype == "bought_item"){
            $ltype = "Purchase";
         }

         if($ltype == "titleeffect"){
            $ltype = "Title";
         }

         //Edit

         $dirt = "SELECT name FROM ipb_members WHERE id = '$luserid'";

         $whore = mysql_query($dirt);

         $try = mysql_fetch_array($whore);
         $tip = $try["name"];
         if($tip==""){
            $tip = "Unkown user?!";
         }


         $the_tmp .= "<TR>\n";
         $the_tmp .= "<TD width=\"5%\" align=\"center\">$lid</td>\n";
         $the_tmp .= "<TD width=\"50%\" align=\"center\">$lmessage</td>\n";
         $the_tmp .="<TD width=\"10%\" align=\"center\"><a href=\"index.php?showuser=$luserid\">$tip</a></td>\n";
         $the_tmp .= "<TD width=\"10%\" align=\"center\">$ltype</td>\n";
         $the_tmp .= "<TD width=\"25%\" align=\"center\">$midgettoss[0]</td>\n";
         $the_tmp .= "</tr>\n";
      }
      $the_tmp .= "</table>";


      $the_tmp .= "<br /> <br />";
      $the_tmp .= "<center>";
      $the_tmp .="<a href=\"index.php?act=trans&current=0\"><<[</a> ";
      ///Before pages

      $page_min = $curpage - 11;
      if($page_min<0){
         $page_min = 0;
         $page_num = 1;
      }
      elseif($page_min>0){
         $page_min = $page_min - 1;
         if($page_min==0){
            $page_num = 1;
         }
         else{
            $page_num = $page_min + 1;
         }
      }
      $itmp = ($page_min*50);

      while($itmp<($curpage*50)  AND $page_num>$page_min) {
         $the_tmp .= "<a href=\"index.php?act=trans&current=$itmp\"> $page_num</a> ";
         $itmp = $itmp + 50;
         $page_num = $page_num + 1;
      }

      $the_tmp .= "<b>$thetmpshow</b> ";

      ///after pages

      $page_max = $curpage + 11;

      if($page_max>$totalpages){
         $page_max = $totalpages;
      }
      $page_num = $curpage + 1;
      $items_max = $pages_max * 50;
      $itmp = $page_num * 50;
      if($curpage<$totalpages){
          while($page_num < $page_max) {
            $page_num = $page_num  + 1;
            $the_tmp .= "<a href=\"index.php?act=trans&current=$itmp\">$page_num</a> ";
            $itmp = $itmp + 50;
         }
      }

      $the_tmp .= "<a href=\"check.php?current=$totalled_items\">]>></a>";

      $the_tmp .= "</center>";
      break;
      /////YAY !!!!1!~1`1!1 We're done with the global case!
      
default:
}
echo "</center>";
        $this->output = $the_tmp;
        $print->add_output("$this->output");
        $print->do_output( array( 'TITLE' => $ibforums->lang['page_title'], 'JS' => 0, NAV => array( $ibforums->lang['page_title'] ) ) );
    }
}
?>


$current is never checked, and it directly queries the database without any 'sanitisation'...any ideas?
View user's profile Send private message
PostPosted: Sat Jan 14, 2006 1:53 pm Reply with quote
Pi3cH
Regular user
Regular user
 
Joined: Dec 15, 2005
Posts: 7




could give me live example?

the $curpage limited at this line of code:
$curpage = ceil(($current) / 50);
View user's profile Send private message
PostPosted: Sat Jan 14, 2006 8:33 pm Reply with quote
e-rased
Beginner
Beginner
 
Joined: Jan 13, 2006
Posts: 2




$query = "SELECT * FROM ipb_store_logs ORDER by lid DESC LIMIT $current, 50";

$curpage is just a var for rendering the before/after links...current isn't touched
View user's profile Send private message
PostPosted: Tue Jan 17, 2006 2:24 pm Reply with quote
Pi3cH
Regular user
Regular user
 
Joined: Dec 15, 2005
Posts: 7




oh! i dont see the left part of =,

could you give live example?
View user's profile Send private message
Injectable?
  www.waraxe.us Forum Index -> Sql injection
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Post new topic  Reply to topic  




Powered by phpBB 2001-2008 phpBB Group






Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2020 Janek Vind "waraxe"
Page Generation: 0.187 Seconds