views:

1075

answers:

12

First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm confortable with all of them, but the problem is that I can't focus just on one.

If for example , I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.

Right now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate ?

Again , I don't want to cause a flame-war or any trouble, I just want honest oppinions from scripters that know what they're doing.

One more thing: maybe some of you will ask "Why settle on one language?". To answer this: I would like to choose only one language, in order to try to master it.

Thanks !

+3  A: 

That depends on the implementation, if it will be distributed I would go with Java, seeing as you know that, because of its portability. If it is just for internal use, or will be used in semi-controlled environments, then go with whatever you are the most comfortable maintaining, and whichever has the best long-term outlook.

Now to just answer the question, I would go with Perl, but I'm a linux guy so I may be a bit biased in this.

Unkwntech
A: 

Well, what kind of exploits are you thinking about? If you want to write something that needs low level stuff (ptrace, raw sockets, etc.) then you'll need to learn C. But both Perl and Python can be used. The real question is which one suits your style more?

As for toolmaking, Perl has good string-processing abilities, is closer to the system, has good support, but IMHO it's very confusing. I prefer Python: it's a clean, easy to use, easy to learn language with good support (complete language/lib reference, 3rd party libs, etc.). And it's (strictly IMHO) cool.

terminus
I'm a believer in C, but you don't need it for ptrace/win32 (PyDbg), and you don't need it for raw packets (IMpacket, pcapy, ruby-pcap).
tqbf
+1  A: 

All of them should be sufficient for that. Unless you need some library that is only available in one language, I'd let personal preference guide me.

Leon Timmermans
+1  A: 

If you're looking for a scripting language that will play well with Java, you might want to look at Groovy. It has the flexibility and power of Perl (closures, built in regexes, associative arrays on every corner) but you can access Java code from it thus you have access to a huge number of libraries, and in particular the rest of the system you're developing.

Rachel
For what it's worth, you can get direct access to Java libraries through JRuby and Jython, both of which are the second most popular implementations of their respective languages.
tqbf
A: 

My personal preference for scripting is Python. I find the syntax (whitespace sensitive) to make things more readable. I'm not a huge fan of Ruby's syntax.

Ruby is more functional programmer friendly with better support for that style of programming.

Python is generally faster but this is changing.

mbowcock
There is so much wrong with what you just said there.
+1  A: 

metasploit is a great framework for penetration testing. It's mainly written in Ruby, so if you know that language well, maybe you can hook in there. However, to use metasploit, you don't need to know any language at all.

jkramer
umm, my copy of metasploit is perl, not ruby... are you talking about plugins?
Tim Howland
heh, check it out, they rewrote it- my mistake!
Tim Howland
+2  A: 

Speaking as a CEH, learn the CEH material first. This will expose you to a variety of tools and platforms used to mount various kinds of attacks. Once you understand your target well, look into the capabilities of the tools and platforms already available (the previously mentioned metasploit framework is very thorough and robust). How can they be extended to meet your needs? Once you know that, you can compare the capabilities of the languages.

I would also recommend taking a look at the tools available on the BackTrack distro.

573f
+6  A: 

[Disclaimer: I am primarily a Perl programmer, which may be colouring my judgement. However, I am not a particularly tribal one, and I think on this particular question my argument is reasonably objective.]

Perl was designed to blend seamlessly into the Unix landscape, and that is why it feels so alien to people with a mainly-OO background (particularly the Java school of OOP). For that reason, though, it’s incredibly widely installed on machines with any kind of Unixoid OS, and many vendor system utilities are written in it. Also for the same reason, servers that have neither Python nor Ruby installed are still likely to have Perl on them, again making it important to have some familiarity with. So if your CEH activity includes extensive activity on Unix, you will have to have some amount of familiarity with Perl anyway, and you might as well focus on it.

That said, it is largely a matter of preference. There is not much to differentiate the languages; their expressive power is virtually identical. Some things are a little easier in one of the languages, some a little easier in another.

In terms of libraries I do not know how Ruby and Python compare against each other – I do know that Perl has them beat by a margin. Then again, sometimes (particularly when you’re looking for libraries for common needs) the only effect of that is that you get deluged with choices. And if you are only looking to do things in some particular area which is well covered by libraries for Python or Ruby, the mass of other stuff on CPAN isn’t necessarily an advantage. In niche areas, however, it matters, and you never know what unforeseen need you will eventually have (err, by definition).

For one-liner use on the command line, Python is kind of a non-starter.

In terms of interactive interpreter environment, Perl… uhm… well, you can use the debugger, which is not that great, or you can install one from CPAN, but Perl doesn’t ship a good one itself.

So I think Perl does have a very slight edge for your needs in particular, but only just. If you pick Ruby you’ll probably not be much worse off at all. Python might inconvenience you a little more noticeably, but it too is hardly a bad choice.

Aristotle Pagaltzis
+3  A: 

I could make an argument for all three :-)

Perl has all of CPAN - giving you a huge advantage in pulling together functionality quickly. It also has a nice flexible testing infrastructure that means you can plug lots of different automated testing styles (including tests in other languages) in the same framework.

Ruby is a lovely language to learn - and lacks some of the cruft in Perl 5. If you're doing web based testing it also has the watir library - which is trez useful (see http://wtr.rubyforge.org/)

Python - nice language and (while it's not to my personal preference) some folk find the way its structured easier to get to grips with.

Any of them (and many others) would be a great language to learn.

Instead of looking at the language - I'd look at your working environment. It's always easier to learn stuff if you have other folk around who are doing similar stuff. If you current dev/testing folk are already focussed on one of the above - I'd go for that. If not, pick the one that would be most applicable/useful to your current working environment. Chat to the rest of your team and see what they think.

adrianh
+1  A: 

If you plan on using Metasploit for pentesting and exploit development I would recomend ruby as mentioned previously metasploit is written in ruby and any exploit/module development you may wish to do will require ruby.

If you will be using Immunity CANVAS for pen testing then for the same reasons I would recomend Python as CANVAS is written in python. Also allot of fuzzing frameworks like Peach and Sulley are written in Python.

I would not recomendd Perl as you will find very little tools/scripts/frameworks related to pen testing/fuzzing/exploits/... in perl.

As your question is "tool writing and exploit development" I would recomend Ruby if you choose metasploit or python if you choode CANVAS.

hope that helps :)

QAZ
+12  A: 

You probably want Ruby, because it's the native language for Metasploit, which is the de facto standard open source penetration testing framework. Ruby's going to give you:

  • Metasploit's framework, opcode and shellcode databases

  • Metasploit's Ruby lorcon bindings for raw 802.11 work

  • Metasploit's KARMA bindings for 802.11 clientside redirection

  • Libcurl and net/http for web tool writing

  • EventMachine for web proxy and fuzzing work (or RFuzz, which extends the well-known Mongrel webserver)

  • Metasm for shellcode generation

  • Distorm for x86 disassembly

  • BinData for binary file format fuzzing.

Second place here goes to Python. There are more pentesting libraries available in Python than in Ruby (but not enough to offset Metasploit). Commercial tools tend to support Python as well --- if you're an Immunity CANVAS or CORE Impact customer, you want Python. Python gives you:

  • Twisted for network access

  • PaiMei for program tracing and programmable debugging

  • CANVAS and Impact support

  • Dornseif's firewire libraries for remote debugging

  • Ready integration with WinDbg for remote Windows kernel debugging (there's still no good answer in Ruby for kernel debugging, which is why I still occasionally use Python).

  • Peach Fuzzer and Sully for fuzzing

  • SpikeProxy for web penetration testing (also, OWASP Pantera).

Unsurprisingly, a lot of web work uses Java tools. The de facto standard web pentest tool is Burp Suite, which is a Java swing app. Both Ruby and Python have Java variants you can use to get access to tools like that. Also, both Ruby and Python offer:

  • Direct integration with libpcap for raw packet work

  • OpenSSL bindings for crypto

  • IDA Pro extensions

  • Mature (or at least reasonable) C foreign function interfaces for API access

  • WxWindows for UI work, and decent web stacks for web UIs

You're not going to go wrong with either language, though for mainstream pentest work, Metasploit probably edges out all the Python benefits, and at present, for x86 reversing work, Python's superior debugging interfaces edge out all the Ruby benefits.

Also: it's 2008. They're not "scripting languages". They're programming languages. ;)

tqbf
Some links for all the tools and libraries would be nice, so we don't have to "google" them. Thank you for your comprehensive answer.
Cristian Ciupitu
A: 

If you are interested in CEH, I'd take a look at Grey Hat Python. It shows some stuff that is pretty interesting and related.

That being said, any language should be fine.

samoz