[英]How to convert a hex address from a char buffer to be written to memory
所以我在這里得到了這個功能,這是從主要功能中調用的:
void overflow(char *arg)
{
char buf[1369];
strcpy (buf, arg);
printf ("Thank you for contacting customer service. You are so important to us that we wrote a program to serve you.\n");
printf ("Please hold for %u minutes while I drop your call\n", (int)strlen(buf));
return;
}
字符串*arg
來自argv[1]
。
當我做類似的事情時:
./overflow1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa29390408
堆棧看起來像這樣:
0xffffce80: 0x07 0x00 0x00 0x61 0x61 0x61 0x61 0x61
0xffffce88: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffce90: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffce98: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffcea0: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffcea8: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffceb0: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffceb8: 0x61 0x61 0x61 0x61 0x61 0x61 0x61 0x61
0xffffcec0: 0x61 0x61 0x32 0x39 0x33 0x39 0x30 0x34
0xffffcec8: 0x30 0x38
那么我如何獲得:
0x32 0x39 0x33 0x39 0x30 0x34 0x30 0x38
成為:
29 39 04 08
?
我確實意識到需要將其從實際的十六進制值轉換為字母數字值,例如08
,但是網絡上的每個字符串工具都沒有給出任何結果,因為08
並非ASCII /字母數字值。
如果要向命令發送任意字節作為參數,則必須在shell中轉義它們。 例如,在bash中,您可以執行以下操作:
echo $'a\x09b\x33c'
它會顯示:
a b3c
因為bash將$''結構中的\\ xHH(兩個十六進制數字)解釋為單字節十六進制值。 0x09是制表符,0x33是數字3。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.