Intro to RE: C : part-5 [Stack Based Buffer Overflow]

Setting the Stage Today, we’re not just smashing buffers — we’re hijacking control flow with user input. Before we start our little “experiment,” let’s make sure the playground is… accommodating. (Optional) ASLR? 1 - That pesky troublemaker has to go. echo 0 | sudo tee /proc/sys/kernel/randomize_va_space Now the memory layout won’t jump around like a caffeinated squirrel. Let’s roll. 😏 The Vulnerable Program Here’s a simple CTF-style challenge: vuln.c #include <stdio....

April 4, 2025 · 11 min · 2313 words · ayedaemon

Elf Chronicles: PLT/GOT (7/?)

Intro In earlier articles, we talked about various parts of an ELF file and the many steps needed to create an executable ELF file that can run on your computer. (Note: The steps are shown visually below; For the source code, check out the symbol table article in this series.) ┌────────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ │ │ │ │ │ │ libarithmatic.c │ │ libarithmatic.h ├───────► │ main.c │ │ │ │ │ │ │ └─────────┬──────────┘ └─────────────────┘ └────────┬────────┘ │ │ │ │ │ /* Compile + assemble */ │ /* Compile + assemble */ │ │ │ │ ▼ ▼ ┌─────────────────────┐ ┌────────────────────┐ │ │ │ │ │ libarithmatic....

April 3, 2024 · 7 min · 1475 words · ayedaemon

Elf Chronicles: Relocations (6/?)

In previous article about Symbol Tables, we talked about the below diagram …. ┌────────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ │ │ │ │ │ │ libarithmatic.c │ │ libarithmatic.h ├───────► │ main.c │ │ │ │ │ │ │ └─────────┬──────────┘ └─────────────────┘ └────────┬────────┘ │ │ │ │ │ /* Compile + assemble */ │ /* Compile + assemble */ │ │ │ │ ▼ ▼ ┌─────────────────────┐ ┌────────────────────┐ │ │ │ │ │ libarithmatic.o │ │ main....

December 8, 2023 · 23 min · 4801 words · ayedaemon

Elf Chronicles: Symbol Tables (5/?)

… prologue At this point I hope you have a general idea of how a C program goes through multiple stages/passes and finally an ELF file is generated. Below is a diagram to jog your memory on this ┌──────────────────┐ │ │ │ hello.c │ // C source │ │ └────────┬─────────┘ │ │ │ /* Compile */ │ │ │ ▼ ┌──────────────────┐ │ │ │ hello.s │ // assembler source │ │ └────────┬─────────┘ │ │ │ /* assemble */ │ │ ▼ ┌──────────────────┐ │ │ │ hello....

October 29, 2023 · 25 min · 5129 words · ayedaemon

Elf Chronicles: String Tables (4/?)

In the article about section headers, you got an introduction to string tables. In this article, we will delve deeper into the topic. …prologue We’ll start with the same program we used in the previous article about section headers. /* file: hello_world.c */ #include <stdio.h> // A macro #define HELLO_MSG1 "Hello World1" // A global variable char HELLO_MSG2[] = "Hello World2"; // main function int main() { // local variable for main char HELLO_MSG3[] = "Hello World3"; // Print messages printf("%s\n", HELLO_MSG1); printf("%s\n", HELLO_MSG2); printf("%s\n", HELLO_MSG3); return 0; } Compile this and then analyze the ELF executable file using readelf (Not everytime we’ll go with xxd)....

October 29, 2023 · 17 min · 3423 words · ayedaemon

ELF Chronicles: Program Headers (3/?)

In preceding articles, we’ve delved into the details of ELF file headers and section headers. Section headers provide insight into how data and instructions are organized based on their characteristics and grouped into distinct sections. These sections remain distinct due to variations in their types and permissions (… and few other things). Up to this point, our focus has been on the aspects of the ELF file as it resides on-disk....

October 20, 2023 · 10 min · 2040 words · ayedaemon

ELF Chronicles: Section Headers (2/?)

Intro Assuming you’ve got ELF headers like Elf64_Ehdr or Elf32_Ehdr at your fingertips, and you’re armed with the know-how and tools to decipher their contents effortlessly. For this article I’ll be using the below C code to generate the ELF file. /* file: hello_world.c */ #include <stdio.h> // A macro #define HELLO_MSG1 "Hello World1" // A global variable char HELLO_MSG2[] = "Hello World2"; // main function int main() { // local variable for main char HELLO_MSG3[] = "Hello World3"; // Print messages printf("%s\n", HELLO_MSG1); printf("%s\n", HELLO_MSG2); printf("%s\n", HELLO_MSG3); return 0; } You can get the ELF binary by compiling this code....

October 19, 2023 · 18 min · 3758 words · ayedaemon

ELF Chronicles: ELF file Header (1/?)

Hexdumps In the fascinating world of computers, we’re stuck conversing in binary, a rather dull language of just ones and zeros. But because we mere humans love things to be a tad more exciting and concise, we’ve come up with our own nifty number system - “hexadecimal” or “hex” for short. This system ditches the binary bore and adds a touch of flair with 16 snazzy symbols. It’s got your usual digits from 0 to 9, plus those fancy A to F letters to make data a bit more, well, hexadecimal-chic!...

October 18, 2023 · 11 min · 2175 words · ayedaemon

Intro to RE: C : part-4

When an operating system (OS) runs a program, the program is first loaded into main memory. Memory is utilized for both program’s machine instructions and program’s data…this includes parameters, dynamic variables, (un)initialized variables, and so on. Most computers today use paged memory allocations, which allow the amount of memory assigned to a program to increase/decrease as the needs of the application change. Memory is allocated to the program and reclaimed by the operating system in fixed-size chunks known as pages....

May 1, 2023 · 14 min · 2938 words · ayedaemon

Eudyptula Task 7

This is Task 07 of the Eudyptula Challenge ------------------------------------------ Great work with that misc device driver. Isn't that a nice and simple way to write a character driver? Just when you think this challenge is all about writing kernel code, this task is a throwback to your second one. Yes, that's right, building kernels. Turns out that's what most developers end up doing, tons and tons of rebuilds, not writing new code....

May 1, 2023 · 9 min · 1826 words · ayedaemon