gpt4 book ai didi

c - 二进制炸弹阶段 5 - 寻找两个整数作为输入

转载 作者:行者123 更新时间:2023-11-30 16:28:10 24 4
gpt4 key购买 nike

我目前正在研究二进制炸弹项目,并停留在第 5 阶段。我的版本似乎与我搜索过的其他演练和教程略有不同。这是 x86-64 程序集。我发现它正在寻找两个整数作为输入。这是phase_5 程序集:

40105c: 55                      push   %rbp
40105d: 53 push %rbx
40105e: 48 81 ec b8 01 00 00 sub $0x1b8,%rsp
401065: c7 84 24 90 01 00 00 movl $0x4,0x190(%rsp)
40106c: 04 00 00 00
401070: 48 c7 84 24 98 01 00 movq $0x0,0x198(%rsp)
401077: 00 00 00 00 00
40107c: 48 c7 84 24 a8 01 00 movq $0x0,0x1a8(%rsp)
401083: 00 00 00 00 00
401088: c7 84 24 70 01 00 00 movl $0x2,0x170(%rsp)
40108f: 02 00 00 00
401093: 4c 8d 9c 24 90 01 00 lea 0x190(%rsp),%r11
40109a: 00
40109b: 4c 89 9c 24 78 01 00 mov %r11,0x178(%rsp)
4010a2: 00
4010a3: 48 c7 84 24 88 01 00 movq $0x0,0x188(%rsp)
4010aa: 00 00 00 00 00
4010af: c7 84 24 50 01 00 00 movl $0x1,0x150(%rsp)
4010b6: 01 00 00 00
4010ba: 48 8d 84 24 70 01 00 lea 0x170(%rsp),%rax
4010c1: 00
4010c2: 48 89 84 24 58 01 00 mov %rax,0x158(%rsp)
4010c9: 00
4010ca: 4c 89 9c 24 68 01 00 mov %r11,0x168(%rsp)
4010d1: 00
4010d2: c7 84 24 30 01 00 00 movl $0xfffffffe,0x130(%rsp)
4010d9: fe ff ff ff
4010dd: 48 8d 94 24 50 01 00 lea 0x150(%rsp),%rdx
4010e4: 00
4010e5: 48 89 94 24 38 01 00 mov %rdx,0x138(%rsp)
4010ec: 00
4010ed: 48 89 84 24 48 01 00 mov %rax,0x148(%rsp)
4010f4: 00
4010f5: c7 84 24 10 01 00 00 movl $0xfffffffb,0x110(%rsp)
4010fc: fb ff ff ff
401100: 48 8d 8c 24 30 01 00 lea 0x130(%rsp),%rcx
401107: 00
401108: 48 89 8c 24 18 01 00 mov %rcx,0x118(%rsp)
40110f: 00
401110: 48 89 94 24 28 01 00 mov %rdx,0x128(%rsp)
401117: 00
401118: c7 84 24 f0 00 00 00 movl $0x8,0xf0(%rsp)
40111f: 08 00 00 00
401123: 48 8d b4 24 10 01 00 lea 0x110(%rsp),%rsi
40112a: 00
40112b: 48 89 b4 24 f8 00 00 mov %rsi,0xf8(%rsp)
401132: 00
401133: 48 89 8c 24 08 01 00 mov %rcx,0x108(%rsp)
40113a: 00
40113b: c7 84 24 d0 00 00 00 movl $0xffffffff,0xd0(%rsp)
401142: ff ff ff ff
401146: 4c 8d 84 24 f0 00 00 lea 0xf0(%rsp),%r8
40114d: 00
40114e: 4c 89 84 24 d8 00 00 mov %r8,0xd8(%rsp)
401155: 00
401156: 48 89 b4 24 e8 00 00 mov %rsi,0xe8(%rsp)
40115d: 00
40115e: c7 84 24 b0 00 00 00 movl $0xb,0xb0(%rsp)
401165: 0b 00 00 00
401169: 4c 8d 8c 24 d0 00 00 lea 0xd0(%rsp),%r9
401170: 00
401171: 4c 89 8c 24 b8 00 00 mov %r9,0xb8(%rsp)
401178: 00
401179: 4c 89 84 24 c8 00 00 mov %r8,0xc8(%rsp)
401180: 00
401181: c7 84 24 90 00 00 00 movl $0x5,0x90(%rsp)
401188: 05 00 00 00
40118c: 4c 8d 94 24 b0 00 00 lea 0xb0(%rsp),%r10
401193: 00
401194: 4c 89 94 24 98 00 00 mov %r10,0x98(%rsp)
40119b: 00
40119c: 4c 89 8c 24 a8 00 00 mov %r9,0xa8(%rsp)
4011a3: 00
4011a4: c7 44 24 70 0d 00 00 movl $0xd,0x70(%rsp)
4011ab: 00
4011ac: 48 8d 9c 24 90 00 00 lea 0x90(%rsp),%rbx
4011b3: 00
4011b4: 48 89 5c 24 78 mov %rbx,0x78(%rsp)
4011b9: 48 c7 84 24 80 00 00 movq $0x0,0x80(%rsp)
4011c0: 00 00 00 00 00
4011c5: 4c 89 94 24 88 00 00 mov %r10,0x88(%rsp)
4011cc: 00
4011cd: 48 89 84 24 a0 01 00 mov %rax,0x1a0(%rsp)
4011d4: 00
4011d5: 48 89 94 24 80 01 00 mov %rdx,0x180(%rsp)
4011dc: 00
4011dd: 48 89 8c 24 60 01 00 mov %rcx,0x160(%rsp)
4011e4: 00
4011e5: 48 89 b4 24 40 01 00 mov %rsi,0x140(%rsp)
4011ec: 00
4011ed: 4c 89 84 24 20 01 00 mov %r8,0x120(%rsp)
4011f4: 00
4011f5: 4c 89 8c 24 00 01 00 mov %r9,0x100(%rsp)
4011fc: 00
4011fd: 4c 89 94 24 e0 00 00 mov %r10,0xe0(%rsp)
401204: 00
401205: 48 89 9c 24 c0 00 00 mov %rbx,0xc0(%rsp)
40120c: 00
40120d: 48 8d 6c 24 70 lea 0x70(%rsp),%rbp
401212: 48 89 ac 24 a0 00 00 mov %rbp,0xa0(%rsp)
401219: 00
40121a: 48 c7 44 24 10 00 00 movq $0x0,0x10(%rsp)
401221: 00 00
401223: 48 89 6c 24 18 mov %rbp,0x18(%rsp)
401228: 48 89 5c 24 20 mov %rbx,0x20(%rsp)
40122d: 4c 89 54 24 28 mov %r10,0x28(%rsp)
401232: 4c 89 4c 24 30 mov %r9,0x30(%rsp)
401237: 4c 89 44 24 38 mov %r8,0x38(%rsp)
40123c: 48 89 74 24 40 mov %rsi,0x40(%rsp)
401241: 48 89 4c 24 48 mov %rcx,0x48(%rsp)
401246: 48 89 54 24 50 mov %rdx,0x50(%rsp)
40124b: 48 89 44 24 58 mov %rax,0x58(%rsp)
401250: 4c 89 5c 24 60 mov %r11,0x60(%rsp)
401255: 48 8d 4c 24 08 lea 0x8(%rsp),%rcx
40125a: 48 8d 54 24 0c lea 0xc(%rsp),%rdx
40125f: be 0d 29 40 00 mov $0x40290d,%esi
401264: b8 00 00 00 00 mov $0x0,%eax
401269: e8 92 f9 ff ff callq 400c00 <__isoc99_sscanf@plt>
40126e: 83 f8 01 cmp $0x1,%eax
401271: 7f 05 jg 401278 <phase_5+0x21c>
401273: e8 09 04 00 00 callq 401681 <explode_bomb>
401278: 83 7c 24 0c 0a cmpl $0xa,0xc(%rsp)
40127d: 76 05 jbe 401284 <phase_5+0x228>
40127f: e8 fd 03 00 00 callq 401681 <explode_bomb>
401284: 48 63 44 24 0c movslq 0xc(%rsp),%rax
401289: 48 8b 44 c4 10 mov 0x10(%rsp,%rax,8),%rax
40128e: 48 85 c0 test %rax,%rax
401291: 74 12 je 4012a5 <phase_5+0x249>
401293: ba 00 00 00 00 mov $0x0,%edx
401298: 03 10 add (%rax),%edx
40129a: 48 8b 40 18 mov 0x18(%rax),%rax
40129e: 48 85 c0 test %rax,%rax
4012a1: 75 f5 jne 401298 <phase_5+0x23c>
4012a3: eb 05 jmp 4012aa <phase_5+0x24e>
4012a5: ba 00 00 00 00 mov $0x0,%edx
4012aa: 39 54 24 08 cmp %edx,0x8(%rsp)
4012ae: 74 05 je 4012b5 <phase_5+0x259>
4012b0: e8 cc 03 00 00 callq 401681 <explode_bomb>
4012b5: 48 81 c4 b8 01 00 00 add $0x1b8,%rsp
4012bc: 5b pop %rbx
4012bd: 5d pop %rbp
4012be: c3 retq

运行 gdb 和 p (char *) 0x40290d 返回“%d %d”,这就是我知道它正在扫描两个整数的方式。我尝试遵循比较和跳转语句,但很快就迷失了方向。任何援助将不胜感激。谢谢。

最佳答案

显然,401278行正在检查第一个数字是否小于或等于10。然后进行一些计算,下一个可以爆炸炸弹的检查位于4012aa。即将计算结果与输入的第二个数字进行比较。由于您使用的是 gdb,因此您可以简单地在该指令上放置一个断点并让程序运行。输入有效的第一个数字,后跟任意第二个数字。当在断点处停止时,打印 edx 中的值。这将是输入的第一个数字的正确匹配。

另一种方法是发现 40128e 行上的条件。这会跳过整个计算,只是将第二个数字与零进行比较。您需要找到正确的值来触发此满足 0x10(%rsp,%rax,8) == 0 的情况。鉴于 40121amovq $0x0,0x10(%rsp) 两个零可以轻松解决问题。

最后,你可以对整个事情进行逆向工程。请注意,它正在总结代码第一部分中在堆栈上创建的链表的元素。求和从第一个数字指定的项开始,并在到达值为零的节点时停止。输入的第二个数字应与计算出的总和相匹配。

关于c - 二进制炸弹阶段 5 - 寻找两个整数作为输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52471750/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com