首页 > 其他分享 >reverse_3

reverse_3

时间:2023-05-01 11:11:06浏览次数:42  
标签:reverse esp int v12 ebp byte 41A144

查壳

拖进32位IDA,老办法

随便进入一个,进入伪代码

int __cdecl main_0(int argc, const char **argv, const char **envp)
{
  size_t v3; // eax
  const char *v4; // eax
  size_t v5; // eax
  char v7; // [esp+0h] [ebp-188h]
  char v8; // [esp+0h] [ebp-188h]
  signed int j; // [esp+DCh] [ebp-ACh]
  int i; // [esp+E8h] [ebp-A0h]
  signed int v11; // [esp+E8h] [ebp-A0h]
  char Destination[108]; // [esp+F4h] [ebp-94h] BYREF
  char Str[28]; // [esp+160h] [ebp-28h] BYREF
  char v14[8]; // [esp+17Ch] [ebp-Ch] BYREF

  for ( i = 0; i < 100; ++i )
  {
    if ( (unsigned int)i >= 0x64 )
      j____report_rangecheckfailure();
    Destination[i] = 0;
  }
  sub_41132F("please enter the flag:", v7);
  sub_411375("%20s", (char)Str);
  v3 = j_strlen(Str);
  v4 = (const char *)sub_4110BE(Str, v3, v14);
  strncpy(Destination, v4, 0x28u);
  v11 = j_strlen(Destination);
  for ( j = 0; j < v11; ++j )
    Destination[j] += j;
  v5 = j_strlen(Destination);
  if ( !strncmp(Destination, Str2, v5) )
    sub_41132F("rigth flag!\n", v8);
  else
    sub_41132F("wrong flag!\n", v8);
  return 0;
}

比较 Des 和 Str2 字符串 前 v5 个字符

看看 Str2 :e3nifIH9b_C@n@dH

再看看 Str2 怎么来的

Des每个字符的ASCII码 + j 然后转化成 字符就是 Str2

那么Des怎么来的

由v4经过 sub_4110BE 函数后构造复制给 Des

sub_4110BE 函数

void *__cdecl sub_411AB0(char *a1, unsigned int a2, int *a3)
{
  int v4; // [esp+D4h] [ebp-38h]
  int v5; // [esp+D4h] [ebp-38h]
  int v6; // [esp+D4h] [ebp-38h]
  int v7; // [esp+D4h] [ebp-38h]
  int i; // [esp+E0h] [ebp-2Ch]
  unsigned int v9; // [esp+ECh] [ebp-20h]
  int v10; // [esp+ECh] [ebp-20h]
  int v11; // [esp+ECh] [ebp-20h]
  void *v12; // [esp+F8h] [ebp-14h]
  char *v13; // [esp+104h] [ebp-8h]

  if ( !a1 || !a2 )
    return 0;
  v9 = a2 / 3;
  if ( (int)(a2 / 3) % 3 )
    ++v9;
  v10 = 4 * v9;
  *a3 = v10;
  v12 = malloc(v10 + 1);
  if ( !v12 )
    return 0;
  j_memset(v12, 0, v10 + 1);
  v13 = a1;
  v11 = a2;
  v4 = 0;
  while ( v11 > 0 )
  {
    byte_41A144[2] = 0;
    byte_41A144[1] = 0;
    byte_41A144[0] = 0;
    for ( i = 0; i < 3 && v11 >= 1; ++i )
    {
      byte_41A144[i] = *v13;
      --v11;
      ++v13;
    }
    if ( !i )
      break;
    switch ( i )
    {
      case 1:
        *((_BYTE *)v12 + v4) = aAbcdefghijklmn[(int)(unsigned __int8)byte_41A144[0] >> 2];
        v5 = v4 + 1;
        *((_BYTE *)v12 + v5) = aAbcdefghijklmn[((byte_41A144[1] & 0xF0) >> 4) | (16 * (byte_41A144[0] & 3))];
        *((_BYTE *)v12 + ++v5) = aAbcdefghijklmn[64];
        *((_BYTE *)v12 + ++v5) = aAbcdefghijklmn[64];
        v4 = v5 + 1;
        break;
      case 2:
        *((_BYTE *)v12 + v4) = aAbcdefghijklmn[(int)(unsigned __int8)byte_41A144[0] >> 2];
        v6 = v4 + 1;
        *((_BYTE *)v12 + v6) = aAbcdefghijklmn[((byte_41A144[1] & 0xF0) >> 4) | (16 * (byte_41A144[0] & 3))];
        *((_BYTE *)v12 + ++v6) = aAbcdefghijklmn[((byte_41A144[2] & 0xC0) >> 6) | (4 * (byte_41A144[1] & 0xF))];
        *((_BYTE *)v12 + ++v6) = aAbcdefghijklmn[64];
        v4 = v6 + 1;
        break;
      case 3:
        *((_BYTE *)v12 + v4) = aAbcdefghijklmn[(int)(unsigned __int8)byte_41A144[0] >> 2];
        v7 = v4 + 1;
        *((_BYTE *)v12 + v7) = aAbcdefghijklmn[((byte_41A144[1] & 0xF0) >> 4) | (16 * (byte_41A144[0] & 3))];
        *((_BYTE *)v12 + ++v7) = aAbcdefghijklmn[((byte_41A144[2] & 0xC0) >> 6) | (4 * (byte_41A144[1] & 0xF))];
        *((_BYTE *)v12 + ++v7) = aAbcdefghijklmn[byte_41A144[2] & 0x3F];
        v4 = v7 + 1;
        break;
    }
  }
  *((_BYTE *)v12 + v4) = 0;
  return v12;
}

一堆函数的调用,而且出现了base64编码表,盲猜一手利用base64编码来进行加密后得到 v4

利用这点,逆推回去,写个脚本

import base64

st = 'e3nifIH9b_C@n@dH'
flag = ''
for i in range(len(st)):
    s = ord(st[i]) - i
    flag += chr(s)
print(base64.b64decode(flag))

得到flag{i_l0ve_you}收工

标签:reverse,esp,int,v12,ebp,byte,41A144
From: https://www.cnblogs.com/TFOREVERY/p/17366279.html

相关文章

  • reverse_2
    查壳(查位数)64位,拖进IDA方法依旧,F5看伪代码int__cdeclmain(intargc,constchar**argv,constchar**envp){intresult;//eaxintstat_loc;//[rsp+4h][rbp-3Ch]BYREFinti;//[rsp+8h][rbp-38h]__pid_tpid;//[rsp+Ch][rbp-34h]chars2[24];......
  • reverse_1
    依旧先查壳(看几位)没壳64位考虑IDA或者OD都行(看个人习惯,OD需要很大的功底)建议先从IDA开始拖入IDA看看发现没有想要的东西-->shift+F12-->(可以ctrl+F)-->也可一个个找关键字flag发现rightflag-->点进去在数据段上(不能操作)没有任何作用-->ctrl+x(查看是谁调用了......
  • XI Samara Regional Intercollegiate Programming Contest Problem E. Substring Re
    Twostringssandtofthesamelengtharegiven.Determinewhetheritispossibletomaketfromsusingexactlyonereverseofsomeitssubstring.InputThefirstlinecontainsthestrings,andthesecond—thestringt.Bothstringshavethesamel......
  • Comparator.reverseOrder() 和 reversed()的区别
    摘要:Comparator.reverseOrder()和reversed()的区别是前者以某字段进行倒序排列,而reversed是针对已排序数据进行处理,常常用于比较器的末尾。  在使用Streamsorted进行排序的时候,常常需要按照摸个属性进行降序排列,有时候reverseOrder()和reversed()都可以实现目标,那他们的区......
  • Minimum Reverse Operations
    MinimumReverseOperationsYouaregivenaninteger n andaninteger p intherange [0,n-1].Representinga0-indexed array arr oflength n whereallpositionsaresetto$0$'s,exceptposition p whichissetto 1 .Youarealsogivenaninte......
  • sort,sorted,reverse,reversed的区别
    python中sort,sorted,reverse,reversed的区别简单的说以上四个内置函数都是排序。对于sort和reverse都是list列表的内置函数,一般不传参数,没有返回值,会改变原列表的值。而sorted和reversed是python内置函数,需要传参数,参数可以是字符串,列表,字典,元组,不管传的参数是什么sorted返回的......
  • How to Configure Nginx reverse proxy the domain
    未测试过,自己记录待用http{resolver8.8.8.8;upstreamexample{serverhttp://example.comresolve[use_last]...;keepalive1024;}第二种负载均衡upstreammytarget{serveraaa.tar.com:443max_fails=3fail_timeout=60s;serverbbb.tar.com:443backup;}server......
  • reverse/base64变体类型
    例:【BUU】特殊的BASE64进入main函数后发现rightflag明显是base64加密的结果(补=)随后发现右base64encode函数进入后发现是传统的base64加密方式,猜测是密码表的变体利用shitf+f12查看字符串发现有类似密码表的字符串利用脚本进行解密importbase64outab="ABCDEFGHIJKLMNOP......
  • string_reverse
      defstring_reverse():s="abcdrfg"foriinrange(len(s)-1,-1,-1):print(s[i],end="")gfrdcba  defstring_reverse():......
  • algrothm_reverse(algrothm+round)【反转链表】
    ......