[Exim] Spam detection

Top Page
Delete this message
Reply to this message
Author: Jason Robertson
Date:  
To: exim-users
Subject: [Exim] Spam detection
With Exim4, has anyone build a spam detecting agent that actually will
now decode the mime messages that spammers are now using?

I do have some PHP Scripts for exim 3.x, that do list the queue, and
allow removing and such of messages, this file is used through a ssh
tunnel. As well you will have to fix the META lines below, there is
two one at the beginning of index.php, and one at the end of exim.php.

Enjoy Jason

will attach inline
==================================================
index.php
<html><head>
<meta http-equiv='refresh'
content='300;URL=http://localhost/index.php'>
</head><body>
<?
$head = shell_exec("exim -Mvh $mid");


$string = shell_exec("exim -bp");
preg_match_all("/(.+) (.+) (.+) (<.*>) \*\*\*(.+)\*\*\*\n\s+ (.+)\n/",
$string, $output, PREG_PATTERN_ORDER);

$string = shell_exec("exim -bp");
preg_match_all("/(\S+) (.+) (.+) (<.*>)\n\s+(.+)\n/", $string,
$output2, PREG_PATTERN_ORDER);

$i = 0;
$j = count($output[0]);

print "<h3>frozen</h3>\n";
print "<form method=post action=exim.php?type=multi&tot=$j>\n";
print "<table>\n";
print "<tr><td>Time</td><td>size</td><td>Message-
ID</td><td>Sender</td><td>Recepient</td><td>&nbsp;</td><td>&nbsp;</td><t
d>&nbsp;</td></tr>\n";
for ($i=0; $i<$j; $i++) {
$output[4][$i] = ereg_replace("<", "&lt", $output[4][$i]);
$output[4][$i] = ereg_replace(">", "&gt", $output[4][$i]);
print "<tr>";
print "<td>".$output[1][$i]."</td>\n";
print "<td>".$output[2][$i]."</td>\n";
print "<td>".$output[3][$i]."</td>\n";
print "<td>".$output[4][$i]."</td>\n";
print "<td>".$output[6][$i]."</td>\n";
print "<td><a
href=exim.php?service=View&type=single&mid=".$output[3][$i]."
>View</a></td>\n";

print "<td><a
href=exim.php?service=Delete&type=single&mid=".$output[3][$i]."
>Delete</a></td>\n";

print "<td><a
href=exim.php?service=Thaw&type=single&mid=".$output[3][$i]."
>Thaw</a></td>\n";

print "<td><a
href=exim.php?service=Fail&type=single&mid=".$output[3][$i]."
>Fail</a></td>\n";

print "<td><a
href=exim.php?service=Deliver&type=single&mid=".$output[3][$i]."
>Deliver</a></td>\n";

print "<td><input type=checkbox name=$i value=".$output[3][$i].">\n";
print "</tr>\n";
$head = shell_exec("exim -Mvh ".$output[3][$i]);
$head = ereg_replace("<", "&lt", $head);
$head = ereg_replace(">", "&gt", $head);
# print "<tr><td colspan=9><textarea rows=10
cols=80>$head</textarea></td></tr>\n";
}

print "</table>\n";
print "<input type=submit name=\"service\" value=\"Delete\">";
print "<input type=submit name=\"service\" value=\"Thaw\">";
print "<input type=submit name=\"service\" value=\"Fail\">";
print "<input type=submit name=\"service\" value=\"Deliver\">";
print "<input type=submit name=\"service\" value=\"Freeze\">";
print "</form>\n";

$i = 0;
$j = count($output2[0]);
print "\n<h3>Unfrozen</h3>\n";
print "<form method=post action=exim.php?type=multi&tot=$j>\n";
print "<table>\n";
print "<tr><td>Time</td><td>size</td><td>Message-
ID</td><td>Sender</td><td>Recepient</td><td>&nbsp;</td><td>&nbsp;</td><t
d>&nbsp;</td></tr>\n";
for ($i=0; $i<$j; $i++) {
$output2[4][$i] = ereg_replace("<", "", $output2[4][$i]);
$output2[4][$i] = ereg_replace(">", "", $output2[4][$i]);
print "<tr>";
print "<td>".$output2[1][$i]."</td>";
print "<td>".$output2[2][$i]."</td>";
print "<td>".$output2[3][$i]."</td>";
print "<td>".$output2[4][$i]."</td>";
print "<td>".$output2[5][$i]."</td>";
print "<td><a
href=exim.php?service=View&type=single&mid=".$output2[3][$i]."
>View</a></td>\n";

print "<td><a
href=exim.php?service=Delete&type=single&mid=".$output2[3][$i]."
>Delete</a></td>\n";

print "<td><a
href=exim.php?service=Freeze&type=single&mid=".$output2[3][$i]."
>Freeze</a></td>\n";

print "<td><a
href=exim.php?service=Fail&type=single&mid=".$output2[3][$i].">Fail</a><
/td>\n";
print "<td><a
href=exim.php?service=Deliver&type=single&mid=".$output2[3][$i]."
>Deliver</a></td>\n";

print "<td><input type=checkbox name=$i
value=\"".$output2[3][$i]."\">\n";
print "</tr>\n";
$head = shell_exec("exim -Mvh ".$output2[3][$i]);
$head = ereg_replace("<", "&lt", $head);
$head = ereg_replace(">", "&gt", $head);
# print "<tr><td colspan=10><textarea rows=10
cols=80>$head</textarea></td></tr>\n";
}
print "</table>\n";
print "<input type=submit name=\"service\" value=\"Delete\">";
print "<input type=submit name=\"service\" value=\"Thaw\">";
print "<input type=submit name=\"service\" value=\"Fail\">";
print "<input type=submit name=\"service\" value=\"Deliver\">";
print "<input type=submit name=\"service\" value=\"Freeze\">";
print "</form>\n";
?>
</body>
</html>
======================================================
exim.php
<?
$type = $HTTP_GET_VARS["type"];
$j = $HTTP_GET_VARS["tot"];
$output = "";
$i = 0;

if (strcmp($type,"single")==0) {
$service = $HTTP_GET_VARS["service"];
$output = $HTTP_GET_VARS["mid"];
}

if (strcmp($type,"multi")==0) {
  $service = $HTTP_POST_VARS["service"];
  for ($i=0;$i<$j;$i++) {
    $output = $output.$HTTP_POST_VARS[$i]." ";
  }
}



if (strcmp($service,"Delete")==0) {
printheader();
$data = shell_exec("exim -Mrm $output");
print "<pre>";
print "Attempted to Delete the following messages\n$output\n\n";
print "$data";
print "</pre>";
}

if (strcmp($service,"Thaw")==0) {
printheader();
$data = shell_exec("exim -Mt $output");
print "<pre>";
print "Attempted to thaw the following messages\n$output\n\n";
print "$data";
print "</pre>";
}

if (strcmp($service,"Fail")==0) {
printheader();
$data = shell_exec("exim -Mg $output");
print "<pre>";
print "Attempted to Fail the following messages\n$output\n\n";
print "$data";
print "</pre>";
}

if (strcmp($service,"Freeze")==0) {
printheader();
$data = shell_exec("exim -Mf $output");
print "<pre>";
print "$output";
print "Attempted to Freeze the following messages\n$output\n\n";
print "$data";
print "</pre>";
}

if (strcmp($service,"Deliver")==0) {
printheader();
$data = shell_exec("exim -d -M $output 2>&1");
print "<pre>";
print "Attempted to Deliver the following messages\n$output\n\n";
print "$data";
print "</pre>";
}

if (strcmp($service,"View")==0) {
set_time_limit(120);


print "<hr>";
$head = shell_exec("exim -Mvh $output");
$body = (shell_exec("exim -Mvb $output"));
$log = (shell_exec("exim -Mvl $output"));

$body = ereg_replace("<", "&lt", $body);
$body = ereg_replace(">", "&gt", $body);
print "<pre>\n";
print "$head\n";
print "</pre>\n";
print "<hr>\n";
print "<pre>\n";
print "$log\n";
print "</pre>\n";
print "<hr>\n";
print "<pre>\n";
print "$body\n";
print "</pre>\n";
}

function printheader() {
print "<html><head>";
print "<meta http-equiv='refresh'
content='2;URL=http://localhost/index.php'>";
print "</head><body>";
}
?>
</body>
</html>

--
Jason Robertson
Now at the Nation Research Council.