0%

buuctf_joker

joker1

没有加壳

image-20210909150331784

F5发现不能反汇编(确定不是IDA的问题,网上说是堆栈市镇偏移出错,选项-常规-点击堆栈指针,快捷键alt+k,值改为0【PS:堆栈不平衡笔记在最后】

在最后一个AC处修改位0

image-20210909162139584

image-20210909162010697

反汇编后伪代码如下,首先是输入长度为24,然后主要函数为wrong omg encrypt三个函数

image-20210909162739475

wrong是加密

image-20210909163728424

omg是比较wrong加密结果和unk_4030C0地址的值是否相同

image-20210909164135177

写个脚本,得出来的flag{fak3_alw35_sp_me!!}是个假的

1
2
3
4
5
6
7
8
9
10
11
12
import string
s=[102, 107, 99, 100, 127, 97, 103, 100, 59, 86, 107, 97, 123, 38, 59, 80, 99, 95, 77, 90, 113, 12, 55, 102]
out=[]
for i in range(0,24):
if i&1 :
s[i]+=i
out.append(s[i])
else:
s[i]^=i
out.append(s[i])
for i in out:
print(chr(i),end='')

注意一下还有一个Encrypt函数,这个函数也是不能反汇编的

image-20210909172356488

image-20210909172621478

动态OD调试试试,进加密函数看看

image-20210909182844710

(或者OllyDump脱壳)IDA动态调试,看到原来的data数据变成了汇编代码,从encrypt函数的起始地址0x401500开始选取,选取所有没有编译的text段数据,按c,点击force

https://www.leadroyal.cn/p/370/

在这里插入图片描述

然后在0x401500处右击创建函数,现在就能看到encrpty函数里的内容了,大概就是将带入的数据与Buffer进行异或操作,然后得到unk_403040地址上的值

image-20210909192327017

1
2
3
4
5
6
7
8
import string

result=[0xe,0xd,0x9,0x6,0x13,0x5,0x58,0x56,0x3e,0x6,0xc,0x3c,0x1f,0x57,0x14,0x6b,0x57,0x59,0xd]
flag=""
haha="hahahaha_do_you_find_me?"
for i in range(19):
flag+=chr(ord(haha[i])^(result[i]))
print(flag)

flag不全

image-20210909193101144

image-20210909193617976

https://blog.csdn.net/CSNN2019/article/details/115328038

堆栈不平衡

IDA f5无法反汇编,出现如图错误一般是因为程序代码有一些干扰代码,比如用push + n条指令 + retn来实际跳转,而IDA会以为是retn是函数要结束,结果分析后发现调用栈不平衡

简单来说就是调用函数后。使用完堆栈esp要回到ebp的位置(大概这么理解

image-20210909153157763

image-20210909155612149

https://www.cnblogs.com/saintlas/p/7093561.html