ctf系列之Linux x64程序逆向&IDA patch &IDA Python

admin 2022年5月3日19:23:53评论71 views字数 1042阅读3分28秒阅读模式

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

Linux X64程序的逆向,通过strings查找关键字符,通过交叉引用定位到关键函数,f5得到伪代码如下

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

    大致分析知道程序本身会打印flag,但是因为sleep时间太长, 所以可以直接patch掉sleep, 然后就可以直接打印出flag了。

    这是64位程序, 参数靠寄存器来传参, sleep只有一个参数, 所以它需要的寄存器只有rdi一个寄存器, 查看call sleep之前对rdi修改的指令代码

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

可以看到最后就是通过这里对rdi进行了修改, 上面一部分是做i*30的计算, 那么可以直接把这条指令给换成xor edi, edi, 那么sleep的参数就会变为0。

直接用IDA来修改汇编代码

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

保存patch后的二进制文件

ctf系列之Linux x64程序逆向&IDA patch &IDA Python


ctf系列之Linux x64程序逆向&IDA patch &IDA Python

当然这题还有别的方法,比如直接正向分析。伪代码中是将unk_400900处的内存拷贝到v4当中,而v4就是我们要比较的字符串,那么我们直接去获取unk_400900的数据并按照代码中的hash函数方法进行爆破攻击,因为v4是int类型,所以unk每四个字节为一组,然后小端序,每四个一组,就是0xDEADBD54是第一组,以此类推

ctf系列之Linux x64程序逆向&IDA patch &IDA Python使用IDAPython提取出来

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

然后根据hash算法爆破得到flag

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

ctf系列之Linux x64程序逆向&IDA patch &IDA Python

li = [3735928148, 3735928106, 3735928157, 3735928147, 3735928113, 3735928119, 3735928206, 3735928123, 3735928106, 3735928152, 3735928128, 3735928116, 3735928206, 3735928123, 3735928128, 3735928119, 3735928199, 3735928111, 3735928125, 3735928128, 3735928148, 3735928206, 3735928096, 3735928150, 3735928121, 3735928150, 3735928096, 3735928128,      3735928199, 3735928128, 3735928105, 3735928201, 3735928213, 3735928077]for i in range(0x22):    for j in range(32, 127):        if ((j+1028)**2//1337)^0xDEADBEEF == li[i]:            print(chr(j),end="")            break

ctf系列之Linux x64程序逆向&IDA patch &IDA Python


原文始发于微信公众号(格格巫和蓝精灵):ctf系列之Linux x64程序逆向&IDA patch &IDA Python

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月3日19:23:53
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   ctf系列之Linux x64程序逆向&IDA patch &IDA Pythonhttps://cn-sec.com/archives/960362.html

发表评论

匿名网友 填写信息