Article View: alt.privacy.anon-server
Article #18451Re: Altering Agent Headers
From: Thomas Shaddack
Date: Wed, 25 Apr 2001 00:37
Date: Wed, 25 Apr 2001 00:37
144 lines
5889 bytes
5889 bytes
Secret Squirrel <squirrel@echelon.alias.net> wrote in
<87b324d63b27426354046c10f08557eb@anonymous.poster>:
>I don't know anything about mail servers, but if somebody had an smtp
>server that a user could connect to, then the remailer could
>presumably reformat the message that it was relaying, so that the user
>could reply to emails exactly as he always does, but, because he's
>using the remailer's smtp server, his ip will be stripped off the
>relayed message. I'd even pay a modest amount per month for this
>service.
I wrote something similar in order to have an utility that would allow me
quickly and simply send emails with arbitrary headers, originally in order
to test email-triggered automatization systems (when ie. I needed to test
if they will be triggered by a mail sent from certain address). (Of course
it found its use ie. in a prank of freaking off a slightly paranoid friend
by a mail appearing to be sent from "agents@nsa.gov" with text like "We
are watching you", followed by a short personal lecture about email
headers.)
It requires a unixoid (linux/freeBSD/whatever) shell account with standard
user rights. CI Host offers industrial grade hosting for modest fee of $20
per month. They are sometimes a bit slow and have couple-minute outages,
but outside of some minor gripes they are more or less acceptable. Don't
know about others, but they will exist too.
It is a short C program, triggered from .procmailrc; set it as a mail alias
of ie. "fakemail@whatever.com". The program itself takes the email from the
stdin (where it is fed by .procmailrc after executing the program), strips
the original mail headers, and feeds the rest into sendmail. The email
itself, sent to the gateway, has to have two sets of headers; first one
originating from the email client itself, second one arbitrary (you have to
specify it on your own; of course, you can alter the program to add
specific headers there instead), then the mail body itself.
The second header is part of the email itself, so allows you to specify it
on your own, line by line. Very useful as a lab tool. :)
The procedure the program does is:
- get executed, get all the mail fed in through stdin
- throw away all the lines until first blank line (end of header)
- throw away all the blank lines (for sure, if there is more than 1)
- popen("/usr/sbin/sendmail -t","w");, feed it with the rest of mail
Very very simple code. Very ad-hoc and rather dirty. Included. :)
The added functions that you will maybe not need is keeping on-site log of
all the mails that gone through it, and sending a bcc: to you. If you'd
remove these lines, you'll shorten the code somehow more.
Eventually ask your nearest geek to do it for you. All I can do for you
with available resources. :(
No warranties. :)
Shaddack, the Mad Scientist
-------------- fakemail.c begin --------------------
//#define DEBUG
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define LOGFILENAME "fakemail.log"
char from[256];
FILE*sendmailopen()
{ FILE*f;
#ifndef DEBUG
f=popen("/usr/sbin/sendmail -t","w");
#else
f=stdout;
#endif
return f;
}
int sendmailclose(FILE*f)
{
#ifndef DEBUG
return pclose(f);
#else
return 0;
#endif
}
int main()
{ FILE*f,*fo,*flog;
char s[256],*sp;
char cttype[512]="";
int header=1;
int secondheader=2;
int iscontenttype=0;
#ifdef DEBUG
f=fopen("test","r");
#else
f=stdin;
#endif
flog=fopen(LOGFILENAME,"a");
if(flog)fprintf(flog,"\n-------------------------------------------\n");
while(!feof(f)){
s[0]=0;fgets(s,250,f);if(flog)fprintf(flog,"%s",s);
if(header)
{if(s[0]=='\n'){header=0;
fo=sendmailopen();if(!fo){fprintf(flog,"ERROR: Cannot
popen sendmail!\n");fclose(flog);return 0;}
continue;}
sp=strchr(s,'\n');if(sp)sp[0]=0;
if(!strncmp(s,"From: ",6)){strcpy(from,s+6);continue;}
if(!strncmp(s,"Content-Type: ",14)){strcpy(cttype,s);continue;}
if((s[0]=='\t')||(s[0]==' '))
{if(iscontenttype){
sp=s;while((sp[0]<=' ')||(sp[0]))sp++;
strcat(cttype," ");strcat(cttype,sp);continue;
}
}else iscontenttype=0;
continue;
}
if(secondheader==2){if(s[0]=='\n')continue;else secondheader=1;}
if(secondheader)if(s[0]=='\n'){
secondheader=0;
fprintf(fo,"Bcc: %s\n",from);
if(cttype[0])fprintf(fo,"%s\n",cttype);
}
fprintf(fo,"%s",s);
}
sendmailclose(fo);
if(flog)fclose(flog);
return 0;
}
--------------- fakemail.c end ---------------------
Required entry in .procmailrc:
:0
* fakemail@whatever.com
| /home/whoever/whereitis/fakemail
Use with caution.
Batteries not included.
Enjoy! :)
Technical Details
Message-ID:
<Xns908E189AD2DE4shaddacktypecom@195.250.128.40>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.mbox.zip!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!212.74.64.35!colt.net!nntp1.aeq.teleglobe.net!teleglobe.net!news.vol.cz!not-for-mailReferences:
<3ae547b6.26490441@news.uncensored-news.com> <87b324d63b27426354046c10f08557eb@anonymous.poster>Show Full Headers
Complete Article Headers
Message-ID: <Xns908E189AD2DE4shaddacktypecom@195.250.128.40> Subject: Re: Altering Agent Headers Date: Wed, 25 Apr 2001 00:37:44 +0000 From: NOSPAMshaddack@type2.com (Thomas Shaddack) References: <3ae547b6.26490441@news.uncensored-news.com> <87b324d63b27426354046c10f08557eb@anonymous.poster> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.mbox.zip!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!212.74.64.35!colt.net!nntp1.aeq.teleglobe.net!teleglobe.net!news.vol.cz!not-for-mail Newsgroups: alt.privacy.anon-server,alt.privacy Organization: New Wave Microtechnology Lines: 144 NNTP-Posting-Host: datelb-1-4-143.dialup.vol.cz X-Trace: news.vol.cz 988159064 11699 212.20.101.177 (25 Apr 2001 00:37:44 GMT) X-Complaints-To: sysadmin@vol.cz NNTP-Posting-Date: 25 Apr 2001 00:37:44 GMT User-Agent: Xnews/M3