Nmap Development mailing list archives

Re: [NSE] Improved version of ms-sql-info


From: Patrik Karlsson <patrik () cqure net>
Date: Sun, 30 Jan 2011 11:04:56 +0100


On 28 jan 2011, at 10.25, Chris Woodbury wrote:

Patrik-

Thanks for the suggestions. I went ahead and built a class that fully
implements the PreLogin packet (both client->server and
server->client). It's much more robust on its own, and I also added
some more error-handling and rigor throughout.

Nice work!


I have two different flavors, depending on what's easier for you (and
others) to review and test out:
1) A stand-alone version of ms-sql-info.nse [1], which should work
with the existing mssql.lua.
2) Updated versions of ms-sql-info.nse [2] and mssql.lua [3][4], with
much of the code factored into mssql.lua.

I think we should go with the second option and place the packet and communication related code into mssql.lua.
I did a quick test of that option against some of my virtual environments and it looked good.

Although I'm no Lua expert here are some quick comments on the code:
* You should probably avoid the leading underscore convention for instance variables and function names to avoid 
confusion with metamethods. [1]
   On that same note, all of my ToString and your new ToBytes method could be changed to __tostring (as I've done in my 
later libraries). 
   This would make it possible to do:

local p = PreLoginPacket:new()
socket:send( tostring(p) )

* To match the rest of the code I would replace the string operations from string.sub(str ... to str:sub( ....
* I don't know if this is or is going to be a problem but os.time() returns a value in seconds. So if two 
PreLoginPackets are created within the same second, the thread id will be the same.
   In the Connect method I'm adding the local port of the socket into the randomseed together with os.time. Looking at 
that particular code now, it could probably be cleaned up a little :)



Functionally, they are the same; the only differences are where the code is.

Let me know what you think.

If you make the suggested changes above, I'll be happy to commit it!

Thanks
-chris

Attached:
[1] ms-sql-info_standalone.nse
[2] ms-sql-info_refactored.nse
[3] mssql.lua
[4] mssql_refactored.patch ([3] as a patch against r21987)




[1] http://www.lua.org/pil/13.html


//Patrik
--
Patrik Karlsson
http://www.cqure.net
http://www.twitter.com/nevdull77





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


Current thread: