
In 2011, I (Stephen A. Ridley) don’t plan on attending too many conferences that require far away travel for many reasons. 1) My work isn’t as interesting anymore ;-( and 2) I can’t travel as easily with Sammiches. With Boston being in the northeast (close to us) we decided we’d try SourceBoston out for the first time. We’ve known the conference organizers from past meetings and conferences, but this is the first time we’d ever attended any of the Source conferences.
SourceBoston was held at the (dog friendly 🙂 Boston Seaport Hotel, a surprisingly fancy venue that was on the waterfront and adjacent to The World Trade Center of Boston. Unlike many Infosec conferences we’ve attended, SourceBoston did a good job of intermingling “suits” with “grunts”. In other words, the attendees and speakers hailed from many different levels in their organizations (with a healthy sprinkling of academic types mixed in). There was also quality representation from the different niches in the Information Security community (from “hardware hacking” to “management and policy”). In short, its a cool little conference.
My talk at Source Boston 2011 was entitled “GreyHat Ruby”. The talk was on the many ways that a devout Python coder has come to find Ruby very useful for Information Security work. Here is a bullet list from a section of the presentation entitled “12 Good Reasons for C/C++/Python coders” (see examples/comparisons/screenshots in the slides!):
- Ruby has an equally useful Interactive Interpreter.
- Ruby has “real” case/switch statements
- Ruby has C style ternary statements
- Ruby has “public” and “private” namespaces
- Ruby (like C++ and Java) let’s you define classes in “piecemeal” (split that class def across files!).
- Ruby has a “container” class called “module” that act as namespace “directories” letting you arrange things as you see fit.
- Ruby doesn’t automatically make a namespace entry for an “included” file.
- Ruby has better “sprintf” functionality.
- Ruby has strong OOP paradigm and convenient “getter/setter” syntax.
- You can modify Ruby Class definitions “on the fly” without cumbersome “get_attr”/”set_attr”.
- Ruby is a “functional” programming language. It has “blocks” and “anonymous functions” (not kludgy lambdas).
- Lots of other neat things like send() and __END__.
After that list, I dive into some of the specific things useful for Information Security professionals:
- Accessing “foreign” functions: getting your Ruby code to call into DLLs and shared objects.
- Existing pure ruby process debuggers and hit-tracers
- Using JRuby to talk to Java RMI services
- Ruby and IDA
- Build quick user-friendly CLIs (like Python’s Cmd module).
- Plugging Ruby into Burp
- Using Ruby’s Win32OLE/Win32API/RubyDL to “script” mouse clicks and keyboard actions on Windows via User32. (demo video here)
- Complete browser automation (Firefox, IE, Safari) allowing you to “script” user interaction with the browser. (Web pen-testing, QA, or fuzzing!)
- Writing distributed code with Drb and Rinda. (Don’t bother with socket code. Or, build a distributed fuzz farm!)
- Using Ruby to create “Domain Specific Languages” for your tasks (like fuzzing ;-).
Sean
April 28, 2011
How can you not mention the Metasploit Framework in a talk about Ruby for security research?
s7ephen
April 28, 2011
I thought it went without saying! Metasploit is great, but I felt it would overshadow everything else as an incentive to learn Ruby. I wanted these bits to stand on their own as incentives to check Ruby out.
Sean
April 28, 2011
Fair enough 😛
Gabe
April 28, 2011
I really enjoyed this talk at Source. Just found your article on Reddit! We talked briefly at the Pwnie Express table but I’d love to see another Ruby talk you present.. Any chance of a grey hat ruby book??
s7ephen
April 28, 2011
Gabe! I remember you, thanks so much for the great feedback…I am glad you found it interesting and useful…thats what I want more, for people to find it useful. Also thanks for the book recommendation, I will have to check it out! Yea using Ruby for task specific DSLs is pretty bling. A great example is Chef: http://en.wikipedia.org/wiki/Chef_(software)
Gabe
April 28, 2011
Also, @ Domain Specific Languages: This Book by Martin Fowler is an excellent resource. Its not all Ruby (lots of Java and other language examples) but it is a great, high level look at DSLs. We used SinatraRB for the PwnPlug Configuration utility. Sinatra claims to be a web app DSL but i feel like that might be a bit of an overstatement. Anyway, I really agreed with your point about using Ruby to do task specific DSLs…