<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:admin="http://webns.net/mvcb/"
>
<channel>
<title>CipherDyne</title>
<link>http://www.cipherdyne.org</link>
<description>The network and system security blog of Michael Rash</description>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2000-2008, Michael Rash.  All Rights Reserved.</dc:rights>
<dc:creator>Michael Rash</dc:creator>
<dc:date>2006-02-28T16:48:01-05:00</dc:date>
<admin:generatorAgent rdf:resource="http://www.cipherdyne.org" />

<!-- begin_stories -->
<item>
<link>http://www.cipherdyne.org/blog/2008/07/software-release-fwknop-1.9.6.html</link>
<title>Software Release - fwknop-1.9.6</title>
<dc:date>2008-07-22T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<!-- category: fwknop.html -->
<!-- category: software-releases.html -->
<a href="/fwknop">
<img align="right" src="/images/release.png" title="software release fwknop-1.9.6" alt="software release fwknop-1.9.6" /></a>
The 1.9.6 release of <a href="/fwknop">fwknop</a> is ready for <a href="/fwknop/download">download</a>.
This release was made at <a href="http://www.thelasthope.org/">The Last HOPE</a> conference over the
weekend in NYC, and introduces several new features that make SPA traffic more difficult to detect
on a network even when an IDS is watching.  Previous to the 1.9.6 version of fwknop, it was
possible to write Snort rules to detect SPA traffic by looking for invariant artifacts from
base-64 encoding and also from encryption operations (both Rijndael and GnuPG).  These artifacts
are now stripped out by the fwknop client before being transmitted on the wire, and the result
is that SPA packets are now more highly randomized.  This implies that SPA packets generated by
the 1.9.6 release are not compatible with older fwknop deployments by default, but the client
does offer command line arguments to maintain compatibility if necessary.
<br/><br/>
Here is an excerpt from the
<a href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.6/ChangeLog">ChangeLog</a>:
<br/><br/>
<ul>
<li>SPA packets are base64-encoded by the fwknop client, and this encoding
pads data with '=' chars until the total length of the encoded data is a
multiple of four.  This characteristic can be used within a Snort rule
to assist in the detection of SPA communications.  The 1.9.6 release of
fwknop strips out these padding characters before the client sends an
SPA packet, and the fwknopd server adds them back in (to form a multiple
of four) before base64 decoding the packet data.  This reduces the level
of identifying information in SPA packets and therefore makes it more
difficult to detect the usage of SPA for service access.  For reference,
a Snort rule that would detect SPA packets via the trailing '=' chars
(previous to this release) would be:
<br/><br/>
alert udp any any -&gt; any 62201 (msg:"fwknop SPA traffic"; dsize:&gt;150;
pcre:"/==$/"; sid:20080001; rev:1;)
<br/><br/>
</li>
<li>According to the 'file' command (via it's 'magic') database, files that
are encrypted with GnuPG begin with 0x8502, and this is true for SPA
packets generated by fwknop (previous to this release).  In
fwknop-1.9.6, the "hQ" prefix is removed by the fwknop client and added
back in by the fwknopd server if it doesn't exist.  This measure is
another effort to make SPA packets more difficult to detect on the wire,
such as with the following Snort rule:
<br/><br/>
alert udp any any -&gt; any 62201 (msg:"fwknop GnuPG encrypted SPA traffic";
content:"hQ"; depth:2; dsize:&gt;1000; sid:20080003; rev:1;)
<br/><br/>
</li>
<li>Updated the fwknop client to randomize the UDP source port for default
SPA packet generation.  There is also a new command line argument
--Source-port &lt;port&gt; to allow the user to manually set the source port
on the fwknop client command line.  A lot more attention is given now to
source ports after the Dan Kaminsky DNS caching exploit, and it turns
out that even on Linux that the kernel did not randomize UDP source
ports until the 2.6.24 kernel.  Of course, any userspace process is free
to request a random port itself, but if a userspace application did not
build this in then it would be up to the kernel to assign a source port.
In the case of Linux, here are two links that show the change to the
kernel code as well as the ChangeLog entry for UDP source port
randomization:
<br/><br/>
<a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=32c1da70810017a98aa6c431a5494a302b6b9a30">Kernel commit</a>
<br/><br/>
<a href="http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.24">ChangeLog-2.6.24</a>
</li>
</ul>

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/07/mitigating-dns-cache-poisoning-attacks-with-iptables.html</link>
<title>Mitigating DNS Cache Poisoning Attacks with iptables</title>
<dc:date>2008-07-14T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: programming.html -->
<a href="http://digg.com/security/Stopping_Kaminsky_s_DNS_Attack_with_One_iptables_Rule">
<img align="left" src="/images/digg_it.gif" title="Digg Mitigating the Kaminksy DNS attack" alt="Digg Mitigating the Kaminksy DNS attack" /></a><br/>
<a href="http://www.doxpara.com/">
<img align="right" src="/images/doxpara_logo.gif" title="Kaminsky DNS Exploit" alt="Kaminsky DNS Exploit" width="300" height="100" /></a>
It is well known that last week
<a href="http://www.doxpara.com/">Dan Kaminsky</a>
<a href="http://www.doxpara.com/?p=1162">publicized</a> a cache poisoning exploit
against DNS.  The details of this exploit have not yet been released, but Dan will present
a talk at the <a href="http://www.blackhat.com/">Blackhat Briefings</a> next month that
will clarify the technical specifics behind the vulnerability - and therefore how to
exploit it.  Even though Dan has yet to release the details, enough
<a href="http://www.kb.cert.org/vuls/id/800113">information</a> has already been
released to show that iptables <i>may</i> be able to mitigate the vulnerability
with a single well-chosen rule in your iptables policy.  Further, this technique can be
used right now whenever a vulnerable DNS server is deployed on (or behind) a system running
iptables.  Although updates have been released in a coordinated effort for most platforms,
not everyone patches their systems immediately, and in some cases it can be easier to
execute a few iptables commands than to deploy such updates.  Of course, patching the
vulnerability should be the top priority, but the exact details of the attack haven't been
disclosed so it is hard to gauge risk.  That said, if Dan Kaminsky says to patch, then
it's probably a good idea to do so.  In the meantime, let's press on.
<br/><br/>
The <a href="http://www.kb.cert.org/vuls/id/800113">CERT advisory</a> highlights
three problems in the existing DNS infrastructure:
<br/><br/>
<ol>
<li>Lack of sufficient randomness in the selection of source ports for DNS queries</li>
<li>DNS transaction ID values that also exhibit insufficient randomness</li>
<li>Multiple outstanding requests for the same resource record</li>
</ol>
For this blog post we are concerned about source port predictability for DNS queries,
but Dan's cache poisoning attack (most likely) relies heavily on the first two problems
in combination.  Dan has probably found a clever way to weaponize his attack so that it
can be leveraged against lots of DNS servers.
<br/><br/>
How can iptables help?  First, let's assume that source port predictability is a
necessary prerequisite to poison a DNS cache by Dan's technique.  So, if iptables can
introduce additional randomness into the source port that
<a href="http://www.isc.org/index.pl?/sw/bind/index.php">bind</a>
uses - at least as far as any upstream DNS server can tell - for each DNS query then an
attacker would not be able to rely on source port predictability.  The iptables <b>SNAT</b>
target supports the ability to randomize both TCP and UDP source ports (see the <b>--random</b>
option) even if a userspace application chooses a specific source port.  This applies to
both locally generated and forwarded packets.  Hence, if a piece of userland software
(such as bind) uses predictable source ports, iptables can rectify this via the SNAT target
subject to some connection tracking restrictions.
<br/><br/>
To illustrate this, we use nmap with its <b>--source-port</b> option to set the source
port to 44444 for a UDP scan of port 53 on two different servers, and verify with a packet
trace that the source port is indeed set to this value.  We'll assume the IP's <b>22.2.2.2</b>
and <b>33.3.3.3</b> simulate upstream DNS servers from a local DNS server on the
system with IP <b>11.1.1.1</b>:
<br/><br/>
<pre>
# nmap --source-port 44444 -P0 -p 53 -sU 22.2.2.2 33.3.3.3

19:26:19.625637 IP 11.1.1.1.44444 &gt; 22.2.2.2.53: [|domain]
19:26:19.625790 IP 11.1.1.1.44444 &gt; 33.3.3.3.53: [|domain]
19:26:19.729520 IP 11.1.1.1.44444 &gt; 33.3.3.3.53: [|domain]
19:26:20.626527 IP 11.1.1.1.44444 &gt; 22.2.2.2.53: [|domain]
</pre>
As you can see, the source port for each UDP datagram from 11.1.1.1 is set to 44444.
Now, to force the source port to be randomized when each packet is transmitted despite
setting it to 44444 from the nmap command line, let's use the SNAT target with the
--random option (note that it is assumed that the iptables policy is also using
connection tracking to allow expected replies through as well, etc.):
<br/><br/>
<pre>
# iptables -t nat -I POSTROUTING 1 -p udp -s 11.1.1.1 --dport 53 \
-j SNAT --to 11.1.1.1 --random
</pre>
By executing the same nmap command again, now we see that the SNAT target has changed
the source port on the outgoing UDP datagrams to 9374 (for 22.2.2.2) and 54743 (for
33.3.3.3):
<br/><br/>
<pre>
# nmap --source-port 44444 -P0 -p 53 -sU 22.2.2.2 33.3.3.3

19:28:05.613637 IP 11.1.1.1.9374 &gt; 22.2.2.2.53: [|domain]
19:28:05.613792 IP 11.1.1.1.54743 &gt; 33.3.3.3.53: [|domain]
19:28:05.717536 IP 11.1.1.1.54743 &gt; 33.3.3.3.53: [|domain]
19:28:06.617553 IP 11.1.1.1.9374 &gt; 22.2.2.2.53: [|domain]

</pre>
Hence, iptables can introduce randomness into source ports via a NAT operation
regardless of whether a userspace application requests a specific source port.
<br/><br/>
However, you may have noticed that nmap generates two packets for each scan
of UDP/53, and you may have also noticed that the source port is 9374 for <i>both</i>
packets sent to 22.2.2.2, and 54743 for <i>both</i> packets sent to 33.3.3.3.  While
the original source port of 44444 has definitely been randomized, it appears that this
randomization is not taking place on a per-packet basis.  What is really happening is
that iptables has to use its connection tracking mechanism to map packets translated
with the SNAT target to the correct socket, and this mapping is created from the
srcIP/dstIP/sport/dport/protocol tuple along with a set of timers (see the
nf_ct_udp_timeout and nf_ct_udp_timeout_stream variables in the kernel
linux/net/netfilter/nf_conntrack_proto_udp.c file).  So, if multiple requests are
made to the same upstream DNS server within a 30 second time window, then the <b>SNAT
--random</b> rule will map the source port for each request to the same (randomly
assigned) source port - the initial tuples are the same after all.
<br/><br/>
At first glance this might seem to be a show stopper, but assuming that Dan's cache
poisoning attack requires a process of querying different DNS servers - at least one
of which is under the control of the attacker so that the source port behavior of the
targeted server can be monitored - then the SNAT --random strategy would provide an
effective defense.  That is, the iptables state tracking code will assign a different
random source port on (at least) a per-server basis even for rapid sets of DNS
queries.  Further, for queries to the same DNS server that are 30 seconds apart, the
source port will change on a per-query basis as well.
<br/><br/>
This should be an effective defense against the attack, but we'll have to wait for
Blackhat to be sure.
<br/><br/>
On another note, applications commonly do not bother requesting specific source ports
for client sockets because they assume that the networking stack provided by the local
kernel will assign a sensible source port.  Or, they don't have to worry about the source
port because they build in enough security at the application layer (unlike DNS
implementations that don't sufficiently randomize transaction ID's) such that source
port prediction does not give an advantage to the attacker.  Still, those stacks that
don't choose a random source port are not helping the state of network security, and
the Kaminsky DNS attack is a perfect example of why.  It turns out that the Linux kernel
has only recently started
<a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=32c1da70810017a98aa6c431a5494a302b6b9a30">
randomizing UDP source ports</a> as of
<a href="http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.24">2.6.24</a>.
<br/><br/>
<i>Update 07/16/2008</i>:  Jon Hart has also written a
<a href="http://blog.spoofed.org/2008/07/mitigating-dns-cache-poisoning-with-pf.html">blog post</a>
that illustrates using OpenBSD's pf firewall to implement a similar mitigation strategy.
Hence, multiple pieces of firewall infrastructure can offer effective protection
from the cache poisoning attack.
<br/><br/>

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/07/analyzing-a-trac-spam-attempt.html</link>
<title>Analyzing a Trac SPAM Attempt</title>
<dc:date>2008-07-05T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: system-administration.html -->
<a href="http://trac.edgewall.org/">
<img align="right" src="/images/trac_logo.png" title="Spam Attempts Through Trac" alt="Spam Attempts Through Trac" /></a>
One of the best web interfaces for visualizing Subversion repositories (as well as providing
integrated project management and ticketing functionality) is the
<a href="http://trac.edgewall.org/">Trac Project</a>, and all Cipherdyne software projects
<a href="http://trac.cipherdyne.org/trac">use it</a>.  With Trac's success, it also becomes
a target for those that would try to subvert it for purposes such as creating spam.  Because
I deploy Trac with the Roadmap, Tickets, and Wiki features
<a href="/blog/2008/02/deploying-the-trac-timeline-and-browse-source-features.html">disabled</a>,
my deployment essentially does not accept user-generated content (like comments in tickets
for example) for display.  This minimizes my exposure to Trac spam, which has become a
problem significant enough for various spam-fighting strategies to be developed such as
<a href="http://madwifi.org/wiki/FightingTracSpam">configuring mod-security</a> and a
<a href="http://trac.edgewall.org/wiki/SpamFilter">plugin</a> from the Trac project itself.
<br/><br/>
Even though my Trac deployment does not display user-generated content, there are still
places where Trac accepts query strings from users, and spammers seem to try and use these
fields for their own ends.  Let's see if we can find a few examples.  Trac web
logs are informative, but sifting through huge logfiles can be tedious.  Fortunately,
simply sorting the logfiles by line length (and therefore by web request length) allows many
suspicious web requests to bubble up to the top.  Below is a simple perl script
<b>sort_len.pl</b> that sorts
any ascii text file by line length, and precedes each printed line with the line length
followed by the number of lines equal to that length.  That is, not all lines are printed
since the script is designed to handle large files - we want the unusually long lines to
be printed but the many shorter lines (which represent the vast majority of legitimate
web requests) to be summarized.  This is an important feature considering that at this
point there is over 2.5GB of log data specifically from my Trac server.
<br/><br/>
<pre>
$ cat sort_len.pl
#!/usr/bin/perl -w
#
# prints out a file sorted by longest lines
#
# $Id: sort_len.pl 1739 2008-07-05 13:44:31Z mbr  $
#

use strict;

my %url       = ();
my %len_stats = ();
my $mlen = 0;
my $mnum = 0;

open F, "&lt; $ARGV[0]" or die $!;
while (&lt;F&gt;) {
    my $len = length $_;
    $url{$len} = $_;
    $len_stats{$len}++;
    $mlen = $len if $mlen &lt; $len;
    $mnum = $len_stats{$len}
        if $mnum &lt; $len_stats{$len};
}
close F;

$mlen = length $mlen;
$mnum = length $mnum;

for my $len (sort {$b &lt;=&gt; $a} keys %url) {
    printf "[len: %${mlen}d, tot: %${mnum}d] %s",
            $len, $len_stats{$len}, $url{$len};
}

exit 0;
</pre>

To illustrate how it works, below is the output of the sort_len.pl script used against
itself.  Note that at the top of the output the more interesting code appears whereas
the most uninteresting code (such as blank lines and lines that contain closing "}"
characters) are summarized away at the bottom:

<pre>
$ ./sort_len.pl sort_len.pl
[len: 51, tot: 1] # $Id: sort_len.pl 1739 2008-07-05 13:44:31Z mbr  $
[len: 50, tot: 1]     printf "[len: %${mlen}d, tot: %${mnum}d] %s",
[len: 48, tot: 1]             $len, $len_stats{$len}, $url{$len};
[len: 44, tot: 1] # prints out a file sorted by longest lines
[len: 43, tot: 1] for my $len (sort {$b &lt;=&gt; $a} keys %url) {
[len: 37, tot: 1]         if $mnum &lt; $len_stats{$len};
[len: 34, tot: 1]     $mlen = $len if $mlen &lt; $len;
[len: 32, tot: 1] open F, "&lt; $ARGV[0]" or die $!;
[len: 29, tot: 1]     $mnum = $len_stats{$len}
[len: 25, tot: 1]     my $len = length $_;
[len: 24, tot: 1]     $len_stats{$len}++;
[len: 22, tot: 2] $mnum = length $mnum;
[len: 21, tot: 1]     $url{$len} = $_;
[len: 20, tot: 2] my %len_stats = ();
[len: 19, tot: 1] #!/usr/bin/perl -w
[len: 14, tot: 3] while (&lt;F&gt;) {
[len: 12, tot: 1] use strict;
[len:  9, tot: 1] close F;
[len:  8, tot: 1] exit 0;
[len:  2, tot: 5] }
[len:  1, tot: 6] 
</pre>

Now, let's execute the sort_len.pl script against the trac_access_log file and look
at one of the longest web requests.  (The sort_len.pl script was able to reduce
the 12,000,000 web requests in my Trac logs to a total of 610 interesting lines.)  This
particular request is 888 characters long, but there were some other similar suspicious
requests that had over 4,000 characters that are not displayed for brevity:

<pre>
[len: 888, tot: 1] 195.250.160.37 - - [02/Mar/2008:00:30:17 \
-0500] "GET /trac/fwsnort/anydiff?new_path=%2Ffwsnort%2Ftags%2Ffwsnort\
-1.0.3%2Fsnort_rules%2Fweb-cgi.rules&amp;old_path=%2Ffwsnort%2Ftags%2F\
fwsnort-1.0.3%2Fsnort_rules%2Fweb-cgi.rules&amp;new_rev=http%3A%2F%2Ff\
1234.info%2Fnew5%2Findex.html%0Ahttp%3A%2F%2Fa1234.info%2Fnew4%2F\
map.html%0Ahttp%3A%2F%2Ff1234.info%2Fnew2%2Findex.html%0Ahttp%3A%2F\
%2Fs1234.info%2Fnew9%2Findex.html%0Ahttp%3A%2F%2Ff1234.info%2Fnew6%2F\
map.html%0A&amp;old_rev=http%3A%2F%2Ff1234.info%2Fnew5%2Findex.html%0Ahttp\
%3A%2F%2Fa1234.info%2Fnew4%2Fmap.html%0Ahttp%3A%2F%2Ff1234.info%2Fnew2\
%2Findex.html%0Ahttp%3A%2F%2Fs1234.info%2Fnew9%2Findex.html%0Ahttp%3A\
%2F%2Ff1234.info%2Fnew6%2Fmap.html%0A HTTP/1.1" 200 3683 "-" \
"User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; \
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR \
1.1.4322; .NET CLR 2.0.50727; InfoPath.2)"
</pre>

My guess is that the above request is a bot that is trying to do one of two
things: <b>1)</b> force Trac to accept the content in the request (which contains
a bunch of links to pages like "http://f1234.info/new/index.html" - note that
I altered the domain so as to not legitimize the original content) and
display it for other Trac users or to search engines, or <b>2)</b> force Trac
itself to generate web requests to the provided links (perhaps as a way to increase
hit or referrer counts from domains - like mine - that are not affiliated with the
spammer).  Either way, the strategy is flawed because the request is against the
Trac "anydiff" interface which doesn't accept user content other than svn revision
numbers, and (at least in Trac-0.10.4) such requests do not cause Trac to issue any
external DNS or web requests - I verified this with tcpdump on my Trac server after
generating similar requests against it.
<br/><br/>
Still, in all of my Trac web logs, the most suspicious web requests are against
the "anydiff" interface, and specifically against the "web-cgi.rules" file
bundled within the <a href="/fwsnort">fwsnort</a> project.  But, the requests
never come from the same IP address, the "anydiff" spam attempts never hit any
other link besides the web-cgi.rules page, and they started with regularity
in March, 2008.  This makes a stronger case for the activity coming from bot
that is unable to infer that its activities are not actually working (no
surprise there).  Finally, I left the original IP address <b>195.250.160.37</b>
of the web request above intact so that you can look for it in your own web
logs.  Although 195.250.160.37 is
<a href="http://www.spamhaus.org/query/bl?ip=195.250.160.37">not listed</a>
in the <a href="http://www.spamhaus.org">Spamhaus</a> DNSBL service, a rudimentary
<a href="http://www.google.com/search?q=195.250.160.37&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=com.ubuntu:en-US:unofficial&amp;client=firefox-a">
Google search</a> indicates that 195.250.160.37 has been noticed before by
other sites as a comment spammer.
<br/><br/>

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/06/spa-talk-at-the-last-hope-computer-security-conference.html</link>
<title>SPA Talk at the Last HOPE Computer Security Conference</title>
<dc:date>2008-06-28T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: passive-authorization.html -->
<!-- category: fwknop.html -->
<a href="http://www.thelasthope.org/">
<img class="leftnofr" src="/images/last_hope_logo.png" title="SPA talk at the Last HOPE conference" alt="SPA talk at the Last HOPE conference" /></a>
Next month in NYC the final <a href="http://www.thelasthope.org/">Hackers On Planet Earth (HOPE)</a>
conference will take place from July 18th through the 20th.  I will be giving a
<a href="http://www.thelasthope.org/talks.php">talk</a> there entitled
"<b>Port Knocking and Single Packet Authorization: Practical Deployments</b>", and here is
the abstract:
<br/><br/>
<img class="left" src="/images/dq.gif" title="" alt="" />&nbsp;&nbsp; <i>Port Knocking and
its big brother, Single Packet Authorization (SPA), can provide a robust additional layer
of protection for services such as SSH, but there are many competing Port Knocking and SPA
implementations. This talk will present practical usages of fwknop in Port Knocking and SPA
modes, and discuss what works and what doesn't from a protocol perspective. Integration
points for both iptables and ipfw firewalls on Linux and FreeBSD systems will be highlighted,
and client-side support on Windows will be demonstrated. Finally, advanced functionality
such as inbound NAT support for authenticated connections, sending SPA packets over the
Tor anonymity network, and covert channel usages will be discussed. With SPA deployed,
anyone scanning for a service with Nmap cannot even tell that it is listening; let alone
target it with an exploit (zero-day or not).</i>
<br/><br/>
A goal for the talk will be to start with the most basic port knocking deployment
(a shared sequence of only one port) and build from there into encrypted port knocking
sequences, and then move into the SPA realm with SPA packets encrypted with Rijndael
and finally with GnuPG.  Along the way security tradeoffs will be discussed.  For example,
a shared sequence of a single port allows an extremely simplistic port knocking
implementation (so there is less risk of a vulnerability in the port knocking software
itself), but then any casual port scan or stray packet that hits the shared port also
qualifies as a valid port knock sequence.  At the high end, SPA packets encrypted with
GnuPG solve all sorts of difficulties with simple port knocking from a protocol
perspective, but there is the slight expense of a more complicated implementation
(although it is still a lot harder to target an SPA implementation with an exploit
than a complicated TCP-based service that advertises its existence to the world under
any basic port scan).
<br/><br/>
At the talk I will also release the next version (1.9.6) of <a href="/fwknop">fwknop</a>.
<br/><br/>If you are going to be at the HOPE conference, please stop by and say
'hello'.  <a href="http://www.nostarch.com">No Starch Press</a> will also be at the
conference so I'm sure I will hang out at their booth much of the time as well.

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/06/software-release-gootrude-0.2.html</link>
<title>Software Release - gootrude-0.2</title>
<dc:date>2008-06-19T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<!-- category: gootrude.html -->
<!-- category: software-releases.html -->
<a href="/gootrude">
<img class="leftnofr" src="http://l.yimg.com/a/i/ww/beta/y3.gif" title="Gootrude queries Yahoo" alt="Gootrude queries Yahoo" /></a>
<a href="/gootrude"><b>Gootrude-0.2</b></a> is available for
<a href="/gootrude/download"><b>download</b></a>. This release changes the
default search engine from Google to Yahoo because it appears that Yahoo's Terms of Service do not
prohibit automated queries (although I'm not a lawyer).  Gootrude retains the ability to query Google
at your own risk if you so desire.  As long as you use Gootrude as designed to collect search engine
results only once per day with a limited number of search terms (say, 20 or less), it is unlikely to
provoke a negative reaction from search engines.  Over time, support for many additional search engines
will be added to Gootrude so that search results can be trended from all sorts of different data
sources.
<br/><br/>
Also, <a href="/blog/2008/06/trending-low-volume-google-searches-introducing-gootrude.html">this post</a>
should really have announced Gootrude as a "search results trender" instead of a "search trender".
The goal of the project is made clear in the
<a href="http://trac.cipherdyne.org/trac/gootrude/browser/gootrude/trunk/README">README</a>, and here
is the complete
<a href="http://trac.cipherdyne.org/trac/psad/browser/psad/tags/gootrude-0.2/ChangeLog">ChangeLog</a>,
for the Gootrude-0.2 release:
<br/><br/>
<ul>
<li>Added support for querying Yahoo for search results and made this the
default because Google's TOS does not technially allow automated
queries.  However, Gootrude continues to support querying Google for
search results, and responsible use of Gootrude once per day with a
limited set of search terms should most likely not be a cause for
concern for Google.  A new syntax of the searchterms.conf file allows
search terms to express which search engine should be queried on an
individual basis according to the following syntax (note the middle
element):

[Linux "highspeed firewalls"] [yahoo:count] [Linux_highspeed_firewalls.dat]
</li>
<li>Changed the default USER_AGENT variable to "Gootrude &lt;version&gt;".</li>
<li>Added a percentage-based offset for the plot minimum and maximum ranges
on the y-axis (with a default of 10% controlled by two new variables
MIN_PERCENT_DIFF and MAX_PERCENT_DIFF).  This value can also be set by
the search terms themselves via an additional config element as follows
(for a 20% offset instead for example):

[yrange:20%/20%]
</li>
<li>Increased SEARCH_TERM_DELAY to two seconds to be nicer to search engines.</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/06/trending-low-volume-google-searches-introducing-gootrude.html</link>
<title>Trending Low-Volume Google Searches - Introducing Gootrude</title>
<dc:date>2008-06-15T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: gootrude.html -->
<!-- category: software-releases.html -->
<a href="/gootrude/download/">
<img class="leftnofr" src="http://www.google.com/intl/en/trends/logo.gif" title="Introducing Gootrude" alt="Introducing Gootrude" /></a>
<b>UPDATE 06/16/08: 1)</b> After <a href="http://tech.slashdot.org/article.pl?sid=08/06/16/1312249">making Slashdot</a>
today and reading the comments, I feel I should clarify a few things regarding this post.
First, it was pointed out (quite rightly) that
<a href="/gootrude">Gootrude</a> trends the number of documents in
Google's index that contain each search term, whereas Google Trends tracks the search volume
associated with a search term.  These are not the same thing.  However, I would wager that
they are related, though certainly not in some nice 1:1 correspondence.  That is, if a
relatively unique word - say, "myspace" - is mentioned within 100,000 web sites, then the
number of times this word is used as a search term in Google will be higher than if "myspace"
were mentioned in only 10 web sites just because it is exposed to many more people who would
then be interested in all things "myspace".  I would also wager that the reverse is true.
So, if "myspace" is an extremely popular search term, then it will probably also appear in
many more web sites around the Internet.  Gootrude attempts to trend the number of hits a
given search term returns in Google, and by the above reasoning, there is a loose correspondence
between this and the number of times the term is searched for in Google.  Perhaps this is
not useful, but only time will tell after Gootrude is used by a lot of people.  If you will
allow the above interpretation, then the remainder of the post below makes sense.
<br/><br/>
<b>2)</b> It was pointed out that Gootrude violates the Google
<a href="http://www.google.com/accounts/TOS">Terms of Service</a>.  After actually reading this
document for the first time today, I think this is a correct interpretation, and if Google were
to ask me to stop making Gootrude able to make web queries then I would comply with their request
(and switch Gootrude to query Yahoo instead).  However, let me just say that Gootrude is designed
to be run once per day with a limited set of search terms (say, about 10).  I personally make
many more manual queries to Google every day than this with my web browser, and my usage of
Gootrude cannot even remotely be interpreted as interfering with their server operations.  I'm
just interested in how Google (being the best search engine) views my open source projects.  As
a precautionary measure, I may switch Gootrude to query Yahoo by default anyway since their TOS
does not seeem to prohibit this.  Also, I would like to mention that other projects seem to make
use of Google services in ways that may be questionable in view of the Google TOS (see the
<a href="http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html">
Gmail Filesystem</a> for example) but Google seems to allow it.  Google probably derives more
benefits from open discussions that such projects foster than would justify shutting them down.
<br/><br/>
Now for the original post:
<br/><br/>
The <a href="http://www.google.com/trends"><b>Google Trends</b></a> project allows you to
input search terms like "Myspace", "2008 election", or "Linux", and see how Google tracks how
popular these search terms are over time.  The resulting graphs can be quite interesting - spikes
in search volume can sometimes be correlated against particular news articles and world events,
and the Google Trends interface points these out.
<br/><br/>
This is a handy tool, but there are many search terms that Google Trends does not display any
results for.  Such terms (such as "Linux Firewalls" - with the quotes) have insufficient search
volumes to display graphs according to the error message that Google Trends generates.  Fair
enough.  I suppose that Google sets an internal threshold on search volume, and this threshold
could be set for reasons that range anywhere from Google Trends is still experimental to Google
not wanting to provide data on how it builds its massive search index for emerging search terms.
Either way, I would like a way to see search term trends that Google doesn't currently make
available to me.
<br/><br/>
Although I'm an open source developer and author, search terms related to my projects are not
popular enough yet to be displayed by Google Trends.  So, I had to roll my own trending mechanism,
and this blog post announces the release of a new open source tool <a href="/gootrude"><b>Gootrude</b></a>
(see the <a href="/gootrude/docs/index.html">quick start</a>, <a href="http://trac.cipherdyne.org/trac/gootrude">
source code</a>, and <a href="/gootrude/download/index.html">download</a> links) that I wrote to do just this.
The basic strategy is to take a collection of search
terms defined by the user, automatically query Google for the number of results associated with each of
these search terms (this is displayed by Google when doing a web search), and graph these numbers over
time with <a href="http://www.gnuplot.info/">Gnuplot</a>.  At this point let me state up front
that Gootrude only makes use of data that Google freely provides to everyone with normal web
searches, and is meant to be run once per day (so as to not be a pest in terms of the numbers
of queries it makes).  As an example, if you type in the word "security" into the Google web
interface, it will return a string like "<b>Results 1 - 10 of about 1,010,000,000</b>".  The
"1,010,000,000" number is collected by Gootrude and stored in a file along with the current time.
<br/><br/>
For the past year, I have sent a set of search terms through Google once per day with Gootrude
and the results are displayed below.  Visible within the data returned from Google are strange
oscillations that vary quite a bit more than I would have expected, and also evidence for what
happens when a large site (like linux.com) posts an article about a Cipherdyne project.
<br/><br/>
First, below is the graph of the fairly unique word "cipherdyne" since late June 2007.  The
filled-in red curve is the absolute number of search results (taken each day around 1am), and
the green line is the 10-day moving average.
<img src="/images/gootrude/cipherdyne.png" title="Gootrude plot of cipherdyne search term" alt="Gootrude plot of cipherdyne search term" />
As you can see, at the beginning of the graph around July 1st Google steadily shows
about 28,000 results for "cipherdyne", but towards the end of July this dips to well below 20,000 only to
rebound in August to about 30,000.  Then, beginning around March 1st, 2008 the results shoot
up to over 100,000 briefly and then back to around 70,000 in May.  How does one interpret this
data?  It seems unlikely that these fluctuations can be entirely explained by "actual"
day-by-day changes in how external sites reference the term "cipherdyne" - there must be some
index updating component that is internal to Google at work here, and we'll see a better example
of this below.
<br/><br/>
Now, here is the graph of the search term "gpgdir":
<img src="/images/gootrude/gpgdir_annotated.png" title="Gootrude plot of gpgdir search term" alt="Gootrude plot of gpgdir search term" />
The most obvious feature of the gpgdir graph above is the large spike to around 60,000 results
around May 1st.  It turns out that an <a href="http://www.linux.com/feature/132999">article</a>
was posted to <a href="http://www.linux.com">linux.com</a> on the 24th of April, so given that
"gpgdir" is not a common word, the spike seems nicely correlated with the posting of the article
as it got bounced around the Internet and blogosphere.  A more interesting feature perhaps is
the sharp cyclic oscillation between July and December 2007.  During this time, search results for
gpgdir bounced from 1,000 to around 10,000 and back again several times, and the transition
each time was fast - making the jump to 10,000 over the course of two days and then stabilizing
for about 10 days or so and then back down to 1,000.  It is almost as though Google was trying to
establish the proper order of magnitude for "gpgdir" search results during this time via a sort
of step function.
<br/><br/>
Finally here is the graph of "single packet authorization":
<img src="/images/gootrude/single_packet_authorization.png" title="Gootrude plot of single packet authorization" alt="Gootrude plot of single packet authorization" />
Again, we see a dramatic spike in search results - from around 5,000 to well over 50,000 and
settling down to about 10,000 around the beginning of June.  Although there has been some
activity related to SPA in the <a href="http://ubuntuforums.org/showthread.php?t=812573">Ubuntu forums</a>
and also in the <a href="http://forums.gentoo.org/viewtopic-t-687956.html?sid=c174bcd01005451b4d701f76cfc20dd3">Gentoo forums</a>, if this caused Google to report the search results as over 50,000 why did
this number return so precipitously back to around 10,000?  The links have not gone away, but
they were probably mentioned on other referencing sites and then moved to less important pages
over time on those sites.  Perhaps Google is trying to find the appropriate steady state for
its search results, and there are many factors that Google takes into account that are not
available to the public.
<br/><br/>
There are lots of unanswered questions this sort of data brings to mind:
<br/><br/>
<ul>
<li>All of the data for the above graphs was collected from a single Linux system.  How
different would the results be if several systems in different geographic locations
collected the data and the average for each data point was used instead?</li>
<li>Each data point was collected around 1am every morning.  If the data collection time
were, say, 1pm, would the results have been significantly different?</li>
<li>What is the "optimal" time scale for the moving average?  Given that Google's own
Trends interface seems to show search results on the macro level, would a much longer
moving average than 10 days - perhaps on the order of several weeks - be a more
accurate reflection of search popularity?</li>
</ul>
One thing is clear - getting search results that are meaningful is much easier with unusual
search terms.  With the posting of this blog entry, the term "Gootrude" should evolve nicely
within Google results, and the graph of these results will be updated daily on the
<a href="/gootrude">main Gootrude page</a> so you can see this evolution as it
unfolds.
<br/><br/>
In closing, I would like to mention that Gootrude is just getting started, so there are
lots of enhancements that need to be made.  Some of the most important features to develop
are:
<br/><br/>
<ul>
<li>Integration with the <a href="http://code.google.com/apis/chart/">Google Charts API</a>.</li>
<li>Development of an online web portal for Gootrude so that users don't have to have their
own infrastructure to run Gootrude.</li>
<li>Ability to import search data from different Gootrude collection systems.</li>
<li>Add support for data collected from additional search engines.</li>
</ul>
If you are an open source developer and would like to contribute, see the
<a href="http://trac.cipherdyne.org/trac/gootrude/browser/gootrude/trunk/TODO">TODO</a> file
for an updated list of development tasks, or send me an email (mbr[at]cipherdyne[dot]org).  Also,
if you have any ideas or feedback on why some of the graphs above look the way they do in the
context of how Google builds its index, please email me.
<br/><br/>
Finally, here are a few additional graphs of search terms over the past year:
<img src="/images/gootrude/fwsnort.png" title="Gootrude plot of fwsnort" alt="Gootrude plot of fwsnort" />
<img src="/images/gootrude/michael_rash.png" title="Gootrude plot of michael rash" alt="Gootrude plot of michael rash" />
<img src="/images/gootrude/Linux_Firewalls_Attack_Detection.png" title="Gootrude plot of Linux Firewalls Attack Detection" alt="Gootrude plot of Linux Firewalls Attack Detection" />
<img src="/images/gootrude/single_packet_authentication.png" title="Gootrude plot of single packet authentication" alt="Gootrude plot of single packet authentication" />
<img src="/images/gootrude/iptables_attack_visualization.png" title="Gootrude plot of iptables attack visualization" alt="Gootrude plot of iptables attack visualization" />


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/06/three-software-releases-psad-fwknop-gpgdir.html</link>
<title>Three software releases - psad, fwknop, gpgdir</title>
<dc:date>2008-06-08T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<!-- category: psad.html -->
<!-- category: fwknop.html -->
<!-- category: gpgdir.html -->
<!-- category: software-releases.html -->
<a href="/about.html">
<img align="right" src="/images/release.png" title="Three software releases" alt="Three software releases" /></a>
The following releases of the Cipherdyne security projects are now available:
<a href="/psad/download">psad-2.1.3</a>, <a href="/fwknop/download">fwknop-1.9.5</a>,
and <a href="/gpgdir/download">gpgdir-1.9.1</a>.  The motivation for a group release
stems from the need to make similar changes to the fwknop and gpgdir projects to
update to version 2.11 of the
<a href="http://search.cpan.org/~schwigon/Class-MethodMaker-2.11/lib/Class/MethodMaker.pm">Class::MethodMaker</a>
perl module from CPAN - a dependency of GnuPG::Interface.  This version fixes a
build error under recent versions of perl (such as perl-5.10.0) which are distributed
on systems like <a href="http://fedoraproject.org/wiki/Releases/9">Fedora 9</a>.
Also, for both fwknop and gpgdir, thanks to a suggestion made by
<a href="http://www.sysnux.pf">Jean-Denis Girard</a> on the fwknop mailing list, the
default locale has been set to "C" via the LC_ALL environmental variable so that
GnuPG output can be properly interpreted even on systems where a different locale is
used.  The locale can be manually set or not used at all with two new command line
arguments --locale &lt;str&gt; and --no-locale respectively.  On another note,
Kevin Hilton has <a href="http://ubuntuforums.org/showthread.php?t=812573">written</a>
an excellent how-to for fwknop on Ubuntu systems.
<br/><br/>
For psad, it was time to make a new release after it became necessary to update the whois client so
that IP addresses such as 116.125.35.98 (which was scanning a psad user) could be
properly identified with whois records.  In addition, psad was updated to parse syslog
files directly for iptables log messages instead of requiring reconfiguration of the
syslog daemon to write kern.info messages to the /var/lib/psad/psadfifo named pipe.
This simplifies the proper installation of psad, and is now a default setting.
Although there is a slight performance penalty since psad now parses all messages
that are written to the /var/log/messages file (this is the default path), it should
not be noticeable on most systems.  Further, the old behavior of using the named
pipe can be restored via the ENABLE_SYSLOG_FILE variable in the /etc/psad/psad.conf
file.
<br/><br/>
Finally, <a href="http://smhteam.info/wiki/">Franck Joncourt</a> has made excellent
progress in developing Debian packages for the IPTables::ChainMgr and IPTables::Parse
<a href="/modules">modules</a>, and he is also close to a Debian package for the
fwknop project.
<br/><br/>
The complete change logs for these new releases can be found as follows:
<a href="http://trac.cipherdyne.org/trac/psad/browser/psad/tags/psad-2.1.3/ChangeLog">psad-2.1.3</a>,
<a href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.5/ChangeLog">fwknop-1.9.5</a>, and
<a href="http://trac.cipherdyne.org/trac/gpgdir/browser/gpgdir/tags/gpgdir-1.9.1/ChangeLog">gpgdir-1.9.1</a>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/06/single-packet-authorization-with-port-randomization.html</link>
<title>Single Packet Authorization with Port Randomization</title>
<dc:date>2008-06-01T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: passive-authorization.html -->
<!-- category: software-releases.html -->
<!-- category: fwknop.html -->
<a href="/fwknop/download/">
<img align="right" src="/images/chinesedoor4.jpg" title="fwknop-1.9.4 release with port randomization" alt="Single Packet Authorization with Port Randomization" height="300" width="199" /></a>
After two months of development, the 1.9.4 release of <a href="/fwknop"><b>fwknop</b></a>
is available for <a href="/fwknop/download"><b>download</b></a>.  This release introduces
new functionality that has implications for hardening both fwknop SPA communications
and the follow-on connections that client programs make (such as SSH).  Specifically,
the 1.9.4 release adds two port randomization options to 1) send the SPA packet over
a random port between 10,000 and 65,535 (requires updating the default PCAP_FILTER
variable on the fwknopd server side), and 2) select a random port that is used as
the destination port in a NAT operation on the fwknopd server system.  These two
options can be used individually or together, and are enabled with two new command
line options, --rand-port and --NAT-rand-port respectively, to the fwknop client
(see examples below).
<br/><br/>
The inspiration for adding this functionality came from a
<a href="http://forums.gentoo.org/viewtopic-t-687956.html?sid=b94683d3747fef4b74d101ccd897008f"><b>post</b></a>
to the "<a href="http://forums.gentoo.org/viewforum-f-12.html?sid=b94e0817ffad5018762afbdcee992f77">Documentation, Tips &amp; Tricks</a>".
Gentoo forum, and I have <a href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.4/CREDITS#L184">credited</a>
John Brendler with the idea.  In response to John's post, I would like to
mention however that <b>all</b> Port Knocking / Single Packet Authorization implementations
suffer from "piggy-back exploits", including those that select random ports for
SPA communications or for NAT operations against follow-on sessions.  A "piggy-back
exploit" is where an attacker takes advantage of the fact that a firewall rule inserted
by a PK/SPA system accepts a connection from an IP address to a destination port
specified by the SPA packet(s).  So, if the attacker can spoof packets from this
source IP, or if the attacker happens to be on the same internal network as the
SPA client (and hence sends connections out through the same NAT device), then the
firewall rule will accept these packets just as though they originated from the
legitimate SPA client system.  If an attacker is in a privileged position and
can sniff the legitimate session as it is initiated, then one can envision an
automated attack that spoofs packets from the same source IP and directs them at the
same service.  Further, such an "attack" can be made just by watching outgoing
connections without paying any attention whatsoever to whether or not a set of SPA
packets are sent first - it doesn't matter if the real connection is made to a random
translated port on the SPA system; the attacker can see this port in the real
connection itself.
<br/><br/>
Now, should you be concerned about such a piggy-back attack?  Not really.  First,
if the attacker is not going through the same NAT device as the real connection, then
any response to a spoofed packet will go back to the spoofed source - not back to the
attacker.  So, for TCP connections, unless the attacker can effectively perform a
sequence prediction attack an existing connection (and even then that is of little
use against an encrypted application layer protocol such as SSH), this is not very
effective.  Second, even if an attacker is behind the same NAT device as the SPA
client, just being able to access the targeted service over TCP/IP does not imply
an automatic vulnerability; SPA is an additive measure to whatever existing
security mechanisms are already in place (barring a vulnerability in libpcap itself
in the SPA server for example).  Third, there are an awful lot of networks out there
to which an attacker will not have such privileged access, and therefore not be in
a position able to sniff anything useful.  Forth, fwknop minimizes the opportunity
for an attacker to conduct a piggy-back attack by maintaining a small window of time
(30 seconds by default) for any new firewall rules after receiving a valid SPA
packet.  By using a connection tracking mechanism built into iptables or ipfw, any
connection established during the accept window is allowed to remain open but all
attempts to create a new connection must first preceeded with a new SPA packet in
order to gain access.
<br/><br/>
Finally, although port randomization is an enhancement, fwknop has had the ability
for a long time to allow the user to select the destination port for SPA packets with
the --Server-port argument as well as the destination port for a NAT'd connection to
an internal system.  Hence, fwknop SPA packets are not always sent over udp/62201.
But, I agree that it is useful to add the port randomization features that John Brendler
suggested, and this is why I've implemented them in fwknop.  Randomizing the SPA
destination port along with the destination port of the follow-on connection makes
traffic analysis more difficult.
<br/><br/>
Now, let us see the new --rand-port and --NAT-rand-port options in a practical
example.  We'll assume that the fwknopd server is at hostname <b>spaserver</b>
with IP 11.1.1.1, and the fwknop client runs on the <b>spaclient</b> system
with IP 12.2.2.2.  We ultimately want to gain access to SSHD on the spaserver
system, and we assume that iptables is configured in a default-drop stance for
all attempts to communicate with SSHD.  Also, there is no requirement to necessarily
attempt to gain access only to an SSHD instance running on an internal server via a
forwarded port - the iptables PREROUTING chain can forward a port to a local socket
as well (based on a routing calculation for the destination IP), and on the fwknop
client command line we use the --NAT-local argument for this.
<br/><br/>
Because the --rand-port option sends the SPA packet over a
random destination port, we first need to set the PCAP_FILTER variable as follows
in the /etc/fwknop/fwknop.conf file:
<pre class="prelarge">
[spaserver]# vi /etc/fwknop/fwknop.conf
PCAP_FILTER                 udp dst portrange 10000-65535;

[spaserver]# /etc/init.d/fwknop restart
[+] knopwatchd is running (pid: 17584), stopping daemon
[+] knoptm is running (pid: 17582), stopping daemon
[+] fwknopd is running (pid: 17580), stopping daemon
Starting the fwknop daemons.
</pre>
With the fwknopd server up and running, we now use the fwknop client to gain access
to SSHD on the spaserver system via a randomly selected NAT'd port (and we show
that SSHD is never accessible over the standard TCP port 22 even from the spaclient
system):
<pre class="prelarge">
[spaclient]$ nmap -sT -n -P0 -p 22 11.1.1.1

Starting Nmap 4.20 ( http://insecure.org ) at 2008-06-02 01:48 EDT
Interesting ports on 11.1.1.1:
PORT   STATE    SERVICE
22/tcp filtered ssh

Nmap finished: 1 IP address (1 host up) scanned in 12.017 seconds

[spaclient]$  fwknop -A tcp/22 --NAT-local --NAT-rand-port \
--rand-port -R -D 11.1.1.1

[+] Starting fwknop client (SPA mode)...
[+] Requesting NAT access for randomized port: 16791
    Resolving external IP via: http://www.whatismyip.org/
    Got external address: 12.2.2.2

[+] Enter an encryption key. This key must match a key in the file
    /etc/fwknop/access.conf on the remote system.

Encryption Key:

[+] Building encrypted Single Packet Authorization (SPA) message...
[+] Packet fields:

        Random data:    4846125760033285
        Username:       mbr
        Timestamp:      1212386108
        Version:        1.9.4
        Type:           5 (Local NAT access mode)
        Access:         12.2.2.2,tcp/22
        NAT access:     11.1.1.1,16791
        SHA256 digest:  ZyWG+nRGYMfWFssJuOy7bhGmJHpHia6T1igaNnVVhqI

[+] Sending 206 byte message to 11.1.1.1 over udp/52949...
    Requesting NAT access to tcp/22 on 11.1.1.1 via port 16791

[spaclient]$  ssh -p 16791 mbr@11.1.1.1
mbr@11.1.1.1's password:
[spaserver]$
</pre>
The above output shows that the client system indeed has access to the spaserver system
via TCP port 16791, which is forwarded to the local SSH daemon.  In the /var/log/messages
file, fwknopd has written the following messages to syslog:
<pre class="prelarge">
[spaserver]# tail /var/log/messages
Jun  2 01:54:16 spaserver fwknopd: received valid Rijndael encrypted \
packet from: 12.2.2.2, remote user: mbr, client version: 1.9.4 (SOURCE \
line num: 151)
Jun  2 01:54:17 spaserver fwknopd: add FWKNOP_PREROUTING 12.2.2.2 \
-&gt; 11.1.1.1(tcp/16791 to 22) DNAT rule 30 sec
Jun  2 01:54:17 spaserver fwknopd: add FWKNOP_INPUT 12.2.2.2 -&gt; \
0.0.0.0/0(tcp/22) ACCEPT rule 30 sec
Jun  2 01:54:58 spaserver fwknop(knoptm): removed iptables \
FWKNOP_PREROUTING DNAT rule for 12.2.2.2 -&gt; 11.1.1.1(tcp/22), 30 \
sec timeout exceeded
Jun  2 01:55:11 spaserver fwknop(knoptm): removed iptables \
FWKNOP_INPUT ACCEPT rule for 12.2.2.2 -&gt; 0.0.0.0/0(tcp/22), 30 sec \
timeout exceeded
</pre>
In closing, here is an abbreviated version (the randomization options are not
duplicated here) of the fwknop-1.9.4 <a 
href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.4/ChangeLog">
ChangeLog:</a>
<br/><br/>
<ul>
<li>Added the ability to specify the port that SPA packets are sent over
with the fwknop client by using the syntax "&lt;host|IP&gt;:&lt;port&gt;".  So, for
example, to have the client send an SPA packet to 11.1.1.1 over UDP port
12345 (instead of the default of 62201), one could use the following
command:
<br/><br/>
      $ fwknop -A tcp/22 -R -D 11.1.1.1:12345
<br/><br/>
</li>
<li>Bugfix to add a check for "keep-state" in ipfw policies in addition to
the existing "check-state" check (noticed by Sebastien Jeanquier).</li>
<li>Updated the install.pl script to try to determine the OS type as early
as possible during the install process.</li>
<li>Added the MIN_SPA_PKT_LEN variable with 160 (bytes) as the default.
This allows fwknopd to ignore packets that are not at least this many
bytes (including packet headers) before any decryption attempt is made.</li>
<li>Added --time-offset-plus and --time-offset-minus args to the fwknop
client command line.  This allows the time stamp within an SPA packet to
be influenced without setting the system clock (which normal users
cannot usually do).  This is useful for when the client and server
systems have clocks that are out of sync.</li>
<li>Bugfix on Ubuntu systems to make sure that the fwknop init script is
installed with a priority of 99 instead of 20 - this puts fwknop as late
as possible within the boot sequence so that the system is ready to run
fwknop.</li>
<li>Bugfix to not open ports that are not specifically requested in an SPA
packet even if those ports are listed in the OPEN_PORTS variable in the
access.conf file.</li>
<li>Updated to version 5.47 of the Digest::SHA module.</li>
<li>Updated to version 0.7 of the IPTables::ChainMgr module (includes
perldoc documentation).</li>
<li>Updated to version 0.6 of the IPTables::Parse module (includes perldoc
documentation).</li>
<li>Added NAT, port randomization, and and time offset option discussions to
fwknop(8) man page.</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/05/software-release-gpgdir-1.9.html</link>
<title>Software Release - gpgdir-1.9</title>
<dc:date>2008-05-31T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: gpgdir.html -->
<!-- category: software-releases.html -->
<a href="/gpgdir/download/">
<img align="right" src="/images/release.png" title="gpgdir-1.9" alt="gpgdir-1.9 released" /></a>
The 1.9 release of <a  href="/gpgdir">gpgdir</a> is ready for
<a  href="/gpgdir/download/">download</a>.  This release
introduces minor fixes to change the --Obfuscate file format and adds
process locking against multiple instances of gpgdir from operating
against the same directory.
<br/><br/>
On a side note, <a href="http://monkeyiq.blogspot.com/">Ben Martin</a> wrote
an article on gpgdir entitled
"<a href="http://www.linux.com/articles/132999">Protecting directory trees with gpgdir</a>"
for <a href="http://www.linux.com">linux.com</a>.
Ben emphasizes using the gpgdir
--Wipe option to securely delete files from the filesystem after they are
encrypted with GnuPG, and I agree with this.  In addition, there is nothing
that prevents gpgdir from being used in conjunction with an encrypted
filesystem such as <a href="http://cryptmount.sourceforge.net/">Cryptmount</a>
to achieve additional protections for directory structures (which gpgdir
does not alter).
<br/><br/>
Here is the complete
<a 
href="http://trac.cipherdyne.org/trac/gpgdir/browser/gpgdir/tags/gpgdir-1.9/ChangeLog">
ChangeLog:</a> for the 1.9 release:
<ul>
<li>Changed --Obfuscate-filenames format to not include the gpgdir PID.
This allows directories to be encrypted/decrypted under -O multiple
times without creating new filenames (which would pollute encrypted
directories under rsync to other systems).  The new -O encrypted
filename format is just "gpgdir_&lt;num&gt;.gpg".</li>
<li>Added PID locking against directories so that multiple gpgdir processes
cannot operate against the same top-level directory simultaneously.
This is useful for users that typically operate with multiple shells
and might launch gpgdir from any of them.</li>
</ul>
]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/05/linux.com-article-on-fwknop.html</link>
<title>linux.com Article on fwknop</title>
<dc:date>2008-05-21T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: publications.html -->
At <a href="http://www.linux.com">linux.com</a> Bob Currier has written a featured
<a href="http://www.linux.com/feature/135100">article</a> on fwknop.  He gives a
good overview of how Single Packet Authorization (SPA) is different from port knocking,
and illustrates how to use fwknop to harden SSH communications.  Here is a quote from
the article:
<br/><br/>
<img class="left" src="/images/dq.gif" title="" alt="" />&nbsp;&nbsp; <i>
Single packet authorization distills the essence of the port knocking concept down to
a single packet. Rather than sending a series of packets to predefined ports, single
packet authorization encodes the "knock" within the payload of one packet. Once a
proper key has been received, SPA applications modify firewall rules to allow access
to the authenticated host. We'll examine how this is accomplished by installing and
testing the Firewall KNock Operator, better known as fwknop.</i>
<br/><br/>
There are several comments attached to the article from interested users, and
additional discussion of both port knocking and SPA topics can be found at Sebastien
Jeanquier's <a href="http://www.securethoughts.net/spa/">online forum</a>.

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/05/site-update-wordpress-theme-without-running-wordpress.html</link>
<title>Site Update - WordPress Theme without Running WordPress</title>
<dc:date>2008-05-08T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: site-news.html -->
<a href="http://www.wordpress.org/">
<img align="right" src="/images/wordpress_logo.gif" title="WordPress" alt="WordPress site" /></a>
<a href="http://www.wordpress.org">WordPress</a> has a loyal following in the blogosphere and
is used to power thousands of websites and blogs, and several books have been written about it.
A compelling measure of WordPress popularity is the number of
<a href="http://themes.wordpress.net/">downloadable themes</a> that can provide an easily deployed
and consistent look and feel to WordPress sites.  So, when I was looking to update the presentation
of the cipherdyne.org site, it seemed a natural step to consider a WordPress theme.
<br/>
I've updated cipherdyne.org to use a slightly modified version of the
<a href="http://themes.wordpress.net/columns/3-columns/3588/daleri-selection-10/">Daleri Selection (v1.0) Theme</a>
by <a href="http://www.andreasviklund.com">Andreas Viklund</a>, but
with a twist: I don't run actually Word Press.  All of that PHP code and MySQL database backend
is throwing a lot of complex code (and associated potential security vulnerabilities) at a problem
that (in my case) can be solved in a simpler way.  That is, I just want to provide an outlet for my
<a href="/about.html">software</a> and <a href="/author.html">publications</a>,
and maintain a <a href="/">blog</a> for my corner of the security technology landscape.
For this, I just need a themed website in plain HTML and CSS along with
<a href="/rss.xml">RSS</a> and <a href="/atom.xml">Atom</a> feeds, and I need an effective
way to manage all of the pages and create new blog posts.  This is where perl, rsync, and
subversion comes in.
<br/>
The cipherdyne.org website and blog is managed by a set of custom perl scripts that
perform each the following tasks:
<ul>
<li>Provide a way to create new blog posts and link them into the cipherdyne.org blog hierarchy.  For
example, the forward and backward links at the end of each post (such as
<a href="/blog/2008/04/port-forwarding-via-single-packet-authorization.html">this one</a>)
are auto-generated based on the posting date, and the permanent blog links
are created from each post by the blog post title.  The number of blog posts is summarized by
date and organized into categories that can be browsed via the
<a href="/archives">blog archives</a>, and updates to the RSS and Atom feeds are automatically
generated.</li>
<li>Validate HTML and XML page structure.  This is exceeding easy through the use of the
perl XML::Simple module.  But, using the W3C <a href="http://validator.w3.org/">HTML validator</a>
is more thorough, so I periodically use it as well to spot check various pages on cipherdyne.org.</li>
<li>Validate software release MD5 digests and GnuPG signatures (see the fwknop
<a href="/fwknop/download">download</a> page for example), and automatically correct if any
digest is invalid.</li>
<li>Search through the entire cipherdyne.org website and flag any broken links (parsing the
output of a recursive wget against the cipherdyne.org staging server make this easy).</li>
<li>Send blog pings out via the XMLRPC::Lite module to various blog aggregation services
such as FeedBurner and Technorati.</li>
<li>Drive the entire cipherdyne.org site via Subversion for source control, and deploy
with rsync to separate staging and production servers. When it comes to deploying a more
complex piece of software for visualizing changes to the source code for any of the
cipherdyne.org projects, my first choice is <a href="http://trac.edgewall.org/">Trac</a>, but
when it comes to the main cipherdyne.org site, a set of HTML pages maintained by a consistent
WordPress theme is sufficient.</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/04/hakin9-march-2008-issue.html</link>
<title>Hakin9 March 2008 Issue</title>
<dc:date>2008-04-19T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: publications.html -->
<a href="http://www.en.hakin9.org/">
<img align="right" src="/images/hakin9_mar08.jpg" title="Hakin9 March 08" alt="Hakin9 March 2008 Issue" /></a>
The <a href="http://hakin9.org/prt/view/about-the-mag/issue/807.html">March issue</a> of
<a href="http://hakin9.org/">Hakin9 Magazine</a> contains some noteworthy articles
and interviews.  First is an article written by Ryan Maple entitled "Best Practices for
Secure Shell" which discusses various security measures that an administrator can use
to heighten the security of SSH.  These measures include (among others) forcing the usage
of SSH protocol version 2, restricting the address (via the ListenAddress variable) that
SSHD binds to from the default of 0.0.0.0, using tcpwrappers, and configuring SSHD to
listen on a port other than tcp/22.  Covering <a href="/fwknop/docs/SPA.html">Single
Packet Authorization</a> would have been difficult to include in the same article, but a
reference is made to another online article <a href="http://www.linuxsecurity.com/content/view/131846/171/">
Knock, Knock, Knockin' on EnGarde's Door (with FWKNOP)</a> that does discuss protecting
SSH with SPA.  Next, is Matt Jonkman's fifth part in his series "Writing IPS Rules".
This article covers the byte_test keyword in the Snort rules language and how to use it
to write signatures against length encoded protocols.  In particular, Matt illustrates
using byte_test to look for specific byte values at particular offsets derived from data
within the DHCP protocol.  The offsets themselves are determined by the data on the wire
and therefore cannot simply be hard coded within a signature beforehand. For those who are
interested in the latest IDS signatures from Matt, he has updated the online home of the
Bleeding Edge Snort ruleset to <a href="http://www.emergingthreats.net">Emerging Threats</a>.
Finally, both <a href="http://www.ranum.com/">Marcus Ranum</a> and <a href="http://taosecurity.blogspot.com/">
Richard Bejtlich</a> were interviewed for the March issue.  I would like to see Hakin9
do a more in-depth interview of Bejtlich though since he always has an
insightful perspective on computer security - particularly as demonstrated in his book
<a href="http://www.amazon.com/Tao-Network-Security-Monitoring-Intrusion/dp/0321246772/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1208634194&amp;sr=1-2">
The Tao of Network Security Monitoring</a>.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/04/fwknop-windows-ui-update.html</link>
<title>fwknop Windows UI Update</title>
<dc:date>2008-04-17T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: passive-authorization.html -->
<!-- category: software-releases.html -->
<!-- category: fwknop.html -->
Sean Greven has released the next version of his fwknop UI for Windows systems.  This
release is compatible with all fwknop daemons that are configured to accept SPA packets
that have been encrypted with the Rijndael symmetric cipher.  The executable can be
downloaded <a href="/fwknop/download/fwknop-client-1.8.3.zip">here</a>, and the source
code is also available <a href="/fwknop/download/fwknop-client-1.8.3-src.zip">here</a>.
Finally, here is a screenshot to illustrate generating an SPA packet from Windows 2000
running under VMware on an Ubuntu 7.10 system.  The fwknopd daemon is running in --debug
mode in the terminal on the right, and you can see the addition of an iptables ACCEPT
rule to allow access to SSHD:
<br/><br/>
<a href="/images/fwknop_UI2.png">
<img src="/images/fwknop_UI2.png" title="fwknop Windows UI" alt="fwknop Window UI update" height="420" width="660" />
</a>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/04/port-forwarding-via-single-packet-authorization.html</link>
<title>Port Forwarding via Single Packet Authorization</title>
<dc:date>2008-04-05T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="http://digg.com/security/How_to_Safely_Connect_to_Your_Closed_Internal_Systems">
<img align="left" src="/images/digg_it.gif" title="Digg SPA NAT access" alt="Digg How to Safely Connect to Your Closed Internal Systems via SPA and NAT" /></a><br/>
<!-- category: passive-authorization.html -->
<!-- category: software-releases.html -->
<!-- category: fwknop.html -->
<a href="/fwknop/download/">
<img align="right" src="/images/chinesedoor.jpg" title="fwknop-1.9.3" alt="Port Forwarding via Single Packet Authorization" height="270" width="180" /></a>
Most port knocking or <a href="/fwknop/docs/SPA.html">Single Packet Authorization</a>
implementations offer the ability to passively authenticate clients for access only
to a locally running server (such as SSHD).  That is, the daemon that monitors a
firewall log or that sniffs the wire for port knock sequences or SPA
packets can only reconfigure a local firewall to allow the client to access a local
socket.  This is usually accomplished by allowing the client to connect to the
server port by putting an <b>ACCEPT</b> rule in the <b>INPUT</b> chain for
<b>iptables</b> firewalls, or adding a <b>pass</b> rule for <b>ipfw</b> firewalls
for the client source IP address.  For local servers, this works well enough, but
suppose that you ultimately want to access an SSH daemon that is running on an
internal system?  If the SPA software is deployed on a Linux gateway that is
protecting a non-routable internal network and has a routable external IP address,
it is inconvenient to first have to login to the gateway and then login to the
internal system.<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Since the 1.9.2 release, <a href="/fwknop">fwknop</a> has supported the creation
of inbound port forwarding rules for iptables firewalls via the <b>DNAT</b>
target in the <b>PREROUTING</b> chain after receiving a valid SPA packet.  This
allows direct access to internal systems on non-routable address space from the
open Internet.  Here is an example - suppose that you are running
fwknop on Linux gateway system that is protecting an internal network
<b>192.168.10.0/24</b> and has an external routable address of <b>11.1.1.1</b>.
Now, suppose that you are on travel somewhere (so your source IP address is not
predictable), and you would like to access an SSH server that is running on the
internal system <b>192.168.10.23</b>.  Finally, because fwknop is deployed, iptables
is configured in a default-DROP stance against all attempts to connect with any SSH
daemon; <b>nmap</b> cannot even tell that there is any SSH server listening.  Access is
granted only after a valid SPA packet is passively sniffed by the fwknopd daemon.
<br/><br/>
With inbound NAT support configured in fwknop (the config is mentioned below), here
is an illustration of fwknop usage in order to gain direct access to SSHD on the
<b>192.168.10.23</b> from an external network (note that the -R argument instructs
the fwknop client to automatically resolve the current IP address - 12.2.2.2 in
this case):
<pre class="prelarge">
[externalhost]$ fwknop -A tcp/22 --Forward-access 192.168.10.23,5001 \
-R -D 11.1.1.1

[+] Starting fwknop client (SPA mode)...
    Resolving external IP via: http://www.whatismyip.org/
    Got external address: 12.2.2.2

[+] Enter an encryption key. This key must match a key in the file
    /etc/fwknop/access.conf on the remote system.

Encryption Key:

[+] Building encrypted Single Packet Authorization (SPA) message...
[+] Packet fields:

        Random data:    6862733471944039
        Username:       root
        Timestamp:      1207404612
        Version:        1.9.3
        Type:           2 (FORWARD access mode)
        Access:         12.2.2.2,tcp/22
        Forward access: 192.168.10.23,5001
        SHA256 digest:  hE4zGafLtQiQiFrep+cSq/wVO7SQhwh65hmLr+ehtrw

[+] Sending 206 byte message to 11.1.1.1 over udp/62201...
</pre>
Now, port 5001 on the external IP address is forwarded through to the SSH server
on the internal 192.168.10.23 system, but only for the client IP 12.2.2.2:
<pre class="prelarge">
[externalhost]$ ssh -p 5001 mbr@11.1.1.1
Password:
[internalhost]$
</pre>
Graphically, this scenario is illustrated by the following picture.  The dotted
lines represent the SPA packet from the fwknop client (which only needs to be
sniffed by the fwknopd daemon running on the Linux gateway), and the solid
arrows represent the SSH connection from the external client through to the
internal SSH server.
<br/><br/>
<img src="/images/SPA_forwarding2.jpg" title="DNAT SPA access to internal SSH server" alt="DNAT SPA access to internal SPA server" />
<br/>
On the Linux gateway system that is running the fwknop daemon, executing the
following command illustrates the additions to the iptables policy to allow the
SSH connection to be forwarded to the internal system.  These firewall rules
are automatically deleted after a 30 second timeout (this is tunable), but any
existing SSH connection remains open through the use of the iptables connection
tracking capability.
<pre class="prelarge">
[gateway]# fwknopd --fw-list
[+] Listing rules in fwknop chains...
Chain FWKNOP_INPUT (1 references)
 pkts bytes target prot opt in out source   destination

Chain FWKNOP_FORWARD (1 references)
 pkts bytes target prot opt in out source     destination
   19  2740 ACCEPT tcp  --  *  *   12.2.2.2   0.0.0.0/0    tcp dpt:22

Chain FWKNOP_PREROUTING (1 references)
 pkts bytes target prot opt in out source     destination
    1    60 DNAT   tcp  --  *  *   12.2.2.2   0.0.0.0/0    tcp \
dpt:5001 to:192.168.10.23:22
</pre>
Finally, the <b>/etc/fwknop/access.conf</b> is configured like so to facilitate
this example, and the ENABLE_IPT_FORWARDING variable is also enabled in the
<b>/etc/fwknop/fwknop.conf</b> file:
<pre class="prelarge">
SOURCE: ANY;
OPEN_PORTS: tcp/22;
PERMIT_CLIENT_PORTS: N;
ENABLE_FORWARD_ACCESS: Y;
FW_ACCESS_TIMEOUT: 30;
KEY: aesdemokey;
</pre>
In addition to explaining the inbound NAT support offered by fwknop, this blog
post also announces the <a  href="/fwknop/download/">1.9.3 release</a>
of fwknop.  Here is the complete <a 
href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.3/ChangeLog">
ChangeLog:</a>
<br/>
<ul>
<li>Added MASQUERADE and SNAT support to complement inbound DNAT connections
for SPA packets that request --Forward-access to internal systems.  This
functionality is only enabled when both ENABLE_IPT_FORWARDING and
ENABLE_IPT_SNAT are set, and is configured by two new variables
IPT_MASQUERADE_ACCESS and IPT_SNAT_ACCESS which define the iptables
interface to creating SNAT rules.  The SNAT supplements of DNAT rules
are not usually necessary because internal systems usually have a route
back out to the Internet, but this feature accommodates those systems
that do not have such a route.  By default, the MASQUERADE target is
used if ENABLE_IPT_SNAT is enabled because this means that the external
IP does not have to be manually defined.  However, the external IP can
be defined by the SNAT_TRANSLATE_IP variable.</li>
<li>Added hex_dump() feature for fwknop client so that raw encrypted SPA
packet data can be displayed in --verbose mode.</li>
<li>When ENABLE_IPT_FORWARDING is set, added a check for the value of the
/proc/sys/net/ipv4/ip_forward file to ensure that the local system
allows packets to be forwarded.  Unless ENABLE_PROC_IP_FORWARD is
disabled, then fwknopd will automatically set the ip_forward file to "1"
if it is set to "0" (again, only if ENABLE_IPT_FORWARDING is enabled).</li>
<li>Minor bugfix to remove sys_log() call in legacy port knocking mode.</li>
<li>Minor bugfix to expand both the Id and Revision tags via the
svn:keywords directive.</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/04/software-release-gpgdir-1.8.html</link>
<title>Software Release - gpgdir-1.8</title>
<dc:date>2008-04-04T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: software-releases.html -->
<!-- category: gpgdir.html -->
<a href="/gpgdir/download/">
<img align="right" src="/images/release.png" title="gpgdir-1.8" alt="Software Release - gpgdir-1.8" /></a>
The 1.8 release of <a  href="/gpgdir"><b>gpgdir</b></a> is ready for
<a  href="/gpgdir/download/"><b>download</b></a>.  This is a minor
feature enhancement release, and here is the
Here is the complete <a 
href="http://trac.cipherdyne.org/trac/gpgdir/browser/gpgdir/tags/gpgdir-1.8/ChangeLog">
ChangeLog:</a>
<br/>
<ul>
<li>Updated the test suite to validate the gpgdir --Obfuscate-filenames
mode to ensure that files are encrypted as "gpgdir_&lt;pid&gt;_&lt;num&gt;.gpg".</li>
<li>Minor bug fix to remove the .gpgdir_map_file in --Obfuscate-filenames
mode after a successful decryption cycle.</li>
<li>Updated to version 0.36 of CPAN GnuPG::Interface module.</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/04/software-release-psad-2.1.2.html</link>
<title>Software Release - psad-2.1.2</title>
<dc:date>2008-04-03T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: software-releases.html -->
<!-- category: psad.html -->
<a href="/psad/download/">
<img align="right" src="/images/release.png" title="psad-2.1.2" alt="Software Release - psad-2.1.2" /></a>
The 2.1.2 release of <a  href="/psad"><b>psad</b></a> is ready for
<a  href="/psad/download/"><b>download</b></a>.  This is a minor
bugfix release to improve support for Linux distributions that report a timestamp
in syslog messages just before any iptables log prefix.  Here is an example of
such syslog messages reported in "<b>psad --Status</b> output (sent to the
<a href="http://lists.sourceforge.net/lists/listinfo/psad-discuss">
psad mailing list</a> by <a href="http://offtopic.artofinfosec.com/">Erik Heidt)</a>:
<br class="clear" />
<pre>
[+] iptables log prefix counters:
      "[ 5370.901768] Default_Drop________": 1
      "[ 9411.899552] Default_Drop________": 1
      "[ 7560.529042] Default_Drop________": 1
      "[ 6454.263813] Default_Drop________": 1
      "[ 7038.635371] Default_Drop________": 1
      "[ 5648.026038] Default_Drop________": 1
      "[ 1207.663709] Default_Drop________": 1
      "[  394.423573] Default_Drop________": 1
      "[  186.740237] Default_Drop________": 1
      "[ 9405.138521] Default_Drop________": 1
      "[ 5364.208693] Default_Drop________": 1
      "[ 7297.121141] Default_Drop________": 1
</pre>
The bug caused the timestamp portion of the syslog messages to be included within
the iptables log prefix strings, and because timestamps are nearly unique, this
forced even the same iptables log prefix to also be treated as unique.
<br/>
Here is the complete <a 
href="http://trac.cipherdyne.org/trac/psad/browser/psad/tags/psad-2.1.2/ChangeLog">
ChangeLog:</a>
<br/>
<ul>
<li>Bugfix to not include kernel timestamps in iptables log prefixes that
contain spaces like "[   65.026008] DROP" (bug reported by Erik Heidt).</li>
<li>Bugfix to skip non-resolved IP addresses (bug reported by Albert Whale)</li>
<li>Better p0f output in --debug mode to display when a passive OS
fingerprint cannot be calculated based on iptables log messages that
include tcp options (i.e., with --log-tcp-options when building a LOG
rule on the iptables command line).</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/03/ids-signature-matching-with-iptables-psad-and-fwsnort.html</link>
<title>IDS signature matching with iptables, psad, and fwsnort</title>
<dc:date>2008-03-20T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: intrusion-detection-and-iptables.html -->
<!-- category: psad.html -->
<!-- category: fwsnort.html -->
<a href="http://www.ukuug.org/newsletter/17.1/#ids_s_mike_">
<img align="right" src="/images/ukuug_logo.png" title="IDS + iptables" alt="IDS signature matching with iptables, psad, and fwsnort" /></a>
The <a href="http://www.ukuug.org/">UK's Unix &amp; Open Systems User Group</a> has re-printed
an article I wrote originally for the December, 2007 security issue of
<a href="http://www.usenix.org/publications/login/2007-12/index.html">USENIX ;login: Magazine</a>
The article is entitled
"<a href="http://www.ukuug.org/newsletter/17.1/#ids_s_mike_">IDS signature matching with iptables, psad, and fwsnort</a>"
and concentrates on how to use the iptables infrastructure in the Linux kernel as a source of
intrusion detection data.  That is, iptables offers many features (such as application layer
string matching) that allow a significant fraction of Snort rules to be converted into
iptables rules, and <a href="/fwsnort">fwsnort</a> automates the conversion process. The
end result is an iptables policy that is looking for evidence of malicious traffic.  Also
covered in the article is the concept of log analysis with an emphasis on passive OS
fingerprinting.  The completeness of the iptables logging format - which even includes
the options portion of the TCP header when the --log-tcp-options argument is given on the
iptables command line when building a LOG rule - allows <a href="/psad">psad</a> to run
the same algorithm that <a href="http://lcamtuf.coredump.cx/p0f.shtml">p0f</a> uses to
passively fingerprint remote operating systems.
<br/><br/>
In other news, Carla Schroder has written an
<a href="http://www.enterprisenetworkingplanet.com/netsecur/article.php/3734771">article</a>
on psad for <a href="http://www.enterprisenetworkingplanet.com">Enterprise Networking Planet</a>.
She recommends running psad alongside Snort, which falls nicely within the principle of
defense-in-depth in order to maintain a strong defensive stance.  Also, Noah Schiffman
has written an <a href="http://www.networkworld.com/community/node/25907">article</a> on port
knocking for <a href="http://www.networkworld.com">Network World</a>.  He mentions the usage
of port knocking within some malware applications as an authentication mechanism, and he also
touches on <a href="/fwknop/docs/SPA.html">Single Packet Authorization</a>.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/03/source-boston-advanced-linux-firewalls-talk-slides.html</link>
<title>SOURCE Boston Advanced Linux Firewalls Talk Slides</title>
<dc:date>2008-03-17T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: conference-talks.html -->
<!-- category: fwknop.html -->
<a href="http://www.sourceboston.com">
<img align="right" src="/images/sourceboston_logo.gif" title="Advanced Linux Firewalls Talk Slides" alt="SOURCE Boston Advanced Linux Firewalls Talk Slides" /></a>
At the <a href="http://www.sourceboston.com">SOURCE Boston</a> conference in Boston
last week I gave talk entitled "Advanced Linux Firewalls"
(<a href="/talks/Advanced_Linux_Firewalls.pdf">slides</a>).  The conference
attendance was good considering that this is the first year the conference was
offered, and I look forward to next year.

I managed to see a few talks, and two that stood out from the crowd were
<a href="http://www.torproject.org/">Roger Dingledine's</a> talk "<b>How To Make
Tor Play Well With The Rest Of The Internet</b>",
and <a href="http://www.securitymetics.org">Andrew Jaquith's</a> talk
"<b>Not Dead But Twitching: Anti-Virus Succumbs to the
Scourge of Modern Malware</b>".  Roger highlighted several technology research
and development areas for the <a href="http://www.torproject.org/">Tor</a> project,
including the ability to use <b>UDP</b> instead of TCP for Tor virtual circuits.
This is of particular interest to me, since it would mean that <a href="/fwknop/docs/SPA.html">
SPA</a> packets could be routed over the Tor network without having to resort to
the establishment of full TCP connections (which breaks the "single packet" part
of "SPA").  Andrew gave some interesting perspectives on malware trends, including
the fact that malware over time is becoming more targeted while at the same time
exhibiting high variability.  The end result is that malware authors are able to
attack the weakest link in the creation of signatures for malware detection - the
people that reverse engineer malware.  Because human resources are scarce and slow
when it comes to reverse engineering (there is no fully automated mechanism for
this yet), malware authors are able to essentially perpetrate a DoS against
vendors that offer malware detection.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/03/fwknop-1.9.2-release-at-source-boston.html</link>
<title>fwknop-1.9.2 Release at SOURCE Boston</title>
<dc:date>2008-03-12T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: conference-talks.html -->
<!-- category: fwknop.html -->
<!-- category: software-releases.html -->
<a href="http://www.sourceboston.com">
<img align="right" src="/images/sourceboston_logo.gif" title="fwknop-1.9.2 released at SOURCE Boston" alt="fwknop-1.9.2 Release at SOURCE Boston" /></a>
Today at the <a href="http://www.sourceboston.com">SOURCE Boston</a> computer
security conference I will give a talk entitled "<b>Advanced Linux Firewalls</b>"
in which I will present many of the themes I discuss in my
<a href="http://www.cipherdyne.org/LinuxFirewalls/">book</a> published late last
year by <a href="http://www.nostarch.com">No Starch Press</a>.  This talk will
also launch the <b>1.9.2</b> release of <a  href="/fwknop"><b>fwknop</b></a>,
and present several new features such as client-derived access timeouts, the
ability to select any of several digest algorithms (SHA-256, SHA-1, or MD5) for
replay attack detection, the removal of the Salted__ prefix in SPA packets
encrypted with Rijndael, and blacklist IP exclusions for incoming SPA packets.
Many of these features were implemented by the
<a href="http://tech.groups.yahoo.com/group/spapict/">SPAPICT team</a>
as well as several other contributors, and I wish to thank all who participated
in the fwknop development process.
<br/><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You can download fwknop-1.9.2
<a href="/fwknop/download">here</a>, and for those interested in the changes in the
fwknop-1.9.2 release, here is the complete <a 
href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.2/ChangeLog">
ChangeLog:</a>
<br/>
<ul>
<li>Crypt::CBC adds the string "Salted__" to the beginning of the encrypted
text (at least for how fwknop interfaces with Crypt::CBC), so the fwknop
client was updated to delete the encoded version of this string
"U2FsdGVkX1" before sending a Rijndael-encrypted SPA packet on the wire.
The fwknopd server will add this string back in before decrypting.  This
makes it harder to write an IDS signature that looks for fwknop traffic;
e.g. look for the default prefix string "U2FsdGVkX1" over UDP port 62201,
which would work for fwknop clients &lt; 1.9.2 (as long as the port number
is not changed with --Server-port).</li>
<li>Added more granular source IP and allowed IP tests so that access to
particular internal IP addresses can be excluded in --Forward-access
mode.  A new keyword "INTERNAL_NET_ACCESS" is now parsed from the
access.conf file in order to implemented these restrictions.</li>
<li>(SPAPICT Group) Added BLACKLIST functionality to allow source IP
addresses to easily be excluded from the authentication process.</li>
<li>(Grant Ferley) Submitted patch to handle SIGCHLD in IPTables::ChainMgr.</li>
<li>(Grant Ferley) Submitted patch to handle Linux "cooked" interfaces for
packet capture (e.g. PPPoE interfaces).</li>
<li>(SPAPICT Group) Applied modified version of the client-defined access
timeout patches submitted by the PICT SPA Group.  There are two new
message types to facilitate client timeouts; one for normal access mode,
and the other for the FORWARD access mode.  In the access.conf file,
there is also a new variable "PERMIT_CLIENT_TIMEOUT" to allow each
SOURCE stanza to allow client-defined timeouts or not.</li>
<li>(SPAPICT Group) Submitted patches to include support for the SHA1 digest
algorithm for SPA packet replay attack detection.  I modified these
patches for maximum configurability (see the --digest-alg argument on
the fwknop command line), and the ability to use the SHA256 algorithm as
well.  The default path to the /var/log/fwknop/md5sums file has been
changed to /var/log/fwknop/digest.cache, and the default digest
algorithm is now SHA256 (but this is tunable via the DIGEST_TYPE
variable in the fwknop.conf file).</li>
<li>Added the Digest::SHA perl module in support of the SHA1 and SHA256
digest algorithms for replay attack detection and SPA message integrity.</li>
<li>Added full packet hex dumps (including packet headers) to fwknopd in
--debug --verbose mode.  This is to help diagnose packet sniffing issues
over the loopback interface on Mac OS X (first reported by Sebastien
Jeanquier).</li>
<li>(Test suite) Bugfix to ensure that the FWKNOP_DIR variable is set to the
local output/ directory in several of the test config files in the
test/conf/ directory.</li>
<li>(Test suite) Added several tests for configurable digest algorithms in
support for the SHA256, SHA1, and MD5 digest changes made by the SPAPICT
Group.</li>
<li>Updated the fwknop client to always call encode_base64() with the string
to encode along with a second null-string argument to force all encoded
data to not include line breaks.</li>
<li>Bugfix in install.pl to not test for the iptable command on non-Linux
systems, and to not test for the ipfw command on systems that are Linux.</li>
<li>(Test suite) Updated to include the /proc/config.gz file so that the
kernel config can be reviewed (not all Netfilter hooks are necessarily
compiled in).</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2008/03/thwarting-distributed-ssh-brute-force-attempts.html</link>
<title>Thwarting Distributed SSH Brute Force Attempts</title>
<dc:date>2008-03-02T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<!-- category: intrusion-detection-and-iptables.html -->
<!-- category: psad.html -->
<a href="http://isc.sans.org/diary.html?storyid=4045">
<img align="right" src="http://isc.sans.org/images/isc/logo_header.gif" title="SSH Brute Force Attempts" alt="Thwarting Distributed SSH Brute Force Attempts" /></a>
The <a href="http://isc.sans.org/">SANS Internet Storm Center</a> has an interesting
<a href="http://isc.sans.org/diary.html?storyid=4045">diary entry</a> that discusses a set
of distributed brute force attempts against SSHD originating from a specific Class C subnet
<b>58.147.10.0/24</b>.  According to the diary entry, a random selection of IP addresses
within this subnet (which is owned by an organization in Thailand) are probing for
listening SSH daemons on the open Internet, but each IP address is limiting the number of
probes to two.  Presumably this is to fly beneath the radar of any threshold-based
detection mechanisms that might automatically block the attempts to communicate with SSHD.<br/>
&nbsp;&nbsp;&nbsp;&nbsp; After rummaging around in my iptables logfiles, I noticed the
following two log entries that show exactly two SYN packets from the IP <b>58.147.10.209</b>
and destined for one of my systems:
<pre>
Jun  3 14:55:06 minastirith kernel: DROP IN=eth0 OUT= \
MAC=00:13:d3:38:b6:e4:00:90:1a:a0:1c:ec:08:00 SRC=58.147.10.209 \
DST=71.N.N.N LEN=60 TOS=0x00 PREC=0x00 TTL=44 ID=11651 DF PROTO=TCP \
SPT=57473 DPT=22 WINDOW=5840 RES=0x00 SYN URGP=0 \
OPT (020405780402080A7CCF5BC50000000001030302)
Jun  3 14:55:09 minastirith kernel: DROP IN=eth0 OUT= \
MAC=00:13:d3:38:b6:e4:00:90:1a:a0:1c:ec:08:00 SRC=58.147.10.209 \
DST=71.N.N.N LEN=60 TOS=0x00 PREC=0x00 TTL=44 ID=11653 DF PROTO=TCP \
SPT=57473 DPT=22 WINDOW=5840 RES=0x00 SYN URGP=0 \
OPT (020405780402080A7CCF677D0000000001030302)
</pre>
These two packets date back to June of last year, so the 58.147.10.0/24 network has
apparently been active for quite some time.  So, beyond the <b>whois</b> information
mentioned in the ISC diary entry, can we tell anything more about our friend at
58.147.10.209?  Because I always use the <b>--log-tcp-options</b> command line argument
when building my iptables LOG rules, we have nice hex dumps included in the log messages
above that represent the options portion of the TCP header.  Having this information is
necessary in order to passively fingerprint the remote TCP stack with
<a href="http://lcamtuf.coredump.cx/p0f.shtml">p0f</a>.  The <a href="/psad">psad</a>
project re-implements the p0f algorithm over iptables log messages - p0f requires raw
packet data acquired via libpcap - so what does psad have to say about the remote TCP
stack?
<pre>
[minastirith]# psad -A -m /var/log/messages --restrict-ip 58.147.10.209
[+] p0f(): 58.147.10.209 len: 60, frag_bit: 1, ttl: 44, win: 5840
[+] MSS: 1400, SACK, Timestamp: 2093964229, NOP, Win Scale: 2,
    Could not match 58.147.10.209 against any p0f signature.
</pre>
Oh well, that is unfortunate.  So, p0f does not seem to have a fingerprint that can
characterize the remote TCP stack.  I also looked through the passive OS fingerprinting
database included with the <a href="http://ettercap.sourceforge.net/">ettercap project</a>,
but no luck there either.  This was a manual process though because psad does not yet
support the format of the fingerprints in ettercap, but this will be supported in the
next release.<br/>
&nbsp;&nbsp;&nbsp;&nbsp; In the meantime, the discussion in the
<a href="http://isc.sans.org/diary.html?storyid=4045">diary entry</a> advocates limiting
the set of IP addresses that are allowed to talk to the SSH daemon, but ends with a
comment stating that this is not always possible.  I agree with this comment, and this is
highlighted whenever you administer a system and you need access to SSHD from
unpredictable source addresses (such as when travel is involved).  A robust solution
is to deploy <a href="/fwknop/docs/SPA.html">Single Packet Authorization</a> with a
default-drop packet filter.  Why let arbitrary source IP addresses communicate with
your SSH daemon?


]]></description>
</item>

<!-- end_stories -->

</channel>
</rss>
