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

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

<a href="/fwsnort/download/">
<img align="right" src="/images/release.png" title="fwsnort-1.6.2" alt="fwsnort-1.6.2 released" /></a>
The 1.6.2 release of <a  href="/fwsnort"><b>fwsnort</b></a> is available for
<a  href="/fwsnort/download/"><b>download</b></a>.  The most impactful
change in this release is a switch to how fwsnort loads translated rules into the
running iptables policy.  Instead of attempting to parse the local policy and only
add those rules in that appear to match protocols that the policy allows, fwsnort
now loads all translated rules by default.  The reasoning for this change is in
the ChangeLog below.  There are a few bug fixes and updates to get fwsnort working
without warnings on recent versions of perl as well as an ICMP type fix for recent
versions of iptables.  As usual, please let me know if there are any issues.
<br/><br/>
Here is the complete fwsnort-1.6.2
<a href="/cgi-bin/gitweb.cgi?p=fwsnort.git;a=blob;f=ChangeLog;h=e33498631edb15f296ce5c34b4d573826dba262f;hb=5d1d646c8806ab8af982a5c8f395e72248cd2e54">ChangeLog</a>:
<br/><br/>
<ul>
<li>Switched --no-ipt-sync to default to not syncing with the iptables policy.
By default fwsnort attempts to match translated Snort rules to the
running iptables policy, but this is tough to do well because iptables
policies can be complex.  And, before fwsnort switched to the
iptables-save format for instantiating the policy, a large set of
translated rules could take a really long time to make active within the
kernel.  Finally, many Snort rules restrict themselves to established TCP
connections anyway, and if a restrictive policy doesn't allow connections
to get into the established state for some port let's say, then there is
little harm in having translated Snort rules for this port.  Some kernel
memory would be wasted (small), but no performance would be lost since
packets won't be processed against these rules anyway.  The end result is
that the default behavior is now to not sync with the local iptables
policy in favor of translating and instantiating as many rules as
possible.</li>
<li>Replaced Net::IPv4Addr with the excellent NetAddr::IP module which has
comprehensive support for IPv6 address network parsing and comparisons.</li>
<li>Moved the fwsnort.sh script and associated files into the
/var/lib/fwsnort/ directory.  This was suggested by Peter Vrabec.</li>
<li>Bug fix for recent versions of iptables (such as 1.4.12) where the icmp
match requires --icmp-type to be set - some Snort rules look for a string
to match in icmp traffic, but don't also specify an icmp type.</li>
<li>Bug fix for 'qw(...) usage as parenthesis' warnings for perl &gt; 5.14</li>
<li>Removed the ExtUtils::MakeMaker RPM build requirement from the
fwsnort.spec file.  This is a compromise which will allow the fwsnort RPM
to be built even if RPM doesn't or can't see that ExtUtils::MakeMaker is
installed - most likely it will build anyway.  If it doesn't, there are
bigger problems since fwsnort is written in perl.  If you want to build
the fwsnort RPM with a .spec file that requires ExtUtils::MakeMaker, then
use the "fwsnort-require-makemaker.spec" file that is bundled in the
fwsnort sources.</li>
</ul>

]]></description>
</item>

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

<a href="/psad/download/">
<img align="right" src="/images/release.png" title="psad-2.2" alt="psad-2.2 released" /></a>
After a long development cycle, the 2.2 release of <a  href="/psad"><b>psad</b></a> is
available for <a  href="/psad/download/"><b>download</b></a>.  This release adds
major new functionality for the detection of malicious traffic that is delivered over IPv6 by
parsing <b>ip6tables</b> logs.  A significant portion of this capability is enabled by the
excellent <a href="http://search.cpan.org/~miker/NetAddr-IP-4.059/IP.pm">NetAddr::IP</a> CPAN
module that can properly handle IPv6 addresses.  In addition, speed optimizations have been
made that result in psad-2.2 being about 15% faster than previous releases, several bugs have
been fixed (including one that caused compile time warnings on recent versions of perl), and
a comprehensive test suite has been added.  psad-2.2 is a stepping stone to the upcoming
psad-3.0 release that will include support for both PF and ipfw firewalls running on *BSD
systems.  Quite a bit of this work has already been done in the
<a href="/cgi-bin/gitweb.cgi?p=psad.git;a=shortlog;h=refs/heads/openbsd_integration">openbsd_integration</a>
branch.
<br/><br/>
Here is an excerpt of the psad-2.2 ChangeLog:
<br/><br/>
<ul>
<li>Added support for detection of malicious traffic that is delivered via
IPv6.  This is accomplished by parsing ip6tables log messages - these are
in a slightly different format than the iptables log messages.  Here is
an example:
<br/><br/>
Mar 17 13:39:13 linux kernel: [956932.483644] DROP IN=eth0 OUT=
MAC=00:13:46:3a:41:36:00:1b:b9:76:9c:e4:86:dd
SRC=2001:0db8:0000:f101:0000:0000:0000:0002
DST=2001:0db8:0000:f101:0000:0000:0000:0001 LEN=80 TC=0 HOPLIMIT=64
FLOWLBL=0 PROTO=TCP SPT=50326 DPT=993 WINDOW=5760 RES=0x00 SYN URGP=0
<br/><br/>
Detection of malicious IPv6 traffic can be disabled via a new
ENABLE_IPV6_DETECTION config variable.</li>
<li>For ICMP6 traffic, added protocol validation for ICMP6 type/code
combinations.</li>
<li>Added a new test suite in the test/ directory to validate psad run time
operations (scan detection, signature matching, and more).  To support
this, a new '--install-test-dir' option was added to the install.pl
script.  Once this is executed, the test suite can be run via the
test-psad.pl script in the test/ directory.</li>
<li>Added a new MAX_SCAN_IP_PAIRS config variable to allow psad memory usage
to be constrained by restricting the number of unique IP pairs that psad
This is useful for when psad is deployed on systems with little memory,
and is best utilized in conjunction with disabling ENABLE_PERSISTENCE so
that old scans will also be deleted (and thereby making room for tracking
new scans under the MAX_SCAN_IP_PAIRS threshold).</li>
<li>Bug fix for 'qw(...) usage as parenthesis' warnings for perl &gt; 5.14</li>
<li>Bug fix that caused psad to emit the following:
<br/><br/>
Undefined subroutine &amp;main::LOG_DAEMON called at ./psad line 10071.
<br/><br/>
This problem was noticed by Robert and reported on the psad mailing list.</li>
<li>Bug fix for ICMP packet handling where psad would incorrectly interpret
ICMP port unreachable messages as UDP packets because the UDP specifics
are included in the iptables log message.  This bug was first reported by
Lukas Baxa to the Debian maintainers and was followed up by Franck
Joncourt: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=596240
An example ICMP log message that exposed the bug is included below:
<br/><br/>
Sep  8 18:04:26 baxic kernel: [28241.572876] IN_DROP IN=wlan0
OUT= MAC=00:1a:9f:91:df:ae:00:21:27:e8:0a:a0:08:00
SRC=10.0.0.138 DST=192.168.1.103 LEN=96 TOS=0x00 PREC=0xC0 TTL=254
ID=63642 PROTO=ICMP TYPE=3 CODE=3
[SRC=192.168.1.103 DST=10.0.0.138 LEN=68 TOS=0x00 PREC=0x00 TTL=0
ID=22458 PROTO=UDP SPT=35080 DPT=33434 LEN=48 ]
</li>
</ul>
The complete psad-2.2 ChangeLog can be found
<a href="/cgi-bin/gitweb.cgi?p=psad.git;a=blob;f=ChangeLog;h=abe9d76fa29bdb35ad1a15a7022810f313cf7534;hb=0afb375fbaae66775ac327d8c2ed38f64e663b8b">here</a>
via the psad <a href="/cgi-bin/gitweb.cgi?p=psad.git;a=summary">gitweb</a> interface.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2012/03/cipherdyne.org-git-repositories-safe-after-github-hack.html</link>
<title>cipherdyne.org git Repositories Safe After github Hack</title>
<dc:date>2012-03-07T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="/fwknop/">
<img align="right" src="/images/github_logo.png" title="github" alt="github" width="200" height="100" /></a>
After a <a href="http://www.extremetech.com/computing/120981-github-hacked-millions-of-projects-at-risk-of-being-modified-or-deleted">widely publicized</a>
hack of <a href="http://www.github.com">github</a> (now fixed), I thought it would be a good idea to ensure
that the <a href="/git">cipherdyne.org git repositories</a> remain secure on both github and on the cipherdyne.org
webserver.  The techniques in the blog post may not be well suited to large git repositories with a lot of
different people able to commit code, but for my repositories these checks provide a fairly high level of
confidence that no malicious code has been introduced.  First, the github hack was made possible through
a "<a href="http://blog.mhartl.com/2008/09/21/mass-assignment-in-rails-applications/">mass assignment</a>"
vulnerability in Ruby on Rails, and would have permitted an attacker to gain admin privileges to any project
on github.  Once admin access is acquired, an attacker would be in a position to do anything
to the underlying code base - including adding new code that implements "undocumented features".
<br/><br/>
Now, in order to add a backdoor into a code base on github, what would an attacker need to do?
<br/><br/>
Altering the code base for a project would need to be done through standard git operations as a new
commit - i.e., make code changes to a local copy, <em>git add ...</em>, <em>git commit ...</em> - as
opposed to manually editing previously committed code in the git repository itself.   This is because every
commit must match a corresponding SHA1 hash according to git's
<a href="http://book.git-scm.com/1_the_git_object_model.html">object model</a>, and a SHA1 collision such
that the bogus data is <em>also</em> working code would be "computationally difficult" to say the least
(<a href="http://www.schneier.com/blog/archives/2005/08/new_cryptanalyt.html">attacks against SHA1</a> not
withstanding).  As a basic check, one can create a git repository for testing purposes, write a random
byte to a random position within the <em>.git/objects/pack/*.pack</em> file and then try to clone it to
see what happens:

<pre>
error: packfile ./objects/pack/pack-9c886ed427d9a7538093f09edf516a0a718201ac.pack does not match index
error: packfile ./objects/pack/pack-9c886ed427d9a7538093f09edf516a0a718201ac.pack cannot be accessed
fatal: git upload-pack: cannot find object 7e8e48412ff985461095a09874059e955145d513:
fatal: The remote end hung up unexpectedly
</pre>

The repository has essentially been corrupted and the clone operation fails.
<br/><br/>

Ok, so a malicious code modification would most likely need to be done via an entirely new commit.  This
could certainly be done by an attacker, but anyone who has cloned the repository would be able to see the
change.  For a large, highly active project without rigorous code review and committer hierarchy, it is
conceivable that such a change might just get lost within the noise of lots of commits.  After all, a human
would need to review the change and recognize it as being malicious.
<br/><br/>

Could such a malicious code change affect the cipherdyne.org projects?  In a word, "no", and here's why: all
commits to the cipherdyne.org code bases are pushed to github from private git repositories on a dedicated
system that is not generally accessible, and <em>git pull ... </em> is only done occasionally and every
change comes from a known source and is reviewed.  The accessible non-private git repositories on
cipherdyne.org are mirrors of the github repositories, so if a malicious change were introduced into github,
then they would have this change too. The private repositories would still be safe however.  So, given this
work flow, what I need is a way to verify that there are no commits in either the github repositories
or cipherdyne.org mirrors that are not in private repositories.  Further, I would like to be able to verify
this without having to push or pull code into the private repositories (so I can regularly check at any
time without any modifications coming through).  There are probably many ways to do this in the git world
- for example, one could just use <em>git fetch</em> to bring in changes into remote tracking branches and
compare these against local branches (any malicious code would not be merged into a local branch after it is
discovered), but here is an alternate solution:
<br/><br/>
<ul>
<li>On my system where the private repositories live, create two directories <em>GH/</em> and <em>CD/</em>, and clone all
of the github repositories into the <em>GH</em> directory and all cipherdyne.org repository mirrors into the <em>CD</em>
directory. We'll assume that the private repositories live in a directory called <em>private/</em></li>
<li>For each repository pair in the <em>GH</em> and <em>CD</em> directories, diff the output of <em>git rev-list --all</em>.
There should be zero differences here.</li>
<li>If the step above checks out, then diff the <em>git rev-list --all</em> output across the
<em>GH/&lt;repo&gt;</em> and <em>private/&lt;repo&gt;</em> pairs.  For this step we expect that the
private repositories will have local commits that are not necessarily pushed upstream - what we're concerned
about is any commit in a <em>GH/&lt;repo&gt;</em> that is not in a <em>private/&lt;repo&gt;</em>.</li>
</ul>

Here are a few commands to accomplish the above (we'll assume that the <em>git clone --bare &lt;repo&gt;</em>
steps have already been done for brevity):

<pre>
$ for r in fwknop psad gpgdir fwsnort IPTables-Parse IPTables-ChainMgr
&gt; do
&gt; echo "[+] Checking $r...";
&gt; diff -u &lt;(cd ~/CD/$r.git &amp;&amp; git rev-list --all ) &lt;( cd ~/GH/$r.git &amp;&amp; git rev-list --all)
&gt; done
[+] Checking fwknop...
[+] Checking psad...
[+] Checking gpgdir...
[+] Checking fwsnort...
[+] Checking IPTables-Parse...
[+] Checking IPTables-ChainMgr...
</pre>

The output above indicates there are identical git commits in the github repositories vs. the
cipherdyne.org mirrors.  Good.  Now, let's compare the github repositories vs the private ones - we grep
on "+" which would indicate new commits in github that are not in the private repositories:

<pre>
$ for r in fwknop psad gpgdir fwsnort IPTables-Parse IPTables-ChainMgr
&gt; do
&gt; echo "[+] Checking $r...";
&gt; diff -u &lt;(cd ~/private/$r.git &amp;&amp; git rev-list --all ) &lt;( cd ~/GH/$r.git &amp;&amp; git rev-list --all) | egrep "^\+" | grep -v @
&gt; done
[+] Checking fwknop...
+++ /dev/fd/62  2012-03-07 22:50:48.004281002 -0500
[+] Checking psad...
+++ /dev/fd/62  2012-03-07 22:50:48.054281002 -0500
[+] Checking gpgdir...
+++ /dev/fd/62  2012-03-07 22:50:48.164281002 -0500
[+] Checking fwsnort...
+++ /dev/fd/62  2012-03-07 22:50:48.194281002 -0500
[+] Checking IPTables-Parse...
[+] Checking IPTables-ChainMgr...
</pre>

Again, good, no commits in github that are not in the private repositories.  If there had been a line like
the following I would have been concerned:
<pre>
+fff688f5b4275152636d8959f67bbcd46839fbbb
</pre>

Rather than modifying code and committing it to a git repository on github, it would have been far
more damaging for an attacker to just alter the github website to serve up drive by exploits for a
popular web browser.  Either way, I'm glad they fixed the vulnerability.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2012/02/on-spa-cross-packet-ciphertext-entropy.html</link>
<title>On SPA Cross-Packet Ciphertext Entropy</title>
<dc:date>2012-02-13T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="/fwknop/">
<img align="right" src="/images/random_dice.jpg" title="fwknop SPA packet entropy" alt="fwknop SPA packet entropy" width="200" height="150" /></a>
With fwknop now re-written in C for the <a href="/blog/2012/01/software-release-fwknop-2.0.html">2.0 release</a>,
I thought it would be a good idea to take a look at how close encrypted SPA packet data comes to having
high levels of entropy - as understood to be a measure of randomness - from one packet to the next.  If
fwknop is properly using encryption, and the ciphers themselves are also well-implemented (fwknop can
use either Rijndael or GPG), then we would expect there to be no obvious relationship between SPA packets
even for repeated access requests to the same service.  If there are any such relationships in the
encrypted data across multiple SPA packets, then an adversary <i>might</i> be able to infer things about
the underlying plaintext - precisely what strong encryption is supposed to make difficult.  This blog
post covers SPA packet entropy for AES (Rijndael) CBC and ECB encryption modes, and leaves GPG to another
post.
<br/><br/>
Although this post has some similarities with an older blog entry
"<a href="/blog/2008/09/visualizing-spa-packet-randomness.html">Visualizing SPA Packet Randomness</a>",
a more rigorous and automated way of measuring cross-packet SPA entropy will be presented.  In addition,
we'll take a look at what happens when (normally) random
<a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29">salt</a>
values for AES encrypted SPA packets are artificially forced to be constant.  This helps to highlight
some real differences in AES electronic codebook (ECB) and cipher block chaining (CBC) encryption
modes.
<br/><br/>
First, the next release of fwknop will most likely offer the ability to select different AES encryption
modes (such as cipher feedback (CFB) mode and output feedback (OFB) mode), and a dedicated
"<a href="/cgi-bin/gitweb.cgi?p=fwknop.git;a=shortlog;h=refs/heads/crypto_update">crypto_update</a>"
branch has been created for this work.  The default AES encryption mode used by fwknop is cipher block chaining
(CBC) mode as defined
<a href="/cgi-bin/gitweb.cgi?p=fwknop.git;a=blob;f=lib/fko.h;h=e694a718a8fd51b02572384e57428101903d592e;hb=71690a1de45b273789af4e26a01594e9d5150eff#l179">here</a>.
Within the <b>crypto_update</b> branch there is a new script
"<a href="/cgi-bin/gitweb.cgi?p=fwknop.git;a=blob;f=extras/spa-entropy/spa-entropy.pl;h=a5ebd7fddaba9bae7393227fb395422781de816d;hb=71690a1de45b273789af4e26a01594e9d5150eff">spa-entropy.pl</a>"
that is designed to execute the fwknop client multiple times, collect the encrypted SPA packet data, use the
<a href="http://www.fourmilab.ch/random/">ent</a> program to measure the entropy in slices for each byte
position across the SPA data set, and then plot the results with gnuplot.  What does this accomplish?  It
allows us to easily see for any given byte position within a collection of SPA packets whether there is a
relation from one to the next.  If there is such a relation, then the cipher used to encrypt the
data was not very good at achieving high levels of entropy in the ciphertext across multiple packets.
<br/><br/>
As a motivating
<a href="http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation">example</a> from Wikipedia, AES in
ECB mode encrypts identical plaintext blocks into identical ciphertext blocks, and this results in patterns
in plaintext data being preserved to some extent in the ciphertext.  So, an adversary can make good guesses
about the underlying plaintext just by looking at the ciphertext!  Wikipedia does a nice job of illustrating
this with the following two images of the Linux kernel mascot "Tux" - before and after AES encryption in
ECB mode:
<br/><br/>

<table>
<tr>
<td><img src="/images/tux.jpg" title="plaintext Tux" alt="plaintext Tux" /></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>AES ECB encryption -&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
<td><img src="/images/tux_ecb.jpg" title="AES ECB encrypted Tux" alt="AES ECB encrypted Tux" /></td>
</tr>
</table>

<i><b>Encryption Fail.</b></i>
<br/><br/>
Now, let's take a look at SPA packet entropy with the <b>spa-entropy.pl</b> script.  For reference, fwknop
builds SPA packets according to the following data format before encryption:
<br/><br/>
<b>[random data: 16 bytes]:[username]:[timestamp]:[version]:[message type]:[access request]:[digest]</b>
<br/><br/>

So, if a user wants repeated access to the same service protected behind fwknopd on some
system, then several fields above will be identical across the corresponding SPA packets before
they are encrypted.  The username, version, message type, and access request fields will likely be the
same.  If fwknop has made proper use of encryption, then the fact that these fields are the same across
multiple SPA packets should not matter.  After encryption, an observer should not be
able to tell anything about the underlying plaintext (other than perhaps size since AES is a block
cipher).  Let's verify this for 1,000 SPA packets encrypted with the default CBC mode - they are all
encrypted with the same key 'fwknoptest' by the <b>spa-entropy.pl</b> script:

<br/><br/>
<code>
$ ./spa-entropy.pl -f 1000_pkts.data -r -c 1000 --base64-decode<br/>
[+] Running fwknop client via the following command:<br/>
<br/>
LD_LIBRARY_PATH=../../lib/.libs ../../client/.libs/fwknop -A tcp/22 -a 127.0.0.2 -D 127.0.0.1 --get-key local_spa.key -B 1000_pkts.data -b -v --test -M cbc<br/>
<br/>
[+] Read in 1000 SPA packets...<br/>
[+] Min entropy: 7.75 at byte: 54<br/>
[+] Max entropy: 7.86 at byte: 115<br/>
[+] Creating entropy.gif gnuplot graph...<br/>
</code>
<br/><br/>

This produces the gnuplot graph below.  Perfectly random data would produce
8 bits of entropy per byte, and the min/max values of 7.75 and 7.86 along with the fairly
uniform distribution of similar values across all of the SPA byte positions implies that
there is little relation from one SPA packet to the next - good.

<img src="/images/1000_spa_cbc.gif" title="SPA entropy for CBC mode" alt="SPA entropy for CBC mode" />

As an aside, here is
what <b>ent</b> reports against the local <b>/dev/urandom</b> entropy source on my Linux system, and it is
the "Entropy =" line that <b>spa-entropy.pl</b> parses for each SPA byte slice:

<br/><br/>
<code>
$ dd if=/dev/urandom count=1000 |ent<br/>
1000+0 records in<br/>
1000+0 records out<br/>
512000 bytes (512 kB) copied, 0.128497 s, 4.0 MB/s<br/>
Entropy = 7.999625 bits per byte.<br/>
<br/>
Optimum compression would reduce the size<br/>
of this 512000 byte file by 0 percent.<br/>
<br/>
Chi square distribution for 512000 samples is 265.77, and randomly<br/>
would exceed this value 50.00 percent of the times.<br/>
<br/>
Arithmetic mean value of data bytes is 127.5076 (127.5 = random).<br/>
Monte Carlo value for Pi is 3.138715386 (error 0.09 percent).<br/>
Serial correlation coefficient is -0.001293 (totally uncorrelated = 0.0).
</code>
<br/><br/>

Now, let's switch to ECB mode and see what happens (just run the <b>spa-entropy.pl</b> script
with '-e ecb'):

<img src="/images/1000_spa_ecb.gif" title="SPA entropy for ECB mode" alt="SPA entropy for ECB mode" />

Well, that still looks pretty good.  Revisiting the ECB encrypted image of Tux above
for a moment - the reason that the Tux outline can be seen in the encrypted version
is that in the JPG image file there must be identical blocks in multiple locations
to represent the solid black regions.  These blocks are all encrypted in the same
way by AES in ECB mode, so the outline persists.  But, this is one instance of ECB
encryption against a file that has multiple identical blocks.  For the encrypted SPA
packets, we're dealing with 1,000 separate instances of encrypted data (all with the
same key).  Across this data set there are certainly lots of identical plaintext
blocks (all of the SPA packets request access for source IP 127.0.0.2 to destination
port tcp/22 for example), but the encrypted data still shows a high level of entropy.
This source of entropy is provided by the random salt values that are used to
generate the initialization vector and final encryption key for each encrypted SPA
packet.  As proof, if we apply the following patch to force the salt to zero for all
SPA packets (of course, one would not want to use this patch in practice):

<br/><br/>
<code>
$ git diff lib/cipher_funcs.c<br/>
diff --git a/lib/cipher_funcs.c b/lib/cipher_funcs.c<br/>
index 0a0ce3b..32c8bd6 100644<br/>
--- a/lib/cipher_funcs.c<br/>
+++ b/lib/cipher_funcs.c<br/>
@@ -153,6 +153,8 @@ rij_salt_and_iv(RIJNDAEL_context *ctx, const char *pass, const unsigned char *da<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get_random_data(ctx-&gt;salt, 8);<br/>
&nbsp;&nbsp;&nbsp;&nbsp; }<br/>
 <br/>
+&nbsp;&nbsp;&nbsp;&nbsp;memset(ctx-&gt;salt, 0x00, 8);<br/>
+<br/>
&nbsp;&nbsp;&nbsp;&nbsp; /* Now generate the key and initialization vector.<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  * (again it is the perl Crypt::CBC way, with a touch of<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  * fwknop).
</code>
<br/><br/>

Here is what <b>spa-entropy.pl</b> reports after recompiling fwknop with the patch above:

<img src="/images/1000_spa_ecb_zero_salt.gif" title="SPA entropy for ECB mode zero salt" alt="SPA entropy for ECB mode zero salt" />

Now we can easily see where there are identical blocks across the SPA packet data set.  The first
eight bytes contains the salt, so these are all zero (note that fwknop strips the
usual "Salted__" prefix before transmitting an SPA packet on the wire).  The next
16 bytes are the random bytes that fwknop includes in every SPA packet so these bytes
have high entropy.  Next up are the username and timestamp - the later changes with
each second, so there is some entropy there since it takes a few seconds to create the
1,000 SPA packet data set.  Then the entropy goes back to zero with the next fields
and there isn't any decent entropy until the final message digest.
<br/><br/>

As a final contrasting case, let's leave the patch applied to force the salt to zero, but now
switch back to CBC mode:

<img src="/images/1000_spa_cbc_zero_salt.gif" title="SPA entropy for CBC mode zero salt" alt="SPA entropy for CBC mode zero salt" />

In CBC mode, the random data included by the fwknop client now results in decent entropy
even though the salt is zero.  This is because every ciphertext block in CBC mode
depends on all previous plaintext blocks, so randomness in one plaintext block implies
that every subsequent encrypted block will look different from one SPA packet to the
next.  This graphically shows that CBC mode is a better choice for strong security.
Now, if the pseudo random number generator on the local operating system is poorly
implemented, this will negatively impact ciphertext entropy regardless of the encryption
mode, but still CBC mode is a better alternative than ECB mode.
<br/><br/>
Although <b>spa-entropy.pl</b> is geared towards measuring SPA packet entropy, this technique
could certainly be generalized to arbitrary collections of ciphertext.  If you know of such
an implementation, please email me.

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2012/01/bing-indexing-of-gitweb.cgi-links.html</link>
<title>Bing Indexing of gitweb.cgi Links</title>
<dc:date>2012-01-21T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="http://www.bing.com/">
<img align="right" src="/images/bing-logo.png" height="100" width="130" title="Bing indexing of gitweb.cgi links" alt="Bing indexing of gitweb.cgi links" /></a>
In June, 2011, all of the cipherdyne.org software projects were switched over to git from svn,
and at the same time the web interface was switched to gitweb (along with hosting at github)
from trac.  Given the switch, I knew there would be a change to how search engines indexed the
code/data, and one question would be whether any particular search engine would take a specific
interest in the code provided via git and/or gitweb.  Note that each of the fwknop, psad,
fwsnort, and gpgdir projects have raw git repositories that can be cloned directly over HTTP
from cipherdyne.org (a nice feature of git), or viewed with any browser through
<a href="http://www.cipherdyne.org/cgi-bin/gitweb.cgi">gitweb</a>.
(Personally, I like the "<a href="http://atrey.karlin.mff.cuni.cz/~clock/twibright/links">links2</a>"
text-based browser rendering of gitweb pages - nice and clean.)
<br/><br/>
First, here are some stats for indexing bots from major search engines across all cipherdyne.org
Apache log data for hits against gitweb.cgi from June, 2011 to today:
<br/><br/>
<table class="ctable" cellspacing="1" cellpadding="1">
<tr><td>Hits</td><td>Percentage</td><td>User-Agent</td></tr>
<tr><td><b>505055</b></td><td>81.01%</td><td><b>Mozilla/5.0 (compatible; bingbot/2.0;)</b></td></tr>
<tr><td><b>50242</b></td><td>8.06%</td><td><b>msnbot/2.0b (+http://search.msn.com/msnbot.htm)._</b></td></tr>
<tr><td><b>25707</b></td><td>4.12%</td><td><b>Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com)</b></td></tr>
<tr><td><b>6583</b></td><td>1.06%</td><td><b>Feedfetcher-Google; (+http://www.google.com/feedfetcher.html;)</b></td></tr>
<tr><td><b>4310</b></td><td>0.69%</td><td><b>Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</b></td></tr>
<tr><td><b>1956</b></td><td>0.31%</td><td><b>Mozilla/5.0 (compatible; SISTRIX Crawler; http://crawler.sistrix.net/)</b></td></tr>
<tr><td><b>1905</b></td><td>0.31%</td><td><b>Mozilla/5.0 (compatible; Purebot/1.1; +http://www.puritysearch.net/)</b></td></tr>
<tr><td><b>1751</b></td><td>0.28%</td><td><b>Mozilla/5.0 (compatible; Yahoo! Slurp;)</b></td></tr>
<tr><td><b>1625</b></td><td>0.26%</td><td><b>Mozilla/5.0 (compatible; MJ12bot/v1.4.0;)</b></td></tr>
<tr><td><b>1451</b></td><td>0.23%</td><td><b>TwengaBot-Discover (http://www.twenga.fr/bot-discover.html)</b></td></tr>
</table>
<br/><br/>
Wow!  So bots associated with Microsoft's Bing search engine take the top two spots for a
combined hit total of well over 500,000 since June, 2011.  If spread out over the entire time
period (which it's not as we'll see) that would be an average of about 2,600 hits <i>per day</i>,
and this figure is more than 20 times the third place bot.  Google is in
a distant forth place, even though Google used to
<a href="/blog/2009/09/google-indexing-of-trac-repositories.html">heavily index Trac repositories</a>.
<br/><br/>
So, let's see how the search engine hits are distributed since June, 2011.  First, here is a
graph of just gitweb hits by the top five crawlers:
<img src="/images/gitweb_user_agents.gif" title="top 5 gitweb indexers" alt="top 5 gitweb indexers" />

Clearly, that is not a very uniform distribution from day to day.  It looks like Bing has been
hitting the gitweb interface at a rate of over 17,000 hits per day for a significant portion
of late December and early January.  The other search engines hardly even show up in the graph -
you know there are big spikes when everything looks better on a logarithmic scale:
<img src="/images/gitweb_user_agents_logscale.gif" title="top 5 gitweb indexers logarithmic" alt="top 5 gitweb indexers logarithmic" />

With some additional work, it looks like the gitweb.cgi links that Bing is indexing are not all
unique.  That is, one might expect that Bing would hit a link, grab the content, and then not return
to the same link for a while.  Some gitweb.cgi links were hit more than 10 times and more than 100,000
links were hit more than once during this time period.
<br/><br/>
How does this compare with hits across other portions of cipherdyne.org?  Bing indexing is still
far and away the largest outlier:
<img src="/images/all_user_agents.gif" title="top 5 indexers of cipherdyne.org" alt="top 5 indexers of cipherdyne.org" />

Given that 1) all of the information gitweb displays is derived from the underlying git repositories,
and 2) the git repositories are directly accessible via HTTP anyway, it would seem that a better way for
search engines to behave would be to just ignore gitweb altogether and pull directly from git.  That
would certainly cut down on the server-side resources necessary to service search engine requests.
Perhaps though the general strategy of search engines is not to be too smart about such things - they
probably just want access to data, and when they see a link they go after it.
Either way, the kind of dedicated and repetitive indexing the Bing is doing against gitweb is a bit much,
and it certainly seems as though they could implement a less intensive crawler.  I'm curious if other
server admins are seeing similar behavior.
<br/><br/>
<b>Update 01/23</b>: There are tons of web analysis tools out there, but I wrote a couple of quick
scripts to generate the data in this blog post.  The first "<a href="/scripts/user_agent_stats_pl.tar.gz">user_agent_stats.pl</a>"
parses Apache logs and produces user-agent graphs with Gnuplot as shown in this post.  The second
"<a href="/scripts/uniq_hits_pl.tar.gz">uniq_hits.pl</a>" is extremely simple and just counts the
number of hits against the same links within the Apache log data.  Both scripts accept log data via
TDIN - here is an example where user agents who hit any "index.html" link are plotted (graph is
not shown):
<br/><br/>
<code>
$ zcat ../logs/cipherdyne.org*.gz |grep "index.html" | ./user_agent_stats.pl -p index_hits<br/>
[+] Parsing Apache log data...<br/>
[+] Total agents: 1769 (abbreviated to: 174 agents)<br/>
[+] Executing gnuplot...<br/>
    Plot file:  index_hits.gif<br/>
    Agent stats: index_hits.agents
</code>
<br/><br/>


]]></description>
</item>

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

<a href="/fwknop/download/">
<img align="right" src="/images/release.png" title="fwknop-2.0" alt="fwknop-2.0 released" /></a>
After a long development cycle, <a  href="/fwknop"><b>fwknop-2.0</b></a> has
been <a href="/fwknop/download">released</a>.  This is the first production release of the
fully re-written C version of fwknop, and is the culmination of an effort to provide
<a href="/fwknop/docs/SPA.html">Single Packet Authorization</a> to multiple open source
firewalls, embedded systems, mobile devices, and more.  On the "server" side, supported
firewalls now include iptables on Linux, ipfw on FreeBSD and Mac OS X, and pf on OpenBSD.
The fwknop client is known to run on all of these platforms, and also functions on
Windows systems running under Cygwin.  There is also an Android client, and a good start
on a iPhone client as well.  On a personal note, I wish to thank Damien Stuart for a
heroic effort to port most of the original perl code over to C.  Also, several other
people have made significant contributions including Jonathan Bennet, Max Kastanas,
Sebastien Jeanquier, Ozmart, and others.  If there are any issues, please get in touch
with me directly or send an email to the fwknop
<a href="https://lists.sourceforge.net/lists/listinfo/fwknop-discuss">mailing list</a>.
<br/><br/>
<b>Update 01/03</b>: Both libfko library that powers much of fwknop operations and the
fwknop client can be compiled as native Windows executables.  In addition, there are perl
and python bindings to libfko as well.
<br/><br/>
<b>Update 01/07</b>: Damien Stuart has built
<a href="/fwknop/download/binaries.html">RPM files</a> for fwknop on RHEL5, RHEL6,
Fedora 15, 16, and 17 and for other architectures the Fedora koji build system can
produce.

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/12/software-release-fwknop-2.0rc5.html</link>
<title>Software Release - fwknop-2.0rc5</title>
<dc:date>2011-12-11T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="/fwknop/download/">
<img align="right" src="/images/fwknop-iphone.jpg" height="275" width="147" title="fwknop-2.0rc5" alt="fwknop-2.0rc5 released" /></a>
The 2.0rc5 candidate release of <a  href="/fwknop"><b>fwknop</b></a> is available for
<a  href="/fwknop/download/"><b>download</b></a>.  There may be a few tweaks to the
code before the official 2.0 release is made, but this is pretty close as-is.  Significant
development work has gone into fwknop since the 2.0rc4 release, and adds some major new
functionality as well as fixing a few bugs.  Here is a summary of the changes:
<br/><br/>
<b>iPhone fwknop client</b>:  Max Kastanas has contributed an iPhone port of the fwknop client.  He had
already contributed on Android client, so the iPhone was the next natural step!  We're looking for a
maintainer of the iPhone code so that eventually it can be made available through the App Store.  If
you have iPhone development experience and are interested in taking this on, please
<a href="http://www.cipherdyne.org/contact.html">contact me</a>.
<br/><br/>
<b>PF firewall support on OpenBSD</b>:  For quite a while now fwknop has brought Single Packet Authorization
 support to iptables firewalls on Linux and ipfw firewalls on FreeBSD and Mac OS X systems. The 2.0rc5
release now introduces support for the <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=pf">PF</a>
firewall on OpenBSD systems.  By interfacing with the <b>pfctl</b> command, fwknop creates new rules to
access a protected service (such as SSHD) to a PF anchor.  Rules are deleted out of a running
anchor with <i>pfctl -a &lt;anchor&gt; -f -</i> with the expired rule(s) removed.  There is support
in the fwknop test suite (see the test/ directory in the fwknop-2.0rc5 sources) to validate fwknop
operations on OpenBSD systems, and if there are any issues please let me know.
<br/><br/>
<b>Expiring SPA keys</b>:  With large SPA deployments where many different encryption
keys - either Rijndael or GPG keys - are used to service lots of external users, key
management can become somewhat of a burden.  This feature allows an expiration date
to be set in the <b>access.conf</b> file on a per-key basis.  Any SPA packet received
for an expired key is ignored by fwknopd.  This feature was suggested by ozmart from
the fwknop mailing list.
<br/><br/>
<b>FORCE_NAT mode</b>:  For iptables firewalls, a new FORCE_NAT mode has been
implemented that works as follows: for any valid SPA packet, force the requested
connection to be NAT'd through to the specified (usually internal) IP and port value.
This is useful if there are multiple internal systems running a service such as
SSHD, and you want to give transparent access to only one internal system
for each stanza in the access.conf file.  This way, multiple external
users can each directly access only one internal system per SPA key.
<br/><br/>
<b>lsof launcher</b>: The fwknop lsof launcher (extras/fwknop-launcher/fwknop-launcher-lsof.pl)
is a lightweight daemon that allows the user to not have to manually run the fwknop
client when attempting to gain access to a service that is protected by
via fwknopd.  This is accomplished by checking the output
of lsof to look for pending connections in the SYN_SENT state, which (usually)
indicate that a remote firewall is blocking the attempted connection.  At this
point, the launcher executes the fwknop client with the --get-key arg (so the
user must place the key in the local filesystem) to generate an SPA packet for
the attempted connection.  The remote fwknopd daemon will reconfigure the
firewall to allow temporary access, and this usually happens fast enough that
the original connection attempt will then succeed as TCP retries to establish
the connection.  The idea for this was originally for a pcap-based connection
watcher by Sebastien Jeanquier.
<br/><br/>
Several other changes and small fixes have been made as well.  The fwknop test
suite supports running all tests through the excellent
<a href="http://www.valgrind.org/">valgrind</a> project, and this enabled
several memory handling issues to be found and corrected.
<br/><br/>
fwknop is released under the GPL version 2, and the complete fwknop-2.0rc5
ChangeLog can be found
<a href="/cgi-bin/gitweb.cgi?p=fwknop.git;a=blob;f=ChangeLog-v2.0rc5;h=65f565b705c1a74ccd93deef24d68e738eb288d4;hb=7ac5319847b6cf75dc5d5cdb4cdd41b55ee711b3">here</a>
via the fwknop <a href="/cgi-bin/gitweb.cgi?p=fwknop.git;a=summary">gitweb</a> interface.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/10/webknock.org-single-packet-authorization-proxy.html</link>
<title>WebKnock.org Single Packet Authorization Proxy</title>
<dc:date>2011-10-10T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

Vasilis Mavroudis has developed a web proxy called <a href="https://webknock.org/">WebKnock.org</a>
that allows anyone to generate an fwknop SPA packet on their behalf with just a web browser.
Although fwknop client portability has improved quite a bit in anticipation of the upcoming
fwknop-2.0 release, it is a nice addition to the SPA world to not need the fwknop client
installed at all.  There are probably several platforms where the native client might not
function but can run a web browser.
<br/><br/>
Using the webknock.org proxy requires that the user provide the SPA key over SSL to
webknock.org, but this is a necessary step in exchange for not having to install the fwknop
client.  As of this writing, SPA via <a href="/fwknop/docs/gpghowto.html">gpg keys</a> is
not yet supported, but there are plans to support this in the future.  All requests to
generate an SPA packet are protected by a captcha.
<br/><br/>
Behind the scenes, webknock.org executes the fwknop client on behalf of users, and Vasilis
informed me that he's using the latest client code (written in C) instead of the older perl
client.  This is good since all recent development is done on the C version of fwknop in
order to make it as small and lightweight as possible.
<br/><br/>
The service is free, and will hopefully be open-sourced at some point as well.  If there are
any issues, please either <a href="/contact.html">email me</a> or open a ticket on the fwknop
<a href="https://github.com/mrash/fwknop/issues">github interface</a>.  Here is a
screenshot of the current webknock.org site:
<a href="/images/webknock_screenshot.png"><img src="/images/webknock_screenshot.png" height="320" width="500" title="webknock.org SPA proxy" alt="webknock.org SPA proxy" /></a>

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/08/fwknop-in-the-openwrt-and-pentoo-linux-distributions.html</link>
<title>fwknop in the OpenWrt and Pentoo Linux Distributions</title>
<dc:date>2011-08-23T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="https://openwrt.org/">
<img align="right" src="/images/openwrt-logo.png" height="51" width="200" title="fwknop in OpenWrt" alt="fwknop in OpenWrt" /></a>
The C version <a href="/fwknop">fwknop</a> has now made it into the <a href="https://openwrt.org">OpenWrt</a>
Linux distribution for embedded devices.  Jonathan Bennett made this possible
by contributing a <a href="http://www.cipherdyne.org/cgi-bin/gitweb.cgi?p=fwknop.git;a=commitdiff;h=e7d275ee312c618c3233a504c5aa54b72312f39a">Makefile</a>
for OpenWrt, and it was picked up the OpenWrt maintainers.  It is good to
see progress made towards the integration of
<a href="/fwknop/docs/SPA.html">Single Packet Authorization</a> into operating
systems that are designed to function as secure gateway devices between multiple
networks.
<br/><br/>
So far, fwknop is available in the OpenWrt trunk packages feed, but will eventually become
available via the opkg package manager too.  Fortunately, OpenWrt makes everything
available via git:
<br/><br/>
<code>
$ git clone git://nbd.name/packages.git openwrt_packages.git<br/>
Initialized empty Git repository in /home/mbr/src/openwrt_packages.git/.git/<br/>
remote: Counting objects: 56118, done.<br/>
remote: Compressing objects: 100% (21342/21342), done.<br/>
remote: Total 56118 (delta 29694), reused 54875 (delta 29054)<br/>
Receiving objects: 100% (56118/56118), 11.85 MiB | 2.57 MiB/s, done.<br/>
Resolving deltas: 100% (29694/29694), done.<br/>
$ cd openwrt_packages.git<br/>
$ git ls-files |grep fwknop<br/>
net/fwknop/Makefile<br/>
$ git log net/fwknop/Makefile<br/>
commit 89475e5d6136833fa3b59c3d47c4f2be02718c7a<br/>
Author: florian &lt;florian@3c298f89-4303-0410-b956-a3cf2f4a3e73&gt;<br/>
Date:   Wed Aug 17 10:13:20 2011 +0000<br/>
<br/>
    [package] add fwknopd<br/>
<br/>
    Signed-off-by; Jonathan Bennett &lt;[email removed]&gt;<br/>
<br/>
    git-svn-id: svn://svn.openwrt.org/openwrt/packages@28030 3c298f89-4303-0410-b956-a3cf2f4a3e73<br/>
<br/>
</code>
<br/><br/>

In other news, both the perl and C versions of fwknop are also available in the
<a href="http://www.pentoo.ch/"><img src="/images/pentoo-logo.png" align="left" height="100" width="100">Pentoo</img></a> Linux
distribution thanks to <a href="https://www.pentoo.ch/pentoo/search?q=fwknop">ozmart and the Pentoo maintainers</a>.
Pentoo is a live-cd distribution that is focused on security and derived from
<a href="http://www.gentoo.org">Gentoo</a>.  ozmart wrote a description of the
use case for fwknop on Pentoo from a pentration testing perspective:
<br/><br/>
<i>
"...This is a useful script when combined with iptables and sshd. Configuration can accommodate
pgp and replay attack checks. It allows the box to appear silent when running daemons
if your box is deployed in say, a hostile environment.
<br/><br/>
It can also allow commands to be run without actually having to log into the box, say if
you wanted to trigger something interesting from a remote location..."
</i>

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/07/software-release-fwsnort-1.6.html</link>
<title>Software Release - fwsnort-1.6</title>
<dc:date>2011-07-28T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="/fwsnort/download/">
<img align="right" src="/images/release.png" title="fwsnort-1.6" alt="fwsnort-1.6 released" /></a>
The 1.6 release of <a  href="/fwsnort"><b>fwsnort</b></a> is available for
<a  href="/fwsnort/download/"><b>download</b></a>.  This is a fairly significant
release that adds support for the Snort <b>fast_pattern</b> keyword, makes enhancements to
the --QUEUE and --NFQUEUE modes, supports the conntrack module for connection tracking,
adds support for case-insensitive pattern matches using the --icase argument to the iptables
string match extension, and several other things.  The Snort fast_pattern keyword allows the
rule author to influence the order in which Snort tries
to match a pattern against network traffic.  When multiple patterns are included in a rule,
Snort usually tries to match the longest pattern first reasoning that the longest pattern
is probably the least likely to trigger a match and therefore the remaining pattern searches
would not have to be performed.  But, there are times when the rule author would like to
explicitly ask Snort to match on a particular pattern first, and the fast_pattern keyword
is the mechanism that makes this possible.  Because iptables matches are evaluated in order
and a failing match short circuits a rule, fast_pattern support with the string match
extension is possible through proper ordering in the iptables rule.  Here is an example
Snort rule from <a href="http://www.emergingthreats.net">Emerging Threats</a> with the
fast_pattern keyword applied to the forth pattern:

<br/><br/>
<code>
alert tcp $EXTERNAL_NET $HTTP_PORTS -&gt; $HOME_NET any (msg:"ET WEB_CLIENT Possible Internet Explorer srcElement Memory Corruption Attempt"; flow:established,to_client; file_data; content:"document.createEventObject"; distance:0; nocase; content:".innerHTML"; within:100; nocase; content:"window.setInterval"; distance:0; nocase; content:"srcElement"; fast_pattern; nocase; distance:0; classtype:attempted-user; reference:url,www.microsoft.com/technet/security/bulletin/ms10-002.mspx; reference:url,tools.cisco.com/security/center/viewAlert.x?alertId=19726; reference:url,www.kb.cert.org/vuls/id/492515; reference:cve,2010-0249; reference:url,doc.emergingthreats.net/2010799; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/CURRENT_EVENTS/CURRENT_MSIE; sid:2010799; rev:5;)
</code>
<br/><br/>

fwsnort translates this rule as follows in iptables-save format from the <b>/etc/fwsnort/fwsnort.save</b>
file - the original iptables commands in non-save format are also available in the
<b>/etc/fwsnort/fwsnort_iptcmd.sh</b> script:

<br/><br/>
<code>
-A FWSNORT_FORWARD_ESTAB -p tcp -m tcp --sport 80 -m string --string "srcElement" --algo bm --from 82 --icase -m string --string "document.createEventObject" --algo bm --from 64 --icase -m string --string ".innerHTML" --algo bm --to 190 --icase -m string --string "window.setInterval" --algo bm --from 74 --icase -m comment --comment "sid:2010799; msg:ET WEB_CLIENT Possible Internet Explorer srcElement Memory Corruption Attempt; classtype:attempted-user; reference:url,www.microsoft.com/technet/security/bulletin/ms10-002.mspx; rev:5; FWS:1.6;" -j LOG --log-ip-options --log-tcp-options --log-prefix "SID2010799 ESTAB "
</code>
<br/><br/>

Note that the <b>srcElement</b> string is matched first in the iptables rule even though
it is the last string in the original Snort rule.

With fast_pattern support, fwsnort policies should be a bit faster at run time in the
in the Linux kernel.

On a final note, the iptables <b>multiport</b> match is also supported with the fwsnort-1.6
release, so Snort rules with lists of source or destination ports (like this:
"alert tcp $HOME_NET [0:20,22:24,26:138,140:444,446:464,466:586,588:901,903:1432,1434:65535] -&gt; any any")
can be translated.
<br/><br/>
The complete fwsnort-1.6 ChangeLog can be found
<a href="/cgi-bin/gitweb.cgi?p=fwsnort.git;a=blob;f=ChangeLog-v1.6;h=345f18c259c655bb2946f55bb676ca699e90e5c5;hb=fwsnort-1.6">here</a>
via the fwsnort <a href="/cgi-bin/gitweb.cgi?p=fwsnort.git;a=summary">gitweb</a> interface.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/06/switched-from-subversion-to-git.html</link>
<title>Switched from subversion to git</title>
<dc:date>2011-06-26T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="http://www.git-scm.com/">
<img align="right" src="/images/git-logo.png" title="switched to git" alt="switched to git" /></a>
After using <a href="http://subversion.tigris.org/">subversion</a> for several years, I've switched
to <a href="http://www.git-scm.com/">git</a> for all cipherdyne.org projects.  Subversion has
certainly served its purpose, but it is hard to look at git and not feel a compelling draw.  Further,
with easy to set up web interfaces to git repositories such as
<a href="https://git.wiki.kernel.org/index.php/Gitweb">gitweb</a> and free hosting services such
as <a href="http://github.com/">github</a>, providing a public git repository is trivial.  Git itself
can allow repositories to be cloned directly over HTTP without needing infrastructure like WebDAV,
and here are links for the cipherdyne.org projects (github and gitweb links too):
<br/><br/>
<ul>
<li><a href="/git/fwknop.git">fwknop</a> (<a href="/cgi-bin/gitweb.cgi?p=fwknop.git;a=summary">gitweb</a>, <a href="http://github.com/mrash/fwknop">github</a>)</li>
<li><a href="/git/fwsnort.git">fwsnort</a> (<a href="/cgi-bin/gitweb.cgi?p=fwsnort.git;a=summary">gitweb</a>, <a href="http://github.com/mrash/fwsnort">github</a>)</li>
<li><a href="/git/psad.git">psad</a> (<a href="/cgi-bin/gitweb.cgi?p=psad.git;a=summary">gitweb</a>, <a href="http://github.com/mrash/psad">github</a>)</li>
<li><a href="/git/gpgdir.git">gpgdir</a> (<a href="/cgi-bin/gitweb.cgi?p=gpgdir.git;a=summary">gitweb</a>, <a href="http://github.com/mrash/gpgdir">github</a>)</li>
</ul>

The <a href="http://trac.cipherdyne.org/trac/">trac</a> interface will remain active for a little
while to see the legacy svn repositories, but the git repositories were all converted from these in
order to preserve the history so trac is no longer important.  If you are interested in the latest
code changes in, say, fwsnort then just clone the repository and then you can make your own changes:

<br/><br/>
<code>
$ git clone http://www.cipherdyne.org/git/fwsnort.git<br/>
Initialized empty Git repository in /home/mbr/tmp/git/fwsnort/.git/<br/>
$ cd fwsnort<br/>
$ git status<br/>
# On branch master<br/>
nothing to commit (working directory clean)<br/>
$ git show --summary<br/>
commit 00c4379a69975097948ed9e5ba356eeba69c0c93<br/>
Author: Michael Rash &lt;mbr@cipherdyne.org&gt;<br/>
Date:   Mon Jun 20 21:00:57 2011 -0400<br/>
<br/>
    Added the --Conntrack-state argument<br/>
<br/>
    Added the --Conntrack-state argument to specify a conntrack state in place of<br/>
    the "established" state that commonly accompanies the Snort "flow" keyword.<br/>
    By default, fwsnort uses the conntrack state of "ESTABLISHED" for this.  In<br/>
    certain corner cases, it might be useful to use "ESTABLISHED,RELATED" instead<br/>
    to apply application layer inspection to things like ICMP port unreachable<br/>
    messages that are responses to real attempted communications.  (Need to add<br/>
    UDP tracking for the _ESTAB chains for this too - coming soon.)<br/>
</code>
<br/><br/>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/06/fwknop-in-backtrack-5.html</link>
<title>fwknop in BackTrack 5</title>
<dc:date>2011-06-23T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
fwknop has made it into <a href="http://www.backtrack-linux.org/">BackTrack</a>
Linux distribution.  Well, it didn't make it into the default image, but it is in
the BackTrack software repository so installing it is a snap with <b>apt-get</b>
or <b>aptitude</b>.  Below is a screenshot of the BackTrack 5 VM installed under
VMware Player running on Ubuntu, and running a search shows both the
<b>fwknop-client</b> and <b>fwknop-server</b> packages that are maintained by
<a href="http://packages.qa.debian.org/f/fwknop.html">Franck Joncourt</a> for
the Debian distribution.

<a href="/images/bt_fwknop_in_repos.png">
<img src="/images/bt_fwknop_in_repos.png" width="600" height="450" title="fwknop in BackTrack 5" alt="fwknop in BackTrack 5" />
</a>
<br/>
Update 06/24/2011: Thanks to <a href="http://www.securitygeneration.com">Sebastien Jeanquier</a>
for calling this to my attention and helping to support the inclusion of fwknop in BackTrack Linux.
<br/><br/>

]]></description>
</item>

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

<a href="/fwsnort/download/">
<img align="right" src="/images/release.png" title="fwsnort-1.5" alt="fwsnort-1.5 released" /></a>
The 1.5 release of <a  href="/fwsnort"><b>fwsnort</b></a> is available for
<a  href="/fwsnort/download/"><b>download</b></a>.  This is a major release
that moves to using the iptables-save format for instantiating the fwsnort policy, and
this allows the run time for adding the fwsnort policy to the kernel to be drastically reduced.
fwsnort now splices in the translated Snort rules into the iptables policy in the running
kernel <i>at the time of translation</i>.  So, any updates to the iptables
policy that are made after fwsnort is executed and before <b>fwsnort.sh</b> is run would be lost.
Hence, it is advisable to execute fwsnort.sh soon after running fwsnort.
This is a reasonable tradeoff though considering the performance benefit as seen
below - which gives an example of how long it takes to add an fwsnort iptables policy
via the old strategy of executing one iptables command at a time vs. implementing the
same policy with iptables-restore.  First, fwsnort is used to translate the Snort
<b>web-misc.rules</b>, <b>web-cgi.rules</b>, <b>backdoor.rules</b> files like so:
<br/><br/>
<code>
[root@minastirith /etc/fwsnort]# fwsnort --snort-rfile web-misc.rules,web-cgi.rules,backdoor.rules --no-ipt-sync<br/>
<br/>
[+] Generated iptables rules for 713 out of 754 signatures: 94.56%<br/>
<br/>
[+] Logfile: /var/log/fwsnort/fwsnort.log<br/>
[+] iptables script (individual commands): /etc/fwsnort/fwsnort_iptcmds.sh<br/>
<br/>
    Main fwsnort iptables-save file: /etc/fwsnort/fwsnort.save<br/>
<br/>
    You can instantiate the fwsnort policy with the following command:<br/>
<br/>
    /sbin/iptables-restore &lt; /etc/fwsnort/fwsnort.save<br/>
<br/>
    Or just execute: /etc/fwsnort/fwsnort.sh<br/>
</code>
<br/><br/>

The output above illustrates the changes for the fwsnort-1.5 release.  All of the previous
behavior in fwsnort has been preserved in the <b>/etc/fwsnort/fwsnort_iptcmds.sh</b>
script.  That is, each individual iptables command to add every fwsnort rule one by
one is implemented in this script - this is analogous to how the <b>fwsnort.sh</b> script was
built by older versions of fwsnort.  But, with the 1.5 release the <b>fwsnort.sh</b> script
now just executes the iptables-restore command against the new <b>fwsnort.save</b> file.
<br/><br/>
If we execute the <b>fwsnort_iptcmds.sh</b> script and time its execution, we get the
following on my desktop system:
<br/><br/>
<code>
[root@minastirith /etc/fwsnort]# time /etc/fwsnort/fwsnort_iptcmds.sh<br/>
[+] Adding backdoor rules:<br/>
    Rules added: 122<br/>
[+] Adding web-cgi rules:<br/>
    Rules added: 696<br/>
[+] Adding web-misc rules:<br/>
    Rules added: 600<br/>
[+] Finished.<br/>
<br/>
real    0m24.391s<br/>
user    0m1.560s<br/>
sys     0m11.500s<br/>
[root@minastirith /etc/fwsnort]# iptables -v -nL |wc -l<br/>
1509
</code>
<br/><br/>

So, the fwsnort policy together with the running iptables policy is about 1500
rules long, and it took over 24 seconds to add to the running kernel.  Now, let's
time the <b>fwsnort.sh</b> script instead (which is just a
wrapper around the iptables-restore command):

<br/><br/>
<code>
[root@minastirith /etc/fwsnort]# time /etc/fwsnort/fwsnort.sh<br/>
<br/>
[+] Splicing fwsnort rules into the iptables policy...<br/>
    Done.<br/>
<br/>
<br/>
real    0m0.121s<br/>
user    0m0.060s<br/>
sys     0m0.040s<br/>
[root@minastirith /etc/fwsnort]# iptables -v -nL |wc -l<br/>
1509
</code>
<br/><br/>

Ok, over 24 seconds to instantiate the fwsnort policy for the old strategy, and about
a 10th of a second for the new strategy for a speed up of 240 times!  This gets even
better for an fwsnort policy with thousands of rules.  Note that the number of iptables
rules is the same between the two executions.
<br/><br/>

The complete
<a href="http://trac.cipherdyne.org/trac/fwsnort/browser/fwsnort/tags/fwsnort-1.5/ChangeLog">
ChangeLog</a> entries are displayed below:
<br/><br/>
<ul>
<li>Major update to use the iptables-save format instead of the older
strategy of always just executing iptables commands directly (which was
very flow for large fwsnort policies).  The /etc/fwsnort/fwsnort.sh
script now just executes:<br/>
<br/>
/sbin/iptables-restore &lt; /etc/fwsnort/fwsnort.save<br/>
<br/>
All fwsnort rules are now placed in the /etc/fwsnort/fwsnort.save file,
but the older fwsnort.sh output (for the individual commands version)
is still available at /etc/fwsnort/fwsnort_iptcmds.sh.  This
functionality extends to ip6tables policies as well.  The fwsnort man
page explain this in better detail:<br/>
<br/>
"As of fwsnort-1.5 all iptables rules built by fwsnort are written out
to the /etc/fwsnort/fwsnort.save file in iptables-save format.  This
allows a long fwsnort policy (which may contain thousands of iptables
rules translated from a large Snort signature set) to be quickly
instantiated via the "iptables-restore" command.  A wrapper script
/etc/fwsnort/fwsnort.sh is also written out to make this easy.  Hence,
the typical work flow for fwsnort is to: 1) run fwsnort, 2) note the
Snort rules that fwsnort was able to successfully translate (the number
of such rules is printed to stdout), and then 3) execute the
/etc/fwsnort/fwsnort.sh wrapper script to instantiate the policy in the
running kernel."</li>
<li>Added the --rules-url argument so that the URL for updating the
Emerging Threats rule set can be specified from the command line.  The
default is:
<br/><br/>
http://rules.emergingthreats.net/open/snort-2.9.0/emerging-all.rules
</li>
<li>Updated to automatically check for the maximum length string that the
string match supports, and this is used to through out any Snort rules
with content matches longer than this length.</li>
<li>Updated the iptables capabilities testing routines to add and delete
testing rules to/from the custom chain 'FWS_CAP_TEST'.  This maintains a
a cleaner separation between fwsnort and any existing iptables policy
even during the capabilities testing phase.</li>
<li>Added the --ipt-check-capabilities argument to have fwsnort test the
capabilities of the local iptables firewall and exit.</li>
<li>Added the --string-match-alg argument to allow the string matching
algorithm used by fwsnort to be specified from the command line.  The
default algorithm is 'bm' for 'Boyer-Moore', but 'kmp' may also be
specified (short for the 'Knuth-Morris-Pratt' algorithm).</li>
<li>Updated to the latest complete rule set from Emerging Threats (see
http://www.emergingthreats.net/).
</li>
</ul>


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2011/01/single-packet-authorization-on-android.html</link>
<title>Single Packet Authorization on Android</title>
<dc:date>2011-01-07T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<img align="right" src="/images/android-logo.jpg" width="140" height="150" title="fwknop on Android" alt="fwknop on Android" />
Kicking off 2011 with a bang is easy this year - Max Kastanas has ported the <a href="/fwknop">fwknop</a>
client to the <a href="http://www.android.com">Android</a> mobile operating sytem.  This brings Single
Packet Authorization to Google's smart phones, and was accomplished using Damien Stuart's
<a href="http://trac.cipherdyne.org/trac/fwknop/browser/trunk/lib">libfko</a> implementation.
All of the Android code can be found in the Cipherdyne
<a href="http://trac.cipherdyne.org/trac/fwknop/browser/trunk/android">Trac respository</a>.
A couple of screenshots of using the SPA app from an Android phone appear below - after the
SPA packet is sent and verified passively by the fwknop daemon on the remote system, the
fwknop Android app automatically launches <a href="http://code.google.com/p/connectbot/">Connectbot</a>
to access SSHD:
<br/><br/>
<img align="right" src="/images/android_fwknop.png" width="245" height="400" title="fwknop Android app" alt="fwknop Android app" />
<img class="rightfr" src="/images/android_connectbot.png" width="245" height="400" title="fwknop Android app" alt="fwknop Android app" />


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2010/08/how-to-avoid-clamav-matches-on-bundled-snort-rules.html</link>
<title>How to avoid ClamAV matches on bundled Snort rules</title>
<dc:date>2010-08-22T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<img align="right" src="/images/clamav.png" title="ClamAV matches on Snort rules" alt="ClamAV matches on Snort rules" />
Recently a <a href="/psad">psad</a> user notified me via email that the psad-2.1.7.tar.gz tarball
was flagged by <a href="http://www.clamav.net">ClamAV</a> as being infected with <b>Exploit.HTML.MHTRedir-8</b>.
After checking a few things, it turns out that ClamAV is triggering on a Snort rule in the
<a href="http://www.emergingthreats.net/">Emerging Threats</a> rule set which is bundled in both
<a href="/psad">psad</a> and <a href="/fwsnort">fwsnort</a>.  The following analysis shows
exactly what ClamAV is detecting and why, and also provides some guidance for how to avoid
this for any software projects that distribute Snort rules.  Similar logic would apply to
other software engineering efforts - including commercial intrusion detection systems - that
are (by their nature) looking for malicious artifacts on the filesystem or within network
traffic.
<br/><br/>
First, let's download psad-2.1.7.tar.gz and check the gpg signature (just to make sure we're
talking about exactly the same file):
<br/><br/>
<code>
$ wget --quiet http://www.cipherdyne.org/psad/download/psad-2.1.7.tar.gz<br/>
$ wget --quiet http://www.cipherdyne.org/psad/download/psad-2.1.7.tar.gz.asc<br/>
$ gpg --verify psad-2.1.7.tar.gz.asc<br/>
gpg: Signature made Wed 14 Jul 2010 06:01:42 PM EDT using DSA key ID 0D3E7410<br/>
gpg: Good signature from "Michael Rash (Signing key for cipherdyne.org projects) &lt;mbr@cipherdyne.org&gt;"
</code>
<br/><br/>
Ok, now here is what <b>clamscan</b> says about the psad-2.1.7.tar.gz tarball:
<br/><br/>
<code>
$ clamscan psad-2.1.7.tar.gz<br/>
psad-2.1.7.tar.gz: Exploit.HTML.MHTRedir-8 FOUND<br/>
<br/>
----------- SCAN SUMMARY -----------<br/>
Known viruses: 816934<br/>
Engine version: 0.96.1<br/>
Scanned directories: 0<br/>
Scanned files: 1<br/>
Infected files: 1<br/>
Data scanned: 6.42 MB<br/>
Data read: 1.16 MB (ratio 5.55:1)<br/>
Time: 7.169 sec (0 m 7 s)
</code>
<br/><br/>
Let's see which file within the psad-2.1.7 tarball matches the <b>Exploit.HTML.MHTRedir-8</b>
signature:
<br/><br/>
<code>
$ tar xfz psad-2.1.7.tar.gz<br/>
$ clamscan -r -i psad-2.1.7<br/>
psad-2.1.7/deps/snort_rules/emerging-all.rules: Exploit.HTML.MHTRedir-8 FOUND<br/>
<br/>
----------- SCAN SUMMARY -----------<br/>
Known viruses: 816934<br/>
Engine version: 0.96.1<br/>
Scanned directories: 41<br/>
Scanned files: 405<br/>
Infected files: 1<br/>
Data scanned: 12.55 MB<br/>
Data read: 6.41 MB (ratio 1.96:1)<br/>
Time: 8.446 sec (0 m 8 s)
</code>
<br/><br/>
Intuitively, this makes sense.  That is, given that ClamAV is out to identify nasty things
within files, and given that Snort rules are designed to identify nasty things as they
communicate over the network, it stands to reason that there might be some overlap.  This
overlap is <i>not</i> an indication of something wrong in either the Snort rules or in ClamAV.
Now, let's find out specifically which Snort rule within the <b>emerging-all.rules</b>
file is triggering the ClamAV match.  We first take a look at the <b>Exploit.HTML.MHTRedir-8</b>
signature:
<br/><br/>
<code>
$ cp /var/lib/clamav/main.cvd .<br/>
$ sigtool --unpack main.cvd<br/>
$ grep Exploit.HTML.MHTRedir-8 main.ndb<br/>
Exploit.HTML.MHTRedir-8:3:*:6d68746d6c3a66696c653a2f2f{1-20}2168
</code>
<br/><br/>
The last line above is the entire ClamAV signature, and the pattern <b>6d68746d6c3a66696c653a2f2f</b>
is the key.  The ":3:" part identifies the signature as type "normalized HTML", so ClamAV
matches the pattern <b>6d68746d6c3a66696c653a2f2f</b> against the "normalized HTML" representation
of each processed file.  We can decode the pattern as follows:
<br/><br/>
<code>
echo 6d68746d6c3a66696c653a2f2f | xxd -r -p<br/>
mhtml:file://
</code>
<br/><br/>
So, within the <b>emerging-all.rules</b> file, we are interested in any Snort rule that
contains the string <b>mhtml:file://</b>.  There is also the "<b>{1-20}2168</b>" criteria
which says to match the hex bytes 2168 anywhere from 1 to 20 bytes after the first
pattern match.
<br/><br/>
<code>
$ grep mhtml psad-2.1.7/deps/snort_rules/emerging-all.rules<br/>
alert tcp $HOME_NET any -&gt; $EXTERNAL_NET $HTTP_PORTS (msg:"ET MALWARE Bundleware Spyware CHM Download"; flow: to_server,established; content:"Referer\: ms-its\:mhtml\:file\://C\:counter.mht!http\://"; nocase; content:"/counter/HELP3.CHM\:\:/help.htm"; nocase; classtype: trojan-activity; sid: 2001452; rev:4;)<br/>
</code>
<br/><br/>
Sure enough, sid:2001452 "<b>ET MALWARE Bundleware Spyware CHM Download</b>" has the
keyword <b>content:"Referer\: ms-its\:mhtml\:file\://C\:counter.mht!http\://"</b>.  Even
though there are escaping backslashes, the normalized HTML processing in ClamAV takes
this into account and matches the pattern anyway from the ClamAV signature.
<br/><br/>
So, how can we keep the original Snort rule, but change it so that ClamAV not longer
flags it?
<br/><br/>
Fortunately, ClamAV does not interpret the Snort rules convention of specifying non-printable
bytes between "|" characters within content fields, so we simply need to change one of
characters to hex notation.  Snort will still offer the same detection if network traffic
matches the rule, and ClamAV won't flag it.  So, let's just change the "m" in "<b>mhtml\:file\://</b>"
to its hex equivalent, like so: "<b>|6d|html\:file\://</b>".  Once we make this change and save the
psad-2.1.7/deps/snort_rules/emerging-all.rules file, we rerun clamscan:
<br/><br/>
<code>
$ clamscan -r -i psad-2.1.7<br/>
<br/>
----------- SCAN SUMMARY -----------<br/>
Known viruses: 816934<br/>
Engine version: 0.96.1<br/>
Scanned directories: 41<br/>
Scanned files: 405<br/>
Infected files: 0<br/>
Data scanned: 17.23 MB<br/>
Data read: 6.41 MB (ratio 2.69:1)<br/>
Time: 10.024 sec (0 m 10 s)
</code>
<br/><br/>
That's better.  Over the next few days I'll re-release all affected versions of psad and
fwsnort with the above change to ensure that there aren't any additional ClamAV matches.
<br/><br/>
In conclusion, if you are involved in any software engineering effort that distributes
or makes use of Snort rules, it is probably a good idea to run distribution packages
through ClamAV and see if there are any matches.  If so, it may be possible to take
advantage of Snort rule syntax options to still achieve the same signature coverage while
not having ClamAV flag anything.


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2010/08/a-new-ssh-password-guessing-botnet-dd_ssh.html</link>
<title>A new SSH password guessing botnet: dd_ssh</title>
<dc:date>2010-08-20T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<img align="right" src="/images/malware.jpg" height="165" width="220" title="dd_ssh botnet" alt="dd_ssh botnet" />
Every few months it seems that there is a new variation of a password guessing botnet.
This time around, as reported by the <a href="http://isc.sans.edu/diary.html?storyid=9370">SANS ISC</a>
and also by <a href="http://www.malwarecity.com/community/index.php?showtopic=1177">malwarecity.com</a>,
a botnet called "<b>dd_ssh</b>" has been built up around a vulnerability in phpMyAdmin.
(Here is the <a href="http://lists.debian.org/debian-security-announce/2010/msg00074.html">vulnerability announcement</a>
from the Debian security list.)  Once a vulnerable webserver has been compromised, the
botnet starts scanning random IP addresses for SSH servers and attempts to brute force
passwords for those systems that accept an SSH connection.  Although software like
<b>Fail2ban</b> and <b>DenyHosts</b> can offer detection and mitigation by applying thresholds to
the number of failed login attempts in the SSH log and communicate offending source IP's
to a set of interested users, a fundamental problem is that the targeted SSH daemons
are reachable in the first place from arbitrary source IP's.  A more powerful
solution is to hide your SSH daemon behind a default-drop firewall policy and only
grant access through <a href="/fwknop">Single Packet Authorization</a>.
Any botnet that is scanning for SSH servers will not be able to guess any
passwords or even exploit a zero-day vulnerability in an SSH daemon that is protected
in this way.
<br/><br/>
Further, SSH brute forcing botnets have shown some
<a href="http://bsdly.blogspot.com/2008/12/low-intensity-distributed-bruteforce.html">innovative techniques</a>
where password guessing attempts are spread out over a long period of time and failed
passwords are distributed across the botnet.  The end result is that each botnet
node knows the population of passwords that other nodes have already tried on
each targeted SSH daemon, and so new passwords can be tried while still slipping
beneath common detection thresholds.  The same password never has to be tried twice
botnet-wide.  It is not clear yet whether the dd_ssh botnet uses a similar password
distribution strategy, but either way I intend to stop such guessing games at the
earliest stage possible and block all SSH connections by default.

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2010/08/http-response-times-for-cipherdyne.org.html</link>
<title>HTTP Response Times for cipherdyne.org</title>
<dc:date>2010-08-15T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="http://oss.oetiker.ch/smokeping/index.en.html">
<img align="right" src="/images/smokeping.png" title="smokeping" alt="smokeping" /></a>
I'm a big fan of the <a href="http://oss.oetiker.ch/smokeping/index.en.html">Smokeping</a>
project developed by Tobi Oetiker, and I use it to graph ICMP, DNS, and HTTP round trip
times for my local internet connections and also for cipherdyne.org.  Since the beginning
of 2010, I've switched around where cipherdyne.org was hosted from a system at a hosting
provider in Canada to a system running on my home network (serviced by a Verizon FiOS
connection).  The drop in RTT's in mid-February was expected and quite large - going
from an average of around 200ms down to about 20ms.  Then, in June, I switched to a
different Verizon DSL connection and moved the cipherdyne.org webserver system to a
newer Verizon FiOS connection at a different location, and the RTT's went up a bit to
about 50ms.  Here is the graph:

<img src="/images/cipherdyne_400_days.png" title="cipherdyne.org 400 days" alt="cipherdyne.org 400 days" />


]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2010/08/fwsnort-available-in-fedora-repositories.html</link>
<title>fwsnort Available in Fedora Repositories</title>
<dc:date>2010-08-13T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[

<a href="http://fedoraproject.org/">
<img align="right" src="/images/fedora_logo.png" title="fwsnort on Fedora" alt="fwsnort on Fedora" /></a>
The <a href="/fwsnort/">fwsnort</a> project is now available directly through the
<a href="https://admin.fedoraproject.org/pkgdb/acls/name/fwsnort?_csrf_token=a9cbb9cbe99f8d2953b015db95f4f30a2bfd7395">Fedora RPM repositories</a>
(for Fedora 12 and 13) thanks to
<a href="http://koji.fedoraproject.org/koji/userinfo?userID=1466">Guillermo Gomez</a>.
The version that is currently bundled is fwsnort-1.0.6.  Once fwsnort-1.2 is
released, the implementation of large iptables rule sets that are derived from
Snort rules will become a lot faster.  This is because fwsnort is going to
support the <b>iptables-save</b> format by integrating the complex rules built by
fwsnort with any existing iptables policy that is instantiated in the kernel.
This is made possible by interpreting the local policy and splicing in all
of the fwsnort rules in the right places - each iptables chain is built from
scratch upon an <b>iptables-restore</b> (including the built-in chains), so
integrating with a running policy is not as easy as just adding each fwsnort
rule into a set of custom chains.  Compatibility with the iptables-save format
has largely been completed with <a href="http://trac.cipherdyne.org/trac/fwsnort/changeset/528">this patch</a>
in the fwsnort-1.2 development effort.
<br/><br/>
If you are running a Fedora 12 or 13 system, you can install fwsnort like so:
<br/><br/>
<code>
# yum install fwsnort
</code>
<br/><br/>

]]></description>
</item>

<item>
<link>http://www.cipherdyne.org/blog/2010/07/pure-c-implementation-of-single-packet-authorization.html</link>
<title>Pure C Implementation of Single Packet Authorization</title>
<dc:date>2010-07-25T21:01:30-05:00</dc:date>
<dc:creator>Michael Rash</dc:creator>
<description><![CDATA[
<a href="/fwknop/">
<img align="right" src="/images/chinesedoor5.jpg" width="180" height="120" title="Pure C Implementation of Single Packet Authorization" alt="Pure C Implementation of Single Packet Authorization" /></a>
For the past several months, the pure-C implementation of Single Packet Authorization
with fwknop has been in development, and the first release candidate of
<a href="/fwknop/download/">fwknop-2.0.0</a> is ready for <a href="/fwknop/download/">download</a>.
Damien Stuart is the primary developer of this code, and I wish to thank him for
all of his efforts in making this release possible.  The original perl version of
fwknop will continue to receive bug fixes as they are found, but the primary
development effort is now on the lightweight and portable C code.  The Trac
interface for the perl code has moved to
<a href="http://trac.cipherdyne.org/trac/fwknop-perl">fwknop-perl</a>.  Any release
that is at fwknop-2.0.0 or above will be the C implementation, and any release in
the 1.9 series or before are in perl (and will remain available
<a href="/fwknop/download/">here</a>).  The perl and C versions are compatible with
each other, so SPA packets created by the fwknop perl client can be properly
decrypted and decoded by the new fwknopd C server, and similarly SPA packets
built with the fwknop C client can be interpreted by the fwknopd perl server.
<br/><br/>
The heart of the new C code is the
<a href="http://trac.cipherdyne.org/trac/fwknop/browser/trunk/lib">libfko library</a>,
which is used by both the fwknop client and the fwknopd server for SPA packet
encryption/decryption and interpretation.  The libfko library is portable to
several platforms including Linux and Windows, and the standard
<a href="http://www.gnu.org/software/autoconf/">GNU autoconf</a>
project is used for building fwknop from sources.
<br/><br/>
Given the compact nature of the C code, the fwknop-2.0.0rc1 release candidate
is already known to function on <a href="http://openwrt.org/">OpenWRT</a>, and
Damien Stuart (the primary developer of the fwknop C code) has built packages
for the OpenWRT Kamikaze and Backfire releases.  This brings SPA functionality
to embedded systems, and has been tested on a Linksys WRT54GS V2.0 router.  The
OpenWRT packages are available <a href="/fwknop/download/">here</a>.
<br/><br/>
There will be a few release candidates of <b>fwknop-2.0.0</b> to ensure proper
operation on a variety of platforms, and the emphasis will be on stability and
ironing out any bugs.  Also, fwknop-2.0.0 will initially support iptables
firewalls on the servers side, with <b>ipfw</b> support coming soon after.  There
is one nice feature in fwknop-2.0.0rc1 that deserves a mention - the fwknop client
now supports the notion of a <b>~/.fwknoprc</b> file that allows a set of
stanzas to be defined for remote SPA servers and customize the command line
arguments used to access each one.  Here is an example stanza:

<br/><br/>
<code>
# Example for a destination server of 192.168.1.20 to open access to<br/>
# SSH for an IP that is resolved externally<br/>
#<br/>
[myssh]<br/>
SPA_SERVER          192.168.1.20<br/>
ACCESS              tcp/22<br/>
ALLOW_IP            resolve<br/>
SPA_SERVER_PORT     50023<br/>
</code>
<br/><br/>

Now, with the fwknop client, we reference this stanza with the <b>-n</b> command
line argument like so:

<br/><br/>
<code>
$ fwknop -n myssh -vvv<br/>
Resolved external IP (via http://www.cipherdyne.org/cgi-bin/myip) as: 123.1.2.3<br/>
Enter encryption password:<br/>
<br/>
FKO Field Values:<br/>
=================<br/>
<br/>
   Random Value: 8308719569638051<br/>
       Username: mbr<br/>
      Timestamp: 1280030806<br/>
    FKO Version: 1.9.12<br/>
   Message Type: 1<br/>
 Message String: 123.1.2.3,tcp/22<br/>
     Nat Access: &lt;NULL&gt;<br/>
    Server Auth: &lt;NULL&gt;<br/>
 Client Timeout: 0<br/>
    Digest Type: 3<br/>
<br/>
   Encoded Data: 8308719569638051:bWJy:1280030806:1.9.12:1:OTYuMjQ0LjE3MS4yNTMsdGNwLzIy<br/>
<br/>
SPA Data Digest: WcUEVesZDIY+CKRKYTck8zMW7HG0S7RcqmXVIMC4L58<br/>
<br/>
Final Packed/Encrypted/Encoded Data:<br/>
<br/>
87wQ3s171if9x8628P6k1oBrQEJEmS5c/+ECed5cfDmu8hGhC5esUCEVcI8IH5TdjWva44efebX+cfXUVPBU9c/6tJpOLwC8k/8sN87SgYkBK+m64aD4FnnndaeqsrIcO/oHcpXHk9S/8rqqypcumNtlXVZD/isS3Q729LMTa+2uI6TsGX9OQ3<br/>
<br/>
Generating SPA packet:<br/>
    protocol: udp<br/>
    port: 50023<br/>
send_spa_packet: bytes sent: 182
</code>
<br/><br/>

On the fwknopd server side, we see the following printed to the terminal in
<b>--foreground</b> mode as the SPA packet is received and an iptables ACCEPT
rule is added for SSH access and then removed after 30 seconds.

<br/><br/>
<code>
Using Digest Cache: '/usr/var/run/fwknop/digest.cache' (entry count = 93)<br/>
PCAP filter is: udp port 50023<br/>
Starting fwknopd main event loop.<br/>
<br/>
<br/>
SPA Packet from IP: 123.1.2.3 received.<br/>
SPA Packet: '87wQ3s171if9x8628P6k1oBrQEJEmS5c/+ECed5cfDmu8hGhC5esUCEVcI8IH5TdjWva44efebX+cfXUVPBU9c/6tJpOLwC8k/8sN87SgYkBK+m64aD4FnnndaeqsrIcO/oHcpXHk9S/8rqqypcumNtlXVZD/isS3Q729LMTa+2uI6TsGX9OQ3'<br/>
<br/>
SPA Decode (res=0):<br/>
SPA Field Values:<br/>
=================<br/>
   Random Value: 8308719569638051<br/>
       Username: mbr<br/>
      Timestamp: 1280030806<br/>
    FKO Version: 1.9.12<br/>
   Message Type: 1<br/>
 Message String: 123.1.2.3,tcp/22<br/>
     Nat Access: &lt;NULL&gt;<br/>
    Server Auth: &lt;NULL&gt;<br/>
 Client Timeout: 0<br/>
    Digest Type: 3<br/>
   Encoded Data: 8308719569638051:bWJy:1280030806:1.9.12:1:OTYuMjQ0LjE3MS4yNTMsdGNwLzIy<br/>
SPA Data Digest: WcUEVesZDIY+CKRKYTck8zMW7HG0S7RcqmXVIMC4L58<br/>
<br/>
Added Rule to FWKNOP_INPUT for 123.1.2.3, tcp/22 expires at 1280030886<br/>
RES=0, CMD_BUF: /sbin/iptables -t filter -L FWKNOP_INPUT --line-numbers -n 2&gt;&amp;1<br/>
RULES LIST: Chain FWKNOP_INPUT (1 references)<br/>
num  target     prot opt source               destination<br/>
1    ACCEPT     tcp  --  123.1.2.3       0.0.0.0/0           tcp dpt:22 /* _exp_1280030886 */<br/>
<br/>
Removed rule 1 from FWKNOP_INPUT with expire time of 1280030886.<br/>
</code>
<br/><br/>


]]></description>
</item>

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

<a href="/psad/download/">
<img align="right" src="/images/release.png" title="psad-2.1.7" alt="psad-2.1.7 released" /></a>
The 2.1.7 release of <a  href="/psad"><b>psad</b></a> is available for
<a  href="/psad/download/"><b>download</b></a>.  This release adds some
relatively minor functionality to switch whois lookups to the destination IP
whenever the source IP is part of a directly connected subnet.  This change gives
better reporting data in normal psad email alerts.  The complete
<a href="http://trac.cipherdyne.org/trac/psad/browser/psad/tags/psad-2.1.7/ChangeLog">
ChangeLog</a> entries are displayed below.  The psad-2.1.6 release was also made
a few days ago, and fixes a bug that caused psad to die on some Ubuntu systems
when using the Date::Calc Decode_Month() function, and it also added the
<b>--Override-config</b> feature so that alternate configuration variables can
be specified via config files besides psad.conf (implemented by Franck Joncourt).
<br/><br/>
<ul>
<li>(Dan A. Dickey) Added the ability to use the "ip" command from the
iproute2 tools to acquire IP addresses from local interfaces.  Dan's
description is as follows: "...A main reason for doing this is in the
case of multi-homed hosts. ifconfig sets these up on an interface using
aliases, iproute2 does not.  So, for a multi-homed interface (eth0 with
multiple addresses), ifconfig -a only shows the first one configured and
not the rest.  ip addr shows all of the configured addresses...".</li>
<li>Added ENABLE_WHOIS_FORCE_ASCII to replace any non-ascii characters in
whois data (which is common with whois lookups against Chinese IP
addresses for example) with the string "NA".  This option is disabled by
default, but can be useful if errors like the following are seen upon
receiving an email alert from psad:
<br/><br/>
        &lt;&lt;&lt; 554 5.6.1 Eight bit data not allowed<br/>
        554 5.0.0 Service unavailable
<br/><br/></li>
<li>Updated psad to issue whois lookups against IP addresses that are not
directly connected to the local system.  This is useful for example when
an internal system is scanning an external destination system, and the
scan is logged in the FORWARD chain.  Issuing whois lookups on the
internal system (frequently on RFC 1918 address space) is not usually
very useful, but issuing the whois lookup against the destination system
gives much more interesting data.  This feature can be disabled with the
new ENABLE_WHOIS_FORCE_SRC_IP variable.</li>
</ul>


]]></description>
</item>

<!-- end_stories -->

</channel>
</rss>

