forked from tchernicum/bcapps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bc-dudmail3.pl
executable file
·54 lines (43 loc) · 1.62 KB
/
bc-dudmail3.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/perl
# downloads dudmail to a Unix-style mail folder
# version 3 will overwrite the original
require "/usr/local/lib/bclib.pl";
# special dir for dudmail
$maildir="/home/barrycarter/mail/dudmail";
# this is an actual 419 bait account I created
$acct = $globopts{acct};
unless ($acct) {die "--acct=account required";}
$url = "http://dudmail.com/for/$acct";
# which msgs do I already have for this account (note: using dudmails
# E?SMTPS? id is more reliable than using senders message-id)
my($cmd) = "egrep -i 'by dudmail.com .postfix. with E?SMTPS? id' $maildir/$acct";
my($out,$err,$res) = cache_command($cmd);
for $i (split(/\n/,$out)) {
$i=~/id (.*?)$/ || warn("No ID: $i");
$seen{$1} = 1;
}
# by its nature, dudmail has no passwords
my($out,$err,$res) = cache_command("curl http://dudmail.com/for/$acct","age=30");
while ($out=~s%href="/emails/(\d+)"%%is) {
my($url) = $1;
$url = "http://dudmail.com/emails/$url?mailbox=$acct&type=original_source";
# this cache can be longer, message doesnt change once received
my($out2,$err2,$res2) = cache_command("curl '$url'","age=86400");
# find message content
$out2=~m%<pre id='email_source'>(.*?)</pre>%s || warn("NO MESSAGE?:");
$msg = $1;
# unescape HTML
$msg=~s/</</isg;
$msg=~s/>/>/isg;
$msg=~s/"/\"/isg;
# find msg id
$msg=~m%by dudmail.com \(postfix\) with E?SMTPS? id (.*?)\n%is || warn "NO DUDMAIL ID: $msg";
my($dudid) = $1;
debug("DUDID: $dudid");
if ($seen{$dudid}) {
debug("Already have: $dudid");
next;
}
# TODO: check for duplicates, dont add msgs many times (but just testing now)
append_file($msg, "$maildir/$acct");
}