Docsity

CSE 466: Computer Systems Security - Security Vulnerabilities and Exploits - Prof. Partha , Study notes of Computer Science

Partial preview of the text

Download CSE 466: Computer Systems Security - Security Vulnerabilities and Exploits - Prof. Partha and more Study notes Computer Science in PDF only on Docsity!

CSE 466: Computer Systems Security

Class:

Date:

Fall 2008

//integer promotionschar c1, c2, c3 result;c1 = 100;c2 = 90;c3 = -120;result = c1+c2+c3;// will work correctly (BAD)

//JPEG vulnerabilityvoid getcomment(unsigned int len, char *src) {

unsigned int size;size = len - 2;char cmment = (char *) malloc(size + 1);memcpy (comment, src, size); } read the value of len from JPG file and then getcomment.

// truncation errormain(argc, argv){

unsigned short int total;total = strlen(argv[1])+strlen(argv[2]);char *buf = malloc (total)strcpy(buf, argv[1]);strcat(buf, argv[2]); }

// truncation problem with conversionbool func(char * name, long cbBuf);

unsigned short bufSize = cbBuf;char *buf = (char *) malloc (bufSize);if buf {

memcpy ( buf, name, cbBuf);

//usage exploitvoid usage(char *p) {

char str[1024];snprintf(str, 1024, “Usage: %s \n”, p);printf(str); } from main, if argc not > 2

usage(argv[0]);

//variadic functionint avg(int first, …) {

int count = 0, sum = 0, i = first;va_list marker;va_start(marker, first);while (i != -1) {

sum += i; count++;i = va_arg(marker, int); } va_end(marker)returns (sum? (sum/count) : 0);} call - avg( 1, 5, 8, -1);

//stretchable bufferchar outbuf[512], buffer[512];sprintf(buffer, “Wrong Command: %.400s”, user);sprintf(outbuf, buffer);-> input %497\x3c\xd3\xff\xbf....[shellcode]

//simplestfunc(char *user){ printf(user);}attack1: %s%s%s%s%s%s…………

may crash

attack2: %08x, %08x, %08x, …………attack3: use %x a few times and then use %sattack4: \xdc\xf5\x42\x01%08x%08x%08x%08x%s (very tricky