Hello!
I am working on the second phase of the binary bomb/bomblab project, and I am a bit stuck.
Basically, we have to input 6 integers to keep the bomb from exploding - however they must be the 6 correct digits, and you have to find them in order. I am using the gdb compiler.
This is my code and the comments are how I understand it at the moment:
08048dc2 <phase_2>:
8048dc2: 55 push %ebp
8048dc3: 89 e5 mov %esp,%ebp
8048dc5: 56 push %esi
8048dc6: 53 push %ebx
8048dc7: 83 ec 30 sub $0x30,%esp
8048dca: 8d 45 e0 lea -0x20(%ebp),%eax
8048dcd: 89 44 24 04 mov %eax,0x4(%esp)
8048dd1: 8b 45 08 mov 0x8(%ebp),%eax
8048dd4: 89 04 24 mov %eax,(%esp) //*esp = eax <- esp points to eax
8048dd7: e8 37 06 00 00 call 8049413 <read_six_numbers> //function call
8048ddc: bb 02 00 00 00 mov $0x2,%ebx // ebx = 2
8048de1: 8d 75 e0 lea -0x20(%ebp),%esi // loop -0x20(%ebp) = &esi
8048de4: 8b 44 9e f8 mov -0x8(%esi,%ebx,4),%eax // eax = esi[ebx-2]
8048de8: 83 c0 05 add $0x5,%eax // eax += 5
8048deb: 39 44 9e fc cmp %eax,-0x4(%esi,%ebx,4) // if (esi[ebx-1] == eax)
8048def: 74 05 je 8048df6 <phase_2+0x34> // safe
8048df1: e8 db 05 00 00 call 80493d1 <explode_bomb> // yuck
8048df6: 83 c3 01 add $0x1,%ebx // ebx += 1
8048df9: 83 fb 07 cmp $0x7,%ebx // if ebx != 7
8048dfc: 75 e6 jne 8048de4 <phase_2+0x22> // go to loop
8048dfe: 83 c4 30 add $0x30,%esp
8048e01: 5b pop %ebx
8048e02: 5e pop %esi
8048e03: 5d pop %ebp
8048e04: c3 ret
08049413 <read_six_numbers>: //checks to make sure you have entered 6 integers & puts them in stack then returns to phase 2
8049413: 55 push %ebp
8049414: 89 e5 mov %esp,%ebp
8049416: 83 ec 28 sub $0x28,%esp
8049419: 8b 55 0c mov 0xc(%ebp),%edx
804941c: 8d 42 14 lea 0x14(%edx),%eax
804941f: 89 44 24 1c mov %eax,0x1c(%esp)
8049423: 8d 42 10 lea 0x10(%edx),%eax
8049426: 89 44 24 18 mov %eax,0x18(%esp)
804942a: 8d 42 0c lea 0xc(%edx),%eax
804942d: 89 44 24 14 mov %eax,0x14(%esp)
8049431: 8d 42 08 lea 0x8(%edx),%eax
8049434: 89 44 24 10 mov %eax,0x10(%esp)
8049438: 8d 42 04 lea 0x4(%edx),%eax
804943b: 89 44 24 0c mov %eax,0xc(%esp)
804943f: 89 54 24 08 mov %edx,0x8(%esp)
8049443: c7 44 24 04 59 9c 04 movl $0x8049c59,0x4(%esp)
804944a: 08
804944b: 8b 45 08 mov 0x8(%ebp),%eax
804944e: 89 04 24 mov %eax,(%esp)
8049451: e8 7e f5 ff ff call 80489d4 <sscanf@plt>
8049456: 83 f8 05 cmp $0x5,%
8049459: 7f 05 jg 8049460 <read_six_numbers+0x4d>
804945b: e8 71 ff ff ff call 80493d1 <explode_bomb>
8049460: c9 leave
8049461: c3 ret
I have been using a few examples to try and walk through the code, and my main problem at the moment is that I feel I should be able to use "p $eax" at this point "cmp %eax,-0x4(%esi,%ebx,4)" to see what is being compared to the numbers I input. It has been returning 6, however, if I use that for my first integer the bomb explodes.
Any help would be greatly appreciated!!!