首页 > 其他分享 >BUUCTF Reverse/[NPUCTF2020]你好sao啊

BUUCTF Reverse/[NPUCTF2020]你好sao啊

时间:2023-09-22 18:36:53浏览次数:31  
标签:BUUCTF sao int 62 rbp flag base NPUCTF2020 rsp

里面就一个加密函数,分析后发现这是一段变表的base解密,将四个字符替换成三个字符

点击查看代码
void *__fastcall RxEncode(const char *a1, int a2)
{
  int v3; // [rsp+18h] [rbp-38h]
  int v4; // [rsp+1Ch] [rbp-34h]
  int v5; // [rsp+20h] [rbp-30h]
  int v6; // [rsp+24h] [rbp-2Ch]
  int v7; // [rsp+28h] [rbp-28h]
  int v8; // [rsp+28h] [rbp-28h]
  int i; // [rsp+2Ch] [rbp-24h]
  _BYTE *v10; // [rsp+30h] [rbp-20h]
  void *s; // [rsp+38h] [rbp-18h]

  v3 = 3 * (a2 / 4);
  v4 = 0;
  v5 = 0;
  if ( a1[a2 - 1] == 61 )
    v4 = 1;
  if ( a1[a2 - 2] == 61 )
    ++v4;
  if ( a1[a2 - 3] == 61 )
    ++v4;
  if ( v4 == 3 )
  {
    v3 += 2;
  }
  else if ( v4 <= 3 )
  {
    if ( v4 == 2 )
    {
      v3 += 3;
    }
    else if ( v4 )
    {
      if ( v4 == 1 )
        v3 += 4;
    }
    else
    {
      v3 += 4;
    }
  }
  s = malloc(v3);
  if ( s )
  {
    memset(s, 0, v3);
    v10 = s;
    while ( v5 < a2 - v4 )
    {
      v6 = 0;
      v7 = 0;
      while ( v6 <= 3 && v5 < a2 - v4 )
      {
        v7 = (v7 << 6) | (char)find_pos(a1[v5]);
        ++v6;
        ++v5;
      }
      v8 = v7 << (6 * (4 - v6));
      for ( i = 0; i <= 2 && i != v6; ++i )
        *v10++ = v8 >> (8 * (2 - i));
    }
    *v10 = 0;
    return s;
  }
  else
  {
    puts("No enough memory.");
    return 0LL;
  }
}

base表: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234{}789+/="

写个爆破脚本来爆破

s = [  0x9E, 0x9B, 0x9C, 0xB5, 0xFE, 0x70, 0xD3, 0x0F, 0xB2, 0xD1, 
  0x4F, 0x9C, 0x02, 0x7F, 0xAB, 0xDE, 0x59, 0x65, 0x63, 0xE7, 
  0x40, 0x9D, 0xCD, 0xFA]
flag = []

base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234{}789+/='
v5 = 0

for i in range(0,24,3):
    v7 = 0
    for j1 in range(len(base)):
        tmp = 0
        v8 = (v7 << 6) | j1
        for j2 in range(len(base)):
            v9 = (v8 << 6) | j2
            for j3 in range(len(base)):
                v10 = (v9 << 6) | j3
                for j4 in range(len(base)):
                    v11 = (v10 << 6) | j4
                    #print(v10)
                    if (s[i] == (v11 >> 16) % 256 ) and (s[i + 1] == (v11 >> 8) % 256 ) and (s[i + 2] == v11 % 256):
                        flag.append(j1)
                        flag.append(j2)
                        flag.append(j3)
                        flag.append(j4)
               
                        print(i,"{}{}{}{}".format(base[j1],base[j2],base[j3],base[j4]))
                       
print(flag)
print(len(flag))

由于这个爆破的结果有几个都满足条件所以我都输出出来了,爆破结果:

0 npuc
3 tf{w
6 0w+y
9 0U+c
12 An+r
12 =n+r
15 3lll
18 Y+c=
18 Y+dA
18 Y+d=
21 nc3}
[39, 41, 46, 28, 45, 31, 57, 48, 52, 48, 62, 50, 52, 20, 62, 28, 0, 39, 62, 43, 64, 39, 62, 43, 55, 37, 37, 37, 24, 62, 28, 64, 24, 62, 29, 0, 24, 62, 29, 64, 39, 28, 55, 58]
44

尝试拼了下前面几段,猜测中间应该是没有等于号(‘=’)的,肯定是拿加号(‘+’)拼接

最终flag:npuctf{w0w+y0U+cAn+r3lllY+dAnc3}

标签:BUUCTF,sao,int,62,rbp,flag,base,NPUCTF2020,rsp
From: https://www.cnblogs.com/ctrl-moyu/p/17723089.html

相关文章

  • Buuctf——[ZJCTF 2019]NiZhuanSiWei
    审题进入题目链接发现是白盒审计<?php$text=$_GET["text"];$file=$_GET["file"];$password=$_GET["password"];if(isset($text)&&(file_get_contents($text,'r')==="welcometothezjctf")){echo"&l......
  • Buuctf——[网鼎杯 2020 青龙组]AreUSerialz
    这是一道序列化的题目<?phpinclude("flag.php");highlight_file(__FILE__);classFileHandler{protected$op;protected$filename;protected$content;function__construct(){$op="1";$filename="/......
  • Buuctf——[RoarCTF 2019]Easy Calc
     有waf,不能出现非数字参数值。使用%20num可以绕过waf(AbusingPHPquerystringparsertobypassIDS,IPS,andWAF(secjuice.com))过滤了单双引号,可以用chr()函数构造字符串?%20num=var_dump(scandir(chr(46))) ?%20num=show_source(chr(47).chr(102).chr(49).chr(97).ch......
  • BUUCTF [GYCTF2020]FlaskApp
    因为题目名Flask,所以先观察功能点,寻找易发生ssti的功能。考虑到功能异常抛出常见于解密环节,所以在解密界面随便输入一段不能解密的。直接报错抛出debug信息,看来是开启了debug模式。payload的使用需要输入到加密界面,再将加密结果输入到解密界面查看结果。方法1首先想办法把完......
  • BUUCTF-Web
    CTF实战:从入门到提升1.3.5.[第一章][1.3.5案例解析][极客大挑战2019]Http 打开页面,没有发现什么有用的东西右键打开页面源代码,发现页面Secret.php 显示Itdoesn'tcomefrom'https://Sycsecret.buuoj.cn',使用postman,增加Referer头显示Please use "Syclo......
  • BUUCTF [De1CTF 2019]SSRF Me
    源码#!/usr/bin/envpython#encoding=utf-8fromflaskimportFlaskfromflaskimportrequestimportsocketimporthashlibimporturllibimportsysimportosimportjsonreload(sys)sys.setdefaultencoding('latin1')app=Flask(__name__......
  • BUUCTF [极客大挑战 2019]FinalSQL
    通过尝试发现注入点在search.php。传递?id=1^1报ERROR!!!;传递?id=1^0报NO!Notthis!Clickothers~~~布尔盲注importrequestsimporttimeurl="http://eab3a4cf-d57d-4236-a9f9-1383446ba4e1.node4.buuoj.cn:81/search.php?"result=''temp={"id":......
  • BUUCTF [SWPU2019]Web1
    进入网站,注册登录,进到申请发布广告,应该就是在这里实现注入。首先尝试:1'or1=1#标题含有敏感词汇应该是哪里被过滤了。经过尝试后是or被过滤了,--+,#等其他的注释符也被过滤了。经过测试后,结尾可以用单引号闭合。再次尝试:1'showdatabases()'1'showdatabases()'空格被......
  • BUUCTF [CISCN2019 华东南赛区]Web11
    切入点如图:测试模板注入最后或者payload:X-Forwarded-For:{ifreadfile('/flag')}{/if}原理是Smarty已经废弃{php}标签。在Smarty3.1,{php}仅在SmartyBC中可用。Smarty的{if}条件判断和PHP的if非常相似,只是增加了一些特性。每个{if}必须有一个配对的{/if}。全部的PHP条件表......
  • BUUCTF [网鼎杯 2020 朱雀组]Nmap
    payload:127.0.0.1|'<?=@eval($_POST["hack"]);?>-oGhack.phtml'nmap`-oG`:将扫描结果输出到一个文本文件中,G代表生成一种称为"grepableoutput"(可用于grep命令的输出)的格式,这种格式是一种易于处理的文本格式。写入`hack.phtml`而不是`hack.php`的原因在于php可能被过......