Created
October 7, 2023 04:25
-
-
Save STashakkori/2075999954abd44e8ebbbf0b439dd6f1 to your computer and use it in GitHub Desktop.
Poor human's hexdump in ps. Works but stupid slow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filePath = "D:\test_binary.exe" | |
$bytes = [System.IO.File]::ReadAllBytes($filePath) | |
$hexLines = @() | |
$asciiLines = @() | |
for ($i = 0; $i -lt $bytes.Length; $i += 8) { | |
$lineBytes = $bytes[$i..($i + 7)] | |
$hexLine = -join ($lineBytes | ForEach-Object { " {0:x2}" -f $_ }) | |
$asciiLine = [System.Text.Encoding]::ASCII.GetString($lineBytes) | |
$hexLines += $hexLine | |
$asciiLines += $asciiLine | |
} | |
for ($i = 0; $i -lt $hexLines.Count; $i++) { | |
Write-Host "$hexLines[$i]|$asciiLines[$i]" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment