BUUCTF(34)特殊的 BASE64

使用pycharm时,如果想把代码撤销到之前的状态可以用 Ctrl+z

如果不小心撤销多了,可以用 Ctrl+Shift+Z 还原, 别傻傻的重新敲了

 

BUUCTF在线评测 (buuoj.cn)

查看字符串,想到base64的变表

51ddb4fca8c34bdba45c3f2299a978c0.png

 

 

 

这里用的c++的标准程序库中的string,头文件是#include<string>

这是base64的加密函数

std::string __cdecl base64Encode(std::string *p_decode)
{
  std::string *v1; // rdx
  char *v2; // rax
  int v3; // ebx
  char *v4; // rax
  int v5; // ebx
  char *v6; // rax
  _BYTE *v7; // rax
  char *v8; // rax
  _BYTE *v9; // rax
  char *v10; // rax
  int v11; // ebx
  char *v12; // rax
  _BYTE *v13; // rax
  __int64 v15; // [rsp+0h] [rbp-80h] BYREF
  int 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;
}

 

 

脚本直接出

0e666b00b3854f7c82993c3d9daba1ff.png

 

 

 

 

一个base64的简单变表,但是是用string标准库函数写的

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值