The learning objective of this homework is for you to understand the basics of network traffic and packet analysis. You will be required to capture DNS
and HTTP/HTTPS
packets using Wireshark and analyze them.
To begin with, you are required to install Wireshark. You need to have access to a computer that support both Wireshark and the libpcap
library. Wireshark is available for Windows, macOS, and Linux. You can download the latest version from the official website [link]. Your operating system (OS) may have the libpcap software installed. If you face an issue with the libpcap library, you can install it as follows, depending on your OS:
Capture
menu and selecting Options
.
Start
button to begin capturing packets. You should see packets being displayed in the packet-listing window.
http
to display only HTTP packets, as shown in this figure.
Capture
menu and select Stop
. You can also click on the red square button in the toolbar.
File
menu and select Save As
. Choose a location and file name to save the captured packets.
ipconfig
(Windows) / ifconfig
(Linux, Mac) to empty the DNS cache on your host.
ip.addr == your_IP_address
into the filter, where you obtain your IP address (the IP address for the computer running Wireshark) with ipconfig
. This filter removes all packets that neither originate nor are destined for your host.
ipconfig
(Windows) / ifconfig
(Linux, Mac) to empty the DNS cache on your host.
ip.addr == your_IP_address
into the filter, where you obtain your IP address (the IP address for the computer running Wireshark) with ipconfig
. This filter removes all packets that neither originate nor are destined for your host.
HTTP
website?HTTPS
website?.tar.gz
) that contains your write-up as a PDF file. Your PDF write-up should contain the following things:
The learning objectives of this homework are for students to gain hands-on experience with buffer overflow
attacks. These attacks exploit a buffer overrun vulnerability in a program, causing it to bypass its usual execution sequence and instead jump to alternative code (typically launching a shell!). The attack overflows the vulnerable buffer to introduce the alternative code onto the stack and modifies the return address to point to that code.
To begin, you are required to use a Linux machine with sudo
privileges. You should not complete this homework on a shared server or any OSU computing clusters. If you perform a buffer overflow attack in these shared environments, you will be responsible for any consequences, and the instructor will not be liable. Note that you cannot run this on a Mac or Windows laptop. While these systems support command-line environments, they do not allow you to execute buffer overflow attacks. If you do not have a Linux machine, the instructor recommends creating a virtual machine using a commodity virtualization software, such as VMWare.
"One way to bypass the configuration hassles is to set up your own server using a popular cloud provider, Amazon Web Services (AWS). To do this, sign up for AWS, go to the AWS Console, and select EC2. Then, launch an instance, choosing the operating system Ubuntu 22.04
and the instance type t2.micro
(which is eligible for the free tier). You will also need to configure an SSH key and a Security Group. Once completed, you can find the server's IP address in the console. Use that IP to log in to the cloud server via your terminal.
$ ssh -i "your-aws-key" ubuntu@"your-server-ip"
To run the code provided by the instructor, you will need to install a few packages, as listed below. Note that you may need to install more packages. In such cases, you can easily search the error message shown in the terminal on Google and find the answers.
$ sudo apt install cmake gcc g++ gdb
$ sudo apt install vim-enhanced
$ sudo apt install python3
Many countermeasures, such as ASLR, have been developed to address buffer overflow vulnerabilities. Circumventing these defenses is not as easy as it may seem, so we will disable them for this homework assignment. You can do so by following these steps:
$ sudo -i
# sysctl -w kernel.randomize_va_space=0
# exit // exit the sudo; our assignment should be done in the user space.
[Important Note] Once you complete the homework, be sure to turn off and delete the cloud server to avoid being charged.
Makefile
:
$ vim Makefile
// paste the content below
CC=gcc
CFLAGS=-g -fno-stack-protector
all: bof.c
$(CC) -m32 -o bof bof.c $(CFLAGS)
Create a vulnerable file bof.c
, as follows:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "unistd.h"
char *trueflag = "cs578{trueflag}";
char *fakeflag = "cs578{fakeflag}";
void
shell(void) {
setregid(getegid(), getegid());
system("/bin/bash");
}
void
process_user_input(void) {
char *flag;
char buff[12];
char data[128];
// set the fake flag
flag = fakeflag;
// load the memory locations
printf("Your flag address is at %p\n", trueflag);
printf("Your fakeflag is at %p\n", fakeflag);
printf("Address of shell is at %p\n", &shell);
printf("Currently, the flag variable has the value %p\n", flag);
fgets(data, sizeof(data), stdin);
// copy the content directly to the buffer
strncpy(buff, data, strlen(data));
printf("Your input was: [%s]\n", buff);
printf("Your flag address is at %p\n", flag);
printf("Your flag is %s\n", flag);
}
int
main(void) {
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
process_user_input();
}
You can now compile the bof.c file by running the make
command. Once compiled, you are ready to exploit the buffer overflow vulnerability. The code by default, will print out the flag cs578{fakeflag}
. Your job is to exploit the buffer overflow and force it to print out cs578{trueflag}
.
bash shell
! (wait what?) Use the exact same program that the Instructor provided above and work hard to get a shell..tar.gz
. .tar
or .zip
) that contains your write-up as a PDF file. Your PDF write-up should contain the followings:trueflag
.bash shell
.