Cyber security assignment support for university students
Private & confidentialWhatsApp +44 7949 817583
Solved Cybersecurity Project

Buffer Overflow Attack Demo: getscore Privilege Escalation Case Study

Understand the assignment first, then follow the completed solution step by step. Each stage below shows what was required, what evidence was produced, what that evidence means, and how it contributes to the final result.

Requirement: Buffer Overflow Attack Demo • Solution: getscore Privilege Escalation • Tools: GCC · GDB · Linux
CourseCSCE 4550 — Operating Systems Security
Lab targetgetscore (setuid root) on a Red Hat Linux VM
Main findingStack buffer overflow
Extra findingOS command injection
Key evidenceEIP overwrite + 134-byte offset
Final lab resultGuest to root privilege escalation
00
Start here

Project Overview

A solved cybersecurity lab case study explaining the getscore buffer overflow requirements, GDB crash analysis, EIP offset discovery, privilege escalation result, defenses and the extra credit command injection finding.

Authorised lab only

This case study describes an authorised university lab using a deliberately vulnerable legacy virtual machine. Exact shellcode bytes, the reusable jump address and the command-injection payload are intentionally omitted from the public article.

01
Understand the brief

Requirement → Solution Map

The lab is organised into four stages: prepare the virtual machine, compile and configure the getscore program, deliberately trigger and inspect a segmentation fault, and then use the crash evidence to reason about a controlled buffer overflow in the authorised lab environment.

Grading Breakdown

Step 115%
Step 215%
Step 330%
Step 440%
What the report must contain

The submitted report must include detailed screenshots for each stage and a detailed explanation of how the result for each stage was obtained.

02
Requirement + solution together

Step-by-Step Assignment Solution

The completed solution followed the same four-stage structure and documented the evidence required to move from a normal program run to a confirmed stack overwrite and finally to successful privilege escalation inside the supplied legacy VM.

01
Lab step

Setup the VM

What the assignment asked

Import the supplied Red Hat virtual machine and prepare the getscore.c and score.txt files in the lab environment.

What the solution did

gcc getscore.c -o getscore | chmod 755 getscore; chmod u+s getscore; chmod 600 score.txt

Evidence

getscore (setuid root) on a Red Hat Linux VM

Why this matters

The solution compiled getscore, applied the required permissions and verified that the setuid bit caused the program to execute with root effective privileges even when it was launched by the guest user.

ResultThe solution compiled getscore, applied the required permissions and verified that the setuid bit caused the program to execute with root effective privileges even when it was launched by the guest user.
02
Lab step

Compile and Configure getscore

What the assignment asked

Compile getscore, set the required executable and setuid permissions, protect score.txt, then verify that the program behaves differently when executed by the guest account.

What the solution did

The solution compiled getscore, applied the required permissions and verified that the setuid bit caused the program to execute with root effective privileges even when it was launched by the guest user.

Evidence

The program was compiled, the required permissions were applied and the guest account was used to verify the setuid behaviour.

Why this matters

This proves why a later memory-safety failure has a much larger security impact: the vulnerable program executes with root effective privileges.

ResultThe setuid-root execution context was confirmed.
View the setup commands used in this lab

Compile the supplied program

gcc getscore.c -o getscore

Apply the lab permissions

chmod 755 getscore; chmod u+s getscore; chmod 600 score.txt
03
Lab step

Trigger the Crash and Inspect GDB Evidence

What the assignment asked

Provide oversized input to cause a segmentation fault, enable a core dump and use GDB to inspect registers and stack memory.

What the solution did

EIP = 0x41414141

Evidence

gdb -c core.xxxx | info registers $eip | info registers $esp | x/100x $esp-200

Why this matters

The key turning point in the solution was the GDB evidence. First, EIP became 0x41414141 after the repeated A input. The cyclic-pattern run then identified the exact saved-EIP position as 134 bytes. This answered the assignment question about where EIP must be overwritten without guessing the offset.

ResultSaved EIP offset: 134 bytes
View the GDB evidence commands

Open a core dump in GDB

gdb -c core.xxxx

Inspect the saved instruction pointer

info registers $eip

Inspect the stack pointer

info registers $esp

Inspect stack memory

x/100x $esp-200
Key findingEIP = 0x41414141 → user input reached the saved instruction pointer

The key turning point in the solution was the GDB evidence. First, EIP became 0x41414141 after the repeated A input. The cyclic-pattern run then identified the exact saved-EIP position as 134 bytes. This answered the assignment question about where EIP must be overwritten without guessing the offset.

04
Lab step

Build and Validate the Lab Exploit

What the assignment asked

Determine how long the input must be, where the saved EIP is located in the input and what kind of return target is needed for the lab exploit.

What the solution did

The final report records successful privilege escalation from guest (uid=500) to root (uid=0) in the authorised Red Hat VM.

Evidence

The final report records successful privilege escalation from guest (uid=500) to root (uid=0) in the authorised Red Hat VM.

Why this matters

Conceptually, the final lab payload contained controlled padding up to the saved return address, a lab-specific control-flow redirection, additional landing space and the supplied shellcode. The important academic point is how the crash evidence was converted into a reproducible payload layout, not the memorisation of one address or byte string.

ResultThe final report records successful privilege escalation from guest (uid=500) to root (uid=0) in the authorised Red Hat VM.
Controlled padding Saved EIP Landing space Lab shellcode

Conceptually, the final lab payload contained controlled padding up to the saved return address, a lab-specific control-flow redirection, additional landing space and the supplied shellcode. The important academic point is how the crash evidence was converted into a reproducible payload layout, not the memorisation of one address or byte string.

Need support with a similar task?

Need help with a similar assignment or project?

Send your assignment brief, marking rubric or existing work for originality-focused support, technical review, troubleshooting and project guidance tailored to your requirements.

03
Understand the vulnerability

Why the Exploit Worked

Unbounded copy

The vulnerable getscore program copies user-controlled data into a fixed-size stack buffer without adequate bounds checking, allowing the saved return address to be overwritten.

Known EIP offset

The cyclic-pattern analysis established the exact position of the saved EIP at 134 bytes.

Controlled redirection

A JMP ESP technique redirected execution toward attacker-controlled data on the stack inside the lab VM.

Setuid root context

Because the binary runs with root effective privileges, successful code execution inherits that elevated privilege in the lab.

Legacy mitigations

The report notes that the supplied environment lacked modern protections such as stack canaries, ASLR and NX, making the demonstration reliable.

04
Turn the exploit into defensive analysis

Defenses That Would Have Prevented It

01
Stack canary (-fstack-protector)

Detects a return-address overwrite and aborts execution.

02
ASLR (randomize_va_space=2)

Randomizes the C library location so a fixed control-flow target is no longer reliable.

03
NX / DEP

Marks stack memory non-executable, preventing injected stack code from running.

04
strncpy / snprintf

Bounds-checked copying prevents the original buffer overwrite.

05
Privilege dropping

Reducing privileges means a successful memory-safety exploit does not automatically become a root shell.

05
Separate vulnerability path

Extra Credit: OS Command Injection Vulnerability

The extra-credit analysis identified a second vulnerability in getscore: OS Command Injection in the error-logging path. When authentication fails, the program formats user-controlled name and SSN values into a shell command and executes that command with system().

Vulnerable logging path
sprintf(command,
    "echo \"%s: Invalid user name or SSN: %s,%s\"|cat >> error.log",
    ctime(&current_time), argv[1], argv[2]);

if (system(command)) {
    perror("Logging");
}
Root cause

User-controlled values are inserted into a shell command and then passed to system().

Security impact

The supplied analysis also notes that main() sets both real and effective UIDs to root. That means an injected command in this path would execute with root privileges. The public case study omits the exploit payload and command sequence and focuses on the vulnerability cause and privilege impact.

06
Revision notes

What Students Should Learn From This Project

01

Start with the assignment requirements and collect evidence for each required step instead of jumping directly to exploitation.

02

Use the segmentation fault and core dump as evidence. The overwritten EIP value proves control of the return address.

03

Use a cyclic pattern to calculate the exact offset rather than estimating where EIP is stored.

04

Explain why setuid changes the security impact of the same memory-safety bug.

05

A strong report connects screenshots and command output to interpretation, then finishes with practical mitigations.

06

Separate the primary buffer-overflow finding from the extra-credit command-injection finding because they arise from different vulnerable code paths.

WhatsApp