xiv Foreword
apply to assessments. Once you can hook the SQL API, you can easily write a
tool to do anomaly detection against SQL queries, providing your organiza-
tion with a quick fix against a persistent attacker.
Everyone knows that it’s pretty hard to get your security researchers to
work as part of a team. Most security researchers, when faced with any sort of
problem, would like to first rebuild the library they are going to use to attack
the problem. Let’s say it’s a vulnerability in an SSL daemon of some kind. It’s
very likely that your researcher is going to want to start by building an SSL
client, from scratch, because “the SSL library I found was ugly.”
You need to avoid this at all costs. The reality is that the SSL library is
not ugly—it just wasn’t written in that particular researcher’s particular style.
Being able to dive into a big block of code, find a problem, and fix it is the
key to having a working SSL library in time for you to write an exploit while
it still has some meaning. And being able to have your security researchers
work as a team is the key to making the kinds of progress you require. One
Python-enabled security researcher is a powerful thing, much as one Ruby-
enabled one is. The difference is the ability of the Pythonistas to work
together, use old source code without rewriting it, and otherwise operate
as a functioning superorganism. That ant colony in your kitchen has about
the same mass as an octopus, but it’s much more annoying to try to kill!
And here, of course, is where this book helps you. You probably already
have tools to do some of what you want to do. You say, “I’ve got Visual Studio.
It has a debugger. I don’t need to write my own specialized debugger.” Or,
“Doesn’t WinDbg have a plug-in interface?” And the answer is yes, of course
WinDbg has a plug-in interface, and you can use that API to slowly put
together something useful. But then one day you’ll say, “Heck, this would
be a lot better if I could connect it to 5,000 other people using WinDbg and
we could correlate our results.” And if you’re using Python, it takes about
100 lines of code for both an XML-RPC client and a server, and now everyone
is synchronized and working off the same page.
Because hacking is not reverse engineering—your goal is not to come
up with the original source code for the application. Your goal is to have a
greater understanding of the program or system than the people who built it.
Once you have that understanding, no matter what the form, you will be able
to penetrate the program and get to the juicy exploits inside. This means
that you’re going to become an expert at visualization, remote synchroni-
zation, graph theory, linear equation solving, statistical analysis techniques,
and a whole host of other things. Immunity’s decision regarding this has
been to standardize entirely on Python, so every time we write a graph
algorithm, it can be used across all of our tools.
In Chapter 6, Justin shows you how to write a quick hook for Firefox to
grab usernames and passwords. On one hand, this is something a malware
writer would do—and previous reports have shown that malware writers do
use high-level languages for exactly this sort of thing (http://philosecurity.org/
2009/01/12/interview-with-an-adware-author). On the other hand, this is
precisely the sort of thing you can whip up in 15 minutes to demonstrate