【bugku】【RE】file WriteUp

FILE

  查壳后显示无壳,拖进IDA:

  运行程序时传递的第一个参数为一个文件名,并打开该文件。下面点进去encode函数分析一下:

  for循环中每三个为一组,进行Base64的操作,接下来两个if分别判断Base64后的尾部是加一个“=”还是两个“=”还是不加“=”。具体Base64编码方式可以参考我的这篇博客:https://www.cnblogs.com/reddest/p/9554948.html。所以encode()是对传入的字符串进行Base64编码。回到主函数看看encode()被用在哪里了:

  圈出来的部分就是判断输入的数据是否是正确的KEY了,并且可以发现并没有用到encode()的返回值v11和v12,所以encode()就是个摆在那里打扰分析思路的。老夫40米巨剑何在。

  根据异或的可逆性,v14[k] = k ^ flllag[k] ^ v13[k]。现在我们只缺v13数组中是哪些元素了,分析sub_400EB9():

  sub_400EB9()的返回值根据sub_400E6A()来定,跟进分析sub_400E6A():

  这里把传入的某个元素判断是否符合某个区间,然后分别返回不同的值。该函数传进来的是sttr_home[]字符串中的元素,主函数中双击该字符串:

  获取了sttr_home的元素后写个脚本跑出v13[],脚本如下:

 1 #include <cstdio>
 2 char str[110] = "664e06226625425d562e766e042d422c072c45692d125c7e6552606954646643";
 3 int jdg(int id){
 4     if(str[id] >= ‘0‘ && str[id] <= ‘9‘)
 5         return str[id] - ‘0‘;
 6     if(str[id] >= ‘A‘ && str[id] <= ‘F‘)
 7         return str[id] - ‘7‘;
 8     if(str[id] < ‘a‘ && str[id] > ‘f‘)
 9         return 0xFFFFFFFFLL;
10     return str[id] - ‘W‘;
11 }
12 int calc(int x, int y){
13     return 16 * jdg(x) + jdg(y);
14 }
15 int main(){
16     for(int i = 0;i < 64;i += 2){
17         printf("%d, ", calc(i, i + 1));
18     }
19     return 0;
20 }

  接着写出根据v14[k] = k ^ flllag[k] ^ v13[k]写出相应脚本跑出KEY,并把KEY存到文件中,代码如下:

  接着用gcc编译并运行后,把a.txt作为参数传给file运行:

  把a.txt的MD5在线计算一下:

  把MD5加上flag{}就OKK啦!

原文地址:https://www.cnblogs.com/reddest/p/10124258.html

时间: 2024-08-30 01:41:53

【bugku】【RE】file WriteUp的相关文章

【翻译自mos文章】使用asmcmd命令在本地和远程 asm 实例之间 拷贝asm file的方法

使用asmcmd命令在本地和远程 asm 实例之间 拷贝asm file的方法 参考原文: How to Copy asm files between remote ASM instances using ASMCMD command (Doc ID 785580.1) 适用于: Oracle Database - Enterprise Edition - Version 11.1.0.6 to 11.2.0.2 [Release 11.1 to 11.2] Information in thi

【翻译自mos文章】注意: ASMB process exiting due to lack of ASM file activity

注意: ASMB process exiting due to lack of ASM file activity 参考原文: NOTE: ASMB process exiting due to lack of ASM file activity (Doc ID 754110.1) 适用于: Oracle Server - Enterprise Edition - Version 10.1.0.2 to 11.2.0.4 [Release 10.1 to 11.2] Information in

【ZBar】ios错误ignoring file xxx missing required architecture x86_64 in file

解决方法: 1.在Project target里"Architectures"设置为:Standard (armv7,armv7s)或者  Standard (armv7,arm64) 2.设置"Build Active Architecture Only"为"NO" 还有一篇文章说的很牛逼,但是还咩有看,http://blog.csdn.net/lanmanck/article/details/39055503 原文地址:[ZBar]ios错误

【翻译自mos文章】Weblogic AdminServer 启动fail,报错为&quot;unable to get file lock, will retry&quot;

Weblogic AdminServer 启动fail,报错为"unable to get file lock, will retry" 参考原文: Weblogic AdminServer fails with "unable to get file lock, will retry" error message (Doc ID 1613945.1) 适用于: Oracle WebLogic Server - Version 8.1 and later Infor

【翻译自mos文章】在不使用par file的情况下,export or import 含有大小写表名的表

在不使用par file的情况下,export or import 含有大小写表名的表 参考原文: How to Export or Import Case Sensitive Tables Without Using a Par File (Doc ID 1622134.1)1 适用于: Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.4 [Release 10.2 to 11.2] Information i

【翻译自mos文章】在unix/linux中使用文件描述符(File Descriptors)来找回被删掉的文件(数据文件or redo log)

在unix/linux中使用文件描述符(File Descriptors)来找回被删掉的文件(数据文件or redo log) 参考原文: Retrieve deleted files on Unix / Linux using File Descriptors (Doc ID 444749.1) 适用于: Oracle Database - Enterprise Edition - Version 8.1.7.0 to 11.2.0.3 [Release 8.1.7 to 11.2] Linu

【翻译自mos文章】对于每一个文件的 file.id and file.incarnation number,重命名文件别名

对于每一个文件的 file.id and file.incarnation number,重命名文件别名 参考原文: Rename Alias of Datafile as Per file.id and file.incarnation number (Doc ID 1494661.1) 适用于: Oracle Database - Enterprise Edition - Version 11.2.0.0 and later Information in this document appl

【翻译自mos文章】Oracle GoldenGate(OGG) trail file的最大大小

Oracle GoldenGate(OGG) trail file的最大大小 参考原文: what's the OGG trail size limit? (文档 ID 1348080.1) 适用于: Oracle GoldenGate - Version: 10.4.0.99 and later   [Release: 10.4.0 and later ] Information in this document applies to any platform. 目标: 在AIX 平台下,做i

【iOS开发-101】解决方案:The file * couldn&#39;t be opened because you don&#39;t have permission to view it

(1)无缘无故出现"The file * couldn't be opened because you don't have permission to view it"错误信息. 解决办法:Window -> Organizer -> 在下面框框左面选择你的项目名字 -> 在右面有一个delete,点击删除即可.不会影响你的文件,删除后相当于从0编译第一次速度会慢一点而已. (2)产生这个问题的原因有很多,如果以上办法不起作用,那么试着看看其他解决办法. 解决办法网

【python之路35】网络编程之socket相关

Socket socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. socket起源于Unix,而Unix/Linux基本哲学之一就是"一切皆文件",对于文件用[打开][读写][关闭]模式来操作.socket就是该模式的一个实现,socket即是一种特殊的文件,一些socket函数就是对其进行的操作(读/写IO.打开.关闭) socket和file的区别: fil