Nmap Development mailing list archives

Re: brute.lua, unpwdb.lua, custom iterators and flexibility


From: David Fifield <david () bamsoftware com>
Date: Wed, 27 Jun 2012 08:47:41 -0700

On Wed, Jun 27, 2012 at 05:11:16PM +0200, Aleksandar Nikolic wrote:
I say "could be" because the current code for account_iterator has
this:
if ( 'table' == type(users) and 'table' == type(pass) ) then
...
elseif ( 'function' == type(users) and 'function' == type(pass) ) then
...
end

This looks like it should be written more clearly anyway:

function table_iterator(t)
        return unpwdb.limited_iterator(unpwdb.closure(t))
end

if 'table' == type(users) then
        users = table_iterator(users)
end
if 'table' == type(pass) then
        pass = table_iterator(pass)
end
...

unpwdb.closure is local but it shouldn't be. It should also have a
better name like, say, table_iterator.

This means that we can only specify an iterator with either both
usernames and passwords as tables or functions
and not , for example, table of usernames and iterator for passwords.
This could easily be expanded for more flexibility by adding two more
elseif blocks for remaining combinations.

Don't add two more cases; coerce everything to an iterator and then you
have just one case.

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


Current thread: