Question

Binary Bomb Phase 2

Asked by: ruevaughn

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 extract that string into an array of integers.

If the string I have entered is equal to six, it will jump back to phase_2, correct?

Once in phase_2, it will check using a loop to see if my int[x] = the correct int, and that is being checked at  8048f81:       39 c3                   cmp    %eax,%ebx, correct?

Now my question is, how am I able to find what numbers it's checking for?

Any help would be appreciated, thanks in advance!

08048f41 <phase_2>:
 8048f41:       55                        push   %ebp
 8048f42:       89 e5                   mov    %esp,%ebp
 8048f44:       83 ec 38              sub    $0x38,%esp
 8048f47:       89 5d f4                mov    %ebx,-0xc(%ebp)
 8048f4a:       89 75 f8                mov    %esi,-0x8(%ebp)
 8048f4d:       89 7d fc                mov    %edi,-0x4(%ebp)
 8048f50:       8d 45 dc                lea    -0x24(%ebp),%eax
 8048f53:       89 44 24 04             mov    %eax,0x4(%esp)
 8048f57:       8b 45 08                mov    0x8(%ebp),%eax
 8048f5a:       89 04 24                mov    %eax,(%esp)
 8048f5d:       e8 5e 04 00 00          call   80493c0 <read_six_numbers>
 8048f62:       bf 00 00 00 00          mov    $0x0,%edi
 8048f67:       8d 5d e8                lea    -0x18(%ebp),%ebx
 8048f6a:       89 de                   mov    %ebx,%esi
 8048f6c:       8b 43 f4                mov    -0xc(%ebx),%eax
 8048f6f:       3b 03                   cmp    (%ebx),%eax
 8048f71:       74 05                   je     8048f78 <phase_2+0x37>
 8048f73:       e8 06 04 00 00          call   804937e <explode_bomb>
 8048f78:       03 7e f4                add    -0xc(%esi),%edi
 8048f7b:       83 c3 04                add    $0x4,%ebx
 8048f7e:       8d 45 f4                lea    -0xc(%ebp),%eax
 8048f81:       39 c3                   cmp    %eax,%ebx
 8048f83:       75 e5                   jne    8048f6a <phase_2+0x29>
 8048f85:       85 ff                   test   %edi,%edi
 8048f87:       75 05                   jne    8048f8e <phase_2+0x4d>
 8048f89:       e8 f0 03 00 00          call   804937e <explode_bomb>
 8048f8e:       8b 5d f4                mov    -0xc(%ebp),%ebx
 8048f91:       8b 75 f8                mov    -0x8(%ebp),%esi
 8048f94:       8b 7d fc                mov    -0x4(%ebp),%edi
 8048f97:       89 ec                   mov    %ebp,%esp
 8048f99:       5d                      pop    %ebp
 8048f9a:       c3                      ret
 
080493c0 <read_six_numbers>:
 80493c0:       55                      push   %ebp
 80493c1:       89 e5                   mov    %esp,%ebp
 80493c3:       83 ec 28                sub    $0x28,%esp
 80493c6:       8b 55 0c                mov    0xc(%ebp),%edx
 80493c9:       8d 42 14                lea    0x14(%edx),%eax
 80493cc:       89 44 24 1c             mov    %eax,0x1c(%esp)
 80493d0:       8d 42 10                lea    0x10(%edx),%eax
 80493d3:       89 44 24 18             mov    %eax,0x18(%esp)
 80493d7:       8d 42 0c                lea    0xc(%edx),%eax
 80493da:       89 44 24 14             mov    %eax,0x14(%esp)
 80493de:       8d 42 08                lea    0x8(%edx),%eax
 80493e1:       89 44 24 10             mov    %eax,0x10(%esp)
 80493e5:       8d 42 04                lea    0x4(%edx),%eax
 80493e8:       89 44 24 0c             mov    %eax,0xc(%esp)
 80493ec:       89 54 24 08             mov    %edx,0x8(%esp)
 80493f0:       c7 44 24 04 79 9c 04    movl   $0x8049c79,0x4(%esp)
 80493f7:       08
 80493f8:       8b 45 08                mov    0x8(%ebp),%eax
 80493fb:       89 04 24                mov    %eax,(%esp)
 80493fe:       e8 35 f5 ff ff          call   8048938 <sscanf@plt>
 8049403:       83 f8 05                cmp    $0x5,%eax
 8049406:       7f 05                   jg     804940d <read_six_numbers+0x4d>
 8049408:       e8 71 ff ff ff          call   804937e <explode_bomb>
 804940d:       c9                      leave
 804940e:       89 f6                   mov    %esi,%esi
 8049410:       c3                      ret

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:

Select allOpen in new window

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-01-31 at 19:13:05ID24102132
Tags

machine language

Topic

Assembly Programming Language

Participating Experts
1
Points
500
Comments
8

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. 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 $...
  2. Binary Bomb Phase 5
    Infinity08 your comments are really helping me understand this better. Could you please let me know if what I wrote is going on here is correct. I can't seem to figure out exactly what this wants, except know it wants a string that is length 6. Thanks again Dump of assemb...
  3. Binary Bomb Final Phase
    Alright, on the last phase of the binary bomb. I have the code commented and just wanted to know if what I think is happening really is. So far I just think it is a bunch of nested loops and that the input will be 5 or less numbers. Alright any feedback would be very appre...
  4. 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....
  5. Buffer Bomb Phase 0
    Hello again! I am starting the Buffer Bomb. Where to get started? I understand the buffer overflow concept, but was wondering if you could point me in the right direction! This is something odd, i'm pretty sure it's important. But... where do I go from here? 8048f93: 3d ef...
  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: Infinity08Posted on 2009-02-01 at 01:54:43ID: 23520745

>>  From what I understand, the the function call read_six_numbers will take in my entered string (six numbers with spaces) and scanf will extract that string into an array of integers.

Correct. It will place those 6 integer values on the stack at the address that was passed to read_six_numbers as second parameter.


>> If the string I have entered is equal to six, it will jump back to phase_2, correct?

If the string you entered contains at least 6 integer values, then the code flow will return to phase_2 (right after the read_six_numbers function call) :

>>  8049403:       83 f8 05                cmp    $0x5,%eax

sscanf returns the number of correctly read integer values, and if that amount is greater than 5, we leave the read_six_numbers function. If not, the bomb explodes.


>> Once in phase_2, it will check using a loop to see if my int[x] = the correct int

That's right.


>> and that is being checked at  8048f81:       39 c3                   cmp    %eax,%ebx, correct?

No, that's the loop condition :

>>  8048f81:       39 c3                   cmp    %eax,%ebx
>>  8048f83:       75 e5                   jne    8048f6a <phase_2+0x29>

as long as eax is not equal to ebx, the loop will continue.

The check happens after the loop has finished :

>>  8048f85:       85 ff                   test   %edi,%edi
>>  8048f87:       75 05                   jne    8048f8e <phase_2+0x4d>
>>  8048f89:       e8 f0 03 00 00          call   804937e <explode_bomb>

You have to make sure that that jump is made, otherwise the bomb will explode.

Note that there's also a possibility for the bomb to explode inside the loop body. You have to avoid that too, obviously.


>> Now my question is, how am I able to find what numbers it's checking for?

You have to look at what the loop is doing exactly. It's taking some input (including the six numbers you entered), and performs some calculations on it.

Here's the complete loop :

 8048f62:       bf 00 00 00 00          mov    $0x0,%edi                                     \  initialization
 8048f67:       8d 5d e8                lea    -0x18(%ebp),%ebx                            /
 8048f6a:       89 de                   mov    %ebx,%esi                                         \
 8048f6c:       8b 43 f4                mov    -0xc(%ebx),%eax                               |
 8048f6f:       3b 03                   cmp    (%ebx),%eax                                       |
 8048f71:       74 05                   je     8048f78 <phase_2+0x37>                    |  loop body
 8048f73:       e8 06 04 00 00          call   804937e <explode_bomb>             |
 8048f78:       03 7e f4                add    -0xc(%esi),%edi                                 |
 8048f7b:       83 c3 04                add    $0x4,%ebx                                         |
 8048f7e:       8d 45 f4                lea    -0xc(%ebp),%eax                               /
 8048f81:       39 c3                   cmp    %eax,%ebx                                         \  loop condition
 8048f83:       75 e5                   jne    8048f6a <phase_2+0x29>                   /

Concentrate on what it's doing by following the logic. Take note of the contents of every register while you follow through one instruction at a time. You'll soon notice a pattern, and that should make things clearer ;)


I'll be here if you have further questions. Give it a try, and see whether you can figure it out :)

 

by: ruevaughnPosted on 2009-02-01 at 16:16:32ID: 23523691

Ok thanks, Do you have suggestions of commands to take note of the contents of the register? Currently i'm using the x /s <register> command.

 

by: ruevaughnPosted on 2009-02-01 at 20:52:42ID: 23524423

Ok, from what it looks like the line
8048f78:       03 7e f4                add    -0xc(%esi),%edi                                 |
is pushing the stack down 3 to make room for edi,

and then 8048f7b:       83 c3 04                add    $0x4,%ebx                                         |
will add the literal value 4 to ebx,

So I get that this is a loop that will be executed while i (%eax) is less than 6 (%ebx).
This loop will increment the value to check by four every time, and continue to push the stack lower for more room. so %ebx must be the value that holds the correct number, and int is stored in the register %esi, right?

The loop will increment my value by 4 every time, but how do I come up with the original value? I would assume eax...

 

by: Infinity08Posted on 2009-02-02 at 02:01:59ID: 23525506

>> Ok thanks, Do you have suggestions of commands to take note of the contents of the register? Currently i'm using the x /s <register> command.

x/s shows the string at a given memory address.

If you want to see the contents of a register, you can use 'p/x name_of_the_register'  (or any other format instead of x, depending on what the register contains).


>> Ok, from what it looks like the line
>> 8048f78:       03 7e f4                add    -0xc(%esi),%edi                                 |
>> is pushing the stack down 3 to make room for edi,

Not really. That instruction simply gets the contents of a memory location, and adds it to %edi. The memory location in question is (%esi - 0xc).


>> So I get that this is a loop that will be executed while i (%eax) is less than 6 (%ebx).

Does %ebx contain 6 ? Look closer. Where is %ebx set before the loop body ? What is it set to ? How is it modified inside the loop body ? What's the condition for the loop to continue ?


Look at the entire function. First figure out where on the stack your 6 integers can be found (after the call to read_six_numbers). Also find out what the rest of the stack contains. Once you have that, you can start advancing one instruction at a time. Take careful note of how the registers change while you work through the code.

 

by: ruevaughnPosted on 2009-02-02 at 12:44:18ID: 23531126

Great, got it! Thanks, I will attempt to complete phase 3. Should I continue on this thread if I have a question?

 

by: Infinity08Posted on 2009-02-02 at 13:22:17ID: 23531519

I don't mind ;)

 

by: ruevaughnPosted on 2009-02-02 at 16:55:20ID: 23533206

Thanks again, okay so I know that phase three needs three parameters, '%d, %a, %d'. That would be a decimal, ascii, decimal. I think this is a switch statement, and the statement parameters are between 3 and 7. So when I enter three, I think I go down to this line,

 8048e60:       81 7d f8 14 02 00 00    cmpl   $0x214,-0x8(%ebp)
 8048e67:       0f 84 c5 00 00 00       je     8048f32 <phase_3+0x121>

But I can't figure out how to make this jump.

Any Suggestions? Or where to look for my ascii character?

You've been great so far, Thanks! You have no idea how much you've helped me out. I was SO frustrated.

08048e11 <phase_3>:
 8048e11:       55                      push   %ebp
 8048e12:       89 e5                   mov    %esp,%ebp
 8048e14:       83 ec 28                sub    $0x28,%esp
 8048e17:       8d 45 f8                lea    -0x8(%ebp),%eax
 8048e1a:       89 44 24 10             mov    %eax,0x10(%esp)
 8048e1e:       8d 45 f7                lea    -0x9(%ebp),%eax
 8048e21:       89 44 24 0c             mov    %eax,0xc(%esp)
 8048e25:       8d 45 fc                lea    -0x4(%ebp),%eax
 8048e28:       89 44 24 08             mov    %eax,0x8(%esp)
 8048e2c:       c7 44 24 04 7d 9a 04    movl   $0x8049a7d,0x4(%esp)
 8048e33:       08
 8048e34:       8b 45 08                mov    0x8(%ebp),%eax
 8048e37:       89 04 24                mov    %eax,(%esp)
 8048e3a:       e8 f9 fa ff ff          call   8048938 <sscanf@plt>
 8048e3f:       83 f8 02                cmp    $0x2,%eax
 8048e42:       7f 05                   jg     8048e49 <phase_3+0x38>
 8048e44:       e8 35 05 00 00          call   804937e <explode_bomb>
 8048e49:       83 7d fc 07             cmpl   $0x7,-0x4(%ebp)
 8048e4d:       8d 76 00                lea    0x0(%esi),%esi
 8048e50:       0f 87 c5 00 00 00       ja     8048f1b <phase_3+0x10a>
 8048e56:       8b 45 fc                mov    -0x4(%ebp),%eax
 8048e59:       ff 24 85 a0 9a 04 08    jmp    *0x8049aa0(,%eax,4)
 8048e60:       81 7d f8 14 02 00 00    cmpl   $0x214,-0x8(%ebp)
 8048e67:       0f 84 c5 00 00 00       je     8048f32 <phase_3+0x121>
 8048e6d:       8d 76 00                lea    0x0(%esi),%esi
 8048e70:       e8 09 05 00 00          call   804937e <explode_bomb>
 8048e75:       b0 6b                   mov    $0x6b,%al
 8048e77:       e9 b8 00 00 00          jmp    8048f34 <phase_3+0x123>
 8048e7c:       81 7d f8 bd 02 00 00    cmpl   $0x2bd,-0x8(%ebp)
 8048e83:       0f 84 a0 00 00 00       je     8048f29 <phase_3+0x118>
 8048e89:       8d b4 26 00 00 00 00    lea    0x0(%esi),%esi
 8048e90:       e8 e9 04 00 00          call   804937e <explode_bomb>
 8048e95:       b0 65                   mov    $0x65,%al
 8048e97:       e9 98 00 00 00          jmp    8048f34 <phase_3+0x123>
 8048e9c:       81 7d f8 83 03 00 00    cmpl   $0x383,-0x8(%ebp)
 8048ea3:       0f 84 89 00 00 00       je     8048f32 <phase_3+0x121>
 8048ea9:       8d b4 26 00 00 00 00    lea    0x0(%esi),%esi
 8048eb0:       e8 c9 04 00 00          call   804937e <explode_bomb>
 8048eb5:       b0 6b                   mov    $0x6b,%al
 8048eb7:       eb 7b                   jmp    8048f34 <phase_3+0x123>
 8048eb9:       b0 77                   mov    $0x77,%al
 8048ebb:       81 7d f8 97 02 00 00    cmpl   $0x297,-0x8(%ebp)
 8048ec2:       74 70                   je     8048f34 <phase_3+0x123>
 8048ec4:       e8 b5 04 00 00          call   804937e <explode_bomb>
 8048ec9:       b0 77                   mov    $0x77,%al
 8048ecb:       eb 67                   jmp    8048f34 <phase_3+0x123>
 8048ecd:       81 7d f8 e7 00 00 00    cmpl   $0xe7,-0x8(%ebp)
 8048ed4:       74 57                   je     8048f2d <phase_3+0x11c>
 8048ed6:       e8 a3 04 00 00          call   804937e <explode_bomb>
 8048edb:       b0 68                   mov    $0x68,%al
 8048edd:       8d 76 00                lea    0x0(%esi),%esi
 8048ee0:       eb 52                   jmp    8048f34 <phase_3+0x123>
 8048ee2:       b0 6c                   mov    $0x6c,%al
 8048ee4:       83 7d f8 66             cmpl   $0x66,-0x8(%ebp)
 8048ee8:       74 4a                   je     8048f34 <phase_3+0x123>
 8048eea:       e8 8f 04 00 00          call   804937e <explode_bomb>
 8048eef:       b0 6c                   mov    $0x6c,%al
 8048ef1:       eb 41                   jmp    8048f34 <phase_3+0x123>
 8048ef3:       81 7d f8 95 01 00 00    cmpl   $0x195,-0x8(%ebp)
 8048efa:       74 31                   je     8048f2d <phase_3+0x11c>
 8048efc:       8d 74 26 00             lea    0x0(%esi),%esi
 8048f00:       e8 79 04 00 00          call   804937e <explode_bomb>
 8048f05:       b0 68                   mov    $0x68,%al
 8048f07:       eb 2b                   jmp    8048f34 <phase_3+0x123>
 8048f09:       81 7d f8 d8 00 00 00    cmpl   $0xd8,-0x8(%ebp)
 8048f10:       74 17                   je     8048f29 <phase_3+0x118>
 8048f12:       e8 67 04 00 00          call   804937e <explode_bomb>
 8048f17:       b0 65                   mov    $0x65,%al
 8048f19:       eb 19                   jmp    8048f34 <phase_3+0x123>
 8048f1b:       90                      nop
 8048f1c:       8d 74 26 00             lea    0x0(%esi),%esi
 8048f20:       e8 59 04 00 00          call   804937e <explode_bomb>
 8048f25:       b0 7a                   mov    $0x7a,%al
 8048f27:       eb 0b                   jmp    8048f34 <phase_3+0x123>
 8048f29:       b0 65                   mov    $0x65,%al
 8048f2b:       eb 07                   jmp    8048f34 <phase_3+0x123>
 8048f2d:       b0 68                   mov    $0x68,%al
 8048f2f:       90                      nop
 8048f30:       eb 02                   jmp    8048f34 <phase_3+0x123>
 8048f32:       b0 6b                   mov    $0x6b,%al
 8048f34:       3a 45 f7                cmp    -0x9(%ebp),%al
 8048f37:       74 05                   je     8048f3e <phase_3+0x12d>
 8048f39:       e8 40 04 00 00          call   804937e <explode_bomb>
 8048f3e:       c9                      leave
 8048f3f:       90                      nop
 8048f40:       c3                      ret
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:

Select allOpen in new window

 

by: Infinity08Posted on 2009-02-03 at 01:54:40ID: 23535560

>> '%d, %a, %d'. That would be a decimal, ascii, decimal.

%a in C99 is for a floating point value, not an ascii value. But it could be that the compiler that your runtime library interprets it differently. Check your system documentation to be sure. From the code, it seems that you're right, but that would be a non-C99 implementation.

I assume that that was the format string you found at memory location 0x8049a7d ?


>> I think this is a switch statement, and the statement parameters are between 3 and 7.

It gets a value, and depending on that value, it jumps to a different location. So, yes, that looks like a switch ;)
I'm not sure why you say it has to be at least 3 though ... The only limitation on the first value entered by the user is this one :

 8048e49:       83 7d fc 07             cmpl   $0x7,-0x4(%ebp)

Maybe you confused with this one ?

 8048e3f:       83 f8 02                cmp    $0x2,%eax
 8048e42:       7f 05                   jg     8048e49 <phase_3+0x38>

which checks the return value of sscanf.



>> So when I enter three, I think I go down to this line,

The jump is performed by this piece of code :

 8048e56:       8b 45 fc                mov    -0x4(%ebp),%eax
 8048e59:       ff 24 85 a0 9a 04 08    jmp    *0x8049aa0(,%eax,4)

So, when the first value entered by the user is 3, the code jumps to the address present at (0x8049aa0 + 4 * 3) which is 0x8049aac.
Note that 0x8049aa0 is the base address of an array of memory addresses. One of the values is picked from this array depending on the value entered by the user. Which address, you'll have to find out by looking at the contents of memory location 0x8049aac.


>> But I can't figure out how to make this jump.

Remember that -0x8(%ebp) contains the third value entered by the user.

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...