<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Matasano Chargen - Latest Comments in Ruby for Pentesters #1: Use Modules For Lists Of Constants</title><link>http://matasanochargen.disqus.com/</link><description></description><language>en</language><lastBuildDate>Tue, 22 Jul 2008 00:37:22 -0000</lastBuildDate><item><title>Re: 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/#comment-2324234</link><description>Don't get the argument -- I'm not a computer scientist.  I'm just a hacker (the good definition) that needs to exploit something.&lt;br&gt;&lt;br&gt;Perl has Net::RawIP to help&lt;br&gt;Python has scapy&lt;br&gt;Ruby has scruby&lt;br&gt;C has libnet and libdnet&lt;br&gt;&lt;br&gt;Python is prob the best IDA Pro automation language (IdaRub has not been updated in forever).  Python also is handy for the Immunity debugger. And a bunch of other good RE tools are in python. &lt;br&gt;&lt;br&gt;Python and Ruby do not have libwhisker so perl has to stick around.&lt;br&gt;&lt;br&gt;&lt;br&gt;Just use what works and learn them all like i had to.....&lt;br&gt;&lt;br&gt;peace out.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Asted Habibbi</dc:creator><pubDate>Tue, 22 Jul 2008 00:37:22 -0000</pubDate></item><item><title>Re: 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/#comment-2324233</link><description>Great, I can't wait to see more in this series!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stephen Reese</dc:creator><pubDate>Sun, 06 Jul 2008 21:27:16 -0000</pubDate></item><item><title>Re: 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/#comment-2324232</link><description>Syntactic sugar causes cancer of the semicolon.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Phill</dc:creator><pubDate>Sat, 05 Jul 2008 23:32:25 -0000</pubDate></item><item><title>Re: 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/#comment-2324231</link><description>Nothing. Even C has this feature. Just use a hash table library to store the enum values!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Thomas Ptacek</dc:creator><pubDate>Sat, 05 Jul 2008 17:49:53 -0000</pubDate></item><item><title>Re: 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/#comment-2324230</link><description>What's wrong with dicts?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt</dc:creator><pubDate>Sat, 05 Jul 2008 15:23:52 -0000</pubDate></item><item><title>Re: 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/#comment-2324226</link><description>This code I wrote ages ago might also be somewhat interesting:&lt;br&gt;&lt;br&gt;&lt;a href="http://flgr.0x42.net/code/enum.rb" rel="nofollow"&gt;http://flgr.0x42.net/code/enum.rb&lt;/a&gt;&lt;br&gt;&lt;br&gt;The main benefit being that inspection of an enum member (wherever it appears) will show you the name instead of the value.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Florian Gross</dc:creator><pubDate>Sat, 05 Jul 2008 06:52:20 -0000</pubDate></item><item><title>Re: 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/#comment-2324228</link><description>in python all class data is stored in a dict :(&lt;br&gt;&lt;br&gt;class C:&lt;br&gt;  pass&lt;br&gt;&lt;br&gt;C.a = 0&lt;br&gt;C.b = 1&lt;br&gt;C.__dict__&lt;br&gt;&lt;br&gt;{'a': 0, '__module__': '__main__', 'b': 1, '__doc__': None}</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Thomas</dc:creator><pubDate>Sat, 05 Jul 2008 05:32:05 -0000</pubDate></item><item><title>Re: 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/#comment-2324229</link><description>When you want to do equivalent stuff in Python, use a class and a metaclass.&lt;br&gt;&lt;br&gt;---8&amp;lt;---&lt;br&gt;class MetaEnum(type):&lt;br&gt;    def __new__(cls, name, bases, classdict):&lt;br&gt;        classdict['to_name_hash'] = \&lt;br&gt;            dict([(enum, val) for enum, val in classdict.iteritems()&lt;br&gt;                   if not enum.startswith('__')])&lt;br&gt;        classdict['to_value_hash'] = \&lt;br&gt;            dict([(val, enum) for enum, val in classdict['to_name_hash'].iteritems()])&lt;br&gt;        return type.__new__(cls, name, bases, classdict)&lt;br&gt;&lt;br&gt;class EFlags(object):&lt;br&gt;    __metaclass__ = MetaEnum&lt;br&gt;    CARRY = (1&amp;lt;&amp;lt; 0)&lt;br&gt;    X0 = (1&amp;lt;&amp;lt; 1)&lt;br&gt;    PARITY = (1&amp;lt;&amp;lt; 2) &lt;br&gt;    # ...&lt;br&gt;    VINT = (1&amp;lt;&amp;lt; 19)&lt;br&gt;    VINTPENDING = (1&amp;lt;&amp;lt; 20)&lt;br&gt;    CPUID = (1&amp;lt;&amp;lt; 21)&lt;br&gt;&lt;br&gt;EFlags.to_name_hash['VINT'] # 524288&lt;br&gt;EFlags.to_value_hash[1 &amp;lt;&amp;lt; 19] # 'VINT'&lt;br&gt;---8&amp;lt;---&lt;br&gt;&lt;br&gt;Oh, I used 2 dicts. So I got 2x0 = 0 credit :'(</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">hidden_pythonista</dc:creator><pubDate>Sat, 05 Jul 2008 04:26:36 -0000</pubDate></item><item><title>Re: 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/#comment-2324227</link><description>class Flags(type):&lt;br&gt;    def __new__(cls, clsname, clsbases, clsdict):&lt;br&gt;        clsdict['to_value_hash'] = clsdict&lt;br&gt;        clsdict['to_name_hash'] = dict([ (y, x) for x, y in clsdict.iteritems() if x.isupper() ])&lt;br&gt;        return type.__new__(cls, clsname, clsbases, clsdict)&lt;br&gt;&lt;br&gt;class EFlags:&lt;br&gt;    __metaclass__ = Flags&lt;br&gt;    &lt;br&gt;    CARRY = (1&amp;lt;&amp;lt; 0)&lt;br&gt;    X0 = (1&amp;lt;&amp;lt; 1)&lt;br&gt;    PARITY = (1&amp;lt;&amp;lt; 2)&lt;br&gt;    # ...&lt;br&gt;    VINT = (1&amp;lt;&amp;lt; 19)&lt;br&gt;    VINTPENDING = (1&amp;lt;&amp;lt; 20)&lt;br&gt;    CPUID = (1&amp;lt;&amp;lt; 21)&lt;br&gt;&lt;br&gt;if __name__ == '__main__':&lt;br&gt;    print 'CARRY', EFlags.CARRY&lt;br&gt;    print 'CPUID', EFlags.to_value_hash['CPUID']&lt;br&gt;    print EFlags.to_name_hash[1 &amp;lt;&amp;lt; 19]</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">snake in the grass</dc:creator><pubDate>Sat, 05 Jul 2008 01:00:41 -0000</pubDate></item><item><title>Re: 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/#comment-2324225</link><description>What's the equivalent mechanism in Python? You get no credit for using a dict.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Thomas Ptacek</dc:creator><pubDate>Fri, 04 Jul 2008 21:10:21 -0000</pubDate></item><item><title>Re: 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/#comment-2324237</link><description>Python and Perl have equivalent mechanisms.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Person</dc:creator><pubDate>Fri, 04 Jul 2008 17:28:31 -0000</pubDate></item><item><title>Re: 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/#comment-2324224</link><description>Nice catch, thanks!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Thomas Ptacek</dc:creator><pubDate>Fri, 04 Jul 2008 01:37:12 -0000</pubDate></item><item><title>Re: 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/#comment-2324236</link><description>I use this all the time. In general, I'm just a big fan of self-enumerating/annotating code. Saves a lot of time. To do this in C is a little bit of work, but saves a ton of mistakes and also propagates new additions to the enum list automatically. See:&lt;br&gt;&lt;br&gt;&lt;a href="http://labs.mudynamics.com/2007/01/03/enums-strings-and-laziness/" rel="nofollow"&gt;http://labs.mudynamics.com/2007/01/03/enums-str...&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">kowsik</dc:creator><pubDate>Fri, 04 Jul 2008 00:03:57 -0000</pubDate></item><item><title>Re: 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/#comment-2324235</link><description>Your github link is broken, it links to &lt;a href="http://www.matasano.com/log/1084/ruby-for-pentesters-1-use-modules-for-lists-of-constants/www.github.com/tqbf/asymy" rel="nofollow"&gt;http://www.matasano.com/log/1084/ruby-for-pente...&lt;/a&gt;&lt;br&gt;&lt;br&gt;Just wanted to let you know :)&lt;br&gt;&lt;br&gt;I &amp;lt;3 Ruby</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lee Hinman</dc:creator><pubDate>Thu, 03 Jul 2008 17:59:06 -0000</pubDate></item></channel></rss>