Lecture 21, buffer overflow attack. After studying this chapter you will be able to understand: Services and ports; a case study on buffer overflow vulnerabilities: the telnet service; buffer overflow attack: understanding the call stack; overrunning the allocated memory in a call stack; demonstration of program misbehavior because of buffer overflow; using gdb to craft program inputs for exploiting buffer-overflow vulnerability. | Lecture 21: Buffer Overflow Attack Lecture Notes on “Computer and Network Security” by Avi Kak (kak@) April 19, 2016 12:10am c 2016 Avinash Kak, Purdue University Goals: • Services and ports • A case study on buffer overflow vulnerabilities: The telnet service • Buffer Overflow Attack: Understanding the call stack • Overrunning the allocated memory in a call stack • Demonstration of Program Misbehavior Because of Buffer Overflow • Using gdb to craft program inputs for exploiting buffer-overflow vulnerability CONTENTS Section Title Page Services and Ports 3 Why is the Buffer Overflow Problem So Important in Computer and Network Security 6 A Case Study in Computer Security: The telnet Service 8 Some Security Bulletins Concerning the telnet Service Buffer Overflow Attack: Understanding the Call Stack 10 15 Buffer Overflow Attack: Overrunning the Memory Allocated on the Call Stack 24 Demonstration of Program Misbehavior Caused by Buffer Overflow 27 Using gdb to Craft Program Inputs for Exploiting Buffer-Overflow Vulnerability 31 Homework Problems 44 2 Computer and Network Security by Avi Kak Lecture 21 : Services and Ports • Since buffer overflow attacks are typically targeted at specific services running on certain designated ports, let’s start by reviewing the service/port pairings for some of the standard services in the internet. • Every service on a machine is assigned a port. On a Unix/Linux machine, the ports assigned to standard services are listed in the file /etc/services. Here is a very small sampling from this list from my Linux laptop: # # # # # # # The latest IANA port assignments for network services can be obtained from: The Well Known Ports are those from 0 through 1023. The Registered Ports are those from 1024 through 49151. The Dynamic and/or Private Ports are those from 49152 through 65535 # Each line describes one service, and