<?xml version="1.0" encoding="windows-1252"?>
<node id="137263" title="(code) One-liner parses ippl log for suspicious packets" created="2002-01-08 20:29:39" updated="2005-08-13 02:56:00">
<type id="1980">
snippet</type>
<author id="14909">
ybiC</author>
<data>
<field name="doctext">
</field>
<field name="snippetdesc">
I've been using this for some time, and having a wee bit o'spare time lately, decided it might possibly maybe perhaps be of use to fellow monks. &amp;nbsp; So without further ado, I offer for your consideration a perl one-liner that can help you to know when your box is being probed by sckiddies and crackers.


&lt;p&gt;
[http://pltplp.net/ippl/|ippl] is a *nix packet logger. &amp;nbsp; By configuring it to log suspicous packets in a longer format than mundane packets, and by resolving their source address, you can trivially extract info on nefarious goings-on. &amp;nbsp; The example log below illustrates my web server being probed for nonexistant FTP, DNS, and WINS services.
&lt;/p&gt;


&lt;p&gt;
&lt;i&gt;* relevent chunk from ippl.conf:&lt;/i&gt;&lt;code&gt;
noresolve all
logformat normal all
log options resolve,detaild tcp port ftp
log options resolve,detaild tcp port domain        # zone xfer
log options resolve,detaild udp port netbios-ns
etc...&lt;/code&gt;
&lt;/p&gt;


&lt;p&gt;
&lt;i&gt;* sample lines from ippl.log:&lt;/i&gt;&lt;code&gt;
Nov  2 20:14:19 www connection attempt from 199.8.65.44
Nov  2 22:03:34 last message repeated 47 time(s)
Nov  2 22:34:49 ftp connection attempt from ts1-850.f1781.quebectel.com [142.169.225.139] (142.169.225.139:21-&gt;204.27.0.137:21)
Nov  3 18:03:09 domain connection attempt from cha213245016252.chello.fr [213.245.16.252] (213.245.16.252:4709-&gt;204.27.0.137:53)
Nov  4 09:34:28 netbios-ns connection attempt from pD905543D.dip.t-dialin.net [217.5.84.61] (217.5.84.61:4642-&gt;204.27.0.137:137)&lt;/code&gt;
&lt;/p&gt;


&lt;p&gt;
&lt;i&gt;* sample munged output:&lt;/i&gt;&lt;code&gt;
Nov  2 22:34:49 ftp connection attempt from ts1-850.f1781.quebectel.com [142.169.225.139] (142.169.225.139:21-&gt;204.27.0.137:21)
Nov  3 18:03:09 domain connection attempt from cha213245016252.chello.fr [213.245.16.252] (213.245.16.252:4709-&gt;204.27.0.137:53)

Nov  4 09:34:28 netbios-ns connection attempt from pD905543D.dip.t-dialin.net [217.5.84.61] (217.5.84.61:4642-&gt;204.27.0.137:137)&lt;/code&gt;
&lt;/p&gt;


&lt;p&gt;
&lt;i&gt;&lt;b&gt;* from a perlish perspective&lt;/b&gt;, it matches any line containing an open-paren *unless* the paren is immediately preceeded by the word "time". &amp;nbsp; &lt;tt&gt;perldoc [perlman:perlre|perlre]&lt;/tt&gt; says that's a zero-width positive lookahead assertion.&lt;/i&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Update: &lt;/b&gt; Hmmm... props to [blakem] for cleaner and more recognizable syntax below. &amp;nbsp; I vaguely recall seeing that in perlre, but must've already had this'un working.
&lt;/p&gt;</field>
<field name="snippetcode">
&lt;br /&gt;&lt;br /&gt;
&lt;CODE&gt;perl -ne 'print if (/\(/ &amp;&amp; $` !~ /time$/)' &lt; ippl.log &gt; ippl.noteworthy&lt;/CODE&gt;
&lt;br /&gt;&lt;/br /&gt;</field>
</data>
</node>
