StackZero
  • Homepage
  • Cryptography and Privacy
  • Ethical Hacking
  • Reverse Engineering
  • Contacts
  • About Me
No Result
View All Result
StackZero
No Result
View All Result

GDB Baby Step 4: Decoding Multiplication in Assembly with GDB

July 10, 2023
in Reverse Engineering
0 0
GDB Baby Step 4: Decoding Multiplication in Assembly with GDB
0
SHARES
1.7k
VIEWS
Share on FacebookShare on Twitter

Welcome to the next stage of our adventure into the fascinating world of GNU Debugger (GDB) – “GDB Baby Step 4: Decoding Multiplication in Assembly with GDB”. This instalment delves deeper into the functional mechanisms of GDB, unravelling how it uncovers operations within program registers. Our focus for this exercise is to identify a specific multiplication constant utilized in a function call, only with a twist: we seek the constant in its decimal form. Ready for the challenge? Let’s dive in.

Table of Contents

Toggle
  • Preceding Steps: Revisiting GDB Baby Steps 1, 2 and 3
  • Stepping Over vs. Stepping Into: The GDB Navigation Basics
  • Getting Ready: Preparing for the Challenge
  • Deciphering the Challenge: GDB Baby Step 4
  • Conclusion

Preceding Steps: Revisiting GDB Baby Steps 1, 2 and 3

Before we take on the Baby Step 4 challenge, a quick recap of our past adventures is in order. Each step of our journey so far – from the introductory lessons of GDB, setting breakpoints, and examining registers to understand program execution flow – has been meticulously preparing us for the task.

GDB Baby Step 1 introduced us to the GDB environment and disassemble executables, Step 2 guided us on examining specific register contents at a function end, and Step 3 steered us towards understanding how memory addresses store values. All these valuable skills will come into play in Baby Step 4. If you missed the previous steps or need a refresher, revisit GDB Baby Step 1, GDB Baby Step 2, and GDB Baby Step 3.

This foundational knowledge will undoubtedly make Baby Step 4 a smoother ride.

If you are really a beginner in reverse engineering, I suggest you start with:

  • Unravelling the Secrets of Reverse Engineering: Practical Applications for In-Depth Analysis
  • A Beginner’s Guide to PicoCTF’s Reverse Engineering: Simple Writeups

Stepping Over vs. Stepping Into: The GDB Navigation Basics

A crucial step in our journey is to understand two fundamental GDB instructions: Step Over” (ni) and “Step Into” (si).
Both commands are about navigating through the program, but they operate differently.

  • “Step Over” (ni) executes the current line of code and stops at the next one
  • “Step Into” (si) digs deeper, entering into functions called by the current line of code.

In other words, ‘ni’ will treat a function call as a single operation, while ‘si’ will take you inside the function for a more detailed analysis. Both instructions are vital for efficient debugging, offering different levels of insight depending on your debugging needs.
And my idea for this article is to take advantage of it to introduce them.

Getting Ready: Preparing for the Challenge

To start off, ensure your Kali virtual machine is running smoothly, and primed for the tasks ahead. Concurrently, be logged into the picoCTF platform, ready to navigate your way through its complex structure to the reverse engineering section. Your destination lies in the ‘GDB Baby Step 4’ challenge.

GDB Baby Step 4 Description

The initial step is to download the file named ‘debugger0_d’ provided within the challenge. This file forms the crux of our journey, so ensure you store it in a working directory you’re comfortable with. Having this file within easy reach will streamline your tasks going forward.

With the setup in place, initiate your terminal right within this working directory. Your stage is set, your tools are prepared, and an enriching experience in the world of GDB debugging awaits you. But, before we get to the actual debugging, let’s extract some preliminary information about our ‘debugger0_d’ file.

Use the command:

 file debugger0_d 

to reveal its nature.

debugger0_d file information

This will return ‘ELF 64-bit LSB, not stripped’. This indicates that the file is a 64-bit binary executable in the ELF format and that it has not been stripped of its debugging information. This valuable insight lays the groundwork for the debugging adventure that is about to unfold.

Deciphering the Challenge: GDB Baby Step 4

Commence your dive into GDB Baby Step 4 by initiating the GDB with the following command:

gdb debugger0_d

Peruse the functions in the program with our trusty command:

info functions

Take a look at the revealed functions:

GDB Baby Step 4 functions list

Main and func1 are the functions that command our attention. The challenge description alludes to a function that multiplies the value of EAX by a constant. This might be our func1.

For a better understanding, let’s run the program and observe the difference between ‘step into’ and ‘step over’ in action.

First, change the disassembly flavour to intel with:

set disassembly-flavour intel

Then, set a breakpoint on the main function with:

break main

Next, enhance the readability of the layout with:

layout asm

Finally, execute the program with:

run

You’ll observe that the execution stops at the main entry point. Use the command:

ni

Followed by the ‘Enter’ key (which repeats the previous command) until you reach the call instruction <main+38>.

GDB Baby Step 4 debugging

If you ‘step over’, the debugger will bypass the call. Hence, we’ll ‘step into’ with:

si

We find ourselves at the entry point of func1. The instruction at <func1+14> is an imul, which we’ve been on the hunt for.

GDB Baby Step 4 mutliplication instruction

The line ‘imul eax, eax, 0x3269’ implies that it multiplies EAX by 0x3269, and stores the result in EAX (first operand).

The number we’ve been searching for is indeed 0x3269. However, the description specifies it requires the decimal base of the constant. So, let’s convert it using gdb’s print command:

print/d 0x3269

The conversion reveals our result: 12905

Convert Hex into Decimal in GDB

With that, we find our flag to be picoCTF{12905}.

Enter it into the input in picoCTF to complete the challenge!

Success is ours.

Conclusion

Congratulations on your successful completion of GDB Baby Step 4! You’ve delved into the depths of GDB and reverse engineering, unravelling the complexities of debugging and acquiring valuable insights along the way.

This marks a milestone in your journey but remember, there’s a vast universe of knowledge that remains unexplored. Stay curious, keep probing, and continue sharpening your skills. The path ahead promises to be more engaging and enlightening as we unravel further mysteries of GDB and reverse engineering together.

I invite you to join us for the upcoming posts on StackZero.net, where we’ll continue our journey. By following us, you’ll stay updated on the latest content and broaden your knowledge on this intriguing subject.

Also, don’t forget to follow our social media profiles. It’s a great way to stay connected, engage in enlightening discussions, and become a part of our thriving community. Your journey into the world of reverse engineering has just begun and we are thrilled to be a part of it.

Remember, every step forward, no matter how small, brings you closer to mastery. Stay tuned, and happy debugging!

Tags: ctfdebugginggdbpico ctfpicoctfreverse engineering
Previous Post

GDB Baby Step 3: Unraveling Debugging Secrets

Next Post

Mastering PicoCTF: Your Ultimate Registration Guide!

Next Post
Mastering PicoCTF: Your Ultimate Registration Guide!

Mastering PicoCTF: Your Ultimate Registration Guide!

You might also like

Cryptographic functions

Cryptographic Hash Functions in Python: Secure Your Data Easily

November 3, 2024
Malware Obfuscation Techniques: All That You Need To Know

Malware Obfuscation Techniques: All That You Need To Know

March 25, 2024
How To Do Process Enumeration: An Alternative Way

How To Do Process Enumeration: An Alternative Way

March 4, 2024
How To Do DLL Injection: An In-Depth Cybersecurity Example

How To Do DLL Injection: An In-Depth Cybersecurity Example

February 8, 2024
Process Injection By Example: The Complete Guide

Process Injection By Example: The Complete Guide

January 24, 2024
How To Build Your Own: Python String Analysis for Malware Insights

How To Build Your Own: Python String Analysis for Malware Insights

November 10, 2023

StackZero

StackZero is a specialized technical blog dedicated to the realm of cybersecurity. It primarily provides insightful articles and comprehensive tutorials designed to educate readers on developing security tools. The blog encompasses a broad spectrum of subjects, starting from the foundational principles of cryptography and extending to more sophisticated areas such as exploitation and reverse engineering. This makes StackZero an invaluable resource for both beginners and professionals in the field of cybersecurity.
The blog covers a wide range of topics, from the basics of cryptography to the more advanced topics of exploitation and reverse engineering.

Tags

application security blind sqli blind sql injection bruteforce c cesar cipher command injection cryptography ctf cybersecurity debugging dom-based xss dvwa ethical-hacking ethical hacking exploitation file inclusion gdb hacking injection javascript malware malware analysis malware evasion network-security pentesting lab picoctf pico ctf python reflected xss reverse engineering sql sqli sql injection static analysis stored xss substitution substitution cipher vulnerable application web application security web exploitation web security windows windows api xss
  • About Me
  • Contacts
  • HomePage
  • Opt-out preferences
  • Privacy Policy
  • Terms and Conditions

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}
No Result
View All Result
  • Homepage
  • Cryptography and Privacy
  • Ethical Hacking
  • Reverse Engineering
  • Contacts
  • About Me