【发布时间】:2023-01-26 19:52:25
【问题描述】:
我有一个执行 shellcode 的 powershell 脚本。
$code = 0xe8,0x3b,0x3d,0x03,0x00,0x3b,0x3d,0x03
$code.GetType()
[Byte[]] $buf = $code
$buf.Length
上面命令的输出是
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
8
但是当我将 shellcode 保存在文本文件中并执行它时,它不会执行并且缓冲区长度也不同。
$codes = @(Get-Content -Raw C:\Users\abc\Downloads\code.txt)
$codes.GetType()
[Byte[]] $buf = $codes.ToCharArray()
echo $buf.Length
上述命令的输出
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
39
我可以通过任何机会从文本文件执行上述 shellcode 并保持缓冲区长度不变。
【问题讨论】:
-
您需要
Get-Content C:\Users\abc\Downloads\code.txt -Encoding Byte(或 PowerShell 7 中的Get-Content C:\Users\abc\Downloads\code.txt -AsByteStream) -
即使尝试 @(Get-Content C:\Users\abc\Downloads\code.txt -Encoding Byte) 结果也是一样的。
-
然后您可能将文字字符串
0xe8,0x3b,0x3d,0x03,0x00,0x3b,0x3d,0x03存储在文件中,请参阅下面我的回答中的第二个建议 :) -
该文件包含一长串 shellcode,上面的 shellcode 是它的 sn-p。
标签: windows powershell shellcode