Metasploit mailing list archives
module style guide
From: dninja at gmail.com (Robin Wood)
Date: Fri, 17 Jul 2009 16:44:46 +0100
2009/7/17 HD Moore <hdm at metasploit.com>:
On Fri, 17 Jul 2009 03:54:37 -0500, Robin Wood <dninja at gmail.com> wrote:Hi I'm writing a new module, are there any guides on correct code structure, styling etc? I'd rather get this stuff right from the start rather than build the module then re-write it before I submit it.If you follow the structure of a similar module, you should be fine. There is a little bit of information about style/format/mixins on the Wikibooks page[1], but it comes down a few general guidelines: ?* Use hard tab indentations vs spaces for all modules ?* If you are calling a non-standad Ruby library, a load-check on the library should be added, or it should be integrated into the framework as a mixin. ?* Socket calls should go through mixins if possible (tcp/udp/etc), if you need to make sockets by hand, please use the Rex::Socket API and pass in the Context parameter like the following: ? ? ? ? ? ? ? ?csock = Rex::Socket::Tcp.create( ? ? ? ? ? ? ? ? ? ? ? ?'PeerHost' ?=> datastore['RHOST'], ? ? ? ? ? ? ? ? ? ? ? ?'PeerPort' ?=> datastore['RPORT'], ? ? ? ? ? ? ? ? ? ? ? ?'Context' ? => ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'Msf' ? ? ? ?=> framework, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'MsfExploit' => self, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}) ?* All shellcode should be what the user specifies as an option. If you need to embed fixup code (heap cleanup,etc), you can use Prepend/PrependEncoder in the Payload section at the top of the module. ?* All return addresses and target-specific information should be stored in the Targets section of the module header and pulled out at runtime.
I want to add a couple of extra ruby libraries, for my testing I've just dropped them into the lib directory along with all the others. Can I send those along with my module to go in that directory or should I put them into the same directory as my module? They are DHCP tools that could have general use, not just things specific to my module. I'll check out the wiki. Robin
Current thread:
- module style guide Robin Wood (Jul 17)
- module style guide HD Moore (Jul 17)
- module style guide Robin Wood (Jul 17)
- module style guide Jerome Athias (Jul 18)
- New errors - MissingSourceFile custom_require.rb wfdawson at bellsouth.net (Jul 19)
- New errors - MissingSourceFile custom_require.rb HD Moore (Jul 19)
- New errors - no such file to load -- msf/core/exploit/browser_autopwn wfdawson at bellsouth.net (Jul 22)
- New errors - no such file to load -- msf/core/exploit/browser_autopwn egypt at metasploit.com (Jul 22)
- module style guide HD Moore (Jul 17)