Arrays 使用powershell将exe转换为hexdump

Arrays 使用powershell将exe转换为hexdump,arrays,windows,powershell,hexdump,Arrays,Windows,Powershell,Hexdump,如何在不运行powershell的情况下从cmd运行此命令 我试着这样做,但不起作用 powershell-命令“[byte[]$hex=获取内容-编码字节-路径 C:\Users\evicode1\Desktop\nc.exe; [System.IO.File]::writeAllines('C:\Users\evicode1\hextump1.txt', ([string]$hex))” 我怎么能做到!然后我需要使用以下命令从文本文件重建可执行文件: [string]$hex=获取内容-路径

如何在不运行powershell的情况下从cmd运行此命令

我试着这样做,但不起作用

powershell-命令“[byte[]$hex=获取内容-编码字节-路径 C:\Users\evicode1\Desktop\nc.exe; [System.IO.File]::writeAllines('C:\Users\evicode1\hextump1.txt', ([string]$hex))”

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

[string]$hex=获取内容-路径C:\Users\user\Desktop\hextump.txt [字节[]]$temp=$hex-拆分“” [System.IO.File]::writealBytes(“C:\ProgramData\Microsoft\Windows\Start 菜单\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)
# 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'))
要从十六进制字符串转换回:

# 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)
# 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'))

你想在这里部署邪恶的东西吗?(如果没有,请分享更多关于您的信息)没有,我只是有一个考试OSCP,我在自己的labsTry上运行它,以使用Base64编码。十六进制是可能的,但不是那么简单。请在linux上使用hextump.bat或运行hextump。请。很好,尽管不严格需要
[System.Text.Encoding]::ASCII
:.NET默认情况下会创建无BOM的UTF-8文件,如果这样的文件只包含ASCII范围字符,就像这里的情况一样,根据定义它也是一个ASCII文件。