如何使用 Powershell 将十六进制字符串转换为 bin?
How to use Powershell to convert hex string to bin?
我试图将一个可执行程序转换为十六进制string.Now我想使用powershell 将这些字符串转换为一个可执行程序。
这个我试过了,还是不行。
我的exe-bank.txt 像这样
据我所知,您应该使用开关 -Raw
读取十六进制文件以获得单个多行字符串。
然后将这些十六进制数字转换为字节数组并输出到文件。
尝试
$hex = Get-Content -Path "C:\blah\exe-bank.txt" -Raw
# split the input string by 2-character sequences and prefix '0X' each 2-hex-digit string
# casting the result to [byte[]] then recognizes this hex format directly.
[byte[]]$bytes = ($hex -split '(.{2})' -ne '' -replace '^', '0X')
[System.IO.File]::WriteAllBytes("C:\blah\exe-bank.exe", $bytes)
我试图将一个可执行程序转换为十六进制string.Now我想使用powershell 将这些字符串转换为一个可执行程序。 这个我试过了,还是不行。
我的exe-bank.txt 像这样
据我所知,您应该使用开关 -Raw
读取十六进制文件以获得单个多行字符串。
然后将这些十六进制数字转换为字节数组并输出到文件。
尝试
$hex = Get-Content -Path "C:\blah\exe-bank.txt" -Raw
# split the input string by 2-character sequences and prefix '0X' each 2-hex-digit string
# casting the result to [byte[]] then recognizes this hex format directly.
[byte[]]$bytes = ($hex -split '(.{2})' -ne '' -replace '^', '0X')
[System.IO.File]::WriteAllBytes("C:\blah\exe-bank.exe", $bytes)