[英]wrong user and password in C code reverse engineering
我從一個二進制文件中獲得了這段代碼,它要求輸入用戶名和密碼,我設法找到了用戶“mari”和密碼“luig”,但它說用戶名錯誤,這里是代碼:
undefined8 main(void)
{
int iVar1;
undefined4 local_96;
undefined2 local_92;
undefined local_90;
undefined4 local_8f;
undefined2 local_8b;
undefined local_89;
char local_88 [64];
char local_48 [64];
local_8f = 0x6769756c;
local_8b = 0x3169;
local_89 = 0;
local_96 = 0x6972616d;
local_92 = 0x316f;
local_90 = 0;
printf("enter username :");
__isoc99_scanf(&DAT_00102019,local_48);
iVar1 = strcmp(local_48,(char *)&local_96);
if (iVar1 == 0) {
printf("enter password :");
__isoc99_scanf(&DAT_00102019,local_88);
iVar1 = strcmp(local_88,(char *)&local_8f);
if (iVar1 == 0) {
printf("welldone use it to submit the flag :D");
}
else {
printf("wrong password");
}
}
else {
printf("wrong username");
}
return 0;
}
為什么“mari”作為用戶而“luig”作為密碼不起作用?
要比較的用戶名和密碼以十六進制形式存儲在 integer 變量中:
local_8f = 0x6769756c; // 4 byte variable: g i u l
local_8b = 0x3169; // 2 byte variable: 1 i
local_89 = 0; // 1 byte variable: \0
local_96 = 0x6972616d; // 4 byte variable: i r a m
local_92 = 0x316f; // 2 byte variable: 1 o
local_90 = 0; // 1 byte variable: \0
這些變量存儲在 memory 中,字節反轉。
因此,變量local_8f
在 memory 中解釋為字符串時,實際上讀取luigi1\0
,而變量local_96
在 memory 中解釋為字符串時,實際上讀取mario1\0
。 這些是您必須輸入的 uid/pwd。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.