<p>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 comfortable with all of them, but the problem is that I can't focus just on one. </p>

<p>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.</p>

<p>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?</p>

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

<p>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.</p>

[{'answer_id': 76441, 'author': 'UnkwnTech', 'author_id': 115, 'author_profile': 'https://Stackoverflow.com/users/115', 'pm_score': 2, 'selected': False, 'text': "<p>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.</p>\n\n<p>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.</p>\n"}, {'answer_id': 76470, 'author': 'terminus', 'author_id': 9232, 'author_profile': 'https://Stackoverflow.com/users/9232', 'pm_score': 0, 'selected': False, 'text': "<p>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?</p>\n\n<p>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.</p>\n"}, {'answer_id': 76495, 'author': 'Leon Timmermans', 'author_id': 4727, 'author_profile': 'https://Stackoverflow.com/users/4727', 'pm_score': 1, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 76508, 'author': 'Rachel', 'author_id': 13138, 'author_profile': 'https://Stackoverflow.com/users/13138', 'pm_score': 1, 'selected': False, 'text': "<p>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. </p>\n"}, {'answer_id': 76546, 'author': 'jkramer', 'author_id': 12523, 'author_profile': 'https://Stackoverflow.com/users/12523', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.metasploit.com/" rel="nofollow noreferrer">metasploit</a> 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 <em>use</em> metasploit, you don\'t need to know any language at all. </p>\n'}, {'answer_id': 76889, 'author': '573f', 'author_id': 13699, 'author_profile': 'https://Stackoverflow.com/users/13699', 'pm_score': 2, 'selected': False, 'text': '<p>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. </p>\n\n<p>I would also recommend taking a look at the tools available on the <a href="http://www.remote-exploit.org/backtrack.html" rel="nofollow noreferrer">BackTrack</a> distro.</p>\n'}, {'answer_id': 77717, 'author': 'Aristotle Pagaltzis', 'author_id': 9410, 'author_profile': 'https://Stackoverflow.com/users/9410', 'pm_score': 3, 'selected': False, 'text': '<p>[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.]</p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>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 <em>other</em> 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).</p>\n\n<p>For one-liner use on the command line, Python is kind of a non-starter.</p>\n\n<p>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.</p>\n\n<p>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 <em>bad</em> choice.</p>\n'}, {'answer_id': 78103, 'author': 'adrianh', 'author_id': 13165, 'author_profile': 'https://Stackoverflow.com/users/13165', 'pm_score': 2, 'selected': False, 'text': '<p>I could make an argument for all three :-)</p>\n\n<p>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.</p>\n\n<p>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 <a href="http://wtr.rubyforge.org/" rel="nofollow noreferrer">http://wtr.rubyforge.org/</a>)</p>\n\n<p>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.</p>\n\n<p>Any of them (and many others) would be a great language to learn.</p>\n\n<p>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.</p>\n'}, {'answer_id': 78106, 'author': 'QAZ', 'author_id': 14260, 'author_profile': 'https://Stackoverflow.com/users/14260', 'pm_score': 2, 'selected': False, 'text': '<p>If you plan on using Metasploit for pen-testing and exploit development I would recommend ruby as mentioned previously Metasploit is written in ruby and any exploit/module development you may wish to do will require ruby.</p>\n\n<p>If you will be using Immunity CANVAS for pen testing then for the same reasons I would recommend Python as CANVAS is written in python. Also allot of fuzzing frameworks like Peach and Sulley are written in Python.</p>\n\n<p>I would not recommend Perl as you will find very little tools/scripts/frameworks related to pen testing/fuzzing/exploits/... in Perl.</p>\n\n<p>As your question is "tool writing and exploit development" I would recommend Ruby if you choose Metasploit or python if you choose CANVAS.</p>\n\n<p>hope that helps :)</p>\n'}, {'answer_id': 78561, 'author': 'tqbf', 'author_id': 5674, 'author_profile': 'https://Stackoverflow.com/users/5674', 'pm_score': 6, 'selected': True, 'text': '<p>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:</p>\n\n<ul>\n<li><a href="http://www.metasploit.com/" rel="noreferrer">Metasploit\'s</a> framework, opcode and shellcode databases</li>\n<li>Metasploit\'s <a href="http://rubyforge.org/projects/ruby-lorcon/" rel="noreferrer">Ruby lorcon</a> bindings for raw 802.11 work.</li>\n<li>Metasploit\'s KARMA bindings for 802.11 clientside redirection.</li>\n<li><a href="http://curl.haxx.se/libcurl/ruby/" rel="noreferrer">Libcurl</a> and net/http for web tool writing.</li>\n<li><a href="http://rubyforge.org/projects/eventmachine" rel="noreferrer">EventMachine</a> for web proxy and fuzzing work (or RFuzz, which extends the well-known Mongrel webserver).</li>\n<li><a href="http://metasm.cr0.org/" rel="noreferrer">Metasm</a> for shellcode generation.</li>\n<li><a href="http://www.ragestorm.net/distorm/" rel="noreferrer">Distorm</a> for x86 disassembly.</li>\n<li><a href="http://blogfranz.blogspot.com/2008/01/bindata-for-ruby-fuzzers.html" rel="noreferrer">BinData</a> for binary file format fuzzing.</li>\n</ul>\n\n<p>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:</p>\n\n<ul>\n<li><a href="http://twistedmatrix.com/trac/" rel="noreferrer">Twisted</a> for network access.</li>\n<li><a href="http://www.openrce.org/downloads/details/208/PaiMei" rel="noreferrer">PaiMei</a> for program tracing and programmable debugging.</li>\n<li>CANVAS and Impact support.</li>\n<li><a href="http://www.matasano.com/log/695/windows-remote-memory-access-though-firewire/" rel="noreferrer">Dornseif\'s</a> firewire libraries for remote debugging.</li>\n<li><a href="http://pydbgeng.sourceforge.net/" rel="noreferrer">Ready integration with WinDbg</a> for remote Windows kernel debugging (there\'s still no good answer in Ruby for kernel debugging, which is why I still occasionally use Python). </li>\n<li><a href="http://peachfuzzer.com/" rel="noreferrer">Peach Fuzzer</a> and Sully for fuzzing.</li>\n<li>SpikeProxy for web penetration testing (also, <a href="http://www.owasp.org/index.php/Category:OWASP_Pantera_Web_Assessment_Studio_Project" rel="noreferrer">OWASP Pantera</a>).</li>\n</ul>\n\n<p>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:</p>\n\n<ul>\n<li>Direct integration with libpcap for raw packet work.</li>\n<li>OpenSSL bindings for crypto.</li>\n<li>IDA Pro extensions.</li>\n<li>Mature (or at least reasonable) C foreign function interfaces for API access.</li>\n<li>WxWindows for UI work, and decent web stacks for web UIs.</li>\n</ul>\n\n<p>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.</p>\n\n<p>Also: it\'s 2008. They\'re not "scripting languages". They\'re programming languages. ;)</p>\n'}, {'answer_id': 3224604, 'author': 'samoz', 'author_id': 39036, 'author_profile': 'https://Stackoverflow.com/users/39036', 'pm_score': 1, 'selected': False, 'text': '<p>If you are interested in CEH, I\'d take a look at <a href="https://rads.stackoverflow.com/amzn/click/com/1593271921" rel="nofollow noreferrer" rel="nofollow noreferrer">Grey Hat Python</a>. It shows some stuff that is pretty interesting and related.</p>\n\n<p>That being said, any language should be fine.</p>\n'}, {'answer_id': 4927367, 'author': 'r3nrut', 'author_id': 373428, 'author_profile': 'https://Stackoverflow.com/users/373428', 'pm_score': 0, 'selected': False, 'text': "<p>I'm with tqbf.  I've worked with Python and Ruby.  Currently I'm working with JRuby.  It has all the power of Ruby with access to the Java libraries so if there is something you absolutely need a low-level language to solve you can do so with a high-level language.  So far I haven't needed to really use much Java as Ruby has had the ability to do everything I've needed as an API tester.</p>\n"}]
['https://Stackoverflow.com/questions/76408', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11234/']