type
status
date
slug
summary
tags
category
icon
password
以下为附件链接,供各位师傅下载练习
https://wwb.lanzout.com/i7mkm21aeegd
趁热打铁,前一阵子打国赛遇到了cpython的题,但是国赛那道cpython和这个相比简直就是”关公面前耍大刀“。
在此也非常感谢z221x师傅的博客
为我提供了一些很好的思路
Noval_cpython
我们可以先用help函数看一下有没有什么比较有用的信息
这里注意一下,它是用python3.10直接编译的,我调了很多遍,发现如果跟版本不一样的话会导致导入不了这个模块
接下来我们用help查看一下,可以得到很多有用的信息

我们注意到了check和encrypt函数,在main.py中它使用的就是check()函数

然后我们可以注意到DATA那里有很多可疑的数据,我们先继续进行分析
首先第一步还是找到模块处理的地方

我们要从check_secret模块开始看

我们发现里面有很多对象,这让我想到之前学习驱动的时候,“驱动之内一切皆对象”,其实cpython在创建模块也需要很多对象


我们发现这里创建了很多对象,这里的操作相当于
这里是密文的初始化

但是我们发现这个跟上面的help的情况不太一样,没有关系我们继续往下面看
这里重新打包了很多东西

但是我们在伪代码层面看不出来它的逻辑
汇编层面:

我们发现它是定义algorithm1,algorithm2,algorithm3.......这些函数

然后最后的时候还有个加密函数,这个加密函数有七个参数,我们发现有一个delta的参数,在这里先猜测它可能是tea加密
继续往下面分析
这里为定义一个xixi变量

这里我们发现定义了一个sbox变量

这里定义haha这个变量

再往下面就是定义了打包的函数模块
这里就是真正定义密文的地方









总结一下上面八个函数以及前面打包函数的时候的两个参数
这里定义一个map函数

后面就是定义encrypt函数,struct函数和check函数

至此我们对于check_secret这个模块分析完了,这个模块全都是初始化的一些东西,然而我们在main.py调用的是check函数,接下来我们分析check函数
我们从上往下进行分析
发现这里调用了range函数

然后这里调用了s_box

梳理一下逻辑
实现了一个替换的功能
下面实现了一个struct函数



然后下面开始加密

发现它还调用了下面的xixi,再往下分析
这里有个+2操作

后面又调用了一次加密函数,但是调用的是haha

然后后面还有一个+2操作,但是到这里我们还无法确认它真正的加密逻辑是什么,然后我们去看encrypt函数
真正的加密在_pyx_pf_12check_secret_16encrypt里面
现在开始才是真正的逆向🈚,一共有5000多行,逆呗谁能逆过你啊
我们可以看到光定义变量都有500多行了

我们发现这个加密函数有两个参数

其实我们还可以大胆写一下那个加密的逻辑
看起来很像tea加密
这里定义了一个uint32的变量

从上往下分析,我们发现还定义了另一个uint32的变量
然后我们有注意到了一个变量

它只有两处引用,可以猜测一下它经过了32次循环




..........................后面的图很多,但是我们发现它经历了好多次重复的操作,然后还调用了大量的map
梳理一下
到这里我们可以确定这就是个tea加密
然后Arr3stY0u战队的师傅们提供了另一个思路
因为这个动态链接库是已经打包好的,所以我们可以直接调用里面的函数然后,再打印出来他们的操作(相当于就是hook操作)
然后我们就可以得到加密的过程

exp
有关Notion安装或者使用上的问题,欢迎您在底部评论区留言,一起交流~
- Author:5m10v3
- URL:https://5m10v3.top/article/22c68850-8b27-4ee6-9231-704533b36c6d
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts