netmail-cvs Mailing List for Open Source Agents for Novell NetMail
Brought to you by:
pascal666
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(2) |
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Pascal <pas...@us...> - 2010-03-12 14:04:12
|
Update of /cvsroot/netmail/netmail In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv21335 Added Files: telnetd.pl Log Message: Port to Perl --- NEW FILE: telnetd.pl --- #!/usr/bin/perl -W # Copyright (C) 2010 Pascal # Originally written for http://netmail.sourceforge.net # Licensed under the terms of the GNU GPL, the text # of which is included as the file named "gpl.txt". use strict; use warnings; use Event::Lib; use IO::Socket::INET; event_new(new IO::Socket::INET(LocalPort => $ARGV[0], Listen => 65535, Proto => "tcp", Reuse => 1, Blocking => 0), EV_READ|EV_PERSIST, \&listen)->add; my @events; event_mainloop; sub listen { my $sock; if (($sock = $_[0]->fh->accept) && (my $remote = $sock->peerhost)) { print "Connection accepted from $remote\n"; pop(@events)->remove while @events; $sock->blocking(0); push(@events, (event_new($sock, EV_READ|EV_PERSIST, \&read, \*STDOUT)->add(), event_new(\*STDIN, EV_READ|EV_PERSIST, \&read, $sock)->add())); } } sub read { my $sock = $_[0]->fh; my $data; if ($_[1] != EV_TIMEOUT && sysread($sock, $data, 2048) && $data) { syswrite($_[2], $data); } else { pop(@events)->remove while @events; print "Connection closed\n"; } } |
From: Pascal <pas...@us...> - 2004-08-02 22:47:07
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23230 Modified Files: hashcash.java Log Message: better matching on from addresses Index: hashcash.java =================================================================== RCS file: /cvsroot/netmail/netmail/hashcash.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- hashcash.java 2 Aug 2004 22:30:40 -0000 1.2 +++ hashcash.java 2 Aug 2004 22:46:58 -0000 1.3 @@ -39,7 +39,7 @@ bits = new Integer(s.split("=")[1]).intValue(); break; case 'f': - from.add(s.split("=")[1].toLowerCase() + " - "); + from.add(s.split("=")[1].toLowerCase()); break; case '#': break; @@ -144,7 +144,7 @@ switch(s.charAt(0)) { case 'F': for (Enumeration n = from.elements(); n.hasMoreElements();) { - if (s.toLowerCase().endsWith((String)n.nextElement())) process = true; + if (s.split(" ")[0].toLowerCase().endsWith((String)n.nextElement())) process = true; } break; case 'R': |
From: Pascal <pas...@us...> - 2004-08-02 22:30:50
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20247 Modified Files: hashcash.java Log Message: Forgot to check if there were any remote users. Index: hashcash.java =================================================================== RCS file: /cvsroot/netmail/netmail/hashcash.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hashcash.java 2 Aug 2004 00:04:30 -0000 1.1 +++ hashcash.java 2 Aug 2004 22:30:40 -0000 1.2 @@ -151,7 +151,7 @@ to.push(s.split(" ")[1]); } } - + if (to.empty()) process = false; PrintStream out = new PrintStream(sock.getOutputStream()); int header = 0; if (process) { |
From: Pascal <pas...@us...> - 2004-08-02 00:05:13
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26827 Added Files: hashcash.conf Log Message: Config file for my hashcash agent for Novell NetMail --- NEW FILE: hashcash.conf --- # Hashcash agent for Novell NetWare configuration file. # http://netmail.sourceforge.net # Lines starting with a # are comments. # The only required option is "from". # The IP address of the server running NMAP. # If running on the same server as NMAP, leave at default. #IP=127.0.0.1 # The TCP port NMAP is listening for agents on. # You will not normally need to change this. #port=689 # Number of bits in desired hash-collision. # SpamAssassin assigns the following values to hashcash: # <20 bits 0 # 20 bits -0.5 # 21 bits -0.7 # 22 bits -1 # 23 bits -2 # 24 bits -3 # 25 bits -4 # >25 bits -5 # This means, when sending email to system running SpamAssassin, collisions # of less than 20 bits or more than 26 bits are a waste of time. #bits=22 # Senders whose email hashcash should be added to. # This field is case-insensitive. # Multiple values are allowed, one per line. # This value is compared to the end of the sender field of each e-mail. # Normally you will set this to your domain name. # Using the author's e-mail address Pas...@Us... as an # example, any of the below would match. from=Forge.Net #from=SourceForge.Net #from=Users.SourceForge.Net #from=66...@Us... #from=Pas...@Us... #from=pas...@us... #from=PAS...@US... #from=PaS...@Us... |
From: Pascal <pas...@us...> - 2004-08-02 00:04:39
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26721 Added Files: hashcash.java Log Message: First working version of my hashcash agent for Novell NetMail --- NEW FILE: hashcash.java --- /* Copyright (C) 2004 Pascal * Originally written for http://netmail.sourceforge.net * Licensed under the terms of the GNU GPL, the text * of which is included as the file named "gpl.txt". */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintStream; import java.net.ServerSocket; import java.net.Socket; import java.util.Calendar; import java.util.EmptyStackException; import java.util.Enumeration; import java.util.Random; import java.util.Stack; import java.util.TimeZone; import java.util.Vector; import java.security.MessageDigest; public class hashcash { public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new FileReader("hashcash.conf")); String s; String host = "127.0.0.1"; int port = 689; int bits = 22; Vector from = new Vector(); while (in.ready()) { s = in.readLine().trim(); if (s.length() > 0) switch(Character.toLowerCase(s.charAt(0))) { case 'i': host = s.split("=")[1]; break; case 'p': port = new Integer(s.split("=")[1]).intValue(); break; case 'b': bits = new Integer(s.split("=")[1]).intValue(); break; case 'f': from.add(s.split("=")[1].toLowerCase() + " - "); break; case '#': break; default: throw new Exception("Error in config file"); } } ServerSocket ss = register(host, port, "HashCash"); Stack freeThreads = HThread.freeThreads = new Stack(); HThread.host = host; HThread.bits = bits; HThread.from = from; while (!ss.isClosed()) { Socket sock = ss.accept(); try { HThread thread = (HThread) freeThreads.pop(); thread.sock = sock; thread.start(); } catch (EmptyStackException e) { new HThread(sock); } } } private static final ServerSocket register(String host, int port, String agent) { Socket nmap = null; ServerSocket ss = null; try { nmap = new Socket(host, port); BufferedReader in = new BufferedReader(new InputStreamReader(nmap.getInputStream())); String s = in.readLine(); ss = new ServerSocket(0,0,nmap.getLocalAddress()); if (s.startsWith("4242 ")) throw new Exception("Please add " + nmap.getLocalAddress().getHostAddress() + " to NMAP trusted hosts via NWAdmin."); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 1: " + s); PrintStream out = new PrintStream(nmap.getOutputStream()); out.println("QWAIT 4 " + ss.getLocalPort() + " " + agent); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("Failed to register with queue: " + s); } catch (Throwable t) { System.out.println(t.getMessage()); System.exit(1); } try { nmap.close(); } catch (Throwable t) {} return ss; } private static final class HThread extends Thread { private static Stack freeThreads; private static String host; private static int bits; private static Vector from; private final Random r = new Random(); private final Calendar cal = Calendar.getInstance(); private final MessageDigest md; public Socket sock; HThread(Socket s) throws Throwable { super(); md = MessageDigest.getInstance("SHA"); sock = s; super.start(); } public final synchronized void start() { this.notify(); } private final synchronized void waitForJob() { while (sock == null) { try { this.wait(1000); } catch (InterruptedException e) {} } } public final void run() { while (true) { try { if (!sock.getLocalAddress().getHostAddress().equals(host)) throw new Exception("unauthorized connection from " + sock.getLocalAddress().getHostAddress()); BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); String s = in.readLine(); if (!s.startsWith("6020 ")) throw new Exception("NMAP protocol error 2: " + s); String id = s.split(" ")[1]; int size = new Integer(s.split(" ")[3]).intValue(); Vector env = new Vector(); for (int x = new Integer(s.split(" ")[2]).intValue() - (in.readLine().length() + 2); x > 0; x -= (s.length() + 2)) { env.add(s = in.readLine()); } s = in.readLine(); if (!s.startsWith("6021 ")) throw new Exception("NMAP protocol error 3: " + s); boolean process = false; Stack to = new Stack(); for (Enumeration e = env.elements(); e.hasMoreElements();) { s = (String)e.nextElement(); switch(s.charAt(0)) { case 'F': for (Enumeration n = from.elements(); n.hasMoreElements();) { if (s.toLowerCase().endsWith((String)n.nextElement())) process = true; } break; case 'R': to.push(s.split(" ")[1]); } } PrintStream out = new PrintStream(sock.getOutputStream()); int header = 0; if (process) { out.println("QHEAD " + id); s = in.readLine(); if (!s.startsWith("2023 ")) throw new Exception("NMAP protocol error 4: " + s); header = new Integer(s.split(" ")[1]).intValue(); for (int x = header; x > 0; x -= (s.length() + 2)) { s = in.readLine(); if (s.startsWith("X-Hashcash: ")) process = false; } s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 5: " + s); } if (process) { out.println("QCREA"); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 6: " + s); out.println("QADDQ " + id + " 0 " + header); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 7: " + s); do { s = "0:" + timeToYYMMDD(cal) + ":" + (String)to.pop() + ":"; byte[] c = new byte[s.length() + Math.max(11,6+bits*100/595)]; System.arraycopy(s.getBytes(),0,c,0,s.length()); for (int x = s.length(); x < c.length; x++) c[x] = getRandomChar(r); byte[] h = new byte[20]; h = md.digest(c); while (!zeroBits(h,bits)) { for (int x = c.length; x-- > s.length() && (c[x] = incChar(c[x])) == 48;); h = md.digest(c); } out.println("QSTOR MESSAGE " + (c.length + 14)); out.println("X-Hashcash: " + new String(c)); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 8: " + s); } while (!to.empty()); out.println("QADDQ " + id + " " + header + " " + (size - header)); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 9: " + s); for (Enumeration e = env.elements(); e.hasMoreElements();) { out.println("QSTOR RAW " + e.nextElement()); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 10: " + s); } out.println("QRUN"); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 11: " + s); out.println("QDELE " + id); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 12: " + s); } out.println("QDONE"); s = in.readLine(); if (!s.startsWith("1000 ")) throw new Exception("NMAP protocol error 13: " + s); } catch (Throwable t) { System.out.println(t.getMessage()); } finally { try { sock.close(); } catch (Throwable t) {} } sock = null; freeThreads.push(this); waitForJob(); } } /* * All methods below this line are from Yet Another Hash Cash Tool 1.0 * Created on 05.12.2003 by Sebastian Gesemann (sgeseman \at upb \dot de) */ /** * @return one random character out of 62 ('A'..'Z','a'..'z','0'..'9') */ private static final byte getRandomChar(Random rnd) { int x = rnd.nextInt(62); if (x<10) return (byte)(48+x); // ASCII code for '0'..'9' x-=10; if (x<26) return (byte)(65+x); // ASCII code for 'A'..'Z' x-=26; return (byte)(97+x); // ASCII code for 'a'..'z' } /** * @param c * @return c+1 (within '0'..'9','A'..'Z','a'..'z') */ private static final byte incChar(byte c) { c++; if (c==48+10) return (byte)65; if (c==65+26) return (byte)97; if (c==97+26) return (byte)48; return c; } /** * @param ba * @param minimum * @return checks whether a bitstring (MSB first) starts at least with [minimum] zeros */ private static final boolean zeroBits(byte[] ba, int minimum) { int o=0; while (minimum>=8) { if (ba[o++]!=(byte)0) return false; minimum-=8; } if (minimum>0) { int m = (0xFF << (8-minimum)) & 0xFF; if ((ba[o] & m) != 0) return false; } return true; } /** * @param i * @return returns a two-digit string (leading zero for i<10) */ private static final String twoDigits(int i) { return i<10 ? "0"+i : Integer.toString(i); } /** * @param c * @return returns a 6 character string (YYMMDD) for a given Calendar */ private static final String timeToYYMMDD(Calendar c) { return twoDigits(c.get(Calendar.YEAR) % 100) +twoDigits((c.get(Calendar.MONTH)+1) % 100) +twoDigits(c.get(Calendar.DAY_OF_MONTH) % 100); } } } |
From: Pascal <pas...@us...> - 2004-07-25 16:34:18
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8433 Modified Files: spamd.raw Log Message: more in line with NMAP standards Index: spamd.raw =================================================================== RCS file: /cvsroot/netmail/netmail/spamd.raw,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- spamd.raw 8 Jul 2004 06:28:08 -0000 1.4 +++ spamd.raw 25 Jul 2004 16:34:08 -0000 1.5 @@ -271,7 +271,7 @@ Listen => SOMAXCONN ) || die "Could not create INET socket: $! $@\n"; my $listen = $server->sockport; -print $nmap "QWAIT 4 $listen SpamAssassin\n"; +print $nmap "QWAIT 1 $listen SpamAssassin\n"; die "Failed to register with queue" if $nmap->getline !~ /^1000 /; $nmap->close; @@ -476,7 +476,7 @@ my @envelope; while ($_ = $client->getline) { last if /^6021 /; - if (/^SpamAssassin/ || /^F- -/) { + if (/^spamAssassin/ || /^F- -/) { until ($client->getline =~ /^6021 /) {}; print $client "QDONE\n"; $_ = $client->getline; @@ -566,7 +566,7 @@ return 1; } } - print $client "QSTOR RAW SpamAssassin\n"; + print $client "QSTOR RAW spamAssassin\n"; unless (/^1000 /) { protocol_error ($_); return 1; |
From: Pascal <pas...@us...> - 2004-07-08 06:28:19
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12947 Modified Files: spamd.raw Log Message: ignore locally generated messages (such as bounces) Index: spamd.raw =================================================================== RCS file: /cvsroot/netmail/netmail/spamd.raw,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- spamd.raw 24 Jun 2004 08:14:21 -0000 1.3 +++ spamd.raw 8 Jul 2004 06:28:08 -0000 1.4 @@ -476,7 +476,8 @@ my @envelope; while ($_ = $client->getline) { last if /^6021 /; - if (/SpamAssassin/) { + if (/^SpamAssassin/ || /^F- -/) { + until ($client->getline =~ /^6021 /) {}; print $client "QDONE\n"; $_ = $client->getline; unless (/^1000 /) { @@ -484,7 +485,7 @@ return 1; } $client->close; - return; + return 1; } push(@envelope, $_); } |
From: <net...@li...> - 2004-06-24 08:14:30
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21166 Modified Files: spamd.raw Log Message: Add -flag option Index: spamd.raw =================================================================== RCS file: /cvsroot/netmail/netmail/spamd.raw,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- spamd.raw 21 Jun 2004 06:31:41 -0000 1.2 +++ spamd.raw 24 Jun 2004 08:14:21 -0000 1.3 @@ -110,6 +110,7 @@ 'c' => \$opt{'create-prefs'}, 'daemonize!' => \$opt{'daemonize'}, 'd' => \$opt{'daemonize'}, + 'flag|f' => \$opt{'flag'}, 'help|h' => \$opt{'help'}, 'ip-address|i=s' => \$opt{'ip-address'}, 'max-children|m=i' => \$opt{'max-children'}, @@ -471,7 +472,23 @@ sub check { my $id = $_[1]; local ($_); - until ($client->getline =~ /^6021 /) {}; + $client->getline; + my @envelope; + while ($_ = $client->getline) { + last if /^6021 /; + if (/SpamAssassin/) { + print $client "QDONE\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + $client->close; + return; + } + push(@envelope, $_); + } + print $client "QRETR $id MESSAGE\n"; $_ = $client->getline; unless (/^2023 /) { @@ -499,11 +516,67 @@ my $mail = Mail::SpamAssassin::NoMailAudit->new ( data => \@msglines ); + undef @msglines; # Now use copy-on-writed (hopefully) SA object my $status = $spamtest->check($mail); if ($status->is_spam) { + if ($opt{'flag'}) { + print $client "QINFO $id\n"; + $_ = $client->getline; + unless (/^2001 /) { + protocol_error ($_); + return 1; + } + @_ = split; + my $header_length = $_[3]; + my $body_length = $_[4]; + print $client "QCREA\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QADDQ $id 0 $header_length\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QSTOR MESSAGE 17\n"; + print $client "X-Spam-Flag: YES\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QADDQ $id $header_length $body_length\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + foreach (@envelope) { + print $client "QSTOR RAW $_"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + } + print $client "QSTOR RAW SpamAssassin\n"; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QRUN\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + } print $client "QDELE $id\n"; $_ = $client->getline; unless (/^1000 /) { @@ -1050,6 +1123,7 @@ -C path, --configpath=path Path for default config files --siteconfigpath=path Path for site configs (def: /etc/mail/spamassassin) -d, --daemonize Daemonize + -f, --flag Set a flag in the message header instead of deleting it -h, --help Print usage message. -i ipaddr, --ip-address=ipaddr IP NMAP is on (default: 127.0.0.1) -m num, --max-children num Allow maximum num children @@ -1129,6 +1203,10 @@ Detach from starting process and run in background (daemonize). +=item B<-f>, B<--flag> + +Add "X-Spam-Flag: YES" to the message header of spam instead of deleting it. + =item B<-h>, B<--help> Print a brief help message, then exit without further action. |
From: <net...@li...> - 2004-06-22 23:32:24
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16569 Modified Files: telnetd.java Log Message: Now listens for a new connection when one terminates. Index: telnetd.java =================================================================== RCS file: /cvsroot/netmail/netmail/telnetd.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- telnetd.java 21 Jun 2004 06:28:31 -0000 1.1 +++ telnetd.java 22 Jun 2004 23:32:15 -0000 1.2 @@ -9,29 +9,30 @@ import java.io.PrintStream; import java.net.ServerSocket; import java.net.Socket; -public class telnetd { +public class telnetd implements Runnable { + static volatile PrintStream out; public static void main(String[] args) throws Throwable { ServerSocket ss = new ServerSocket(Integer.parseInt(args[0])); - Socket s = ss.accept(); - System.out.println("Connection from: " + s.getInetAddress()); - (new send(s.getOutputStream())).start(); - BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); + new Thread(new telnetd()).start(); while (true) { - System.out.println(in.readLine()); + Socket s = ss.accept(); + System.out.println("Connection from: " + s.getInetAddress()); + out = new PrintStream(s.getOutputStream()); + BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); + String t = in.readLine(); + while (t != null) { + System.out.println(t); + t = in.readLine(); + } + System.out.println("Connection closed."); } } -} - -class send extends Thread { - OutputStream s; - send(OutputStream s) { - this.s = s; - } public void run() { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - PrintStream out = new PrintStream(s); + String x; while (true) try { - out.println(in.readLine()); + x = in.readLine(); + out.println(x); } catch(Throwable t){} } } |