打开IDA ,查看main函数,F5查看反编译
unsigned __int64 get_flag()
{
unsigned int v0; // eax
int i; // [rsp+4h] [rbp-3Ch]
int j; // [rsp+8h] [rbp-38h]
__int64 s; // [rsp+10h] [rbp-30h] BYREF
char v5; // [rsp+18h] [rbp-28h]
unsigned __int64 v6; // [rsp+38h] [rbp-8h]
v6 = __readfsqword(0x28u);
v0 = time(0LL); //得到时间
srand(v0); //使用时间作为种子生成随机数字
for ( i = 0; i <= 4; ++i )
{
switch ( rand() % 200 ) //产生1-199随机数
{
case 1:
puts("OK, it's flag:");
memset(&s, 0, 0x28uLL);
strcat((char *)&s, f1); // f1 = GXY{do_not_
strcat((char *)&s, &f2); //初始化f2
printf("%s", (const char *)&s);
break;
case 2:
printf("Solar not like you");
break;
case 3:
printf("Solar want a girlfriend");
break;
case 4:
s = 9180147350284624745LL;
v5 = 0;
strcat(&f2, (const char *)&s); //f2和s进行拼接
break;
case 5: //对拼接后的f2进行处理
for ( j = 0; j <= 7; ++j )
{
if ( j % 2 == 1 )
*(&f2 + j) -= 2;
else
--*(&f2 + j);
}
break;
default:
puts("emmm,you can't find flag 23333");
break;
}
}
return __readfsqword(0x28u) ^ v6;
}
大端模式:
低地址------>高地址
0x12 | 0x34 | 0x56 | 0x78
小端模式:
低地址-------->高堵住
0x78 | 0x56 | 0x34 | 0x12
可见,大端模式和字符串的存储模式类似。
flag = 'GXY{do_not_'
f2 = [0x7F,0x66,0x6F,0x60,0x67,0x75,0x63,0x69][::-1]
for i in range(len(f2)):
if(i%2==1):
s = chr(f2[i] - 2)
else:
s = chr(f2[i] -1)
flag = flag + s
print(flag)