Nmap Development mailing list archives
Re: A sleep function for NSE
From: Ron <ron () skullsecurity net>
Date: Wed, 18 Feb 2009 15:14:27 -0600
David Fifield wrote:
Hi all, One of the Nmap TODO items is a sleep function for NSE. Such a function allows rate-limiting traffic for politeness or to avoid triggering some filter. The attached stdnse.sleep.diff implements such a function. Even though sleep is implemented through Lua's C API, I put in in stdnse, which is otherwise a pure Lua module. I originally put it in the nmap module just because that is already a C module and it was easy to implement there. But then I reflected that sleep doesn't fit the description of the nmap module: "an interface with Nmap's internal functions and data structures." Looking at the other modules I though that stdnse was the best fit. This trick is accomplished by loading sleep into a private stdnse.c module. stdnse.lua requires this module, then transfers its contents into its own namespace; i.e., stdnse.c.sleep becomes stdnse.sleep. What do you think? I think we should group functions by what they do, not by what language they happen to be implemented in, whenever possible. The person calling stdnse.sleep likely doesn't care if it's written in Lua or C. I attached a patch against sql-injection.nse showing how sleep can be made into a rate limiter. The patched script sleeps if necessary between page retrievals so that no more than one page per second is requested. Does someone else have a use for a sleep function? Is the design suitable for you? David Fifield
Hi David,This is a great idea, and something I was looking for fairly recently. There are places in my code that would greatly benefit from a sleep function.
I just have on question -- does this implementation of Sleep proper yield to other Lua threads (coroutines?) while the sleep is happening, or is everything blocked?
Ron _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- A sleep function for NSE David Fifield (Feb 18)
- Re: A sleep function for NSE Ron (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 18)
- Re: A sleep function for NSE Ron (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 18)
- Re: A sleep function for NSE jah (Feb 18)
- Re: A sleep function for NSE Arturo 'Buanzo' Busleiman (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 20)
- Re: A sleep function for NSE Ron (Feb 20)
- Re: A sleep function for NSE jah (Feb 20)
- Re: A sleep function for NSE David Fifield (Feb 20)
- Re: A sleep function for NSE Ron (Feb 18)
- Re: A sleep function for NSE David Fifield (Feb 23)