转换exe到hexdump与powershell



如何从CMD运行此命令而不运行powershell ?

> [byte[]] $hex = get-content -encoding byte -path C:tempnc.exe
> [System.IO.File]::WriteAllLines("C:temphexdump.txt", ([string]$hex))

我试过了,但是没有用

powershell -command "[byte[]] $hex = get-content -encoding byte -pathC:Usersevilcode1Desktopnc.exe;[System.IO.File]:: WriteAllLines("C: evilcode1 hexdump1.txt用户",([string]美元十六进制),

我怎么能那样做!然后我需要用以下命令从文本文件重建可执行文件:

[string]$hex = get-content -path C:UsersuserDesktophexdump.txt[Byte[]] $temp = $hex -split ' '[System.IO.File]:: WriteAllBytes(微软"C: ProgramData Windows 开始启动菜单程序 nc.exe"临时美元)

如何从CMD直接运行它们而不打开powershell

将字节转换为十六进制字符串:

# read the binary data as byte array
[byte[]]$data = [System.IO.File]::ReadAllBytes('D:Testblah.exe')
# write to new file as string of hex encoded characters
[System.IO.File]::WriteAllText('D:Testblah.hex',[System.BitConverter]::ToString($data).Replace('-',''), [System.Text.Encoding]::ASCII)

从转换回十六进制字符串:

# read the textfile as single ASCII string
$hex = [System.IO.File]::ReadAllText('D:Testblah.hex', [System.Text.Encoding]::ASCII)
# convert to bytes and write these as new binary file
[System.IO.File]::WriteAllBytes('D:Testblahblah.exe', ($hex -split '(.{2})' -ne '' -replace '^', '0X'))

最新更新