Nmap Development mailing list archives

Re: [Lua snippit] print_hex


From: "Patrick Donnelly" <batrick.donnelly () gmail com>
Date: Sun, 7 Sep 2008 23:02:55 -0600

On Sun, Sep 7, 2008 at 9:48 PM, Ron <ron () skullsecurity net> wrote:
Putting the variable outside of a function like that has a weird field
to it. It seems like it's asking for trouble if something else happens
to use that name without scoping it to "local" as well. Putting do..end
fixes that potential issue, but it looks a little hackish to me.

I wouldn't presume to speak for the authors but I'm pretty sure that
was the intended use for do ... end.

I actually noticed a problem in the newest version, though. If
characters aren't in the standard printable range (0x20 - 0x7F), it
shouldn't try and display them. '\n' and '\r' screw up the output, for
example. Is there some easy way to fix that? I looked briefly, but
didn't see any clean way.

%c uses iscntrl() from the standard C library to determine if the
character is a control character. On my box, '\n' and '\r' are both
control characters so I didn't experience this problem. You can make a
character class that should capture the other cases:

string.gsub("[%c\n\r\t]", ".")

Cheers,

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant

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


Current thread: