Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

User Examine the provided binary executable* and practice using it. The C source code for this binary is provided below. Run** it to test its

User Examine the provided binary executable* and practice using it. The C source code for this binary is provided below. Run** it to test its operation. The program is a server which listens on a chosen port number and waits for an incoming TCP connection from a client. The server prompts and then takes an input from the client and returns a welcome message with the inputted string. Examine the operation of this program. Your first task is to identify the vulnerability in the code. The next task is to explain how a malicious code of 28 bytes will be injected by exploiting the identified vulnerability. You are not required to demonstrate the code injection. The task requires explanation of the code injection process. Use of figures, and gdb screenshots will be helpful in explaining the code injection process. For instance, identify the most appropriate stack location where the 28 bytes malicious code will be injected. You should also discuss the important parts of the payload including the 28 bytes malicious code. The corresponding source code that makes up the core part of the binary is: #include "co5607_portfo_ex1.h" #define MAX_DATA_SIZE 256 void serve_welcome_response(int the_connection) { char buffer[32]; // buffer to hold the client's name memset(buffer, 0, 32); // Clear the buffer for receiving // Send the query to the client... write(the_connection, "Please enter your name: ", 24); // Get the client's name... read(the_connection, buffer, MAX_DATA_SIZE); // Print the received message locally... printf("Message received: "); printf(buffer); printf(" "); // Send the message back to the client to welcome them... write(the_connection, "Welcome ", 8); // Send 8 characters write(the_connection, buffer, strlen(buffer)); return; } int server_loop(int port_number) { int sockfd, newsockfd; char some_space[48]; // Establish a socket for this server to listen on... sockfd = create_socket(port_number); for (;;) { // Loop forever // Accept a new connection - get a 'new socket fd' to handle it... newsockfd = accept_connection(sockfd); // serve the client... serve_welcome_response(newsockfd); // We've now finished with this 'new socket file descriptor' close(newsockfd); } } int main(int argc, char *argv[]) { char some_space[64]; int port_number; if (argc < 2) { printf("ERROR: no port provided "); exit(-1); } else { // Get the port number as provided on the command line... port_number = atoi(argv[1]); server_loop(port_number); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions