簡體   English   中英

二進制炸彈階段5-尋找兩個整數作為輸入

[英]Binary Bomb Phase 5 - Looking for two ints as input

我目前正在從事二進制炸彈項目的研究,目前處於階段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)兩個零簡單地解決了這個問題。

最后,您可以對整個過程進行反向工程。 注意,它是對在代碼的第一部分中在堆棧上創建的鏈表的元素進行匯總。 求和從第一個數字指定的項開始,到達到零值的節點時停止。 輸入的第二個數字應與計算得出的總和匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM