exp8_66_css
exp8_66_css
Roll No 66
EXPERIMENT NO:8
Aim: Simulate buffer overflow attack using Ollydbg, Splint, Cppcheck etc
Objective:
To simulate and analyze a buffer overflow attack using tools such as OllyDbg, Splint, and Cppcheck, in
order to understand how buffer overflow vulnerabilities occur and how they can be detected.
Outcome:
The experiment demonstrated how software vulnerabilities, specifically buffer overflows, can be detected using:
• OllyDbg (for dynamic debugging and binary analysis),
• Splint (for static analysis with annotations), and
• Cppcheck (for identifying C/C++ code bugs not caught by compilers).
Theory:
In information security and programming, a buffer overflow, or buffer overrun, is an anomaly
where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent
memory locations.A buffer overflow occurs when data written to a buffer also corrupts data values in
memory addresses adjacent to the destination buffer due to insufficient bounds checking. This can occur
when copying data from one buffer to another without first checking that the data fits within the
destination buffer.
1.Cppcheck :
Cppcheck is a tool for static C/C++ code analysis (CLI).
Cppcheck is a command- line tool that tries to detect bugs that your C/C++
compiler doesn't see. It is versatile, and can check non-standard code
including various compiler extensions, inline assembly code, etc. Its internal
preprocessor can handle includes, macros, and several pre-processor
commands. While Cppcheck is highly configurable, you can start using it
just by giving it a path to the source code.
It includes checks for:
1. pointers to out-of-scope auto variables;
2. assignment of auto variables to an effective parameter of a function;
3. out-of-bounds errors in arrays and STL;
4. missing class constructors;
5. variables not initialized by a constructor;
6. Use of memset, memcpy, etcetera on a class;
7. non-virtual destructors for base classes;
8. operator= not returning a constant reference to itself
2. OllyDbg:
OllyDbg is a 32-bit assembler level analysing debugger for Microsoft Windows. Emphasis on
binary code analysis makes it particularly useful in cases where source is unavailable.
Features:
● Intuitive user interface, no cryptical commands
● Code analysis – traces registers, recognizes procedures, loops, API calls, switches, tables,
constants and strings
● Directly loads and debugs DLLs
● Object file scanning – locates routines from object files and libraries
● Allows for user-defined labels, comments and function descriptions
● Understands debugging information in Borland format
● Saves patches between sessions, writes them back to executable file and updates fixups
● Open architecture – many third-party plugins are available
● No installation – no trash in registry or system directories
● Debugs multi threaded applications
● Attaches to running programs
3. Splint:
Splint is a tool for statically checking C programs for security vulnerabilities and coding
mistakes. With minimal effort, Splint can be used as a better lint. If additional effort is invested adding
annotations to programs, Splint can perform stronger checking than can be done by any standard lint.
Code :
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
}
strcpy(buffer, argv[1]);
printf("buffer content= %s\n", buffer);
return 0;
}
Output :
Successful Execution -
Buffer Overflow -
Conclusion:
Software vulnerabilities causing buffer overflow are studied and detected using
Ollydbg, Splint and cppcheck.