发布于1月23日1月23日 Psobf - PowerShell 混淆器 4 个月前 上午 8:30 | FaradaySEC 赞助的帖子| 多用户渗透测试环境锡安3R 用 Go 编写的用于混淆PowerShell脚本的工具。该程序的主要目的是混淆PowerShell代码,使其分析和检测更加困难。该脚本提供 5 个级别的混淆,从基本混淆到脚本碎片化。这允许用户根据自己的特定需求定制混淆级别。 ./psobf -h ██████╗ ███████╗ ██████╗ ██████╗ ███████╗ ██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██████╔╝███████╗██║ ██║██████╔╝█████╗ ██╔═══╝ ╚════██║██║ ██║██╔══██╗██╔══╝ ██║ ███████║╚██████╔╝██████╔╝██║ ╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ @TaurusOmar v.1.0 Usage: ./obfuscator -i <inputFile> -o <outputFile> -level <1|2|3|4|5> Options: -i string Name of the PowerShell script file. -level int Obfuscation level (1 to 5). (default 1) -o string Name of the output file for the obfuscated script. (default "obfuscated.ps1") Obfuscation levels: 1: Basic obfuscation by splitting the script into individual characters. 2: Base64 encoding of the script. 3: Alternative Base64 encoding with a different PowerShell decoding method. 4: Compression and Base64 encoding of the script will be decoded and decompressed at runtime. 5: Fragmentation of the script into multiple parts and reconstruction at runtime. 特征: 混淆级别:四个混淆级别,每个级别都比前一个更复杂。 通过将脚本拆分成单个字符来进行 1 级混淆。 脚本的 2 级 Base64 编码。 级别 3 使用不同的 PowerShell 解码方法替代 Base64 编码。 脚本的 4 级压缩和 Base64 编码将在运行时解码和解压缩。 级别 5 将脚本分割成多个部分并在运行时重建。 压缩和编码:级别 4 包括在以 base64 编码之前对脚本进行压缩。 变量混淆:添加了一个函数来混淆 PowerShell 脚本中的变量名称。 随机字符串生成:生成随机字符串以混淆变量名。 安装 go install github.com/TaurusOmar/psobf@latest 混淆级别示例 混淆级别分为5个选项,首先你需要有一个需要混淆的PowerShell文件,假设你有一个文件,文件script.ps1内容如下: Write-Host "Hello, World!" 级别 1:基本混淆 使用 1 级混淆运行脚本。 ./obfuscator -i script.ps1 -o obfuscated_level1.ps1 -level 1 这将生成一个obfuscated_level1.ps1以模糊化内容命名的文件。结果将是您的脚本的一个版本,其中每个字符都用逗号分隔并在运行时组合。结果(级别 1) $obfuscated = $([char[]]("`W`,`r`,`i`,`t`,`e`,`-`,`H`,`o`,`s`,`t`,` `,`"`,`H`,`e`,`l`,`l`,`o`,`,` `,`W`,`o`,`r`,`l`,`d`,`!`,`"`") -join ''); Invoke-Expression $obfuscated 第 2 级:Base64 编码 使用 2 级混淆运行脚本: ./obfuscator -i script.ps1 -o obfuscated_level2.ps1 -level 2 这将生成一个obfuscated_level2.ps1以 base64 编码的内容命名的文件。执行此脚本时,它将在运行时解码并运行。结果(级别 2) $obfuscated = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('V3JpdGUtSG9zdCAiSGVsbG8sIFdvcmxkISI=')); Invoke-Expression $obfuscated 第 3 级:替代 Base64 编码 使用 3 级混淆执行脚本: ./obfuscator -i script.ps1 -o obfuscated_level3.ps1 -level 3 此级别使用 PowerShell 中略有不同的 base64编码和解码形式,添加了额外的混淆层。结果(级别 3) $e = [System.Convert]::FromBase64String('V3JpdGUtSG9zdCAiSGVsbG8sIFdvcmxkISI='); $obfuscated = [System.Text.Encoding]::UTF8.GetString($e); Invoke-Expression $obfuscated 级别 4:压缩和 Base64 编码 使用4级混淆执行脚本: ./obfuscator -i script.ps1 -o obfuscated_level4.ps1 -level 4 此级别在对脚本进行 base64 编码之前对其进行压缩,使分析更加复杂。结果将在运行时解码和解压。结果(级别 4) $compressed = 'H4sIAAAAAAAAC+NIzcnJVyjPL8pJUQQAlRmFGwwAAAA='; $bytes = [System.Convert]::FromBase64String($compressed); $stream = New-Object IO.MemoryStream(, $bytes); $decompressed = New-Object IO.Compression.GzipStream($stream, [IO.Compression.CompressionMode]::Decompress); $reader = New-Object IO.StreamReader($decompressed); $obfuscated = $reader.ReadToEnd(); Invoke-Expression $obfuscated 第五级:脚本碎片化 使用 5 级混淆运行脚本: ./obfuscator -i script.ps1 -o obfuscated_level5.ps1 -level 5 此级别将脚本分割成多个部分,并在运行时重新构建。结果(级别 5) $fragments = @( 'Write-', 'Output "', 'Hello,', ' Wo', 'rld!', '"' ); $script = $fragments -join ''; Invoke-Expression $script 本程序仅用于教育和研究目的。不得将其用于恶意活动。 下载 Psobf
创建帐户或登录后发表意见