這道題是一個64位元elf檔案,分析起來不是很難,只是我沒學switch函數,導致磨蹭了些時間
放入64位元ida分析虛擬碼簡單明瞭,輸入幸運數位儲存進v4執行patch_me函數
如果輸入的幸運數位為偶數,則進入get_flag函數
虛擬碼如下:
unsigned __int64 get_flag()
{
unsigned int v0; // eax
char v1; // al
signed int i; // [rsp+4h] [rbp-3Ch]
signed int j; // [rsp+8h] [rbp-38h]
__int64 s; // [rsp+10h] [rbp-30h]
char v6; // [rsp+18h] [rbp-28h]
unsigned __int64 v7; // [rsp+38h] [rbp-8h]
v7 = __readfsqword(0x28u);
v0 = time(0LL);
srand(v0);
for ( i = 0; i <= 4; ++i )
{
switch ( rand() % 200 )
{
case 1:
puts("OK, it's flag:");
memset(&s, 0, 0x28uLL);
strcat((char *)&s, f1);
strcat((char *)&s, &f2);
printf("%s", &s);
break;
case 2:
printf("Solar not like you");
break;
case 3:
printf("Solar want a girlfriend");
break;
case 4:
v6 = 0;
s = 9180147350284624745LL; //轉換成16進位製為0x69,0x63,0x75,0x67,0x60,0x6f,0x66,0x7f
strcat(&f2, (const char *)&s);
break;
case 5:
for ( j = 0; j <= 7; ++j )
{
if ( j % 2 == 1 )
v1 = *(&f2 + j) - 2;
else
v1 = *(&f2 + j) - 1;
*(&f2 + j) = v1;
}
break;
default:
puts("emmm,you can't find flag 23333");
break;
}
}
return __readfsqword(0x28u) ^ v7;
}
經過查閱知道switch函數使用需要排序,大概分析後順序為case4,case5,case1
f1中的值為:GXY{do_not_
寫個python3指令碼跑出flag:GXY{do_not_hate_me}
flag='GXY{do_not_'
f2=[0x69,0x63,0x75,0x67,0x60,0x6f,0x66,0x7f,0]
v1=[]
for i in range(8):
if i%2==1:
v1.append(f2[i]+i-2)
else:
v1.append(f2[i]+i-1)
f2[i]=v1[i]-i
flag+=chr(f2[i])
print(flag)