/***********************************************
* released under (E) licensing ... *
* (E) RULES AND REGULATIONS *
* permission to use/rewrite/add : granted *
* permission to trojan/steal : denied *
* permission to use illegally : denied *
* permission to use on /dev/urandom : denied *
***********************************************/
/* contact el8@press.co.jp for full license */
/* code copyrighted by ~el8 -- don't infringe! */
/* Added To The IRC Schooling Article */
// by matt ( kode shamenz )
/*+
| kesha (k@de.kode.kodeshamenz.com) (Internic Commercial)
| ircname : * I'm to lame to read px25.RFC *
| channels : @#phrack @#FEH @#!/bin/sh @#idlers +#us-opers
+ server : irc.lightning.net ([207.45.69.69] Cataclysmic and Prolific)*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* standardish bxish */
#define OPER "| operator : %s (is NOT an IRC warrior)\n"
/* add more if you like */
/* BX Mode only (do others use this?) */
#define DOT_COM "Internic Commercial"
#define DOT_NET "Internic Network"
#define DOT_EDU "Educational Institution"
#define DOT_ORG "Internic Non-Profit Organization"
#define DOT_GOV "Government"
#define DOT_MIL "Military"
#define DOT_DEF "unknown" // Default
#define NICK_MAX (char*) malloc ((10) * sizeof (char)) // standard + 1
#define IDENT_MAX (char*) malloc ((15) * sizeof (char))
#define HOST_MAX (char*) malloc ((255) * sizeof (char))
#define REALNAME_MAX (char*) malloc ((80) * sizeof (char))
#define CHAN_MAX (char*) malloc ((255) * sizeof (char))
#define SERVER_MAX (char*) malloc ((255 + 255) * sizeof (char))
#define MAX_MAX (10 + 15 + 255 + 80 + 255 + (255 + 255) +10) // math iz for
// h03z
/* BitchX */
#define BitchX 1
char whoisBitchX[] = "+\n"\
"| %s (%s@%s) (%s)\n"\
"| ircname : %s\n"\
"| channels : %s\n"\
"+ server : %s\n";
/* ircii-EPIC */
#define EPIC 2
char whoisEPIC[] = "*** %s is %s@%s (%s)\n"\
"*** on channels: %s\n"\
"*** on irc via server %s\n";
/* Ninja-IRC */
#define NINJA 3
char whoisNINJA[] = "!\\! %s is %s@%s \"%s\"\n"\
"!\\! on channel: %s\n"\
"!\\! on irc via server %s\n";
/* dont worry, just declaring */
char *Nick;
char *Ident;
char *Host;
char *Realname;
char *Chan;
char *Server;
int verboze = 0;
int op3r = 0;
char oper [50 + 10];
char * argv0;
extern char * optarg;
#define MAX_SERV 6
char *unet[]=
{
"NewYork.NY.US.Undernet.Org (NYC Undernet Server - www.nac.net)",
"NewBrunswick.NJ.US.Undernet.Org ([204.127.145.17] AT&T WorldNet IRC Chat Services)",
"Arlington.VA.US.Undernet.Org ([207.96.122.250] Erols Internet Services')",
"atlanta.ga.us.undernet.org ([207.69.200.131] MindSpring Enterprises, Inc)",
"washington.dc.us.undernet.org ([205.188.149.3] AOL Public Client Server)",
"Baltimore.MD.US.Undernet.Org ([207.114.4.35] [undernet.abs.net] ABSnet's Undernet)"
};
char *efnet[]=
{
"irc.core.com ([208.133.73.83] Segmentation fault (core dumped))",
"irc.lightning.net ([207.45.69.69] Cataclysmic and Prolific)",
"irc.freei.net ([209.162.144.11] Freei Networks - Seattle, WA)",
"ircd.lagged.org ([199.3.235.130] Powered By SHOUTcast)",
"irc.cs.cmu.edu ([128.2.220.250] calloc(1,sizeof(geek)))",
"irc-roc.frontiernet.net (Yo Quiero Taco Bell)"
};
char *getDOM(char *);
char *makewhois(int);
int checkargs(void);
void usage(void);
void verbose(char *msg)
{
if (verboze>0)
fputs(msg,stderr);
else
return;
}
char *getDOM(char *fullhostname)
{
char *DOMname = (char *) NULL;
DOMname = strrchr(fullhostname,'.');
if (DOMname == (char *) NULL)
return (char *) NULL;
if (!strncmp(DOMname,".com",4))
return DOT_COM;
else
if (!strncmp(DOMname,".net",4))
return DOT_NET;
else
if (!strncmp(DOMname,".org",4))
return DOT_ORG;
else
if (!strncmp(DOMname,".edu",4))
return DOT_EDU;
else
if (!strncmp(DOMname,".gov",4))
return DOT_GOV;
else
if (!strncmp(DOMname,".mil",4))
return DOT_MIL;
else {
verbose("getDOM() returning Default\n");
return DOT_DEF;
}
}
char *makewhois(int type)
{
char *WHOIS = (char *) malloc( MAX_MAX * (sizeof (char)) + 1);
switch (type)
{
case BitchX:
snprintf(WHOIS,MAX_MAX,whoisBitchX,
Nick,
Ident,
Host,
getDOM(Host),
Realname,
Chan,
Server);
if (op3r!=0) {
sprintf(oper,OPER,Nick);
strcat(WHOIS,oper);
}
verbose("Whois'ing BitchX style.\n");
return WHOIS;
case EPIC:
snprintf(WHOIS,MAX_MAX,whoisEPIC,
Nick,
Ident,
Host,
Realname,
Chan,
Server);
verbose("Whois'ing EPIC style.\n");
return WHOIS;
case NINJA:
snprintf(WHOIS,MAX_MAX,whoisNINJA,
Nick,
Ident,
Host,
Realname,
Chan,
Server);
verbose("Whois'ing Ninja-IRC style.\n");
return WHOIS;
default:
fprintf(stderr,"Unknown Whois Format! [%i]\n",type);
usage();
}
exit(-1);
}
int checkargs(void)
{
if (Nick == (char *) NULL)
{
fprintf(stderr,"No Nick!\n");
usage();
}
else if (verboze>0) fprintf(stderr,"Nick: %s",Nick);
if (Ident == (char *) NULL)
{
fprintf(stderr,"No Ident!\n");
usage();
}
else if (verboze>0) fprintf(stderr,"Ident: %s",Ident);
if (Host == (char *) NULL)
{
fprintf(stderr,"No Host!\n");
usage();
}
else if (verboze>0) fprintf(stderr,"Host: %s",Host);
if (Realname == (char *) NULL)
{
fprintf(stderr,"No Realname!\n");
usage();
}
else if (verboze>0) fprintf(stderr,"Realname: %s",Realname);
if (Chan == (char *) NULL)
{
fprintf(stderr,"No Channels!\n");
usage();
}
else if (verboze>0) fprintf(stderr,"Channels: %s",Chan);
if (Server == (char *) NULL)
{
fprintf(stderr,"No Server!\n");
usage();
}
else if (verboze>0) fprintf(stderr,"Server: %s",Server);
verbose("passed checkargs.\n");
return 1;
}
void usage(void)
{
/* learn to use me */
fprintf(stderr,
"Fake Whois v0.1 by Matt Ashimoto for ~el8[0] -- 1998\n"
"usage: %s [args]\n"
"\t-n:\tNick\n"
"\t-i:\tIdent\n"
"\t-H:\tHost\n"
"\t-r:\tRealname\n"
"\t-c:\tChannels\n"
"\t-o:\tOper - show this person as an IRCOP [BX mode only]\n"
"\t-s:\tServer [use \"efnet\" or \"unet\" for random ef/unet servers]\n"
"\t-t:\tWhois Syntax Type [1 = BitchX, 2 = EPIC, 3 = Ninja-IRC, ...]\n"
"\t-v:\tbe verbose\n"
"\nQuestions/Comments to: el8@press.co.jp SUBJECT: FakeWhois\n",
argv0);
/* leave me be */
exit(-1);
}
int main(int argc,char **argv)
{
int c=0, whoistype=1;
/* allocate globals */
Nick = NICK_MAX;
Ident = IDENT_MAX;
Host = HOST_MAX;
Realname = REALNAME_MAX;
Chan = CHAN_MAX;
Server = SERVER_MAX;
/* set argv0 for usage() */
argv0 = argv[0];
/* check for too leetle options */
if (argc < 13) usage();
/* parse options */
while (EOF != (c = getopt(argc,argv,"n:i:H:r:c:s:t:vo")))
{
switch(c)
{
case 'n':
Nick = optarg;
break;
case 'i':
Ident = optarg;
break;
case 'H':
Host = optarg;
break;
case 'r':
Realname = optarg;
break;
case 'c':
Chan = optarg;
break;
case 's':
Server = optarg;
break;
case 't':
whoistype = atoi(optarg);
break;
case 'v':
verboze=1;
break;
case 'o':
op3r=1;
break;
default:
usage();
}
}
/* random unet server */
if (!strcmp(Server,"unet"))
{
srand(Nick); // this way, the same host will be used for the same nicks
strcpy(Server,(unet[rand()%MAX_SERV])); // blah blah, lower-order bitz
}
else
/* random efnet server */
if (!strcmp(Server,"efnet"))
{
srand(Nick);
strcpy(Server,(efnet[rand()%MAX_SERV]));
}
/* make sure all values were specified */
checkargs();
/* make the whois / send it to stdout */
fprintf(stdout,"%s",makewhois(whoistype));
/* let forever be */
return;
}
syntax highlighted by Code2HTML, v. 0.9.1