使用 powershell 将 exe 转换为 hexdump
convert exe to hexdump with powershell
我如何在没有 运行 powershell 的情况下从 cmd 运行 这个命令?
> [byte[]] $hex = get-content -encoding byte -path C:\temp\nc.exe
> [System.IO.File]::WriteAllLines("C:\temp\hexdump.txt", ([string]$hex))
我这样试过,但没用
powershell -command " [byte[]] $hex = get-content -encoding byte -path
C:\Users\evilcode1\Desktop\nc.exe ;
[System.IO.File]::WriteAllLines('C:\Users\evilcode1\hexdump1.txt',
([string]$hex))"
我该怎么做!然后我需要使用此命令从文本文件重建可执行文件:
[string]$hex = get-content -path C:\Users\user\Desktop\hexdump.txt
[Byte[]] $temp = $hex -split ' '
[System.IO.File]::WriteAllBytes("C:\ProgramData\Microsoft\Windows\Start
Menu\Programs\Startup\nc.exe", $temp)
如何在不打开 powershell 的情况下直接从 cmd 运行 他们
将字节 转换为 十六进制字符串:
# read the binary data as byte array
[byte[]]$data = [System.IO.File]::ReadAllBytes('D:\Test\blah.exe')
# write to new file as string of hex encoded characters
[System.IO.File]::WriteAllText('D:\Test\blah.hex',[System.BitConverter]::ToString($data).Replace('-',''), [System.Text.Encoding]::ASCII)
转换回 FROM 十六进制字符串:
# read the textfile as single ASCII string
$hex = [System.IO.File]::ReadAllText('D:\Test\blah.hex', [System.Text.Encoding]::ASCII)
# convert to bytes and write these as new binary file
[System.IO.File]::WriteAllBytes('D:\Test\blahblah.exe', ($hex -split '(.{2})' -ne '' -replace '^', '0X'))
我如何在没有 运行 powershell 的情况下从 cmd 运行 这个命令?
> [byte[]] $hex = get-content -encoding byte -path C:\temp\nc.exe > [System.IO.File]::WriteAllLines("C:\temp\hexdump.txt", ([string]$hex))
我这样试过,但没用
powershell -command " [byte[]] $hex = get-content -encoding byte -path C:\Users\evilcode1\Desktop\nc.exe ; [System.IO.File]::WriteAllLines('C:\Users\evilcode1\hexdump1.txt', ([string]$hex))"
我该怎么做!然后我需要使用此命令从文本文件重建可执行文件:
[string]$hex = get-content -path C:\Users\user\Desktop\hexdump.txt [Byte[]] $temp = $hex -split ' ' [System.IO.File]::WriteAllBytes("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\nc.exe", $temp)
如何在不打开 powershell 的情况下直接从 cmd 运行 他们
将字节 转换为 十六进制字符串:
# read the binary data as byte array
[byte[]]$data = [System.IO.File]::ReadAllBytes('D:\Test\blah.exe')
# write to new file as string of hex encoded characters
[System.IO.File]::WriteAllText('D:\Test\blah.hex',[System.BitConverter]::ToString($data).Replace('-',''), [System.Text.Encoding]::ASCII)
转换回 FROM 十六进制字符串:
# read the textfile as single ASCII string
$hex = [System.IO.File]::ReadAllText('D:\Test\blah.hex', [System.Text.Encoding]::ASCII)
# convert to bytes and write these as new binary file
[System.IO.File]::WriteAllBytes('D:\Test\blahblah.exe', ($hex -split '(.{2})' -ne '' -replace '^', '0X'))