/* by pmsac@toxyn.org, 1999, GPLed */ /* little-endian... */ #include #include #include #include #include #include #define QUOTES 9 char *quotes[QUOTES] = { "Viva Zapata!", "Faça uma pausa... Kit-Kat", "25 de Abril, sempre!", "Fascismo nunca mais!", "Don't hesitate, fornicate.", "Internet - Liberdade de expressão", "Don't secure Hash, Smoke it", "When I grow up I wannabe a PTnet Coder", "Free the Source Luke." }; #define MAXSAVEDIPS 256 u_long savedIPs[MAXSAVEDIPS]; struct { char *text; u_long mask; #define MAXFILTERS 11 } ipFilters[MAXFILTERS] = { {"EUnet", 0x7EC1}, {"FCCN/RCCN", 0x88C1}, {"FCCN/RCCN", 0x89C1}, {"Comnexo", 0x26C2}, {"Telepac", 0x41C2}, {"Esoterica", 0x16C3}, {"IP-Global", 0x17C3}, {"Global-One", 0x3DC3}, {"Teleweb", 0x10D4}, {"ITnet", 0x36D4}, }; char *randomQuote(void) { int i; i = time(NULL) % QUOTES; return quotes[i]; } void printHeader(const char *title) { printf("Content-Type: text/html\n\n" "\n\n%s\n\n" "\n" "

%s

\n
\n", title, title); } void printForm(void) { printf("
\n127." "\n" "\n"); } void printFilter(u_long fakeIP, int saved) { int i, j, count; fakeIP |= 0x0000007F; count = 0; for (i = 0; i < saved; i++) for (j = 0; j < MAXFILTERS; j++) if (((savedIPs[i] & 0x0000FFFF) ^ ipFilters[j].mask) == 0) { count = 1; printf("
\n

%s é provavelmente da ", inet_ntoa(*(struct in_addr*)&fakeIP)); printf("%s, %s

\n", ipFilters[j].text, inet_ntoa(*(struct in_addr*)&savedIPs[i])); break; } if (!count) { printf("
\n

Rede ainda não filtrada... azar.

\n" "

(ou entrou por um ircd versao 1.5.38U+, /version server.ptnet.org para verificar)

\n"); } } void printError(const char *error) { printf("
\n

%s

\n", error); } void printFooter(const char *text) { printf("
\n" "\"We\n
\n%s\n\n\n", text); } void getIP(u_long *fakeIP) { #define MAXBUFFER 18 #define MAXREAD 12 char buffer[MAXBUFFER] = "127."; if (fgetc(stdin) == EOF) { *fakeIP = 0xFFFFFFFF; return; } fgets(&buffer[4], MAXREAD, stdin); if (buffer[strlen(buffer)-1] == '\n') buffer[strlen(buffer)-1] = '\0'; if ((*fakeIP = inet_addr(buffer)) == -1) *fakeIP = 0; } int main(int argc, char *argv[]) { u_long fakeIP, ip, offset; unsigned long long int realIP; int saved; printHeader("PTnot - PT ne(a)t obfuscator translator"); printForm(); if (argc != 1) { printError("Game Over, Insert Coin"); printFooter(randomQuote()); return -1; } getIP(&fakeIP); if (fakeIP == 0xFFFFFFFF) { printFooter(randomQuote()); return 0; } fakeIP &= 0xFFFFFF00; if (fakeIP == 0) { printError("IP inválido, lerdo..."); printFooter(randomQuote()); return -1; } for (realIP = 0x0, offset = 1, saved = 0; realIP < 0xFFFFFFFF; realIP += offset) { ip = htonl(realIP); ip ^= (ip << 8); ip ^= (ip << 16); ip ^= (ip >> 12); ip &= 0xFFFFFF00; if (ip == fakeIP) { if (saved == MAXSAVEDIPS) { printError("Critical error, mission aborted"); printFooter(randomQuote()); return -1; } savedIPs[saved++] = htonl(realIP); offset = 0x10000; } } printFilter(fakeIP, saved); printFooter(randomQuote()); return 0; }