64位exe
运行还是只有一个输入点,输错退出 ida查看字符串
等一个密码表.jpg 查看main函数 C++写的程序
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3;
__int64 v4;
std::string result;
std::string rightFlag;
std::string str;
char v9;
std::string v10;
_main();
std::string::string(&str);
std::allocator<char>::allocator(&v9);
std::string::string(&rightFlag, "mTyqm7wjODkrNLcWl0eqO8K8gc1BPk1GNLgUpI==", &v9);
std::allocator<char>::~allocator(&v9);
v3 = std::operator<<<std::char_traits<char>>(refptr__ZSt4cout, "Please input your flag!!!!");
std::ostream::operator<<(v3, refptr__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_);
std::operator>><char,std::char_traits<char>,std::allocator<char>>(refptr__ZSt3cin, &str);
std::string::string(&v10, &str);
base64Encode(&result);
std::string::~string(&v10);
if ( std::operator==<char>(&result, &rightFlag) )
v4 = std::operator<<<std::char_traits<char>>(refptr__ZSt4cout, "The flag is right!!!!!!!!!");
else
v4 = std::operator<<<std::char_traits<char>>(refptr__ZSt4cout, "This is a wrong flag!!!!!!!!");
std::ostream::operator<<(v4, refptr__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_);
std::string::~string(&result);
std::string::~string(&rightFlag);
std::string::~string(&str);
return 0;
}
啥也不用管,直接看base64Encode() 没有操作密码表的
std::string __cdecl base64Encode(std::string *p_decode)
{
std::string *v1;
char *v2;
int v3;
int v4;
char *v5;
int v6;
int v7;
char *v8;
int v9;
_BYTE *v10;
int v11;
char *v12;
int v13;
_BYTE *v14;
int v15;
char *v16;
int v17;
int v18;
char *v19;
int v20;
_BYTE *v21;
int v22;
__int64 v24;
char v25;
int pos_0;
int pos;
int len;
int i;
std::string *p_encodeResult;
std::string *p_decodea;
p_encodeResult = p_decode;
p_decodea = v1;
std::allocator<char>::allocator((char *)&v24 + 47);
std::string::string(p_encodeResult, &unk_489084, &v25);
std::allocator<char>::~allocator(&v25);
len = std::string::length(p_decodea);
for ( i = 0; len / 3 > i; ++i )
{
v2 = (char *)std::string::operator[](p_decodea, 3 * i);
v3 = *(char *)std::string::operator[](&baseKey, *v2 >> 2);
std::string::operator+=(p_encodeResult);
v4 = 16 * (*(_BYTE *)std::string::operator[](p_decodea, 3 * i) & 3);
v5 = (char *)std::string::operator[](p_decodea, 3 * i + 1);
v6 = *(char *)std::string::operator[](&baseKey, v4 | (*v5 >> 4));
std::string::operator+=(p_encodeResult);
v7 = 4 * (*(_BYTE *)std::string::operator[](p_decodea, 3 * i + 1) & 0xF);
v8 = (char *)std::string::operator[](p_decodea, 3 * i + 2);
v9 = *(char *)std::string::operator[](&baseKey, v7 | (*v8 >> 6));
std::string::operator+=(p_encodeResult);
v10 = (_BYTE *)std::string::operator[](p_decodea, 3 * i + 2);
v11 = *(char *)std::string::operator[](&baseKey, *v10 & 0x3F);
std::string::operator+=(p_encodeResult);
}
if ( len % 3 == 1 )
{
pos = 3 * (len / 3);
v12 = (char *)std::string::operator[](p_decodea, 3 * (len / 3));
v13 = *(char *)std::string::operator[](&baseKey, *v12 >> 2);
std::string::operator+=(p_encodeResult);
v14 = (_BYTE *)std::string::operator[](p_decodea, pos);
v15 = *(char *)std::string::operator[](&baseKey, 16 * (*v14 & 3));
std::string::operator+=(p_encodeResult);
std::string::operator+=(p_encodeResult, "==");
}
if ( len % 3 == 2 )
{
pos_0 = 3 * (len / 3);
v16 = (char *)std::string::operator[](p_decodea, 3 * (len / 3));
v17 = *(char *)std::string::operator[](&baseKey, *v16 >> 2);
std::string::operator+=(p_encodeResult);
v18 = 16 * (*(_BYTE *)std::string::operator[](p_decodea, pos_0) & 3);
v19 = (char *)std::string::operator[](p_decodea, pos_0 + 1);
v20 = *(char *)std::string::operator[](&baseKey, v18 | (*v19 >> 4));
std::string::operator+=(p_encodeResult);
v21 = (_BYTE *)std::string::operator[](p_decodea, pos_0 + 1);
v22 = *(char *)std::string::operator[](&baseKey, 4 * (*v21 & 0xF));
std::string::operator+=(p_encodeResult);
std::string::operator+=(p_encodeResult, "=");
}
return (std::string)p_encodeResult;
}
直接拿去用就好了
import base64
import string
str1 = 'mTyqm7wjODkrNLcWl0eqO8K8gc1BPk1GNLgUpI=='
string1 = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0987654321/+"
string2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
print (base64.b64decode(str1.translate(str.maketrans(string1,string2))))
flag{Special_Base64_By_Lich}
|