<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Weekend Challenge &#8211; Answers</title>
	<atom:link href="http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/</link>
	<description>Your source for invisible security bug spray</description>
	<lastBuildDate>Fri, 12 Aug 2011 18:22:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: jc</title>
		<link>http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/comment-page-1/#comment-737</link>
		<dc:creator>jc</dc:creator>
		<pubDate>Thu, 10 Dec 2009 21:24:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisbrenton.org/?p=722#comment-737</guid>
		<description>Makes sense I just want to be difficult ;-)
I am trying to see if there is a way of accomplishing this using bit masking. Just realised my previous reply tried to match a nibble not the byte so here goes one last try
src net 2001:db8::/122 and ((ip6[23] &amp; 0xF0 = 0x10) or (ip6[23] = 0×20))’

So 
ip6[23] &amp; 0xF0 = 0x10 (should match decimal 16 - 31)  and then ip6[23] = 0x20 should match 32.  Or is it time to throw in the towel ??</description>
		<content:encoded><![CDATA[<p>Makes sense I just want to be difficult <img src='http://www.chrisbrenton.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
I am trying to see if there is a way of accomplishing this using bit masking. Just realised my previous reply tried to match a nibble not the byte so here goes one last try<br />
src net 2001:db8::/122 and ((ip6[23] &amp; 0xF0 = 0&#215;10) or (ip6[23] = 0×20))’</p>
<p>So<br />
ip6[23] &amp; 0xF0 = 0&#215;10 (should match decimal 16 &#8211; 31)  and then ip6[23] = 0&#215;20 should match 32.  Or is it time to throw in the towel ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/comment-page-1/#comment-726</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Wed, 09 Dec 2009 15:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisbrenton.org/?p=722#comment-726</guid>
		<description>The filter:
ip[23]&amp;F0==1
will look at the four high order bits and match on the *lowest* order bit being set. In other words, the specified value ( 1) would be perceived as decimal and is outside of the mask range. If you run the filter you will see that tcpdump gives you a syntax error. :(

Let&#039;s look at this last byte in binary to see if that makes the problem any easier. 
We are trying to match any binary value from:
00010000 - 00100000
The &quot;src net&quot; portion of the filter takes care of ensuring the two high order bits (64 &amp; 128) are set to 0, so we don&#039;t have to worry about them. 
The rest of our filters needs to check to see:
1) Is bit 32 turned on, with all lower order bits turned off (exactly 00100000).

or...

2) Is bit 32 turned off, bit 16 turned on, ignoring any lower order bits ( value range is 00010000 - 00011111).

So the easiest way to filter on this is to include the greater than and less than primitives. What we want to say is:
00010000 &lt;= VALUE &lt;= 00100000

Now, convert this back to Hex and you get:
0x10 &lt; = VALUE &lt;= 0x20

In tcpdump speak, you write this expression as:
ip6[23] &gt;= 0×10 &amp;&amp; ip6[23] &lt;= 0×20

or:
ip6[23] &gt;= 0×10 and ip6[23] &lt;= 0×20

Make a bit more sense?</description>
		<content:encoded><![CDATA[<p>The filter:<br />
ip[23]&#038;F0==1<br />
will look at the four high order bits and match on the *lowest* order bit being set. In other words, the specified value ( 1) would be perceived as decimal and is outside of the mask range. If you run the filter you will see that tcpdump gives you a syntax error. <img src='http://www.chrisbrenton.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Let&#8217;s look at this last byte in binary to see if that makes the problem any easier.<br />
We are trying to match any binary value from:<br />
00010000 &#8211; 00100000<br />
The &#8220;src net&#8221; portion of the filter takes care of ensuring the two high order bits (64 &#038; 128) are set to 0, so we don&#8217;t have to worry about them.<br />
The rest of our filters needs to check to see:<br />
1) Is bit 32 turned on, with all lower order bits turned off (exactly 00100000).</p>
<p>or&#8230;</p>
<p>2) Is bit 32 turned off, bit 16 turned on, ignoring any lower order bits ( value range is 00010000 &#8211; 00011111).</p>
<p>So the easiest way to filter on this is to include the greater than and less than primitives. What we want to say is:<br />
00010000 < = VALUE <= 00100000</p>
<p>Now, convert this back to Hex and you get:<br />
0x10 < = VALUE <= 0x20</p>
<p>In tcpdump speak, you write this expression as:<br />
ip6[23] >= 0×10 &#038;&#038; ip6[23] < = 0×20</p>
<p>or:<br />
ip6[23] >= 0×10 and ip6[23] <= 0×20</p>
<p>Make a bit more sense?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jc</title>
		<link>http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/comment-page-1/#comment-711</link>
		<dc:creator>jc</dc:creator>
		<pubDate>Sun, 06 Dec 2009 23:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisbrenton.org/?p=722#comment-711</guid>
		<description>ok so to match the first nibble of the last byte. (I only want it to match 1 (which yields 16 - 31) will 
ip6[23] &amp; F0 == 1 
do the trick ?</description>
		<content:encoded><![CDATA[<p>ok so to match the first nibble of the last byte. (I only want it to match 1 (which yields 16 &#8211; 31) will<br />
ip6[23] &amp; F0 == 1<br />
do the trick ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/comment-page-1/#comment-707</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sun, 06 Dec 2009 14:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisbrenton.org/?p=722#comment-707</guid>
		<description>Updating my reply due to lack of caffeine:
src net 2001:db8::/122
We&#039;re masking on 122 bits. This specifies that bits 33 - 122 are equal to 0.
ip6[23] &amp; 0xE0 == 0
This filter says bits 121 - 123 must be 0.
ip6[23] == 0×20
This filter says bit 123 must be 1.

So to just focus on the last byte, your statement says &quot;bits 121 and 122 must be off and (bit 123 must be off or bit 123 must be on)&quot;.  This gets us close, but what if bit 124 is off? This could match the filter but still put us outside the specified range of addresses.</description>
		<content:encoded><![CDATA[<p>Updating my reply due to lack of caffeine:<br />
src net 2001:db8::/122<br />
We&#8217;re masking on 122 bits. This specifies that bits 33 &#8211; 122 are equal to 0.<br />
ip6[23] &#038; 0xE0 == 0<br />
This filter says bits 121 &#8211; 123 must be 0.<br />
ip6[23] == 0×20<br />
This filter says bit 123 must be 1.</p>
<p>So to just focus on the last byte, your statement says &#8220;bits 121 and 122 must be off and (bit 123 must be off or bit 123 must be on)&#8221;.  This gets us close, but what if bit 124 is off? This could match the filter but still put us outside the specified range of addresses.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jc</title>
		<link>http://www.chrisbrenton.org/2009/12/weekend-challenge-answers/comment-page-1/#comment-703</link>
		<dc:creator>jc</dc:creator>
		<pubDate>Sun, 06 Dec 2009 09:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.chrisbrenton.org/?p=722#comment-703</guid>
		<description>Chris,
chiming in late but following along with timtowtdi
how about...
&#039;src net 2001:db8::/122 and ((ip6[23] &amp; 0xE0 == 0) or (ip6[23] == 0x20))&#039;</description>
		<content:encoded><![CDATA[<p>Chris,<br />
chiming in late but following along with timtowtdi<br />
how about&#8230;<br />
&#8216;src net 2001:db8::/122 and ((ip6[23] &amp; 0xE0 == 0) or (ip6[23] == 0&#215;20))&#8217;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

