32位无壳 又是一个直接退出的
留意一下特殊字符 (先猜一个base扔在这里 跟进main函数
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3;
int result;
int v5;
int v6;
int v7;
__int16 v8;
char v9;
char v10;
sub_403CF8((int)&byte_40E140);
scanf(aS, &v10);
v5 = 0;
v6 = 0;
v7 = 0;
v8 = 0;
v9 = 0;
sub_401080((int)&v10, strlen(&v10), (int)&v5);
v3 = 0;
while ( *((_BYTE *)&v5 + v3) == byte_40E0E4[v3] )
{
if ( ++v3 > strlen((const char *)&v5) )
goto LABEL_6;
}
sub_403CF8((int)aError);
LABEL_6:
if ( v3 - 1 == strlen(byte_40E0E4) )
result = sub_403CF8((int)aAreYouHappyYes);
else
result = sub_403CF8((int)aAreYouHappyNo);
return result;
}
输出输入,通过sub_401080()函数加密后与byte_40E0E4比较 byte_40E0E4=zMXHz3TIgnxLxJhFAdtZn2fFk3lYCrtPC2l9
int __cdecl sub_401080(int a1, int a2, int a3)
{
int v3;
int v4;
int v5;
int v6;
int v7;
int v8;
int v9;
int v10;
int v11;
_BYTE *v12;
int v13;
int v15;
v3 = 0;
v4 = 0;
sub_401000();
v5 = a2 % 3;
v6 = a1;
v7 = a2 - a2 % 3;
v15 = a2 % 3;
if ( v7 > 0 )
{
do
{
LOBYTE(v5) = *(_BYTE *)(a1 + v3);
v3 += 3;
v8 = v4 + 1;
*(_BYTE *)(v8++ + a3 - 1) = dword_40E0A0[(v5 >> 2) & 0x3F];
*(_BYTE *)(v8++ + a3 - 1) = dword_40E0A0[16 * (*(_BYTE *)(a1 + v3 - 3) & 3)
+ (((signed int)*(unsigned __int8 *)(a1 + v3 - 2) >> 4) & 0xF)];
*(_BYTE *)(v8 + a3 - 1) = dword_40E0A0[4 * (*(_BYTE *)(a1 + v3 - 2) & 0xF)
+ (((signed int)*(unsigned __int8 *)(a1 + v3 - 1) >> 6) & 3)];
v5 = *(_BYTE *)(a1 + v3 - 1) & 0x3F;
v4 = v8 + 1;
*(_BYTE *)(v4 + a3 - 1) = dword_40E0A0[v5];
}
while ( v3 < v7 );
v5 = v15;
}
if ( v5 == 1 )
{
LOBYTE(v7) = *(_BYTE *)(v3 + a1);
v9 = v4 + 1;
*(_BYTE *)(v9 + a3 - 1) = dword_40E0A0[(v7 >> 2) & 0x3F];
v10 = v9 + 1;
*(_BYTE *)(v10 + a3 - 1) = dword_40E0A0[16 * (*(_BYTE *)(v3 + a1) & 3)];
*(_BYTE *)(v10 + a3) = 61;
LABEL_8:
v13 = v10 + 1;
*(_BYTE *)(v13 + a3) = 61;
v4 = v13 + 1;
goto LABEL_9;
}
if ( v5 == 2 )
{
v11 = v4 + 1;
*(_BYTE *)(v11 + a3 - 1) = dword_40E0A0[((signed int)*(unsigned __int8 *)(v3 + a1) >> 2) & 0x3F];
v12 = (_BYTE *)(v3 + a1 + 1);
LOBYTE(v6) = *v12;
v10 = v11 + 1;
*(_BYTE *)(v10 + a3 - 1) = dword_40E0A0[16 * (*(_BYTE *)(v3 + a1) & 3) + ((v6 >> 4) & 0xF)];
*(_BYTE *)(v10 + a3) = dword_40E0A0[4 * (*v12 & 0xF)];
goto LABEL_8;
}
LABEL_9:
*(_BYTE *)(v4 + a3) = 0;
return sub_401030(a3);
}
开头结尾一个 sub_401000()函数,一个sub_401030()函数,中间是一个base64加密
查看sub_401000()
signed int sub_401000()
{
signed int result;
char v1;
result = 6;
do
{
v1 = word_40E0AA[result];
word_40E0AA[result] = dword_40E0A0[result];
dword_40E0A0[result++] = v1;
}
while ( result < 15 );
return result;
}
把word_40E0AA和dword_40E0A0的下标6到14替换 查看地址发现是同一串字符串的顺序更改一下
也就是QRSTUVWXY 和GHIJKLMNOP 相互交换了一下,就是更改base64的密码表
查看另一个sub_401030()函数
int __cdecl sub_401030(const char *a1)
{
__int64 v1;
char v2;
v1 = 0i64;
if ( strlen(a1) != 0 )
{
do
{
v2 = a1[HIDWORD(v1)];
if ( v2 < 97 || v2 > 122 )
{
if ( v2 < 65 || v2 > 90 )
goto LABEL_9;
LOBYTE(v1) = v2 + 32;
}
else
{
LOBYTE(v1) = v2 - 32;
}
a1[HIDWORD(v1)] = v1;
LABEL_9:
LODWORD(v1) = 0;
++HIDWORD(v1);
}
while ( HIDWORD(v1) < strlen(a1) );
}
return v1;
}
一个大小写转换,过了
解题思路就是 转换大小写 更改base64密码表解密(参考)
import base64
import string
str1 = 'zMXHz3TIgnxLxJhFAdtZn2fFk3lYCrtPC2l9'.swapcase()
string1 = "ABCDEFQRSTUVWXYPGHIJKLMNOZabcdefghijklmnopqrstuvwxyz0123456789+/"
string2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
print (base64.b64decode(str1.translate(str.maketrans(string1,string2))))
一跑就出了
flag{bAse64_h2s_a_Surprise}
|