/**************************** file: CountSpam.c written by Keith Oxenrider November 6, 2003 This program will auto generate a bunch of random email addresses and create a web page that contains them. It is intended to give spammers some headaches. Notes from its original purpose as a page counter: For use on the web as a cgi program. Is activated by calling the program as an image, i.e., to increment counter without having a visible display, invoke as follows: If the last character in the input string is an '!' then the counter will not be incremented, just displayed ****************************/ #include #include #include #include #include /*hardcoded path to directory to store count file, change here */ #ifdef Win32 char path[] = "countdata\\"; #else /* presumed *nix */ char path[] = "countdata/"; #endif /* IMPORTANT!! Change this to the path on your machine where you want the file! */ char outputFileName[] = "\\emails.html"; /* used in writeFile() */ #define MAXCHARS 10 /* for length of randomly created names and domains */ #define MAXENTRIES 30 /* for number of name/domain pairs created */ /* used in main() */ #define TRUE 1 #define FALSE 0 #define MAXCHAR 100 #define MAXLINELENGTH 1000 /* hex coded bitmaps */ char *digits[] ={ "0xff","0xff","0xff","0xc3","0x99","0x99","0x99","0x99", "0x99","0x99","0x99","0x99","0xc3","0xff","0xff","0xff", "0xff","0xff","0xff","0xcf","0xc7","0xcf","0xcf","0xcf", "0xcf","0xcf","0xcf","0xcf","0xcf","0xff","0xff","0xff", "0xff","0xff","0xff","0xc3","0x99","0x9f","0x9f","0xcf", "0xe7","0xf3","0xf9","0xf9","0x81","0xff","0xff","0xff", "0xff","0xff","0xff","0xc3","0x99","0x9f","0x9f","0xc7", "0x9f","0x9f","0x9f","0x99","0xc3","0xff","0xff","0xff", "0xff","0xff","0xff","0xcf","0xcf","0xc7","0xc7","0xcb", "0xcb","0xcd","0x81","0xcf","0x87","0xff","0xff","0xff", "0xff","0xff","0xff","0x81","0xf9","0xf9","0xf9","0xc1", "0x9f","0x9f","0x9f","0x99","0xc3","0xff","0xff","0xff", "0xff","0xff","0xff","0xc7","0xf3","0xf9","0xf9","0xc1", "0x99","0x99","0x99","0x99","0xc3","0xff","0xff","0xff", "0xff","0xff","0xff","0x81","0x99","0x9f","0x9f","0xcf", "0xcf","0xe7","0xe7","0xf3","0xf3","0xff","0xff","0xff", "0xff","0xff","0xff","0xc3","0x99","0x99","0x99","0xc3", "0x99","0x99","0x99","0x99","0xc3","0xff","0xff","0xff", "0xff","0xff","0xff","0xc3","0x99","0x99","0x99","0x99", "0x83","0x9f","0x9f","0xcf","0xe3","0xff","0xff","0xff" }; /* this will only work with the ASCII character set */ char getChar(int index){ char val = rand() % 25; if (rand() % 2) val += 65; else val += 97; if (index > 2){/* to produce variable length values */ if (rand() % 3 == 0) return '\0'; } return val; } int writeFile(int seed){ FILE *fout; int i, j, suf; /* add as many suffixes as you like, just be sure the last one is NULL */ char *suffixes[] = {"com", "net", "org", "edu", NULL}; char name[MAXCHARS+1], domain[MAXCHARS+1]; srand(seed); if ((fout = fopen(outputFileName, "w")) == NULL){ return 0; } fprintf(fout, "\nsecret email addresses\n\n\n"); fprintf(fout, "You are visitor number to this page.

\n"); fprintf(fout, "Here is the list of emails...\n


\n"); fprintf(fout, "\n"); for (i=0; i\n"); for (suf=0; suffixes[suf]; suf++){ for (j=0; j%s@%s.%s\n", name, domain, suffixes[suf], name, domain, suffixes[suf]); } fprintf(fout, "\n"); } fprintf(fout, "
\n"); fprintf(fout, "\n"); fclose(fout); return 1; } /* the main program acts as a web page counter */ int main () { unsigned long count; FILE *fin = NULL; char numb[MAXCHAR], *input, cc[] = "0"; int len, x, y, c, i, write = TRUE, wipe = FALSE; char filename[MAXLINELENGTH]; struct tm *time_date; time_t timer; input = getenv("QUERY_STRING"); if (input == NULL) return 0; len = strlen(input); /*if input is too high, exit*/ if (len >= MAXLINELENGTH - sizeof(path)) return 0; /*check for invalid characters (thanks infamous42md!)*/ for (i=0; i10) wipe = TRUE; if (wipe){ strcpy(numb, "0"); break; } } count = atol(numb); if (write){ count++; if (fin = fopen(filename, "w")){ fprintf(fin, "%lu", count); /* get the time and format to look nice*/ time(&timer); time_date = localtime(&timer); fprintf(fin, " %02d/%02d/%d %02d:%02d:%02d", time_date->tm_mon +1, time_date->tm_mday, time_date->tm_year+1900, time_date->tm_hour, time_date->tm_min, time_date->tm_sec); fclose(fin); } } sprintf(numb, "%lu", count); len = strlen(numb); printf("Content-type: image/x-xbitmap\n\n"); printf("#define count_width %d\n", len * 8); printf("#define count_height 16\n"); printf("static char count_bits[] = {\n"); for (x=0; x<16; x++){ for (y=0; y