程序为mac 64位应用,且未加壳,使用ida64位程序打开
查看快捷键查看字符串,发现flag字符,下方有个success,猜测是输入正确的字符串后会输出success
点击进入,查看伪代码
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rsi
int result; // eax
signed int i; // [rsp+2Ch] [rbp-124h]
char v6[264]; // [rsp+40h] [rbp-110h]
__int64 v7; // [rsp+148h] [rbp-8h]
memset(v6, 0, '\x01\0');
v3 = (char *)256;
printf("Input your flag:\n", 0LL);
get_line(v6, 256LL);
if ( strlen(v6) != 33 )
goto LABEL_12;
for ( i = 1; i < 33; ++i )
v6[i] ^= v6[i - 1];
v3 = global;
if ( !strncmp(v6, global, '!') )
printf("Success", v3);
else
LABEL_12:
printf("Failed", v3);
result = __stack_chk_guard;
if ( __stack_chk_guard == v7 )
result = 0;
return result;
}
if ( strlen(v6) != 33 ),这里先判断字符长度是不是33位
for ( i = 1; i < 33; ++i ) v6[i] ^= v6[i - 1];,然后进行异或运算
查看前面的汇编代码,发现了字母和16进制数字
需要将十六进制转为字符,再与前一位进行异或运算即可得到flag
脚本
string = ['f', 0x0A, 'k', 0x0C, 'w', '&', 'O', '.', '@', 0x11, 'x', 0x0D, 'Z', ';', 'U', 0x11, 'p', 0x19, 'F', 0x1F, 'v',
'"', 'M', '#', 'D', 0x0E, 'g', 6, 'h', 0x0F, 'G', '2', 'O']
for i in range(1, len(string)):
if (isinstance(string[i], int)):
string[i] = chr(string[i])
string = ''.join(string)
flag = 'f'
for i in range(1, len(string)):
flag += chr(ord(string[i]) ^ ord(string[i-1]))
print(flag)
flag{QianQiuWanDai_YiTongJiangHu}
标签:Buuctf,xor,Reverse,33,char,int,flag,v6,string
From: https://www.cnblogs.com/scarecr0w7/p/17377196.html