[net.sources] NSA keyword scanner

holloway@drivax.UUCP (04/06/87)

It took years of dedicated effort, enough money to make a dent in the
national debt, and friends in high places to get this code. I hope
this is appreciated.

The NSA uses the following code to scan through articles on the net. It
appears to print a report based on an article in stdin, although this
may be a deception on their part. You know how they are.

If you believe in freedom, RUN YOUR ARTICLES THROUGH THIS FILTER FIRST,
and remove questionable references, or refer to them indirectly, and you
may escape the tightening grip of the NSA.

This code includes a top secret DES decrypter. Sources who have asked to
remain nameless indicate that the NSA may intercept this message and
replace the code with something much more innocuous - I ask only that those
sites that get the unaltered code pass them as widely as possible. The
real code is identified by the initials of the author - CJN - sprinkled
throughout the copious comments. This code is about ten thousand lines
long, and can get a little vague at times, but you'll find it can
decrypt any message I've been able to pipe through it - compressed, crypted,
ARCed files - all are no challenge. A truly extraordinary piece of code.

----------

#include <stdio.h>

extern char *ctime();
extern long time();
extern void srand();
extern int rand();

extern char *gets();

int rnd();

char ltime[25];
char iline[1024];

#define	WORDS	struct _words

WORDS {
    char *keyword;
    int occur;
    };

WORDS keys[] = {
    { "Security", 0 },
    { "Intelligence", 0 },
    { "LSD", 0 },
    { "toxin", 0 },
    { "Soviet", 0 },
    { "USSR", 0 },
    { "China", 0 },
    { "Moscow", 0 },
    { "ABSCAM", 0 },
    { "DES", 0 },
    { "crypt", 0 },
    { "oversea", 0 },
    { "Libya", 0 },
    { "Khadaffi", 0 },
    { "nuclear", 0 },
    { "atomic", 0 },
    { "code", 0 },
    { "secret", 0 },
    { "meet me wednesday by the cadenza", 0 },
    { "border", 0 },
    { "alien", 0 },
    { "UFO", 0 },
    { "Project Blue Book", 0 },
    { "Velikovsky", 0 },
    { "Hitler", 0 },
    { "Nazi", 0 },
    { "comsymp", 0 },
    { "red", 0 },
    { "United Nations", 0 },
    { "airplane", 0 },
    { "X-15", 0 },
    { "X-29", 0 },
    { "Saudi", 0 },
    { "Lebanon", 0 },
    { "Embassy", 0 },
    { "United States", 0 },
    { "Ottawa", 0 },
    { "Cuba", 0 },
    { "Havana", 0 },
    { "Castro", 0 },
    { "Lenin", 0 },
    { "Marx", 0 },
    { "Stalin", 0 },
    { "Gorbachev", 0 },
    { "Chernenko", 0 },
    { "Kruschev", 0 },
    { "Brezhnev", 0 },
    { "Kennedy", 0 },
    { "FBI", 0 },
    { "CIA", 0 },
    { "NSA", 0 },
    { "NRA", 0 },
    { "John Birch", 0 },
    { "Iran", 0 },
    { "Contra", 0 },
    { "Israel", 0 },
    { "hostage", 0 },
    { "North", 0 },
    { "Poindexter", 0 },
    { "drug", 0 },
    { "IRS", 0 },
    { "assassin", 0 },
    { "dwarf", 0 }
    };

#define	NUMKWORDS	((sizeof keys)/sizeof(WORDS))

char *states[] = {
    "Closet Liberal",
    "Young Democrat",
    "Reactionary",
    "Dangerous Reactionary",
    "Communist Agitator"
};

#define	NUMSTATES	((sizeof states)/sizeof(char *))

char *disp[] = {
    "Hold for Questioning",
    "Hold Indefinitely",
    "Electronic Surveillance",
    "Terminate with Extreme Prejudice",
    "Monitor Future Net Access",
    "Proceed with Income Tax Audit - Impound Personal Property",
    "Hold Spouse for Questioning - Terminate Children"
};

#define	NUMDISPS	((sizeof disp)/sizeof(char *))

main(){
    long zzz;
    int i, j, num=0, col=0;
    char zap[100];

    srand((int)time(0L));

    while(gets(iline)){
	for(i=0; i<NUMKWORDS; ++i){
	    j = findkeyword(iline,keys[i].keyword);
	    keys[i].occur += j;
	    num += j;
	    }
	}

    (void) time(&zzz);
    strcpy(ltime,ctime(&zzz));
    ltime[strlen(ltime)-1] = 0;
    printf("%s NSA file #%d - keywords caught - %d\n",ltime,rnd((int)zzz),num);
    if(num){
	printf("Keywords found:\n");
	for(i=0; i<NUMKWORDS; ++i)
	    if(keys[i].occur){
		sprintf(zap,"%d %s",keys[i].occur,keys[i].keyword);
		if(col == 4){
		    printf("\n");
		    col = 0;
		    }
		printf("%-18.18s ",zap);
		++col;
		}
	if(col) printf("\n");
	printf("Classification - %s\n",states[rnd(NUMSTATES)]);
	printf("Disposition - %s\n",disp[rnd(NUMDISPS)]);
	}
    else{
	printf("Classification - Unclassified\n");
	printf("Disposition - Cleared for release\n");
	}
}

int rnd(n)
int n;
{
    return((rand() & 0x7FFF) % n);
}

int chupper(ch)
int ch;
{
    return((ch >= 'a' && ch <= 'z') ? ch-'a'+'A' : ch);
}

int cstrncmp(s1,s2,n)
char *s1, *s2;
int n;
{
    int i;

    for(i=0; i < n && *s1 && *s2 && chupper(*s1) == chupper(*s2);
				++s1, ++s2, ++i);
    if(i == n) return(0);
    else return(*s2 - *s1);
}

int findkeyword(inp,word)
char inp[], word[];
{
    int l, w, i, num=0;

    l = strlen(inp);
    w = strlen(word);
    for(i=0; i <= (l-w); ++i)
	if(!cstrncmp(&inp[i],word,w))
	    ++num;
    return(num);
}
-- 
Bruce Holloway - Relapsed Newsaholic
{seismo,hplabs,sun,ihnp4}!amdahl!drivax!holloway
Put the power of RANDOM NUMBERS to work FOR YOU!