获取已编码的不可打印字符串的字节

时间:2015-07-11 16:29:43

标签: powershell escaping sqlmap non-printing-characters

当我使用带有--hex键的sqlmap转储表条目时,我正确地获得了密码哈希字节,但powershell将这些字节表示为字符串。所有不可打印的字符都被转义,我将这些字节作为\\?e1\n\\?dc9I\\?baY\\?ab\\?beV\\?e0W\\?f2\x0f\\?88>。我怎样才能从这个字符串中取出来获取原始字节呢?

1 个答案:

答案 0 :(得分:0)

从字符串到字节将取决于它是否是每个字节的字符串,如果是这样的话,试试这个:

# simulated output as a byte per string
$str = [string[]][char[]][byte[]](0xE1,0x0A,0xDC,0x39,0x49,0xBA,0x59,0xAB,0xBE,0x56,0xE0,0x57,0xF2,0x0F,0x88,0x3E)

# convert to bytes
$str | Foreach {[byte][char]$_}

如果是单个字符串,请尝试:

# simulated output as a single string containing all the bytes
$ofs=''
$str = [string][char[]][byte[]](0xE1,0x0A,0xDC,0x39,0x49,0xBA,0x59,0xAB,0xBE,0x56,0xE0,0x57,0xF2,0x0F,0x88,0x3E)

# convert to bytes
$str.ToCharArray() | % {[byte]$_}