mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-05-22 23:49:41 +02:00
Updated WEEK05
This commit is contained in:
+15
-15
@@ -1,6 +1,6 @@
|
||||
?# Week 6: Static Variables in Embedded Systems: Debugging and Hacking Static Variables w/ GPIO Input Basics
|
||||
# 📘 Week 6: Static Variables in Embedded Systems: Debugging and Hacking Static Variables w/ GPIO Input Basics
|
||||
|
||||
## ? What You'll Learn This Week
|
||||
## 🎯 What You'll Learn This Week
|
||||
|
||||
By the end of this tutorial, you will be able to:
|
||||
- Understand the difference between regular (automatic) variables and static variables
|
||||
@@ -312,7 +312,7 @@ Embedded-Hacking/
|
||||
|
||||
---
|
||||
|
||||
## ? Part 5: Hands-On Tutorial - Static Variables and GPIO Input
|
||||
## 🔧 Part 5: Hands-On Tutorial - Static Variables and GPIO Input
|
||||
|
||||
### Step 1: Review the Source Code
|
||||
|
||||
@@ -422,7 +422,7 @@ This demonstrates unsigned integer overflow!
|
||||
|
||||
---
|
||||
|
||||
## ? Part 6: Debugging with GDB (Dynamic Analysis)
|
||||
## 🐛 Part 6: Debugging with GDB (Dynamic Analysis)
|
||||
|
||||
> ? **REVIEW:** This setup is identical to previous weeks. If you need a refresher on OpenOCD and GDB connection, refer back to Week 3 Part 6.
|
||||
|
||||
@@ -613,7 +613,7 @@ TRY IT!
|
||||
|
||||
---
|
||||
|
||||
## ? Part 7: Understanding the Assembly
|
||||
## 🔬 Part 7: Understanding the Assembly
|
||||
|
||||
Now that we've explored the binary in GDB, let's make sense of the key patterns.
|
||||
|
||||
@@ -720,7 +720,7 @@ This is an **unconditional branch** back to `0x10000264` (the `movs r1, #42` at
|
||||
|
||||
---
|
||||
|
||||
## ? Part 8: Hacking the Binary with a Hex Editor
|
||||
## ✏️ Part 8: Hacking the Binary with a Hex Editor
|
||||
|
||||
Now for the fun part - we'll patch the `.bin` file directly using a hex editor!
|
||||
|
||||
@@ -730,7 +730,7 @@ Now for the fun part - we'll patch the `.bin` file directly using a hex editor!
|
||||
|
||||
1. Open **HxD** (or your preferred hex editor: ImHex, 010 Editor, etc.)
|
||||
2. Click **File** -> **Open**
|
||||
3. Navigate to `C:\Users\assem.KEVINTHOMAS\OneDrive\Documents\Embedded-Hacking\0x0014_static-variables\build\`
|
||||
3. Navigate to `C:\Users\flare-vm\Desktop\Embedded-Hacking-main\0x0014_static-variables\build\`
|
||||
4. Open `0x0014_static-variables.bin`
|
||||
|
||||
### Step 18: Calculate the File Offset
|
||||
@@ -755,7 +755,7 @@ movs r1, #0x2a -> bytes: 2a 21
|
||||
|
||||
To change the value from 42 (`0x2a`) to 43 (`0x2b`):
|
||||
|
||||
1. In HxD, open `C:\Users\assem.KEVINTHOMAS\OneDrive\Documents\Embedded-Hacking\0x0014_static-variables\build\0x0014_static-variables.bin`
|
||||
1. In HxD, open `C:\Users\flare-vm\Desktop\Embedded-Hacking-main\0x0014_static-variables\build\0x0014_static-variables.bin`
|
||||
2. Press **Ctrl+G** (Go to offset)
|
||||
3. Enter offset: `264`
|
||||
4. You should see the byte `2A` at this position
|
||||
@@ -816,14 +816,14 @@ This is the **opposite** of the original behavior!
|
||||
|
||||
---
|
||||
|
||||
## ? Part 9: Converting and Flashing the Hacked Binary
|
||||
## 🚀 Part 9: Converting and Flashing the Hacked Binary
|
||||
|
||||
### Step 22: Convert to UF2 Format
|
||||
|
||||
Open a terminal and navigate to your project directory:
|
||||
|
||||
```powershell
|
||||
cd C:\Users\assem.KEVINTHOMAS\OneDrive\Documents\Embedded-Hacking\0x0014_static-variables
|
||||
cd C:\Users\flare-vm\Desktop\Embedded-Hacking-main\0x0014_static-variables
|
||||
```
|
||||
|
||||
Run the conversion command:
|
||||
@@ -859,13 +859,13 @@ static_fav_num: 43
|
||||
- LED should now be **ON by default** (when button is NOT pressed)
|
||||
- LED should turn **OFF** when you press the button
|
||||
|
||||
? **BOOM! We successfully:**
|
||||
🎉 **BOOM! We successfully:**
|
||||
1. Changed the printed value from 42 to 43
|
||||
2. Inverted the LED/button logic
|
||||
|
||||
---
|
||||
|
||||
## ? Part 10: Summary and Review
|
||||
## 📊 Part 10: Summary and Review
|
||||
|
||||
### What We Accomplished
|
||||
|
||||
@@ -945,7 +945,7 @@ static_fav_num: 43
|
||||
|
||||
---
|
||||
|
||||
## ? Key Takeaways
|
||||
## 💡 Key Takeaways
|
||||
|
||||
1. **Static variables persist** - They keep their value between function calls and loop iterations.
|
||||
|
||||
@@ -969,7 +969,7 @@ static_fav_num: 43
|
||||
|
||||
---
|
||||
|
||||
## ? Glossary
|
||||
## 📖 Glossary
|
||||
|
||||
| Term | Definition |
|
||||
| --------------------- | ---------------------------------------------------------------- |
|
||||
@@ -992,7 +992,7 @@ static_fav_num: 43
|
||||
|
||||
---
|
||||
|
||||
## ? Additional Resources
|
||||
## 📚 Additional Resources
|
||||
|
||||
### GPIO Input Reference
|
||||
|
||||
|
||||
Reference in New Issue
Block a user