1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# Exploit Title: TorrentTrader 2.6 Multiple vulnerabilities # Google Dork: "Powered by TorrentTrader v2.06" # Date: 29 Décembre 2010 # Author: EsS4ndre # Software Link: http://sourceforge.net/projects/torrenttrader/files/TorrentTrader%20v2/TorrentTrader-v2.06/ # Version: 2.6 # Tested on: Linux ----------------------------------------------------------------------------------------------------------------- blocks-edit.php Line 27: if($preview){ echo "<a name=\"".$name."\"></a>"; begin_frame("Block preview"); echo "<br /><center><b>"._BLC_USE_SITE_SET_."</b><hr>"; echo "<table border=0 width=200 align=\"center\"><tr><td>"; include("blocks/".$name."_block.php"); echo "</td></tr></table><hr>"; echo "<center><a href=\"javascript: self.close();\">"._CLS_WIN_."</a></center>"; end_frame(); stdfoot(); die(); The variable $preview isn't declared in the file, so it's exploitable from the url for example. http://localhost/blocks-edit.php?preview=1&name=../../../../../../../etc/passwd%00 Line 28: echo "<a name=\"".$name."\"></a>"; Like the variable $name isn't declared, it's exploitable for a XSS from the url. http://localhost/blocks-edit.php?preview=1&name=[XSS] Line 46: if($addnew){ foreach($addnew as $addthis){ $i = $addthis; $addblock = $_POST["addblock_".$i]; $wantedname = "'".$_POST["wantedname_".$i]."'"; $name = "'".str_replace("_block.php","",$addblock)."'"; $description = "'".$_POST["wanteddescription_".$i]."'"; mysql_query("INSERT INTO blocks (named, name, description, position, enabled, sort) VALUES ($wantedname, $name, $description, 'left', 0, 0)")or ((mysql_errno() == 1062) ? show_error_msg("Error","Sorry, this block is in database already!",1) : show_error_msg("Error","Database Query failed: " . mysql_error())); if(mysql_affected_rows() != 0){ $success = "<center><font size=\"3\"><b>"._SUCCESS_ADD_."</b></font></center><br />"; } The variables $description, $addblock, $name and $wantedname aren't filtered, so it's vulnerable for a sql injection. Line 189: if($left){ mysql_query("UPDATE blocks SET position = 'left', sort = $nextleft WHERE id = ".$left) or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); The variable $left isn't declared in the file, so it's vulnerable to Sql injection from the url. It's exploitable with a csrf. Line 196: if($middle){ mysql_query("UPDATE blocks SET position = 'middle', sort = $nextmiddle WHERE id = ".$middle) or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); The variable $middle isn't declared in the file, so it's vulnerable to Sql injection from the url. Line 203: if($right){ mysql_query("UPDATE blocks SET position = 'right', sort = $nextright WHERE enabled=1 AND id = ".$right) or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); The variable $right isn't declared in the file, so it's vulnerable to Sql injection from the url. Line 210: if($up){ $cur = mysql_query("SELECT position, sort, id FROM blocks WHERE id = $up"); $curent = mysql_fetch_assoc($cur); mysql_query("UPDATE blocks SET sort = ".$sort." WHERE sort = ".($sort-1)." AND id != $up AND position = '".$position."'") or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); mysql_query("UPDATE blocks SET sort = ".($sort-1)." WHERE id=$up") or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); } The variable $up isn't declared in the file, so it's vulnerable to Sql injection. Line 219: if($down){ $cur = mysql_query("SELECT position, sort, id FROM blocks WHERE id = $down"); $curent = mysql_fetch_assoc($cur); mysql_query("UPDATE blocks SET sort = ".($sort+1)." WHERE id=$down") or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); mysql_query("UPDATE blocks SET sort = ".$sort." WHERE sort = ".($sort+1)." AND id != $down AND position = '".$position."'") or show_error_msg(_ERROR_,_FAIL_DB_QUERY_.": " . mysql_error()); } The variable $down isn't declared in the file, so it's vulnerable to Sql injection. Info: - Register_globale is required - There needs to be admin - All this vulnerabilities are exploitables by crsf. Line 82 to 146: The upload form doesn't filter uploaded files. So, it's possible to send a backdoor on the server with the upload form. Rename the backdoor in backdoor_block.php and the file will be uploaded in the /blocks directory. http://localhost/blocks/backdoor_block.php ================================================================================================================= torrents-import.php Line 101 : $ret = mysql_query("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon) VALUES (".sqlesc($fname).", '".$CURUSER['id']."', ".sqlesc($name).", ".sqlesc($descr).", '".$inames[0]."', '".$inames[1]."', '".$type."', '" . get_date_time() . "', '".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."', '".$langid."','$anon')"); Sql vulnérability, the variable $type isn't declared. Info: - There needs to be moderator - Register_globale is required. ================================================================================================================= report.php The variables $takeuser, $takeuser, $takeforumid, $takecomment, $takeforumpost are vulnerable to sql injection and the variable $takereason is vulnerable to XSS. Line 40: $res = mysql_query("SELECT id FROM reports WHERE addedby = $CURUSER[id] AND votedfor = $takeuser AND type = 'user'"); Line 43: mysql_query("INSERT into reports (addedby,votedfor,type,reason) VALUES ($CURUSER[id],$takeuser,'user', '$takereason')"); Line 44: print("User: $takeuser, Reason: $takereason<p></p>Successfully Reported"); Line 65: $res = mysql_query("SELECT id FROM reports WHERE addedby = $CURUSER[id] AND votedfor = $taketorrent AND type = 'torrent'"); Line 68: print("Torrent: $taketorrent, Reason: $takereason<p></p>Successfully Reported"); Line 89: $res = mysql_query("SELECT id FROM reports WHERE addedby = $CURUSER[id] AND votedfor = $takecomment AND type = 'comment'"); Line 92: print("Comment: $takecomment, Reason: $takereason<p></p>Successfully Reported"); Line 113: $res = mysql_query("SELECT id FROM reports WHERE addedby = $CURUSER[id] AND votedfor= $takeforumid AND votedfor_xtra= $takeforumpost AND type = 'forum'"); Line 117: print("User: $takeuser, Reason: $takereason<p></p>Successfully Reported"); ================================================================================================================= /torrents.php The variable $parent_check isn't declared in the file, so it's vulnerable to sql injection. Line 89: $res = mysql_query("SELECT COUNT(*) FROM torrents LEFT JOIN categories ON category = categories.id $where $parent_check") or die(mysql_error()); Line 94: if ($count) { list($pagertop, $pagerbottom, $limit) = pager(20, $count, "torrents.php?" . $addparam); $query = "SELECT torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit"; $res = mysql_query($query) or die(mysql_error()); }else{ unset($res); } Info: Register_globale is required. ================================================================================================================= /torrents-search.php The variable parent_cat and parent_check aren't securised in this file. Line 10: $parent_cat = $_GET["parent_cat"]; Line 167: $res = mysql_query("SELECT COUNT(*) FROM torrents $where $parent_check") or die(mysql_error()); Line 191; $res = mysql_query("SELECT COUNT(*) FROM torrents $where $parent_check"); Line 212: if ($count) { //SEARCH QUERIES! list($pagertop, $pagerbottom, $limit) = pager(20, $count, "torrents-search.php?" . $addparam); $query = "SELECT torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit"; $res = mysql_query($query) or die(mysql_error()); }else{ unset($res); } Line 217: $query = "SELECT torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit"; $res = mysql_query($query) or die(mysql_error()); Line 257: $subcatsquery = mysql_query("SELECT id, name, parent_cat FROM categories WHERE parent_cat='$parent_cat' ORDER BY name")or die(mysql_error()); - Need magic_quotes: off. Info: Register_globale is required ================================================================================================================= /faq.php The data returned from the sql query are displayed without being filtered and it's possible to inject javascript from the administrator pannel (/faq-actions.php). So it's vulnerable to XSS. ================================================================================================================= /faq-actions.php The variable $_POST[order] isn't filtered, it's vulnerable to sql injection. Line 20: if ($_GET[action] == "reorder") { foreach($_POST[order] as $id => $position) mysql_query("UPDATE <code>faq</code> SET <code>order</code>='$position' WHERE id='$id'"); header("Refresh: 0; url=faq-manage.php"); } The variable $_GET[id] isn't filtere, so it's vulnerable to sql injection. Line 31: $res = mysql_query("SELECT * FROM <code>faq</code> WHERE <code>id</code>='$_GET[id]' LIMIT 1"); The variables $_POST[flag], $_POST[categ] and $_POST[id] aren't filtered, so it's vulnerable to sql injection. Line 72: elseif ($_GET[action] == "edititem" && $_POST[id] != NULL && $_POST[question] != NULL && $_POST[answer] != NULL && $_POST[flag] != NULL && $_POST[categ] != NULL) { $question = addslashes($_POST[question]); $answer = addslashes($_POST[answer]); mysql_query("UPDATE <code>faq</code> SET <code>question</code>='$question', <code>answer</code>='$answer', <code>flag</code>='$_POST[flag]', categ</code>='$_POST[categ]' WHERE id='$_POST[id]'"); header("Refresh: 0; url=faq-manage.php"); } Line 80: elseif ($_GET[action] == "editsect" && $_POST[id] != NULL && $_POST[title] != NULL && $_POST[flag] != NULL) { $title = addslashes($_POST[title]); mysql_query("UPDATE <code>faq</code> SET <code>question</code>='$title', <code>answer</code>='', <code>flag</code>='$_POST[flag]', <code>categ</code>='0' WHERE id='$_POST[id]'"); Line 87: elseif ($_GET[action] == "delete" && isset($_GET[id])) { if ($_GET[confirm] == "yes") { mysql_query("DELETE FROM <code>faq</code> WHERE <code>id</code>='$_GET[id]' LIMIT 1"); header("Refresh: 0; url=faq-manage.php"); } Line 139: elseif ($_GET[action] == "addnewitem" && $_POST[question] != NULL && $_POST[answer] != NULL && $_POST[flag] != NULL && $_POST[categ] != NULL) { $question = addslashes($_POST[question]); $answer = addslashes($_POST[answer]); $res = mysql_query("SELECT MAX(<code>order</code>) FROM <code>faq</code> WHERE <code>type</code>='item' AND <code>categ</code>='$_POST[categ]'"); while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) $order = $arr[0] + 1; mysql_query("INSERT INTO <code>faq</code> (<code>type</code>, <code>question</code>, <code>answer</code>, <code>flag</code>, <code>categ</code>, <code>order</code>) VALUES ('item', '$question', '$answer', '$_POST[flag]', '$_POST[categ]', '$order')"); header("Refresh: 0; url=faq-manage.php"); } Line 149: elseif ($_GET[action] == "addnewsect" && $_POST[title] != NULL && $_POST[flag] != NULL) { $title = addslashes($_POST[title]); $res = mysql_query("SELECT MAX(<code>order</code>) FROM <code>faq</code> WHERE <code>type</code>='categ'"); while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) $order = $arr[0] + 1; mysql_query("INSERT INTO <code>faq</code> (<code>type</code>, <code>question</code>, <code>answer</code>, <code>flag</code>, <code>categ</code>, <code>order</code>) VALUES ('categ', '$title', '', '$_POST[flag]', '0', '$order')"); header("Refresh: 0; url=faq-manage.php"); } Info: There needs to be admin ================================================================================================================= /admincp.php Line 347: if (mysql_query("INSERT INTO stylesheets (name, uri) VALUES ('$_POST[name]', '$_POST[uri]')")) The variable $_POST[name] and $_POST[uri] are vulnerable to sql injection. Line 348: show_error_msg("Success", "Theme '$_POST[name]' added.", 0); The variable $_POST[name] isn't filtered, so it's vulnerable to XSS. Line 588: print("<input type=hidden name=returnto value=$returnto>\n"); The variable $returnto isn't filtered, so it's vulnerable to XSS. Line 793: mysql_query("UPDATE torrents SET category=$newcatid WHERE category=$id") or die(mysql_error()); The variable $newcatid isn't filtered, so it's vulnerable to sql injection. Line 1406: $url = " .$_SERVER[PHP_SELF]"; $count = $row[0]; $perpage = 40;list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $url); print("<BR><b> Current Email Bans ($count)</b>\n"); $url isn't filtered and pager() does not filter anything. So it's vulnerable to XSS. Line 2006: $query = mysql_query("SELECT id FROM users WHERE class IN (".implode(",", $updateset).")"); The variable $updateset isn't filtered, so it's vulnerable to sql injection. Line 2340: if($action == "censor") { stdhead("Censor"); navmenu(); //Output if ($_POST['submit'] == 'Add Censor'){ $query = "INSERT INTO censor (word, censor) VALUES ('" . $_POST['word'] . "','" . $_POST['censor'] . "');"; mysql_query($query); } if ($_POST['submit'] == 'Delete Censor'){ $aquery = "DELETE FROM censor WHERE word = '" . $_POST['censor'] . "' LIMIT 1"; mysql_query($aquery); } The variables $_POST['word'] and $_POST['censor'] aren't filtered, so it's vulnerable to sql injection. Info: There needs to be admin ================================================================================================================= admin-modtasks.php Line 71: mysql_query("UPDATE users SET title=".sqlesc($title).", downloaded='$downloaded', uploaded='$uploaded', signature=".sqlesc($signature).", avatar='$avatar', ip='$ip', donated='$donated', forumbanned='$forumbanned', warned='$warned',modcomment='$modcomment', enabled='$enabled', invites='$invites' WHERE id=$userid"); The variables $invites, $enabled, $modcomment, $warned, $forumbanned, $donated, $ip, $avatar, $uploaded and $downloaded are vulnerable to sql injection. Info: There needs to be admin ================================================================================================================= /backend/functions.php Line 136: function getip() { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = $_SERVER['REMOTE_ADDR']; } } else { if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) { $ip = getenv('HTTP_CLIENT_IP'); } else { $ip = getenv('REMOTE_ADDR'); } } return $ip; } It's possible of spoof your ip address with the header X-Forwarded-For or Client-ip. Use $_SERVER['HTTP_X_FORWARDED_FOR'] or $_SERVER['HTTP_CLIENT_IP'] isn't secured. Prefer using $_SERVER['REMOTE_ADDR']. Line 296: function show_error_msg($title, $message, $wrapper = "1") { if ($wrapper=="1") { stdhead($title); //echo "<b>DEBUG: stdhead Wrapper ON/Kill php gen further</b>";//remove later } begin_frame("<font color=red>". htmlspecialchars($title) ."</font>"); print("<p><CENTER><B>" . stripslashes(sqlesc($message)) . "</B></CENTER></p>\n"); end_frame(); if ($wrapper=="1"){ stdfoot(); die(); } } if the $message variable isn't filtered before being passed as a parameter to the function that is vulnerable to XSS. ================================================================================================================= /backend/smilies.php Line 159: function insert_smilies_frame () { GLOBAL $site_config, $smilies; echo "<table><tr><td class=\"colhead\">Type...</td><td class=\"colhead\">To make a...</td></tr>"; foreach ($smilies as $code => $url) { echo "<tr><td>$code</td><td><a href=\"javascript:window.opener.SmileIT('$code', '$_GET[form]', '$_GET[text]')\"><img src=\"$site_config[SITEURL]/images/smilies/$url\" alt=\"$code\" title=\"$code\" border=\"0\"></a></td></tr>"; } echo "</table>"; } The variable $_GET[form] and $_GET[text] are vulnerable to XSS. http://localhost/backend/smilies.php?action=display&text=[XSS] /backend/smilies.php is included in backend/functions.php, so it's exploitable with all the files that contain this include. ----------------------------------------------------------------------------------------------------------------- Greetz and Thanks to : Mr Pad, Sh0ck, Syscall, PhOeNiX95, BestPig, Spl3en, Xylitol, Nico and those i forgot <3 ----------------------------------------------------------------------------------------------------------------- |