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:
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.
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 , which should work
with the existing mssql.lua.
2) Updated versions of ms-sql-info.nse  and mssql.lua , 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. 
On that same note, all of my ToString and your new ToBytes method could be changed to __tostring (as I've done in my
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!
 mssql_refactored.patch ( as a patch against r21987)
Sent through the nmap-dev mailing list
Archived at http://seclists.org/nmap-dev/
Re: [NSE] Improved version of ms-sql-info Chris Woodbury (Jan 28)
Re: [NSE] Improved version of ms-sql-info Chris Woodbury (Feb 06)