4.7 KiB
Embedded Systems Reverse Engineering
Week 1
Introduction and Overview of Embedded Reverse Engineering: Ethics, Scoping, and Basic Concepts
Non-Credit Practice Exercise 1: Explore in Ghidra
Objective
Learn how to navigate Ghidra's Symbol Tree to find and analyze functions, specifically examining the stdio_init_all function.
Prerequisites
- Ghidra installed and running
0x0001_hello-worldproject already created and imported in Ghidra- The
0x0001_hello-world.elffile already imported and analyzed
Task Description
Your goal is to explore the stdio_init_all function in Ghidra and understand what it does based on:
- Its decompiled code
- The functions it calls
- The variables it accesses
Step-by-Step Instructions
Step 1: Open Your Ghidra Project
- Launch Ghidra on your computer
- In the Ghidra Project Manager window, you should see your
0x0001_hello-worldproject - If you don't see it, create a new project or open an existing one
- Double-click on the project to open it
Step 2: Access the Symbol Tree
In the CodeBrowser window that opens:
- Look at the left side panel - you should see several tabs
- Find and click on the Symbol Tree tab (it might be labeled "Symbol Tree" or showing a tree icon)
- If you don't see it, go to Window → Symbol Tree in the menu
Step 3: Expand the Functions List
- In the Symbol Tree, look for a folder or section labeled Functions
- Click the arrow/triangle next to "Functions" to expand it
- This will show you a list of all the functions that Ghidra identified in the binary
Step 4: Find the stdio_init_all Function
- In the expanded Functions list, scroll through to find
stdio_init_all - Alternative method: If the list is long, you can use Search → For Address or Label from the menu and type
stdio_init_allto jump directly to it - Once you find it, click on it to navigate to that function in the CodeBrowser
Step 5: Examine the Decompiled Code
Once you've navigated to stdio_init_all:
- On the right side of the window, you should see the Decompile view
- This shows the C-like code that Ghidra has reconstructed from the assembly
- Read through the decompiled code carefully
Step 6: Answer These Questions
Based on what you see in the decompiled code, answer the following:
Question 1: What does the function return?
Look at the return type at the top of the function. Is it void, int, bool, or something else?
Question 2: What parameters does it take?
Look at the function signature. Does it take any parameters? (Hint: Look for anything inside the parentheses)
Question 3: What functions does it call?
Look for function calls within stdio_init_all. What other functions does it call? List them:
- Function 1: ________________
- Function 2: ________________
- Function 3: ________________ (There may be more or fewer)
Question 4: What's the purpose?
Based on the functions it calls and the overall structure, what do you think stdio_init_all() is setting up? Think about what "stdio" stands for:
- std = Standard
- io = Input/Output
What types of I/O might be getting initialized?
Step 7: Explore Called Functions (Optional Challenge)
If you want to go deeper:
- In the Decompile view, click on one of the functions that
stdio_init_allcalls - Ghidra will navigate to that function
- Look at what that function does
- Can you build a picture of what's being initialized?
Expected Output
You should be able to write a brief summary like:
stdio_init_all() returns: [your answer]
It takes [number] parameters
It calls the following functions: [list them]
Based on these calls, I believe it initializes: [your analysis]
Questions for Reflection
- Why would we need to initialize standard I/O before using
printf()? - Can you find other functions in the Symbol Tree that might be related to I/O?
- How does this function support the
printf("hello, world\r\n")call in main?
Tips and Hints
- If you see a function name you don't recognize, you can right-click on it to see more options
- The Decompile view is your best friend - it shows you what code is doing in an almost-C format
- Don't worry if some variable names are automatic (like
local_4orparam_1) - that's normal when symbols aren't available - You can collapse/expand sections in the Decompile view by clicking the arrows next to braces
{}
Next Steps
After completing this exercise, you'll have a better understanding of:
- How to navigate Ghidra's interface
- How to find functions using the Symbol Tree
- How to read decompiled code
- How initialization functions work in embedded systems