Question

diffusing a binary bomb phase_3

Asked by: errang

Hey, I need to diffuse a binary bomb, I'm pretty sure this thing has a switch statement in it, and needs 2 numbers, but beyond that, I'm kinda drawing a blank... so any help would be appreciated =)

08051a1d <phase_3>:
 8051a1d:       55                      push   %ebp
 8051a1e:       89 e5                   mov    %esp,%ebp
 8051a20:       53                      push   %ebx
 8051a21:       83 ec 14                sub    $0x14,%esp
 8051a24:       bb 00 00 00 00          mov    $0x0,%ebx
 8051a29:       8d 45 f8                lea    0xfffffff8(%ebp),%eax
 8051a2c:       50                      push   %eax
 8051a2d:       8d 45 f4                lea    0xfffffff4(%ebp),%eax
 8051a30:       50                      push   %eax
 8051a31:       68 7e 23 05 08          push   $0x805237e
 8051a36:       ff 75 08                pushl  0x8(%ebp)
 8051a39:       e8 1a fb ff ff          call   8051558 <_PROCEDURE_LINKAGE_TABLE_+0xb0>
 8051a3e:       83 c4 10                add    $0x10,%esp
 8051a41:       83 f8 01                cmp    $0x1,%eax
 8051a44:       7f 05                   jg     8051a4b <phase_3+0x2e>
 8051a46:       e8 61 07 00 00          call   80521ac <explode_bomb>
 8051a4b:       83 7d f4 07             cmpl   $0x7,0xfffffff4(%ebp)
 8051a4f:       77 3c                   ja     8051a8d <phase_3+0x70>
 8051a51:       8b 45 f4                mov    0xfffffff4(%ebp),%eax
 8051a54:       ff 24 85 bc 22 05 08    jmp    *0x80522bc(,%eax,4)
 8051a5b:       81 c3 a9 01 00 00       add    $0x1a9,%ebx
 8051a61:       81 eb 7d 01 00 00       sub    $0x17d,%ebx
 8051a67:       81 c3 82 00 00 00       add    $0x82,%ebx
 8051a6d:       81 eb 69 02 00 00       sub    $0x269,%ebx
 8051a73:       81 c3 27 01 00 00       add    $0x127,%ebx
 8051a79:       81 eb b8 02 00 00       sub    $0x2b8,%ebx
 8051a7f:       81 c3 b8 02 00 00       add    $0x2b8,%ebx
 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx
 8051a8b:       eb 05                   jmp    8051a92 <phase_3+0x75>
 8051a8d:       e8 1a 07 00 00          call   80521ac <explode_bomb>
 8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp)
 8051a96:       7f 05                   jg     8051a9d <phase_3+0x80>
 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx
 8051a9b:       74 05                   je     8051aa2 <phase_3+0x85>
 8051a9d:       e8 0a 07 00 00          call   80521ac <explode_bomb>
 8051aa2:       8b 5d fc                mov    0xfffffffc(%ebp),%ebx
 8051aa5:       c9                      leave
 8051aa6:       c3                      ret

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-04-25 at 22:03:58ID24355832
Tags

binary bomb

,

assembly

Topics

Assembly Programming Language

,

Miscellaneous Programming

Participating Experts
1
Points
500
Comments
45

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. defuse binary bomb
    I have a homework in which I have to disassembler the code and figure out how to defuse the bomb. Can anyone help please thanks bomb-quiet: file format elf32-i386 Disassembly of section .init: 08048718 <_init>: 8048718: 55 push %ebp 804871...
  2. Binary Bomb Phase 4
    Alright i'm on phase 4 of the binary bomb problem, have analyzed the assembly and this is what I have. Dump of assembler code for function phase_4: 0x08048c2c <phase_4+0>: push %ebp 0x08048c2d <phase_4+1>: mov %esp,%ebp 0x08048c2f <phase_4+3>: sub $...
  3. Binary Bomb Final Phase
    I am working through the CS:APP textbook (auditing a class at the local state U) and I'm trying to complete the final phase of the binary bomb lab. Basically, I need to figure out what string to send to this function (in C) so that the "bomb" doesn't "explode....
  4. Binary Bomb - Phase_5 - Assembly
    Hi everyone, It's the classic binary bomb lab, and I'm completely stuck on phase 5. Here's what I got:
  5. Binary Bomb Phase 2
    Hello, I am needing help with the Binary Bomb Assignment. I have completed phase one by using the x /s command. I am now stuck on phase 2. From what I understand, the the function call read_six_numbers will take in my entered string (six numbers with spaces) and scanf will ...
  6. Binary Bomb Phase One
    I am working on the cvlassic binary bomb assignment, and I am having a little bit of difficulty on the first phase. I have a pretty good understanding of what each individual line of code represents and does, but the logic flow is confusing, and I don't know how to paste the...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: errangPosted on 2009-04-27 at 23:07:49ID: 24247960

This is what I figured out about phase_3...

There are 3 calls to explode bomb.
     - 1, after line 8051a41:       83 f8 01                cmp    $0x1,%eax
         -This one jumps over only if eax is greater than 1.  So I'm guessing its supposed 2 or more numbers... and eax keeps track of them.
     - 2, after line 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx
         -I'm not sure about this jmp instruction... I think its an unconditional jump, so that explode_bomb is there just to mess with us?
     - 3, after this line  8051a9b:       74 05                   je     8051aa2 <phase_3+0x85>
        -now, that's a jump when equal... so
 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx  has to be true, and ebx is given at this instruction: 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx

So... ebx is one of the numbers I need, right? and according to... these two lines:
8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp)
 8051a96:       7f 05                   jg     8051a9d <phase_3+0x80>

I would say the other number has to be greater than 5?

did I at least manage to get something right?

 

by: Infinity08Posted on 2009-04-27 at 23:30:53ID: 24248071

>>      - 1, after line 8051a41:       83 f8 01                cmp    $0x1,%eax
         -This one jumps over only if eax is greater than 1.

The other way around ;) The jump is made if 1 is greater than eax.

>> So I'm guessing its supposed 2 or more numbers... and eax keeps track of them.

eax is the return value of the call to function 8051558.




>>          -I'm not sure about this jmp instruction... I think its an unconditional jump, so that explode_bomb is there just to mess with us?

jmp is an unconditional jump indeed.

The explode_bomb is not just there to mess with you though. Do you see where this instruction jumps to ?

>>  8051a4f:       77 3c                   ja     8051a8d <phase_3+0x70>



>>         -now, that's a jump when equal... so
>>  8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx  has to be true, and ebx is given at this instruction: 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx

Sure ...



>> So... ebx is one of the numbers I need, right?

Don't jump to conclusions just yet. But you're going in the right direction.

 

by: errangPosted on 2009-04-27 at 23:41:00ID: 24248114

>>The explode_bomb is not just there to mess with you though. Do you see where this instruction jumps to ?

>>  8051a4f:       77 3c                   ja     8051a8d <phase_3+0x70>

Yes, it jumps to a call to explode_bomb near the end of the program...
8051a8d:       e8 1a 07 00 00          call   80521ac <explode_bomb>

That's a jump address instruction though... isn't that just like the jmp instruction??

>>Don't jump to conclusions just yet. But you're going in the right direction.

right direction... that's good to hear, so, what am I missing? the 2nd number? some calculation I didn't see?

 

by: Infinity08Posted on 2009-04-28 at 00:07:05ID: 24248231

>> Yes, it jumps to a call to explode_bomb near the end of the program...
>> 8051a8d:       e8 1a 07 00 00          call   80521ac <explode_bomb>

More specifically the one you assumed was there just to mess with you ;)


>> That's a jump address instruction though... isn't that just like the jmp instruction??

ja == jump if above. It's like jg, but for unsigned integer values.


>> so, what am I missing? the 2nd number? some calculation I didn't see?

Well, first figure out where the two numbers that are read in are placed ... I assume that the call 8051558 is a call to the standard fscanf function, which would mean that its second argument ($0x805237e) is the format string. Check that to see which format string it is. The arguments after that will contain the values read from the user.

 

by: errangPosted on 2009-04-28 at 00:17:21ID: 24248283

>>Well, first figure out where the two numbers that are read in are placed ... I assume that the call 8051558 is a call to the standard fscanf function, which would mean that its second argument ($0x805237e) is the format string. Check that to see which format string it is. The arguments after that will contain the values read from the user.

after $0x805237e, there's pushl  0x8(%ebp), so the numbers are getting stored in an array?

And I know numbers because our professor was kind enough to tell us what we need to be looking for, phase 6 has symbols... *oh joy...*

 

by: Infinity08Posted on 2009-04-28 at 00:27:06ID: 24248324

$0x805237e is the address is a string literal. You can use your debugger to find out which one.

>> after $0x805237e, there's pushl  0x8(%ebp), so the numbers are getting stored in an array?

Remember that function arguments are pushed in reverse order. 0x8(%ebp) is the first argument, $0x805237e is the second, etc.
Do you know how the fscanf function works ?

        http://cplusplus.com/reference/clibrary/cstdio/fscanf/


>> And I know numbers because our professor was kind enough to tell us what we need to be looking for

Good. You know you need two numbers. You just need to know where they are stored in memory (on the stack) ;)

 

by: errangPosted on 2009-04-28 at 00:43:21ID: 24248393

>>Good. You know you need two numbers. You just need to know where they are stored in memory (on the stack) ;)

Isn't ebx one of them?

>>Do you know how the fscanf function works ?

Yeah, i've used fscanf before, it basically reads one line from a file, right?

 

by: errangPosted on 2009-04-28 at 00:44:47ID: 24248400

now that I look at the code again... I am somewhat confused by this line:
8051a54:       ff 24 85 bc 22 05 08    jmp    *0x80522bc(,%eax,4)

is that jumping to a function pointer?

 

by: errangPosted on 2009-04-28 at 00:47:08ID: 24248406

Oh... and I realized what I thought was just there to mess us up, it was these lines:
 
 8051a8b:       eb 05                   jmp    8051a92 <phase_3+0x75>
 8051a8d:       e8 1a 07 00 00          call   80521ac <explode_bomb>

jmp is an unconditional jump instruction... it just jumps to a certain location when the program reaches that line, correct?

 

by: Infinity08Posted on 2009-04-28 at 00:48:53ID: 24248411

>> Yeah, i've used fscanf before, it basically reads one line from a file, right?

It reads certain values from input depending on the format string. So, for example if the format string contains "%d %d", that means it'll try to read two integer values. Did you already check the format string ?

The locations where the values are read are given as extra parameters to the fscanf function.

>> Isn't ebx one of them?

No. ebx is not passed as argument to fscanf.


>> I am somewhat confused by this line:

Don't jump ahead. First know what you're dealing with. Where are the two numbers that the user gave ?

 

by: Infinity08Posted on 2009-04-28 at 00:49:33ID: 24248414

>> it just jumps to a certain location when the program reaches that line, correct?

Right. I've already confirmed that here : http:#24248071

 

by: errangPosted on 2009-04-28 at 00:56:55ID: 24248443

so that call to bomb under jump was just to trick us, right?

It goes right over it and jumps to 8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp)

and if that's greater than 5, jumps to the explode bomb part...

and if its not, then it jumps to 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx

Since we know that ebx is set to 0 (8051a24:       bb 00 00 00 00          mov    $0x0,%ebx), we would just need to follow these calculations, right?
8051a5b:       81 c3 a9 01 00 00       add    $0x1a9,%ebx
 8051a61:       81 eb 7d 01 00 00       sub    $0x17d,%ebx
 8051a67:       81 c3 82 00 00 00       add    $0x82,%ebx
 8051a6d:       81 eb 69 02 00 00       sub    $0x269,%ebx
 8051a73:       81 c3 27 01 00 00       add    $0x127,%ebx
 8051a79:       81 eb b8 02 00 00       sub    $0x2b8,%ebx
 8051a7f:       81 c3 b8 02 00 00       add    $0x2b8,%ebx
 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx

So... to get past 8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp), the number has to be less than or equal to 5.

And, since the jump instruction after 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx is a jump equal... we just need to figure out what one of them comes out to... and we got the solution?

first number is less than or equal to 5, and 2nd is whatever ebx is at 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx?

Or am I jumping too ahead again? lack of sleep + excitement over finally getting this bomb over with makes me jittery...

 

by: errangPosted on 2009-04-28 at 01:03:06ID: 24248470

I just calculated what ebx is supposed to be at 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx, its -1134.

 

by: errangPosted on 2009-04-28 at 01:12:04ID: 24248525

and no... apparently I did jump the gun... again.. what'd I do wrong?

 

by: errangPosted on 2009-04-28 at 01:14:07ID: 24248532

>>Don't jump ahead. First know what you're dealing with. Where are the two numbers that the user gave ?

They would be in... 8051a36:       ff 75 08                pushl  0x8(%ebp), correct?

>>Remember that function arguments are pushed in reverse order. 0x8(%ebp) is the first argument, $0x805237e is the second, etc.

Wait... aren't word sizes usually 4? how come the 2nd number isn't 0x4(%ebp)?

 

by: errangPosted on 2009-04-28 at 01:36:29ID: 24248655

maybe... I should sleep for a bit.. my mind starts to get a lil jumpy around 4:36 am... lol =(

 

by: Infinity08Posted on 2009-04-28 at 02:09:49ID: 24248832

>> so that call to bomb under jump was just to trick us, right?

No, it's not. As i said earlier, this jump instruction jumps to that line :

>>  8051a4f:       77 3c                   ja     8051a8d <phase_3+0x70>


>> >>Don't jump ahead. First know what you're dealing with. Where are the two numbers that the user gave ?
>> They would be in... 8051a36:       ff 75 08                pushl  0x8(%ebp), correct?

No. I already told you that that's NOT the numbers - it is the FIRST parameter of fscanf. What you are looking for are the parameters after the format. See here : http:#24248324

It's a bit hard if I have to repeat everything several times ;)

 

by: errangPosted on 2009-04-28 at 12:43:56ID: 24254448

hm... ok

 8051a21:       83 ec 14                sub    $0x14,%esp
 8051a3e:       83 c4 10                add    $0x10,%esp

>>Good. You know you need two numbers. You just need to know where they are stored in memory (on the stack) ;)

those 2 statements leave a difference of 4... so the values the user enters are in that space?

But if they are... those values aren't getting moved to anything.. right? So what are they getting compared to?

 

by: Infinity08Posted on 2009-04-28 at 12:51:19ID: 24254518

Please re-read the last few lines of my previous post ...

 

by: errangPosted on 2009-04-28 at 13:05:58ID: 24254665

>>No. I already told you that that's NOT the numbers - it is the FIRST parameter of fscanf. What you are looking for are the parameters after the format. See here : http:#24248324

Those? But you said the numbers were on the stack...

And.. 8051a31:       68 7e 23 05 08          push   $0x805237e gets pushed onto the stack?

fscanf (pFile, "%f", &f);... so... the numbers are right after 0x805237e gets pushed onto the stack?

 

by: errangPosted on 2009-04-28 at 13:29:13ID: 24254792

wait... the stack is different from regular registers.. right? so each offset of the stack can store its values?

 8051a21:       83 ec 14                sub    $0x14,%esp
 8051a3e:       83 c4 10                add    $0x10,%esp

like I said in my previous post... there is a difference of 4 after those instructions are carried out... so, according to fscanf (pFile, "%f", &f); (which I got from the link you gave me), first variable is the file, 2nd the format, and the 3rd and 4th are the numbers?

It... kinda fits, right?

 

by: Infinity08Posted on 2009-04-28 at 13:52:49ID: 24255018

>> first variable is the file, 2nd the format, and the 3rd and 4th are the numbers?

Yes, so which ones are the numbers ?

The sub and add have nothing to do with it. If a function takes 4 parameters, then those 4 parameters are pushed onto the stack (in reverse order) before the function is called.

 

by: errangPosted on 2009-04-28 at 14:05:12ID: 24255130

>>The sub and add have nothing to do with it. If a function takes 4 parameters, then those 4 parameters are pushed onto the stack (in reverse order) before the function is called.

Uh... could you please explain that?

 

by: errangPosted on 2009-04-28 at 14:08:33ID: 24255157

If the sub and add have nothing to do with it... where are they getting stored? in ebp?

 

by: errangPosted on 2009-04-28 at 14:13:40ID: 24255209

hm... it couldn't be in eax... could it?

8051a29:       8d 45 f8                lea    0xfffffff8(%ebp),%eax
 8051a2c:       50                      push   %eax
 8051a2d:       8d 45 f4                lea    0xfffffff4(%ebp),%eax
 8051a30:       50                      push   %eax

???

 

by: Infinity08Posted on 2009-04-28 at 14:19:44ID: 24255268

>> Uh... could you please explain that?

Explain what ? Which part of that phrase wasn't clear ?


>> in ebp?

If you read back through all your threads about this, you'll find that it has been explained several times already that ebp is the base pointer, which points to the start of the current stack frame. It would make no sense to save a number in there.


>> hm... it couldn't be in eax... could it?

Again, if you read back, you'll find an explanation of how the lea instruction works ...

 

by: errangPosted on 2009-04-28 at 14:27:20ID: 24255329

>>Explain what ? Which part of that phrase wasn't clear ?

You said that the numbers got pushed onto the stack in reverse order before the function was called... so how come sub and add don't have anything to do with it?

When I was doing phase 2... I thought you said subtracting the esp was the same as allocating memory?

 

by: errangPosted on 2009-04-28 at 14:30:27ID: 24255354

>>Again, if you read back, you'll find an explanation of how the lea instruction works ..

LEA Load effective address LEA Dest,Source Dest := address of Source

It calculates the address and stores it in the register... right?

 

by: Infinity08Posted on 2009-04-28 at 14:44:59ID: 24255471

>> I thought you said subtracting the esp was the same as allocating memory?

Yes, but we're looking for the numbers now, not for a block of allocated memory.

>> It calculates the address and stores it in the register... right?

Yes, so ... continue that thought.

 

by: errangPosted on 2009-04-28 at 14:49:56ID: 24255509

Am I right here?

 08051a1d <phase_3>:
 8051a1d:       55                      push   %ebp
 8051a1e:       89 e5                   mov    %esp,%ebp
 8051a20:       53                      push   %ebx

---------------------------------------------------------
Just pushing registers onto the stack, so far:
ebp = esp
ebx on the stack
---------------------------------------------------------

 8051a21:       83 ec 14                sub    $0x14,%esp

---------------------------------------------------------
esp - 14
---------------------------------------------------------

 8051a24:       bb 00 00 00 00          mov    $0x0,%ebx

---------------------------------------------------------
ebx = 0
---------------------------------------------------------

 8051a29:       8d 45 f8                lea    0xfffffff8(%ebp),%eax
 8051a2c:       50                      push   %eax

---------------------------------------------------------
new address loaded into eax and eax is pushed onto the stack
---------------------------------------------------------

 8051a2d:       8d 45 f4                lea    0xfffffff4(%ebp),%eax
 8051a30:       50                      push   %eax

---------------------------------------------------------
new address loaded into eax and eax is pushed onto the stack
---------------------------------------------------------

 8051a31:       68 7e 23 05 08          push   $0x805237e
 8051a36:       ff 75 08                pushl  0x8(%ebp)

---------------------------------------------------------
$0x805237e and 0x8(%ebp) are pushed onto the stack
---------------------------------------------------------

 8051a39:       e8 1a fb ff ff          call   8051558 <_PROCEDURE_LINKAGE_TABLE_+0xb0>
 8051a3e:       83 c4 10                add    $0x10,%esp

---------------------------------------------------------
there's a call to <procedure_linkage_table>, that has nothing to do with this answer, tho right?
esp + 10
---------------------------------------------------------

 8051a41:       83 f8 01                cmp    $0x1,%eax
 8051a44:       7f 05                   jg     8051a4b <phase_3+0x2e>
 8051a46:       e8 61 07 00 00          call   80521ac <explode_bomb>

---------------------------------------------------------
As you had corrected... if 1 is greater than eax, so eax needs to be < 1?
---------------------------------------------------------

 8051a4b:       83 7d f4 07             cmpl   $0x7,0xfffffff4(%ebp)
 8051a4f:       77 3c                   ja     8051a8d <phase_3+0x70>

---------------------------------------------------------
I'm going to assume cmpl works the same way as cmp... so,
if $0x7 is greater than 0xfffffff4(%ebp), the jump will take place?
---------------------------------------------------------

 8051a51:       8b 45 f4                mov    0xfffffff4(%ebp),%eax
 8051a54:       ff 24 85 bc 22 05 08    jmp    *0x80522bc(,%eax,4)

---------------------------------------------------------
eax = 0xfffffff4(%ebp)
and an unconditional jump takes place
---------------------------------------------------------

 8051a5b:       81 c3 a9 01 00 00       add    $0x1a9,%ebx
 8051a61:       81 eb 7d 01 00 00       sub    $0x17d,%ebx
 8051a67:       81 c3 82 00 00 00       add    $0x82,%ebx
 8051a6d:       81 eb 69 02 00 00       sub    $0x269,%ebx
 8051a73:       81 c3 27 01 00 00       add    $0x127,%ebx
 8051a79:       81 eb b8 02 00 00       sub    $0x2b8,%ebx
 8051a7f:       81 c3 b8 02 00 00       add    $0x2b8,%ebx
 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx
 8051a8b:       eb 05                   jmp    8051a92 <phase_3+0x75>
 8051a8d:       e8 1a 07 00 00          call   80521ac <explode_bomb>

---------------------------------------------------------
A huge mess of calculations, and then an unconditional jump.
---------------------------------------------------------

 8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp)
 8051a96:       7f 05                   jg     8051a9d <phase_3+0x80>

---------------------------------------------------------
if 5 greater than 0xfffffff4(%ebp), the jump would take place?
---------------------------------------------------------

 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx
 8051a9b:       74 05                   je     8051aa2 <phase_3+0x85>

---------------------------------------------------------
that jump will only take place if 0xfffffff8(%ebp) and %ebx are equal
---------------------------------------------------------

 8051a9d:       e8 0a 07 00 00          call   80521ac <explode_bomb>
 8051aa2:       8b 5d fc                mov    0xfffffffc(%ebp),%ebx

---------------------------------------------------------
so... ebx is a return value?
---------------------------------------------------------

 8051aa5:       c9                      leave
 8051aa6:       c3                      ret

 

by: errangPosted on 2009-04-28 at 14:55:55ID: 24255550

>>Yes, so ... continue that thought.

Uh... continue what now?

>>If you read back through all your threads about this, you'll find that it has been explained several times already that ebp is the base pointer, which points to the start of the current stack frame. It would make no sense to save a number in there.

The only place lea used is:

 8051a29:       8d 45 f8                lea    0xfffffff8(%ebp),%eax
 8051a2c:       50                      push   %eax
 8051a2d:       8d 45 f4                lea    0xfffffff4(%ebp),%eax
 8051a30:       50                      push   %eax

are you saying that we calculate that number with 8051a1d being ebp?

 

by: errangPosted on 2009-04-28 at 15:01:18ID: 24255594

so... you are saying that the numbers aren't stored at ebx... but they are stored at these addresses?
0xfffffff8(%ebp) and 0xfffffff4(%ebp)???

 

by: Infinity08Posted on 2009-04-28 at 15:04:39ID: 24255618

>> there's a call to <procedure_linkage_table>, that has nothing to do with this answer, tho right?

That's the call to fscanf ... The one we've been talking about all along ... So, it most certainly has got something to do with the "answer" ;)


>> The only place lea used is:

Yes ... And we were looking for the locations of the two numbers ... So ...

 

by: Infinity08Posted on 2009-04-28 at 15:06:17ID: 24255632

>> but they are stored at these addresses? 0xfffffff8(%ebp) and 0xfffffff4(%ebp)???

Now we're getting somewhere :) So, the two numbers will be in 0xfffffff8(%ebp) and 0xfffffff4(%ebp) resp. The rest of the phase_3 function (after the fscanf call) will use these two numbers, and will check their values to see if they are correct.

So, just follow what's happening, starting just after the fscanf call ...

 

by: errangPosted on 2009-04-28 at 15:10:56ID: 24255665

uhm... could I get a little more help mere? after the fscanf call... there's just the

 8051a3e:       83 c4 10                add    $0x10,%esp
 8051a41:       83 f8 01                cmp    $0x1,%eax

And...
 8051a29:       8d 45 f8                lea    0xfffffff8(%ebp),%eax
 8051a2c:       50                      push   %eax
 8051a2d:       8d 45 f4                lea    0xfffffff4(%ebp),%eax
 8051a30:       50                      push   %eax

I can see that eax gets pushed onto the stack... but what is going on here?

 

by: errangPosted on 2009-04-28 at 15:14:22ID: 24255692

hm... could you please tell me what 8051a54:       ff 24 85 bc 22 05 08    jmp    *0x80522bc(,%eax,4) is doing?

 

by: errangPosted on 2009-04-28 at 15:16:24ID: 24255699

>>Now we're getting somewhere :) So, the two numbers will be in 0xfffffff8(%ebp) and 0xfffffff4(%ebp) resp. The rest of the phase_3 function (after the fscanf call) will use these two numbers, and will check their values to see if they are correct.

Ok... but what does it check those numbers against?

I can see one of them is here... cmp    0xfffffff8(%ebp),%ebx

But where is the other one??

 

by: errangPosted on 2009-04-28 at 15:25:53ID: 24255769

please help me out.. its due in about 5 hours.. and I got class in.. 35 mins =(

 

by: errangPosted on 2009-04-28 at 15:27:46ID: 24255786

Are these the 2 numbers that are getting compared????

 8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp)
 8051a96:       7f 05                   jg     8051a9d <phase_3+0x80>
 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx
 8051a9b:       74 05                   je     8051aa2 <phase_3+0x85>

They certainly fit the addresses...

 

by: errangPosted on 2009-04-28 at 15:29:26ID: 24255798

the first number has to be less than 5:
cmpl   $0x5,0xfffffff4(%ebp)

And the second one has to be equal to %ebx

Correct??

I know it kinda does sound like what I've been going on about from the start... but

>>Now we're getting somewhere :) So, the two numbers will be in 0xfffffff8(%ebp) and 0xfffffff4(%ebp) resp. The rest of the phase_3 function (after the fscanf call) will use these two numbers, and will check their values to see if they are correct.

???

 

by: Infinity08Posted on 2009-04-28 at 15:30:00ID: 24255803

>> Ok... but what does it check those numbers against?

That's what you need to find out next. Now that you know where the numbers are, you can easily follow the code along.

Follow the code line by line, and see what happens with those two numbers.

This is the part you're looking at now :

 8051a4b:       83 7d f4 07             cmpl   $0x7,0xfffffff4(%ebp)
 8051a4f:       77 3c                   ja     8051a8d <phase_3+0x70>
 8051a51:       8b 45 f4                mov    0xfffffff4(%ebp),%eax
 8051a54:       ff 24 85 bc 22 05 08    jmp    *0x80522bc(,%eax,4)
 8051a5b:       81 c3 a9 01 00 00       add    $0x1a9,%ebx
 8051a61:       81 eb 7d 01 00 00       sub    $0x17d,%ebx
 8051a67:       81 c3 82 00 00 00       add    $0x82,%ebx
 8051a6d:       81 eb 69 02 00 00       sub    $0x269,%ebx
 8051a73:       81 c3 27 01 00 00       add    $0x127,%ebx
 8051a79:       81 eb b8 02 00 00       sub    $0x2b8,%ebx
 8051a7f:       81 c3 b8 02 00 00       add    $0x2b8,%ebx
 8051a85:       81 eb da 03 00 00       sub    $0x3da,%ebx
 8051a8b:       eb 05                   jmp    8051a92 <phase_3+0x75>
 8051a8d:       e8 1a 07 00 00          call   80521ac <explode_bomb>
 8051a92:       83 7d f4 05             cmpl   $0x5,0xfffffff4(%ebp)
 8051a96:       7f 05                   jg     8051a9d <phase_3+0x80>
 8051a98:       3b 5d f8                cmp    0xfffffff8(%ebp),%ebx
 8051a9b:       74 05                   je     8051aa2 <phase_3+0x85>
 8051a9d:       e8 0a 07 00 00          call   80521ac <explode_bomb>

What does the first line do ? Once you know what it does, check the second line, etc.

 

by: errangPosted on 2009-04-28 at 15:33:43ID: 24255834

The first line checks if 7 is greater than that offset of ebp (i'm not sure if its the first or 2nd, please help me out here)

2nd line jumps if 7 is greater than that offset of ebp

3rd line moves that offset of ebp into eax

4th, I've asked this several times, I'm not sure what this does exactly, I'm guessing its a call to a function pointer...

5-12, adds and subtracts various values into ebx

13, unconditional jump

the next 4 lines refer to my previous post http:#24255786

 

by: Infinity08Posted on 2009-04-28 at 15:39:47ID: 24255878

>> 4th, I've asked this several times, I'm not sure what this does exactly, I'm guessing its a call to a function pointer...

The best way to understand this is to use your debugger. You'll need it to find out what's at address 0x80522bc, but you also use it to follow the flow of the code ...

The other lines, you seem to understand.

Now it's just a matter of taking a step back, looking at these few instructions, and what they do, and finding out what two numbers the code expects ...

 

by: Infinity08Posted on 2009-04-28 at 15:41:09ID: 24255890

I need to go get some sleep now, but I'll be back tomorrow.

 

by: errangPosted on 2009-04-30 at 02:27:10ID: 24268094

after some trial and error, I did manage to get this phase =)

The final answer was 0 and -1134 =)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...