如何将 shellcode 转换为原始字节?

问题描述 投票:0回答:2

我有一个像这样的简单 shellcode :

buf =("\xfc\xe8\x8f\x00\x00\x00\x60\x31\xd2\x89\xe5\x64\x8b\x52\x30"
"\x8b\x52\x0c\x8b\x52\x14\x0f\xb7\x4a\x26\x8b\x72\x28\x31\xff"
"\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\x49")....

我想(使用Python)将其更改为原始字节,如下例所示: 0x69,0x16,0x69,0x02,0x68,0x25,0xaa,0xaa,0xaa,0xca,0x9b,0x69,0x38,0x68,0x23,0x69,0x0f,0xce,0x68,0x21 ,0xf8,0x9a,0x68,0x21,0xf8,0xa6,0x68,0x21,0xf8,0xbe,0xa5,0x68,0x1d,0xe0,0x8c,0x68,0x21,0xd8,0x82....

(逗号很重要)。我怎样才能做到这一点?

python byte shellcode raw
2个回答
0
投票
# Shellcode string
buf = ("\xfc\xe8\x8f\x00\x00\x00\x60\x31\xd2\x89\xe5\x64\x8b\x52\x30"
   "\x8b\x52\x0c\x8b\x52\x14\x0f\xb7\x4a\x26\x8b\x72\x28\x31\xff"
   "\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\x49")

# Convert to raw bytes
raw_bytes = ",".join(f"0x{ord(c):02x}" for c in buf)

-1
投票

你可以使用chatgpt,如果你要求他会把它变成原始字节(我有同样的问题)。

© www.soinside.com 2019 - 2024. All rights reserved.