Nmap Development mailing list archives

Writing a parser in LUA


From: Ron <ron () skullsecurity net>
Date: Sat, 18 Oct 2008 12:52:33 -0500

Hi guys,

I'm looking at how I can improve the marshalling code for my MSRPC
library. Currently, I'm marshalling parameters manually, but that's
obviously less than ideal. What I'd like to do is take an 'idl' file,
which is a markup file used in Samba, Metasploit (apparently), and other
tools, and generate the packets based on that. Here's an example of an
IDL file:

http://websvn.samba.org/cgi-bin/viewcvs.cgi/branches/SAMBA_4_0/source/librpc/idl/srvsvc.idl?rev=19588&view=markup

One function I'm using, for example, is this:

        /******************/
        /* Function: 0x0f */
        WERROR srvsvc_NetShareEnumAll (
                [in]   [string,charset(UTF16)] uint16 *server_unc,
                [in,out]   uint32 level,
                [in,out,switch_is(level)] srvsvc_NetShareCtr ctr,
                [in]   uint32 max_buffer,
                [out]  uint32 totalentries,
                [in,out]   uint32 *resume_handle
                );

The 'ctr' parameter is this:
        typedef struct {
                uint32 count;
                [size_is(count)] srvsvc_NetShareInfo0 *array;
        } srvsvc_NetShareCtr0;

And the 'array' parameter of that is this:
        typedef struct {
                [string,charset(UTF16)] uint16 *name;
        } srvsvc_NetShareInfo0;

As you can see, it's all a C-like definition of the structure.
Marshalling each individual element is easy using the 'bin.pack()'
function, once you know what it's supposed to be.

So here's my question -- do any of the Lua experts here think this is
something that could be done without too much difficulty? And any
suggestions on how to do it?

I'd like to write this, but I'm afraid of getting in way over my head
and ending up quitting..

Thanks!

--
Ron Bowes
http://www.skullsecurity.org/
http://www.javaop.com/

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: