查看文件信息
64位ida打开
查看字符串
先存着GXY{do_not_
查看主函数
welcome()是欢迎,重点看patch_me()函数
继续跟进
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);
//s的前40位置零
strcat((char *)&s, f1);
//f1:'GXY{do_not_'
strcat((char *)&s, &f2);
//f2初值为空
//将f1和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 = 0x7F666F6067756369LL;//' fo`guci'
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;
}
那么问题就在于获取f2的值
总结一下分支
case1是最终flag,2、3没用,case4给f2赋值,case5改变f2的值
顺序应该为451
查看s的地址发现是小端序存储,取值时应该逆序取
flag = 'GXY{do_not_'
f2 = [0x7F, 0x66, 0x6F, 0x60, 0x67, 0x75, 0x63, 0x69][::-1]
s = ''
for i in range(8):
if i % 2 == 1:
s = chr(int(f2[i]) - 2)
else:
s = chr(int(f2[i]) - 1)
flag += s
print(flag)
getflag