<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Matasano Chargen</title>
	<atom:link href="http://www.matasano.com/log/feed" rel="self" type="application/rss+xml" />
	<link>http://www.matasano.com/log</link>
	<description></description>
	<pubDate>Mon, 21 Jul 2008 23:38:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Regarding The Post On Chargen Earlier Today</title>
		<link>http://www.matasano.com/log/1105/regarding-the-post-on-chargen-earlier-today/</link>
		<comments>http://www.matasano.com/log/1105/regarding-the-post-on-chargen-earlier-today/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 23:38:21 +0000</pubDate>
		<dc:creator>Thomas Ptacek</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1105</guid>
		<description><![CDATA[Earlier today, a security researcher posted their hypothesis regarding
Dan Kaminsky&#8217;s DNS finding. Shortly afterwards, when the story began
getting traction, a post appeared on our blog about that
hypothesis. It was posted in error. We regret that it ran. We removed
it from the blog as soon as we saw it. Unfortunately, it takes only
seconds for Internet publications [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today, a security researcher posted their hypothesis regarding
Dan Kaminsky&#8217;s DNS finding. Shortly afterwards, when the story began
getting traction, a post appeared on our blog about that
hypothesis. It was posted in error. We regret that it ran. We removed
it from the blog as soon as we saw it. Unfortunately, it takes only
seconds for Internet publications to spread.</p>

<p>We dropped the ball here.</p>

<p>Since alerting the Internet earlier in July about the upcoming
announcement of his finding, Dan has consistently urged DNS operators
to patch their servers. We confirmed the severity of the problem then
and, by inadvertantly verifying another researcher&#8217;s results today,
reconfirm it today. This is a serious problem, it merits immediate
attention, and the extra attention it&#8217;s receiving today may increase
the threat. The Internet needs to patch this problem ASAP.</p>

<p>Dan told me about his finding personally, in order to help ensure
widespread patching before further details were announced at the
upcoming Black Hat conference. We chose to have a story locked and
loaded for that presentation, or for any other confirmed public
disclosure. On a personal level, I regret this as well.</p>

<p>Dan did phenomenal work on this research. It was impossible to talk to
him today and not know that he was sincere about coordinating a
graceful disclosure and fix for the problem. That I helped detract
from that work is painful both personally and professionally, and I
apologize to Dan for the way this played out.</p>

<p>Thomas Ptacek</p>

<p>Principal, Matasano Security</p>

<p>Jul 21, 2008</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1105/regarding-the-post-on-chargen-earlier-today/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What I&#8217;ve Been Doing On My Summer Vacation or, &#8220;It has to work; Otherwise gdb wouldn&#8217;t&#8221;</title>
		<link>http://www.matasano.com/log/1100/what-ive-been-doing-on-my-summer-vacation-or-it-has-to-work-otherwise-gdb-wouldnt/</link>
		<comments>http://www.matasano.com/log/1100/what-ive-been-doing-on-my-summer-vacation-or-it-has-to-work-otherwise-gdb-wouldnt/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 06:22:00 +0000</pubDate>
		<dc:creator>Timur</dc:creator>
		
		<category><![CDATA[Apple]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1100</guid>
		<description><![CDATA[An intern expects to be given simple projects, like coffee retrieval,
or &#8220;Hello, World.&#8221; So I&#8217;ve been sorely disappointed by Matasano. I
have been offered coffee retrieval services by senior engineers and my
latest project has been anything but &#8220;Hello, World.&#8221; 

In fact, it&#8217;s been more like, &#8220;Hello, OS X. Tell me your secrets&#8221;.

This is the story of [...]]]></description>
			<content:encoded><![CDATA[<p>An intern expects to be given simple projects, like coffee retrieval,
or &#8220;Hello, World.&#8221; So I&#8217;ve been sorely disappointed by Matasano. I
have been offered coffee retrieval services by senior engineers and my
latest project has been anything but &#8220;Hello, World.&#8221; </p>

<p>In fact, it&#8217;s been more like, &#8220;Hello, OS X. Tell me your secrets&#8221;.</p>

<p>This is the story of one trial-by-fire project handed to an intern
that turned out to be more complicated than anyone expected.</p>

<h3>1.</h3>

<p>It started with Thomas, innocently enough, handing me some debugger
code. It was both C and Ruby, and for Solaris and Win32.  He said, &#8220;I
would like you to port this Win32 Ruby code to OS X.&#8221;</p>

<p>&#8220;Um, okay.&#8221; </p>

<p>At that point I&#8217;d just finished learning the basics of Ruby via my
previous Matasano project, a database backed HTTP proxy. I knew
nothing about debuggers, let alone the low level C library calls I&#8217;d
need and Ruby bindings to make them work. I know, <em>fun</em>, right?</p>

<p>I started simply and dusted the C off in my head so I could begin to
read and understand the code Thomas dumped on me, and perhaps learn
how a debugger works and gets used. It took a day or two just to read
it. I&#8217;d ask the office some fairly basic question about debuggers, and
receive in return a much longer response than I&#8217;d anticipated. Like a
tutorial on the workings of x86 assembly. Eventually, I got to a point
where I was almost comfortable with how the C debugger worked.</p>

<p>When staring at C code stopped doing me any good, and writing Ruby
code started seeming feasible, I moved on to porting the Ruby
code. &#8220;How hard could it be?&#8221;. </p>

<h3>2.</h3>

<p>Thomas gave me a starting point. Our Ruby code called directly into C
libraries using Win32API and Ruby/DL. We have wrapper libraries that
make those C calls look like Ruby library functions. So, for instance,
in our Wrap32 library, we have:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="co1"># just grab some local memory</span><br />
&nbsp; &nbsp; <span class="kw1">def</span> malloc<span class="br0">&#40;</span>sz<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; r = CALLS<span class="br0">&#91;</span><span class="st0">&quot;msvcrt!malloc:L=L&quot;</span><span class="br0">&#93;</span>.<span class="me1">call</span><span class="br0">&#40;</span>sz<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">raise</span> WinX.<span class="me1">new</span><span class="br0">&#40;</span><span class="re3">:malloc</span><span class="br0">&#41;</span> <span class="kw1">if</span> r == <span class="nu0">0</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw2">return</span> r<br />
&nbsp; &nbsp; <span class="kw1">end</span></div></div>

<p>We had a small piece of this written for OS X as well. I had to build
it out. I started with <em>getpid()</em>, a simple system call I could make
sure worked before I moved on to something harder. It worked right
away. My confidence was high. I was feeling cocky.</p>

<p>Here I should mention that I&#8217;d never worked on a decently large coding
project before. This was my first.</p>

<p>Throughout this entire project I&#8217;ve been trying to write the entire
thing far before I actually write even a single function. So,
I had many questions:</p>

<ul>
<li><p>What was the script implementing the debugger to look like? </p></li>
<li><p>Was it to be event driven? </p></li>
<li><p>Did we want objects to represent each process, threads, or to
make his lunch for him? </p></li>
</ul>

<p>I was overzealous. The team was patient. Thomas said simply, &#8220;There is
no spoon. You&#8217;ll need <em>ptrace()</em> and <em>wait()</em> for the breakpoint
insertion and signal catching. Just copy the functionality from the
Win32 version.&#8221;</p>

<h3>3.</h3>

<p><em>An brief word from the team about how debuggers work.</em></p>

<p>The thing you most want to do with a debugger is set and handle
breakpoints. On X86, there are two kinds of breakpoints: hardware and
software. You mostly use software breakpoints. They way software
breakpoints work is, you pick the place in the program you want to
break at, and you replace the instruction at that point with &#8220;INT
3&#8243; (conveniently enough, this is just the byte &#8220;0xCC&#8221;). When the
program hits the INT instruction, it generates an interrupt. The OS
catches the interrupt and kills the program.</p>

<p>Unless you have a debugger attached. If you have a debugger attached,
instead of killing the program, the OS tells the debugger. The
debugger then swaps the original instruction back in, &#8220;rewinds&#8221; the
prograam back to it, and resumes execution.</p>

<p>Every OS has debugging features. They boil down to the following
four capabilities:</p>

<ul>
<li><p>Reading and writing the memory of another process (that&#8217;s
how you swap INT in for instructions to set breakpoints).</p></li>
<li><p>Catching events from other processes, like breakpoint
    interrupts.</p></li>
<li><p>Starting, stopping, and pausing threads inside other
    processes.</p></li>
<li><p>Changing the <em>register state</em> in other processes, for 
instance by moving the EIP register back 1 byte to rewind
the INT 3 instruction that just fired.</p></li>
</ul>

<p>The best known Unix debugger interface is <em>ptrace()</em>, and it basically
does all four of those things for you, along with the <em>wait()</em> call
for detecting events. On Win32, any program can read or write from a
process it has the right permissions for, even if it isn&#8217;t a debugger;
the debugger mostly exists to catch interrupts.</p>

<h3>4.</h3>

<p>Coding the wrappers for <code>ptrace()</code>, <code>wait()</code>, and <code>waitpid()</code> didn&#8217;t
take too long. Each just takes a few integers and returns an
integer. But <em>ptrace</em> works with request codes, like &#8220;PEEK&#8221; to read
memory or &#8220;STEP&#8221; to single-step the process. I couldn&#8217;t test without
knowin all the request codes. So, I started reading man pages, poking
at code and trying to get my OS X functions to work.</p>

<p>&#8220;To the headers!&#8221; I cried. But which one and where are they? As I
mentioned, I&#8217;m a little new to real &#8212; as in non-academic &#8212;
programming.  Google worked OK to get the man pages, but didn&#8217;t
include the request code numeric values, just the names and what they
did. Frustrated, I asked for help.</p>

<p>&#8220;<code>find /usr/include | xargs grep ptrace | less</code>&#8221; was the response I
got from Thomas. You didn&#8217;t know he speaks *nix? He does. Hexadecimal too,
from what I&#8217;ve heard.</p>

<p>A little reading and some copying later I had the constants I needed,
and began to test my <code>ptrace</code> and <code>wait</code> functions. The code wasn&#8217;t
pretty but it seemed to work. I could attach to a process by PID and
<code>wait()</code> for it. Now I just needed to get its registers and I&#8217;d be
almost done.</p>

<p>It didn&#8217;t take long to sketch my code based on the Win32 debugger I
was given to start with. Soon I had what I thought was the start of a
functional debugger in Ruby, along with a handy explanation of the
Ruby way of doing things. Up until that point I&#8217;d been trying to do
things the C way, passing variables by reference, trying to make the
Ruby function call an exact match to the C call, and other things I&#8217;d
picked up from the C/C++/JAVA I learned in college.</p>

<p>I thought I was doing well. Then I tried to find the OSX equivalent of
<code>PTRACE_GETREGS</code> to read the registers from other processes, which is
kind of important for debuggers.</p>

<h3>5.</h3>

<p>Here everything starts to get more complicated. </p>

<p>It turns out Apple, in their infinite wisdom, had gutted
<code>ptrace()</code>. The OS X man page lists the following request codes:</p>

<ul>
<li><p><code>PT_ATTACH</code> &#8212; to pick a process to debug</p></li>
<li><p><code>PT_DENY_ATTACH</code> &#8212; so processes can stop themselves from being debugged</p></li>
<li><p><code>PT_TRACE_ME</code> &#8212; so debuggers can launch processes that start debugged</p></li>
<li><p><code>PT_CONTINUE</code> &#8212; to restart a program after it&#8217;s been stopped</p></li>
<li><p><code>PT_STEP</code> &#8212; to execute just one instruction in the process</p></li>
<li><p><code>PT_KILL</code> &#8212; to kill the process</p></li>
<li><p><code>PT_DETACH</code> &#8212; to release the process</p></li>
</ul>

<p>No mention of reading or writing memory or registers. Which would have
been discouraging if the man page had not also mentioned <code>PT_GETREGS</code>,
<code>PT_SETREGS</code>, <code>PT_GETFPREGS</code>, and <code>PT_SETFPREGS</code> in the error codes
section. So, I checked <code>ptrace.h</code>. There I found:</p>

<ul>
<li><p><code>PT_READ_I</code> &#8212; to read instruction words</p></li>
<li><p><code>PT_READ_D</code> &#8212; to read data words</p></li>
<li><p><code>PT_READ_U</code> &#8212; to read U area data if you&#8217;re old enough to remember
what the U area is</p></li>
<li><p><code>PT_WRITE_I</code> &#8212; and write instructions</p></li>
<li><p><code>PT_WRITE_D</code> &#8212; and data</p></li>
<li><p><code>PT_WRITE_U</code> &#8212; and U</p></li>
<li><p><code>PT_SIGEXC</code> &#8212; and EXC SIGs</p></li>
<li><p><code>PT_THUPDATE</code> &#8212; and update THs</p></li>
<li><p><code>PT_ATTACHEXC</code> &#8212; and attach EXCs</p></li>
</ul>

<p>There&#8217;s one problem solved. I can read and write memory for
breakpoints. But I still can&#8217;t get access to registers, and I need to
be able to mess with EIP.</p>

<p>That&#8217;s when I start hearing &#8220;It has to work, otherwise gdb
wouldn&#8217;t&#8221;, rather frequently, from more than one person. </p>

<p>Well, <code>ptrace()</code> won&#8217;t work for retrieving registers in OS X. </p>

<p>Matasano Secret Intern X referred me to Nemo&#8217;s article at
uninformed.org. In it, Nemo lays out the Mach kernel calls that
replace some of the lost <em>ptrace()</em> functionality. So, I wrote
wrappers for:</p>

<ul>
<li><p><code>task_for_pid</code> &#8212; to find the Mach task of an OS X process</p></li>
<li><p><code>mach_task_self</code> &#8212; to get my debugger&#8217;s task</p></li>
<li><p><code>task_threads</code> &#8212; to walk the threads inside a task</p></li>
<li><p><code>thread_get_state</code> &#8212; to get the registers for one of those threads</p></li>
<li><p><code>thread_set_state</code> &#8212; to change those registers</p></li>
</ul>

<p>Since I wasn&#8217;t using them natively in C I needed to know more about
the usage of each function. </p>

<p>&#8220;No problem,&#8221; I thought, &#8220;I&#8217;ll just fire up terminal and&#8230; Oh, <a
title="Oxhorn's Unabridged Dictionary"
href="http://oxhornbrand.blogspot.com/2007/08/script-oxhorns-unabridged-dictionary.html"
target="_blank">bloit</a>!&#8221; No man pages. </p>

<p>I pored over Nemo&#8217;s work, what I could find in the headers, and
figured out how to call the functions. Now another problem. The Mach
functions take pointers to raw C memory. </p>

<p>The way I was told to handle this was, pack the data I needed into
Ruby strings or native numeric types with Ruby/DL. After a long, dark
period of messing with calls to &#8220;strdup&#8221; and &#8220;DL.malloc&#8221;, I found
&#8220;String#to_ptr&#8221;, and at last managed to get the Mach functions
working.</p>

<p>I had also found the correct way to get <code>errno</code> through Ruby/DL: 
<code>DL.last_error</code>. This appears to be documented nowhere in English.</p>

<p>Except for an odd bus error I ran into now and then (but couldn&#8217;t
duplicate), my Ruby debugger was working and could read and write
registers. I&#8217;d even checked to make sure they were coming back to me
in the correct sequence.</p>

<p>Then, running my <code>get_registers()</code> function repeatedly, I found the
registers of a stopped process changing on every call. When I printed
them without marshalling they contained the names of some of the
functions I&#8217;d written occasionally.</p>

<p>&#8220;Oh, <a title="Oxhorn's Unabridged Dictionary"
href="http://oxhornbrand.blogspot.com/2007/08/script-oxhorns-unabridged-dictionary.html"
target="_blank">bloit</a>! I&#8217;m really <a title="Oxhorn's Unabridged
Dictionary"
href="http://oxhornbrand.blogspot.com/2007/08/script-oxhorns-unabridged-dictionary.html"
target="_blank">chakked</a> now. I&#8217;ve been calling a <a
title="Oxhorn's Unabridged Dictionary"
href="http://oxhornbrand.blogspot.com/2007/08/script-oxhorns-unabridged-dictionary.html"
target="_blank">bloitting</a> buffer overflow a register lookup,&#8221; I
said to myself. I despaired of my project and my future.</p>

<h3>6.</h3>

<p>On the train home and all weekend I looked through Apple&#8217;s
documentation. Google. The header files &#8220;It has to work; Otherwise gdb
wouldn&#8217;t,&#8221; another friend said. But he wasn&#8217;t able to find the
documentation I was looking for. He did find fxr.watson.org and some
better explanations of the functions at
web.mit.edu/darwin/src/modules/xnu/osfmk/man/. Those turned out to be
gold later.</p>

<p>During week one of coding:</p>

<ul>
<li><p>several necessary functions wrapped and working</p></li>
<li><p>DL.txt is really the only Ruby/DL documentation that exists</p></li>
<li><p>Ruby/DL is great for simple C function wrapping but rough around the edges when it comes to more interesting calls.</p></li>
<li><p>Avergage familiarity with Ruby</p></li>
<li><p>Basic understanding of how a debugger works</p></li>
<li><p>A Ruby object that can attach to a process, continue it, detach from it and wait() for it.</p></li>
<li><p>One really convoluted method to read/write random locations in memory</p></li>
<li><p>Average familiarity with system calls in C (now rust free)</p></li>
</ul>

<h3>7.</h3>

<p>Starting the following week, things went a little smoother.</p>

<p>I had my coding flow going. I had better documentation than just
header files. I started reading the Mach kernel code. </p>

<p>I wrote a small program in C to test the sequence of system calls I
was using in Ruby. If It worked in C, why didn&#8217;t it work in Ruby?
Then, I found it. I was calling <code>task_threads()</code> wrong, passing an
pointer where it expected a pointer-to-pointer. Whee! I 
vetted the results with gdb&#8217;s output.</p>

<p>My code said:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="st0">&quot;regs = [&quot;</span>c0003<span class="st0">&quot;, &quot;</span><span class="nu0">32390</span><span class="st0">&quot;, &quot;</span>bffff74c<span class="st0">&quot;, &quot;</span>90e441ba<span class="st0">&quot;, &quot;</span><span class="nu0">0</span><span class="st0">&quot;, &quot;</span><span class="nu0">0</span><span class="st0">&quot;, &quot;</span>bffff768<span class="st0">&quot;, &quot;</span>bffff74c<span class="st0">&quot;, &quot;</span>1f<span class="st0">&quot;, &quot;</span><span class="nu0">286</span><span class="st0">&quot;, &quot;</span>90e441ba<span class="st0">&quot;, &quot;</span><span class="nu0">7</span><span class="st0">&quot;, &quot;</span>1f<span class="st0">&quot;, &quot;</span>1f<span class="st0">&quot;, &quot;</span><span class="nu0">0</span><span class="st0">&quot;, &quot;</span><span class="nu0">37</span><span class="st0">&quot;]&quot;</span></div></div>

<p>gdb replied:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;">eax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0xc0003786435<br />
ecx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0xbffff74c<span class="nu0">-1073744052</span><br />
edx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0&#215;90e441ba<span class="nu0">-1864089158</span><br />
ebx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0&#215;32390205712<br />
esp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0xbffff74c0xbffff74c<br />
ebp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0xbffff7680xbffff768<br />
esi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0&#215;00<br />
edi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0&#215;00<br />
eip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0&#215;90e441b50&#215;90e441b5<br />
eflags &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;286646<br />
cs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;77<br />
ss &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;1f31<br />
ds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;1f31<br />
es &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;1f31<br />
fs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;00<br />
gs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#215;3755</div></div>

<p>They agreed! I went home for the day.</p>

<h3>8.</h3>

<p>Now for <em>wait()</em>, to catch debugger events. <code>wait()</code> was hanging the
debugger if I called it more than once. I set it up to use the
<code>NOHANG</code> option. I fixed an return value error. </p>

<p>Then, I tested single-stepping with <code>ptrace</code>. Kernel panic.</p>

<p>I put that on the list of broken parts of <code>ptrace</code> to be replaced by a
Mach call. </p>

<p>Next up was setting breakpoints. They seemed to install themselves
without error but the child wasn&#8217;t stopping when ran the command that
would hit the breakpoint I&#8217;d set. Upon inspection, the breakpoint was
replacing an instruction of <code>-1</code>. Which gdb told me was actually
<code>0x55</code>.</p>

<p>I started researching the problem, finding only hints. Did I mention
<code>ptrace</code> was gutted in OS X? I read the source for Apple&#8217;s version of
gdb. Thomas gave me a copy of a DTrace <code>truss</code> and said, &#8220;Just do
whatever gdb does.&#8221;</p>

<p>It took me a while to get the script working. It seems iTunes causes
errors in <code>truss</code> (also <code>dtruss</code>) whenever it&#8217;s running. I closed
iTunes and started using watching gdb for <code>ptrace</code> calls. Rather
quickly I noticed an extreme lack of call to <code>ptrace</code>. </p>

<p>Was gdb even using <code>ptrace</code> for reading the process&#8217; memory?</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="br0">&#40;</span>gdb<span class="br0">&#41;</span> PID/LWP &nbsp; SYSCALL<span class="br0">&#40;</span>args<span class="br0">&#41;</span> &nbsp;= <span class="kw1">return</span><br />
<span class="kw2">break</span> *0&#215;420f<br />
Breakpoint <span class="nu0">1</span> at 0&#215;420f<br />
<span class="br0">&#40;</span>gdb<span class="br0">&#41;</span> run<br />
Starting program: /usr/bin/ftp<br />
Reading symbols <span class="kw1">for</span> shared libraries ++++. <span class="me1">done</span><br />
ftp&amp;gt; &nbsp; <span class="nu0">939</span>/<span class="nu0">94968960</span>: &nbsp;ptrace<span class="br0">&#40;</span>0&#215;0, 0&#215;0, 0&#215;0, 0&#215;0<span class="br0">&#41;</span> = <span class="nu0">0</span> <span class="nu0">0</span><br />
<span class="nu0">939</span>/<span class="nu0">94968960</span>: &nbsp;ptrace<span class="br0">&#40;</span>0xC, 0&#215;0, 0&#215;0, 0&#215;0<span class="br0">&#41;</span> = <span class="nu0">0</span> <span class="nu0">0</span><br />
<span class="nu0">930</span>/<span class="nu0">66961480</span>: &nbsp;ptrace<span class="br0">&#40;</span>0xD, 0&#215;3AB, 0&#215;2C1B, 0&#215;0<span class="br0">&#41;</span> = <span class="nu0">0</span> <span class="nu0">0</span><br />
<span class="nu0">930</span>/<span class="nu0">66961480</span>: &nbsp;ptrace<span class="br0">&#40;</span>0xD, 0&#215;3AB, 0&#215;2C1B, 0&#215;0<span class="br0">&#41;</span> = <span class="nu0">0</span> <span class="nu0">0</span><br />
<span class="nu0">930</span>/<span class="nu0">66961480</span>: &nbsp;ptrace<span class="br0">&#40;</span>0xD, 0&#215;3AB, 0&#215;2C1B, 0&#215;0<span class="br0">&#41;</span> = <span class="nu0">0</span> <span class="nu0">0</span></div></div>

<p>It became apparent ptrace was only really used by gdb to:</p>

<ul>
<li><p>prevent the process from exiting on signals</p></li>
<li><p>passing signals to the child after it processed them.</p></li>
</ul>

<p>I then remembered that uninformed.org article. A quick read reminded
me that Mach <code>vm_read</code> and <code>vm_write</code> were needed to replace <code>PT_READ</code>
and <code>PT_WRITE</code>.</p>

<p>The next day, Thomas was in the office to check on my progress. To
move things along he implemented <code>vm_read</code> and <code>vm_write</code> for me while
I confirmed a few things with <code>truss</code> and looked for <code>vm_read</code> calls
in gdb. I didn&#8217;t find any. When he finished the functions, I used them
in my breakpoint setting routines. No errors.</p>

<p>No stopping at breakpoints either.</p>

<p>Again the instructions were <code>-1</code>. When I mentioned this Thomas
informed me I&#8217;d probably need <code>vm_protect</code> as well. Why hadn&#8217;t I
thought of that? Not too long after that I was able to set and remove
breakpoints correctly! I went home for the long weekend.</p>

<p>During week two of coding:</p>

<ul>
<li><p>wrapped and implemented all necessary system calls</p></li>
<li><p>added thread state and breakpoint manipulation to Debuggerx</p></li>
<li><p>gained some knowledge of OS X internals</p></li>
<li><p>found a repeatable kernel panic</p></li>
<li><p>learned basic usage of dtrace and gdb</p></li>
<li><p>learned I tend to overthink my code before writing it</p></li>
<li><p>began to use irb as a scratch pad for testing functions</p></li>
</ul>

<h3>9.</h3>

<p>Now another problem. You can set a breakpoint with the debugger. You
can catch the breakpoint. You can resume the process. But you can&#8217;t
reset the breakpoint without single stepping: to resume the process,
you have to clear the breakpoint.</p>

<p>But PT_STEP was panicking the kernel!</p>

<p>I settled on setting the TRAP flag in the EFLAGS register to simulate
single-stepping with ptrace. This seemed to work. But now I&#8217;m getting
bus errors when I resume the process. I verified with Thomas how they
were supposed to work. I tried watching gdb for <code>vm_write</code> from
<code>truss</code> again, nothing. After some debugging I discovered <code>waitpid()</code>
was clearing the trap flag, which Thomas informed me was correct
behavior. Some more monkeying around trying to get it working ate up
the rest of the day.</p>

<p>The next day, I was able to pass through a breakpoint and reset
it. Only problem was, the breakpoint wasn&#8217;t being reset fast enough, it
wasn&#8217;t done immediately one step after it was hit. After clearing some
confusion on my part with Thomas, I decided to try <code>PT_STEP</code> again. It
worked and didn&#8217;t panic the kernel this time. Finally, I had a
debugging tool that was complete! </p>

<p>All that remained was to clean up some debug tracing prints and
implement a better method to view the registers. Both fairly simple
things completed early the next day.</p>

<h3>10.</h3>

<p>There it is, the story of the birth of DebuggerX. A &#8220;simple&#8221; porting
task handed to an intern to better his understanding of debuggers and
Ruby. During the project I&#8217;d become quite familiar with Ruby, learned
some OS X internals, found a kernel panic in ptrace, and learned
better programming technics. I still tend to overthink my code and
&#8220;have a hard time believing that you&#8217;re supposed to ask programs to do
the things it looks like they need to do,&#8221; according to Thomas, but I
have learned it&#8217;s quite a bit easier to try something in code than in
your head. Since completion of the project as originally stated, I&#8217;ve
added calls to get information about a thread and began looking into
retrieving a list of function symbols from the process&#8217; file. I&#8217;ll
make another post about that in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1100/what-ive-been-doing-on-my-summer-vacation-or-it-has-to-work-otherwise-gdb-wouldnt/feed/</wfw:commentRss>
		</item>
		<item>
		<title>2008 Pwnie Awards: Last Chance For Nominations</title>
		<link>http://www.matasano.com/log/1101/2008-pwnie-awards-last-chance-for-nominations/</link>
		<comments>http://www.matasano.com/log/1101/2008-pwnie-awards-last-chance-for-nominations/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 01:24:34 +0000</pubDate>
		<dc:creator>Dave G.</dc:creator>
		
		<category><![CDATA[Industry Punditry]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1101</guid>
		<description><![CDATA[Just as a reminder, today is the last day that you can nominate yourself your peers for a pwnie award.  Categories include:

Best Server-Side Bug
Best Client-Side Bug
Mass 0wnage
Most Innovative Research
Lamest Vendor Response
Most Overhyped Bug
Best Song
Most Epic FAIL
Lifetime Achievement Award

As things stand today, the community clearly thinks that a hacker with the simple moniker of &#8216; [...]]]></description>
			<content:encoded><![CDATA[<p>Just as a reminder, today is the last day that you can nominate <del datetime="2008-07-15T01:05:30+00:00">yourself</del> your peers for a pwnie award.  Categories include:
<ol>
<li>Best Server-Side Bug
<li>Best Client-Side Bug
<li>Mass 0wnage
<li>Most Innovative Research
<li>Lamest Vendor Response
<li>Most Overhyped Bug
<li>Best Song
<li>Most Epic FAIL
<li>Lifetime Achievement Award</p>

<p>As things stand today, the community clearly thinks that a hacker with the simple moniker of <B>&#8216;</B> deserves to win every category.  I think we can do better.</p>

<p>Go <A HREF="http://pwnie-awards.org/2008/awards.html">here</A> now to give your peers the recognition they deserve&#8230;  a toy for children ages 5 and up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1101/2008-pwnie-awards-last-chance-for-nominations/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Patch Your (non-DJBDNS) Server Now. Dan Was Right. I Was Wrong.</title>
		<link>http://www.matasano.com/log/1093/patch-your-non-djbdns-server-now-dan-was-right-i-was-wrong/</link>
		<comments>http://www.matasano.com/log/1093/patch-your-non-djbdns-server-now-dan-was-right-i-was-wrong/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 23:47:21 +0000</pubDate>
		<dc:creator>Thomas Ptacek</dc:creator>
		
		<category><![CDATA[Feature]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1093</guid>
		<description><![CDATA[Thanks to Rich Mogull, Dino and I just got off the phone with Dan
Kaminsky. We know what he&#8217;s going to say at Black Hat.

What can we say right now?


Dan&#8217;s got the goods. You know that scene near the end of High
Fidelity where Jack Black listens to the skate punk&#8217;s electroclash
demo? Yep. It&#8217;s really f&#8217;ing good.
This [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to Rich Mogull, Dino and I just got off the phone with Dan
Kaminsky. We know what he&#8217;s going to say at Black Hat.</p>

<p>What can we say right now?</p>

<ol>
<li><p>Dan&#8217;s got the goods. You know that scene near the end of High
Fidelity where Jack Black listens to the skate punk&#8217;s electroclash
demo? Yep. <em>It&#8217;s really f&#8217;ing good.</em></p></li>
<li><p>This is strong year at Black Hat: Dowd and Lawson in
particular have awesome talks linked up. But Dan may have Best of Show
here. </p></li>
<li><p>If you were running DJBDNS before, you&#8217;re safe. If you made
fun of me for running DJBDNS: <em>sucker</em>.</p></li>
<li><p>Ryan Russell pointed out earlier on our blog that Dan takes a
lot of crap for doing so much public research. You can&#8217;t be in the
public eye for long without taking fire from people who write
shellcode instead of Black Hat talks and press releases. Ryan is
right: it&#8217;s not fair. I don&#8217;t know how you can give Dan crap about his
work after this. </p></li>
</ol>

<p>I think Dan should come clean on this and publish the details. The 30
days he&#8217;s given before Black Hat won&#8217;t make much of a difference. But
his reason for not doing it is at least plausible. And he did the
work. So, it&#8217;s his call.</p>

<p>I think I owe Chris Eng $100 now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1093/patch-your-non-djbdns-server-now-dan-was-right-i-was-wrong/feed/</wfw:commentRss>
		</item>
		<item>
		<title>So&#8230; How Do I Manage It?</title>
		<link>http://www.matasano.com/log/1086/so-how-do-i-manage-it/</link>
		<comments>http://www.matasano.com/log/1086/so-how-do-i-manage-it/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 21:18:39 +0000</pubDate>
		<dc:creator>Dave G.</dc:creator>
		
		<category><![CDATA[Feature]]></category>

		<category><![CDATA[Matasano]]></category>

		<category><![CDATA[Navel Gazing]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1086</guid>
		<description><![CDATA[&#8220;If we just get this hardware layer 7 firewall to market in 3 months we&#8217;ll be funded in 4 and we&#8217;ll be millionaires in 24 months tops!&#8221;  &#8212; Thomas Ptacek, shortly before I give the two weeks notice that became 6 weeks at Symantec.

Matasano has been around for over three years now, and we [...]]]></description>
			<content:encoded><![CDATA[<h3>&#8220;If we just get this hardware layer 7 firewall to market in 3 months we&#8217;ll be funded in 4 and we&#8217;ll be millionaires in 24 months tops!&#8221;  &#8212; Thomas Ptacek, shortly before I give the two weeks notice that became 6 weeks at Symantec.</h3>

<p>Matasano has been around for over three years now, and we are not millionaires.  The company&#8217;s original goal was to create a new way for companies to solve the internal access control nightmare (that still persists, in spite of NAC).  In 2005, our thought process was the typical startup blueprint: We have a great team, a great idea, lets go get some funding and build a product company.</p>

<p>I could probably write a series of blog posts on the VC process, but during both the due diligence process and our independent conversations with customers, we had a common question keep coming up.  &#8220;This product {sounds great, sounds impossible, is the holy grail}.  <strong>So&#8230; How do I manage it?</strong>&#8221;</p>

<p>When a product doesn&#8217;t exist yet, it is really easy to talk about how you manage it.  And since it was a common hurdle, we kept coming up with more and more clever answers to the problem.  So, now we had a revolutionary new idea for the firewall, and we also had an incredibly sophisticated management interface.  This would be great except we just kept evolving the product to the point where we would have needed a ton of funding to proceed.  Also, we learned that we probably know more about the business that we want to build than anyone else.</p>

<p>So, after regrouping, we realized that the common thread in most of our conversations with potential customers was The Management Question.  So, we went back to a lot of the folks we talked to and drilled down.  We found that even now, in 2008, organizations are still struggling to manage what is arguably the most ubiquitous security product on your network.  The firewall.</p>

<p>Yes, the problem of managing firewalls isn&#8217;t as fascinating as figuring out how to perform line speed, full decode of protocols and making stop/go decisions at 10Gbits.  Instead, we are solving a real operations problem.  The type of product where you don&#8217;t make everyone&#8217;s life more difficult when you deploy, but instead make everyone&#8217;s life better.  </p>

<p>The obvious question is, &#8220;3 years&#8230; really?&#8221;.  </p>

<h3>&#8220;We have a team of kernel developers working on a web-app&#8230; two months, tops.&#8221;</h3>

<p>This wasn&#8217;t three years spent dedicated to application development.  The application was built in spare cycles.  The fact of the matter is, while we were building this product, we were also building a consulting business.  </p>

<p>We started the business based out of Jeremy&#8217;s apartment.  This was great for me, as the commute was about 10 minutes (Jeremy lived one block further away from me than the old @stake office).  Jeremy eventually moved, and we decided to move the office to my apartment.  The commute got better, but running a business from your (or at least, my) home is a big quality of life hit for everyone involved.  Just ask Dino and Jeremy, they worked on opposite sides of what used to be a dining room table, with Dino having to squeeze in between the air conditioner and the table with like 2 inches to spare.  Mostly though, it is hard to feel like a real company when there isn&#8217;t an office.  It is also hard to feel like a company when you are three people (after Dino and Window left us!).  It is also really hard to feel like a company when a customer calls the business line at 10PM to leave a voicemail and gets me answering the phone with the television blaring in the background.  </p>

<p>So, we got an office.  Then Chicago got an office.  Both of these offices were unbelievably humble.  The first New York space had four people working inside of a 100 sq. ft. office. The Chicago office wasn&#8217;t much bigger.  Also, water leaking from the ceiling.  Also, it was above some weird print shop.  But you know what.  Also, it started to feel like a real company.</p>

<p>We also started hiring.  Almost like Clockwork, we would get more work as soon as we hired someone (which, basically meant that we still had a gap).  Also moving the real company dial.</p>

<h3>&#8220;Corporate blogging is a total waste of time.&#8221; &#8212; Dave Goldsmith</h3>

<p>At this point, we would cue the Montage:</p>

<p>Offices of the non-leaking variety for Chicago.  Hiring amazing people.  Holy crap, we have a benefits person.    More great customers.  Lots and lots of blog posts (almost one a workday since the inception of the company).  Dedicated developer for Playbook.  Bigger offices for New York and Chicago. 401k&#8217;s?!  Crazier and crazier consulting projects.  Which lead to blackhat talks.  Which lead to even crazier projects.  UI Designers cost how much?  Horribly&#8230; horribly&#8230; awesome.  Tom calling me to tell me that if we don&#8217;t do X in Y time frame the company will surely collapse.  Jeremy looking at me like he is going to stab me in the neck if we don&#8217;t start hiring more people.  </p>

<p>In spite of everything I just ranted about, services is and will continue to be a great business for us.  Not only is the work exciting and ever-changing, we just wouldn&#8217;t get the same level of visibility into the real life challenges that modern enterprises face.  </p>

<p>That being said, we started Matasano with the goal of selling security products.  And as of July 2nd, 2008&#8230; we <A HREF="http://www.matasano.com/log/1081/matasanos-playbook-available-now/">do</A>.</p>

<p>ps: It would be absurd if I didn&#8217;t take a moment to thank Adam, Alex, Craig, Dan, Dino, Duncan, Eric, Erin, Kim, Max, Mike, Jeremy, Jess, Timur, Tom, Window, Wes, all of our customers, partners and trusted advisors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1086/so-how-do-i-manage-it/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dan Kaminsky could have made hundreds of thousands of dollars with this DNS flaw!</title>
		<link>http://www.matasano.com/log/1089/dan-kaminsky-could-have-made-hundreds-of-thousands-of-dollars-with-this-dns-flaw/</link>
		<comments>http://www.matasano.com/log/1089/dan-kaminsky-could-have-made-hundreds-of-thousands-of-dollars-with-this-dns-flaw/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 03:39:15 +0000</pubDate>
		<dc:creator>Thomas Ptacek</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1089</guid>
		<description><![CDATA[We interrupt this pile-on to bring you this important message: Dan has the goods. Patch now, ask questions later. More to come this evening.



Java JSESSIONID: BB16479A0338D3DCF26D11712F138BC1

.NET ASPESSIONID: HHODHGFDJOJAKDIPPJCKHGOE

SiteMinder SMESSIONID: 

su/hxP2nLeaZBdEn8qClOdeCGwG2xfLaBfXQF2QpSCSxKYBLVTF7OfqtVcHxLITpuNa6+1W
c2ZJ9MKWInlFlEe5GqZAjobgyzInCwe3JiTebqyJaftWtVht/La0qlvjLF9oaI5y1aIdtUGiTmQI
OW28AL0gLJe4pdA0sw2fq4cBG8ZWPMblwX4nGCGXGU8JQ1PtOhm8ohtSQcXZ7lm35t29
P5tcbfDrQs3z4g43zrLRO5M68m91xP7xcHY0uLuSYUSMFIrUbaEVSVVewFY4tskjPYecoWT
uLV0deSJilKpfSTVyekbzGXO2ejhIPxsE5cvPVNPt5AoJ6KIdvWMezUHz+KQt3uVuJEHpZkU
QhEfLrWAdJ2TwE++na2G3GI8BqlSOB+KRl3rz19/9nqpE87c/IWsscSfOQLemzwd/Z3DZfn
ioKB/tFsZWLndqdNq5XmDuRvRN2+EVMT8QFYEq1c+mNhsOIeFCjo8JOOXPG3F+r6h0kXN
M4zjRtgN/qSYRAycXluqKozAIMgr5qemW1UItwCyqJu1cDMLuKgkSq9XXA3Cru6PVPF74D1
t8l2IvV2HWmxL2PP4RdIXa5Ofb1sCLc6AUZ9opLGhwYHt7S3PnxXzKoYsMJwoFm7nGqjKp
J7S9e0iRTMUqY7fOgSQALLw+hsac7hhNCUtB3/xEhvfJ7Y4b1Xj26jWJAujEnHgF+DUJQHvX
hkLl7Rr2dbCPJu/8hDMOKdfz4QJXAQSbCJyA4MrJLXn4UZLpgwMeIVMddvloO4dZatrxQT9m
ZQtqvow5jKcpUKhtxqqf7M4MFDMOEvQdIT3U8WRsbjk1lT4UajljxyTa9TSF9sCid1BH/O3Hq
YyJtfpDcr7QxqHXr9AZYtHbO93DX/I82bQ3mcCco

DNS XID: 04d8

Getting To File This Week&#8217;s Front Page Security Story Before Changing Out Of Your Pajamas: Priceless.

There are some vulnerabilities money can&#8217;t buy. For everything [...]]]></description>
			<content:encoded><![CDATA[<p><strong>We interrupt this pile-on to bring you this important message</strong>: Dan has the goods. Patch now, ask questions later. More to come this evening.</p>

<hr />

<p><strong>Java JSESSIONID</strong>: BB16479A0338D3DCF26D11712F138BC1</p>

<p><strong>.NET ASPESSIONID</strong>: HHODHGFDJOJAKDIPPJCKHGOE</p>

<p><strong>SiteMinder SMESSIONID</strong>: </p>

<p>su/hxP2nLeaZBdEn8qClOdeCGwG2xfLaBfXQF2QpSCSxKYBLVTF7OfqtVcHxLITpuNa6+1W
c2ZJ9MKWInlFlEe5GqZAjobgyzInCwe3JiTebqyJaftWtVht/La0qlvjLF9oaI5y1aIdtUGiTmQI
OW28AL0gLJe4pdA0sw2fq4cBG8ZWPMblwX4nGCGXGU8JQ1PtOhm8ohtSQcXZ7lm35t29
P5tcbfDrQs3z4g43zrLRO5M68m91xP7xcHY0uLuSYUSMFIrUbaEVSVVewFY4tskjPYecoWT
uLV0deSJilKpfSTVyekbzGXO2ejhIPxsE5cvPVNPt5AoJ6KIdvWMezUHz+KQt3uVuJEHpZkU
QhEfLrWAdJ2TwE++na2G3GI8BqlSOB+KRl3rz19/9nqpE87c/IWsscSfOQLemzwd/Z3DZfn
ioKB/tFsZWLndqdNq5XmDuRvRN2+EVMT8QFYEq1c+mNhsOIeFCjo8JOOXPG3F+r6h0kXN
M4zjRtgN/qSYRAycXluqKozAIMgr5qemW1UItwCyqJu1cDMLuKgkSq9XXA3Cru6PVPF74D1
t8l2IvV2HWmxL2PP4RdIXa5Ofb1sCLc6AUZ9opLGhwYHt7S3PnxXzKoYsMJwoFm7nGqjKp
J7S9e0iRTMUqY7fOgSQALLw+hsac7hhNCUtB3/xEhvfJ7Y4b1Xj26jWJAujEnHgF+DUJQHvX
hkLl7Rr2dbCPJu/8hDMOKdfz4QJXAQSbCJyA4MrJLXn4UZLpgwMeIVMddvloO4dZatrxQT9m
ZQtqvow5jKcpUKhtxqqf7M4MFDMOEvQdIT3U8WRsbjk1lT4UajljxyTa9TSF9sCid1BH/O3Hq
YyJtfpDcr7QxqHXr9AZYtHbO93DX/I82bQ3mcCco</p>

<p><strong>DNS XID</strong>: 04d8</p>

<p><strong>Getting To File This Week&#8217;s Front Page Security Story Before Changing Out Of Your Pajamas</strong>: Priceless.</p>

<p>There are some vulnerabilities money can&#8217;t buy. For everything else:
there&#8217;s the DNS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1089/dan-kaminsky-could-have-made-hundreds-of-thousands-of-dollars-with-this-dns-flaw/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hello! A self introduction by Chris Rohlf</title>
		<link>http://www.matasano.com/log/1088/hello-a-self-introduction-by-chris-rohlf/</link>
		<comments>http://www.matasano.com/log/1088/hello-a-self-introduction-by-chris-rohlf/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 16:10:13 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
		
		<category><![CDATA[Feature]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1088</guid>
		<description><![CDATA[Hello! My name is Chris Rohlf and I just joined the Matasano team. I will be working on various different client projects from the NYC office. I have spent the last 5 years in the security world working on various things from R&#38;D to operations at both government and corporate organizations. Most of my interest [...]]]></description>
			<content:encoded><![CDATA[<p>Hello! My name is Chris Rohlf and I just joined the Matasano team. I will be working on various different client projects from the NYC office. I have spent the last 5 years in the security world working on various things from R&amp;D to operations at both government and corporate organizations. Most of my interest and work has revolved around reverse engineering, and vulnerability discovery on different platforms. Some of you may have read my personal blog in the past [<a href="http://em386.blogspot.com">EM_386</a>] where I blog about <a href="http://em386.blogspot.com/2007/05/its-easy-to-overlook-some-bugs.html">reversing</a>, <a href="http://em386.blogspot.com/2007/11/your-favorite-better-than-c-scripting.html">vulnerabilities</a>, <a href="http://em386.blogspot.com/2008/06/bitstruct-is-great.html">programming</a> and my general security related <a href="http://em386.blogspot.com/2007/02/quiet-reporting-of-loud-vulnerabilities.html">opinions</a>.</p>

<p>Most recently I worked in an operational role where I got to see first hand the security threats and challenges that a large enterprise faces every day. But now I look forward to putting my prior research experience to work at Matasano.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1088/hello-a-self-introduction-by-chris-rohlf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CitySec Updates And Now More Ways To Stalk Us!</title>
		<link>http://www.matasano.com/log/1087/citysec-updates-and-now-more-ways-to-stalk-us/</link>
		<comments>http://www.matasano.com/log/1087/citysec-updates-and-now-more-ways-to-stalk-us/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 01:11:46 +0000</pubDate>
		<dc:creator>Dave G.</dc:creator>
		
		<category><![CDATA[Citysec]]></category>

		<category><![CDATA[Matasano]]></category>

		<category><![CDATA[NYSec]]></category>

		<category><![CDATA[Navel Gazing]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1087</guid>
		<description><![CDATA[
STLSec.  Shawn @ Agurasec yelled at me for not letting everyone know that St. Louis has an active CitySec meetup:

The next STLSec is July 10 @ the Fox and Hound. Be there or be square.


We had a great crowd our second time out, about 15-20 folks, roughly the
same as the first one, with a [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li><strong>STLSec</strong>.  Shawn @ Agurasec yelled at me for not letting everyone know that St. Louis has an active <A HREF="http://www.citysec.org">CitySec</A> meetup:
<BLOCKQUOTE>
The next STLSec is July 10 @ the Fox and Hound. Be there or be square.</li>
</ol>

<p>We had a great crowd our second time out, about 15-20 folks, roughly the
same as the first one, with a number of new faces. That&#8217;s VERY
impressive considering that CITYSec groups in cities three times our
size get less turnout than that&#8230; Cool, huh?</p>

<p>If you haven&#8217;t came out yet, please do. CitySec is what you make it, so
drop by, have a few beers and help us all figure out why we&#8217;re all crazy
enough to do this crap for a living. Plus, beer. I mentioned that, right?</p>

<p>Directions, as always, at http://www.stlsec.org
</BLOCKQUOTE></p>

<ol>
<li><strong>NYSEC.</strong>  The next <A HREF="http://www.sockpuppet.org/nysec">NYSEC</A> will be on July 15th.  </li>
<li><p><strong>LinkedIn.</strong>  <A HREF="http://www.linkedin.com/e/gis/132361/18D1997AF7B4">STLSec</A>, <A HREF="http://www.linkedin.com/e/gis/122279/537A0B0B6FF8">NYSEC</A> and <A HREF="">CHISEC</A> all have LinkedIn groups.  </p></li>
<li><p><strong>Twitter.</strong>  Matasano has a corp. <A HREF="http://twitter.com/matasano">twitter</A> account.  How could you not want to see us have to communicate in 140 characters or less?!</p></li>
</ol>

<p>Finally, if you are in the US, enjoy the long weekend.  If you aren&#8217;t, enjoy the normal weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1087/citysec-updates-and-now-more-ways-to-stalk-us/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby for Pentesters #1: Use Modules For Lists Of Constants</title>
		<link>http://www.matasano.com/log/1084/ruby-for-pentesters-1-use-modules-for-lists-of-constants/</link>
		<comments>http://www.matasano.com/log/1084/ruby-for-pentesters-1-use-modules-for-lists-of-constants/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 21:03:30 +0000</pubDate>
		<dc:creator>Thomas Ptacek</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1084</guid>
		<description><![CDATA[Almost 2 years ago, Dino declared Python to be the &#8220;lingua-franca of over-the-hill hackers&#8221;, boldly asserting that 5 out of 6 security hackers under the age of 30 preferred Ruby instead. Being 30 at the time, I was an easy psychological target for this argument. I made the switch and haven&#8217;t regretted it. You can [...]]]></description>
			<content:encoded><![CDATA[<p>Almost 2 years ago, Dino declared Python to be the <a href="http://www.matasano.com/log/421/python-is-the-lingua-franca-of-over-the-hill-hackers/">&#8220;<em>lingua-franca</em> of over-the-hill hackers&#8221;</a>, boldly asserting that 5 out of 6 security hackers under the age of 30 preferred Ruby instead. Being 30 at the time, I was an easy psychological target for this argument. I made the switch and haven&#8217;t regretted it. You can tell me all you want that &#8220;named nested functions are just as good as lambdas&#8221;, or that &#8220;you can fake Ruby blocks with a for loop and a generator&#8221;. Ruby is just nicer to write testing code in, and makes me feel at least 2 years younger and less experienced than I really am. Thanks, Ruby!</p>

<p>I&#8217;ve been meaning to write a long post about our house Ruby style, and some of the Ruby tips and tricks we&#8217;ve picked up along the way. But every time I sit down to write it, that post starts sounding a lot like work. So instead, I&#8217;d like to inaugurate a new series of much easier posts: <strong>Ruby for Pen-testers</strong>. </p>

<p>Where was I?</p>

<h2>1. Use Modules For Lists Of Constants</h2>

<p>If you test protocols or C code, you run into lists of magic numbers all the time. For example, here&#8217;s a bit of ptrace(2):</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="co2">#define PT_TRACE_ME &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; /* child declares it&#8217;s being traced */</span><br />
<span class="co2">#define PT_READ_I &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; /* read word in child&#8217;s I space */ &nbsp;</span><br />
<span class="co2">#define PT_READ_D &nbsp; &nbsp; &nbsp; 2 &nbsp; &nbsp; &nbsp; /* read word in child&#8217;s D space */</span><br />
<span class="co2">#define PT_READ_U &nbsp; &nbsp; &nbsp; 3 &nbsp; &nbsp; &nbsp; /* read word in child&#8217;s user structure */</span><br />
<span class="co2">#define PT_WRITE_I &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; &nbsp; /* write word in child&#8217;s I space */</span><br />
<span class="co2">#define PT_WRITE_D &nbsp; &nbsp; &nbsp;5 &nbsp; &nbsp; &nbsp; /* write word in child&#8217;s D space */</span><br />
<span class="co2">#define PT_WRITE_U &nbsp; &nbsp; &nbsp;6 &nbsp; &nbsp; &nbsp; /* write word in child&#8217;s user structure */</span><br />
<span class="co2">#define PT_CONTINUE &nbsp; &nbsp; 7 &nbsp; &nbsp; &nbsp; /* continue the child */</span><br />
<span class="co2">#define PT_KILL &nbsp; &nbsp; &nbsp; &nbsp; 8 &nbsp; &nbsp; &nbsp; /* kill the child process */</span></div></div>

<p>This is gross, but it&#8217;s C code, so you give them a break. But here&#8217;s some code from Pedram&#8217;s PyDbg:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;">TH32CS_SNAPHEAPLIST = 0x00000001<br />
TH32CS_SNAPPROCESS &nbsp;= 0x00000002<br />
TH32CS_SNAPTHREAD &nbsp; = 0x00000004<br />
TH32CS_SNAPMODULE &nbsp; = 0x00000008<br />
TH32CS_INHERIT &nbsp; &nbsp; &nbsp;= 0x80000000</div></div>

<p>Now, Pedram does have the excuse of writing in Python. But here&#8217;s Ruby-MySql:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;">COM_SLEEP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span class="nu0">0</span><br />
&nbsp; COM_QUIT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span class="nu0">1</span><br />
&nbsp; COM_INIT_DB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span class="nu0">2</span><br />
&nbsp; COM_QUERY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span class="nu0">3</span></div></div>

<p>This code has no excuse. (<a href="http://www.github.com/tqbf/asymy">Here&#8217;s a rewrite that is much faster</a>). Now, let&#8217;s look at net-ssh; if you haven&#8217;t read Jamis&#8217; net-ssh code, you shouldn&#8217;t write any more packet processing code until you do.</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="kw1">module</span> Constants<br />
&nbsp; &nbsp; <span class="co1"># Transport layer generic messages</span><br />
&nbsp; &nbsp; DISCONNECT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span class="nu0">1</span><br />
&nbsp; &nbsp; IGNORE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span class="nu0">2</span><br />
&nbsp; &nbsp; UNIMPLEMENTED &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span class="nu0">3</span><br />
&nbsp; &nbsp; DEBUG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span class="nu0">4</span><br />
&nbsp; &nbsp; <span class="co1"># &#8230;</span><br />
<span class="kw1">end</span></div></div>

<p>Getting closer. But not there yet. Here&#8217;s an even better way:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="kw1">module</span> EFlags<br />
&nbsp; &nbsp; CARRY = <span class="br0">&#40;</span><span class="nu0">1</span>&lt;&lt; <span class="nu0">0</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; X0 = <span class="br0">&#40;</span><span class="nu0">1</span>&lt;&lt; <span class="nu0">1</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; PARITY = <span class="br0">&#40;</span><span class="nu0">1</span>&lt;&lt; <span class="nu0">2</span><span class="br0">&#41;</span> <br />
&nbsp; &nbsp; <span class="co1"># &#8230;</span><br />
&nbsp; &nbsp; VINT = <span class="br0">&#40;</span><span class="nu0">1</span>&lt;&lt; <span class="nu0">19</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; VINTPENDING = <span class="br0">&#40;</span><span class="nu0">1</span>&lt;&lt; <span class="nu0">20</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; CPUID = <span class="br0">&#40;</span><span class="nu0">1</span>&lt;&lt; <span class="nu0">21</span><span class="br0">&#41;</span><br />
<span class="kw1">end</span></div></div>

<p>That&#8217;s right: one module per set of constants. In other words, substitute &#8220;module&#8221; for &#8220;enum&#8221;. This has many benefits:</p>

<ol>
<li><p>It&#8217;s clean. You can immediately find all the related magic numbers, both from the list, and
by looking at code that uses the magic numbers &#8212;- you see Ragweed::EFlags::CARRY, you know to look 
for &#8220;EFlags&#8221;.</p></li>
<li><p>Modules come with special bonus features. </p></li>
</ol>

<p>For instance:</p>

<div class="codesnip-container" ><div class="codesnip" style="font-family: monospace;"><span class="kw1">class</span> <span class="kw1">Module</span><br />
&nbsp; &nbsp; <span class="kw1">def</span> to_name_hash<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">@name_hash</span> ||= constants.<span class="me1">map</span> <span class="br0">&#123;</span>|k| <span class="br0">&#91;</span>k.<span class="me1">intern</span>, const_get<span class="br0">&#40;</span>k.<span class="me1">intern</span><span class="br0">&#41;</span><span class="br0">&#93;</span><span class="br0">&#125;</span>.<span class="me1">to_hash</span><br />
&nbsp; &nbsp; <span class="kw1">end</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">def</span> to_value_hash<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">@key_hash</span> ||= constants.<span class="me1">map</span> <span class="br0">&#123;</span>|k| <span class="br0">&#91;</span>const_get<span class="br0">&#40;</span>k.<span class="me1">intern</span><span class="br0">&#41;</span>, k.<span class="me1">intern</span><span class="br0">&#93;</span><span class="br0">&#125;</span>.<span class="me1">to_hash</span><br />
&nbsp; &nbsp; <span class="kw1">end</span><br />
<span class="kw1">end</span><br />
<br />
EFlags.<span class="me1">to_value_hash</span><span class="br0">&#91;</span><span class="nu0">1</span> &lt;&lt; <span class="nu0">19</span><span class="br0">&#93;</span> <span class="co1"># =&gt; :VINT</span></div></div>

<p>&#8230; which is super nice when you&#8217;re printing out the contents of packets.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1084/ruby-for-pentesters-1-use-modules-for-lists-of-constants/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Matasano&#8217;s Playbook: Available Now!</title>
		<link>http://www.matasano.com/log/1081/matasanos-playbook-available-now/</link>
		<comments>http://www.matasano.com/log/1081/matasanos-playbook-available-now/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 20:28:19 +0000</pubDate>
		<dc:creator>Max Caceres</dc:creator>
		
		<category><![CDATA[Matasano]]></category>

		<guid isPermaLink="false">http://www.matasano.com/log/?p=1081</guid>
		<description><![CDATA[We are very pleased to announce the availability of Matasano&#8217;s Playbook!



What is Playbook?

Playbook is a web-based command center for network firewalls. From a single console, Playbook allows firewalls teams to search firewall rulesets, design access rules with full change tracking, and push them out to one, ten or one hundred devices with a single click.

Playbook [...]]]></description>
			<content:encoded><![CDATA[<p>We are very pleased to announce the availability of Matasano&#8217;s <a href="http://playbook.matasano.com">Playbook</a>!</p>

<p style="text-align: center;"><a href="http://www.matasano.com/log/wp-content/uploads/2008/07/playbook.png"><img class="alignnone size-medium wp-image-1082" title="playbook" src="http://www.matasano.com/log/wp-content/uploads/2008/07/playbook.png" alt="" width="192" height="94" /></a></p>

<blockquote>What is Playbook?</blockquote>

<blockquote>Playbook is a web-based command center for network firewalls. From a single console, Playbook allows firewalls teams to search firewall rulesets, design access rules with full change tracking, and push them out to one, ten or one hundred devices with a single click.</blockquote>

<p>Playbook helps organizations with multiple network firewalls to better manage their policies by providing a centralized and version controlled repository of rulesets, which can be easily browsed or searched via the web. Network operators can review all recent rule changes affecting the London branch, document a recently provisioned firewall at corporate offices, and rollback to the last known version of rules for the North-East group after an update gone wrong with only a couple of clicks and without having to log into 50 different devices. </p>

<p>Playbook takes advantage of an expressive wiki engine to help you document rulesets, protocols, and your network infrastructure, so that you not only have a complete audit trail of all your changes, but you also know why those changes are there in the first place.</p>

<p>There is more information at the product&#8217;s <a href="http://playbook.matasano.com">official website</a>. We&#8217;ll keep you posted as Playbook continues to evolve.</p>

<p>If you currently manage multiple firewalls and are are interested in learning more about Playbook we&#8217;d love to talk with you. Shoot us an <a href="mailto:playbook@matasano.com">e-mail</a> or give us a call at 1-888-677-0666 x7529 (PLAY).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matasano.com/log/1081/matasanos-playbook-available-now/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
