Skip to content

Instantly share code, notes, and snippets.

@maravedi
Created November 21, 2019 13:40
Show Gist options
  • Save maravedi/fe22ccf1c097d259fd2102d0a4049110 to your computer and use it in GitHub Desktop.
Save maravedi/fe22ccf1c097d259fd2102d0a4049110 to your computer and use it in GitHub Desktop.
Separator for an HTTP Request with combined ASCII and Hex
Param(
[String]$Raw,
$ASCIIColor = 'White',
$HexColor = 'Blue'
)
$Original = $Host.UI.RawUI.ForegroundColor
Write-Host "======================="
$Host.UI.RawUI.ForegroundColor = $ASCIIColor
Write-Host "$($ASCIIColor): ASCII"
$Host.UI.RawUI.ForegroundColor = $HexColor
Write-Host "$($HexColor): Hex"
$Host.ui.RawUI.ForegroundColor = $Original
Write-Host "=======================`n"
$Cleaned = ($Raw -Replace '\^M','').Trim()
$TextArray = $Cleaned -Split ' '
$ASCII = @()
$Hex = @()
Foreach($Item in $TextArray){
If($Item -like '0x*'){
$Hex += "$([char][byte]$Item)"
}
Else{
$ASCII += "$($Item)"
}
}
$Host.ui.RawUI.ForegroundColor = $ASCIIColor
Write-Host "$($ASCII -Split ' ')"
$Host.ui.RawUI.ForegroundColor = $HexColor
Write-Host "$($Hex -Join '')"
$Host.ui.RawUI.ForegroundColor = $Original
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment