本文主要是介绍BUUCTF(34)特殊的 BASE64,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用pycharm时,如果想把代码撤销到之前的状态可以用 Ctrl+z
如果不小心撤销多了,可以用 Ctrl+Shift+Z 还原, 别傻傻的重新敲了
BUUCTF在线评测 (buuoj.cn)
查看字符串,想到base64的变表
这里用的c++的标准程序库中的string,头文件是#include<string>
这是base64的加密函数
std::string __cdecl base64Encode(std::string *p_decode)
{std::string *v1; // rdxchar *v2; // raxint v3; // ebxchar *v4; // raxint v5; // ebxchar *v6; // rax_BYTE *v7; // raxchar *v8; // rax_BYTE *v9; // raxchar *v10; // raxint v11; // ebxchar *v12; // rax_BYTE *v13; // rax__int64 v15; // [rsp+0h] [rbp-80h] BYREFint pos_0; // [rsp+30h] [rbp-50h]int pos; // [rsp+34h] [rbp-4Ch]int len; // [rsp+38h] [rbp-48h]int i; // [rsp+3Ch] [rbp-44h]std::string *p_decodea; // [rsp+68h] [rbp-18h]p_decodea = v1;std::allocator<char>::allocator(&v15 + 47);std::string::string(p_decode, &unk_489084);std::allocator<char>::~allocator();len = std::string::length(p_decodea);for ( i = 0; len / 3 > i; ++i ){v2 = std::string::operator[](p_decodea, 3 * i);std::string::operator[](&baseKey, *v2 >> 2);std::string::operator+=(p_decode);v3 = 16 * (*std::string::operator[](p_decodea, 3 * i) & 3);v4 = std::string::operator[](p_decodea, 3 * i + 1);std::string::operator[](&baseKey, v3 | (*v4 >> 4));std::string::operator+=(p_decode);v5 = 4 * (*std::string::operator[](p_decodea, 3 * i + 1) & 0xF);v6 = std::string::operator[](p_decodea, 3 * i + 2);std::string::operator[](&baseKey, v5 | (*v6 >> 6));std::string::operator+=(p_decode);v7 = std::string::operator[](p_decodea, 3 * i + 2);std::string::operator[](&baseKey, *v7 & 0x3F);std::string::operator+=(p_decode);}if ( len % 3 == 1 ){pos = 3 * (len / 3);v8 = std::string::operator[](p_decodea, pos);std::string::operator[](&baseKey, *v8 >> 2);std::string::operator+=(p_decode);v9 = std::string::operator[](p_decodea, pos);std::string::operator[](&baseKey, 16 * (*v9 & 3));std::string::operator+=(p_decode);std::string::operator+=(p_decode, "==");}if ( len % 3 == 2 ){pos_0 = 3 * (len / 3);v10 = std::string::operator[](p_decodea, pos_0);std::string::operator[](&baseKey, *v10 >> 2);std::string::operator+=(p_decode);v11 = 16 * (*std::string::operator[](p_decodea, pos_0) & 3);v12 = std::string::operator[](p_decodea, pos_0 + 1);std::string::operator[](&baseKey, v11 | (*v12 >> 4));std::string::operator+=(p_decode);v13 = std::string::operator[](p_decodea, pos_0 + 1);std::string::operator[](&baseKey, 4 * (*v13 & 0xF));std::string::operator+=(p_decode);std::string::operator+=(p_decode, "=");}return p_decode;
}
脚本直接出
一个base64的简单变表,但是是用string标准库函数写的
这篇关于BUUCTF(34)特殊的 BASE64的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!