0
点赞
收藏
分享

微信扫一扫

HackTheBox Impossible Password 题目分析


HackTheBox Impossible Password 题目分析_字符串


题目链接:

https://app.hackthebox.com/challenges/26

开始

die分析程序

HackTheBox Impossible Password 题目分析_伪代码_02

64位的程序,其他就没有什么特别之处了,但是用ida无法打开

HackTheBox Impossible Password 题目分析_安全_03

用strings查看程序内的字符串

HackTheBox Impossible Password 题目分析_安全_04

发现一个英语单词

SuperSeKretKey

我们运行程序输入这个单词试试

HackTheBox Impossible Password 题目分析_linux_05

这个程序要经过两次验证才能输出flag,使用ltrace跟踪一下程序试试

HackTheBox Impossible Password 题目分析_伪代码_06

可以看到,我们输入SuperSeKretKey后,和内置的字符串对比了一下,然后我们随便输入一个字符串试试

HackTheBox Impossible Password 题目分析_字符串_07

可以看到,这个程序调用了time函数,参数为0,说明调用了当前的时间作为参数来随机生成一个字符串和我们输入的值比较,这里我们需要动态调试来程序

这里先使用ghidra来查看一下程序的伪代码

HackTheBox Impossible Password 题目分析_安全_08


HackTheBox Impossible Password 题目分析_网络安全_09

可以看到,程序的伪代码和我们分析的差不多,只需要绕过验证即可,接下来使用r2来动态程序

HackTheBox Impossible Password 题目分析_linux_10


HackTheBox Impossible Password 题目分析_网络安全_11


HackTheBox Impossible Password 题目分析_字符串_12

在第一次 strcmp() 调用之后,它将我们的输入与该字符串进行比较

HackTheBox Impossible Password 题目分析_linux_13

如果 strcmp 返回 0,将跳转到0x400925,否则指令指针将执行下一条指令,将 1 移动到堆栈然后调用 exit

在下面还找了一个fcn.0040078d的函数,我们进去看看

HackTheBox Impossible Password 题目分析_linux_14


HackTheBox Impossible Password 题目分析_字符串_15

在 0x004007b3 上调用 time(0),在 0x004007d9 上调用 srand(),在 0x004007e9 上调用 malloc(),然后进行了一个循环,和我们之前的猜想一样,调用了当前的时间作为参数来随机生成一个字符串和我们输入的值比较

回到main函数,在此次还进行了一次对比

HackTheBox Impossible Password 题目分析_伪代码_16


我看完整个程序的汇编代码后,找到了三种解决方案

第一个是nop掉我们输入错误后执行jmp指令的地址
第二个是在test指令执行后修改eax的值为1,这样不管我们输入正确与否,都会判断为正确
第三个是直接跳转到直接调用flag的地址

这里我演示第一种方法,直接nop掉指令

输入oo+,以读写的方式打开,然后跳转到这个地址

HackTheBox Impossible Password 题目分析_安全_17

s 0x00400968

然后修改程序,nop掉这个跳转操作

wx 9090
wa nop

HackTheBox Impossible Password 题目分析_字符串_18

然后我们在看看main函数

HackTheBox Impossible Password 题目分析_linux_19

已经成功修改了程序,现在我们输入q退出程序,然后运行

HackTheBox Impossible Password 题目分析_网络安全_20

成功程序


举报

相关推荐

0 条评论