Nmap Security Scanner
*Intro
*Ref Guide
*Install Guide
*Download
*Changelog
*Book
*Docs
Security Lists
*Nmap Hackers
*Nmap Dev
*Bugtraq
*Full Disclosure
*Pen Test
*Basics
*More
Security Tools
*Pass crackers
*Sniffers
*Vuln Scanners
*Web scanners
*Wireless
*Exploitation
*Packet crafters
*More
Site News
Site Search:
Exploit World
Advertising
About/Contact
Credits
Sponsors:




nmap-dev logo Nmap Development mailing list archives

Re: [Lua snippit] print_hex
From: Ron <ron () skullsecurity net>
Date: Sun, 07 Sep 2008 22:48:31 -0500

Patrick Donnelly wrote:
On Sat, Sep 6, 2008 at 9:51 AM, Ron <ron () skullsecurity net> wrote:

That looks fine. I put the "out" local out of the function definition
to prevent the string from repeatedly being remade (numbers are
constant folded but not strings). I did this mainly to expose people
on the list to some good practices (among other things I did), even
though it probably won't make a huge difference in a debugging
function. If you moved it inside because you didn't want to clutter
the surrounding function (the file) with variables, you can surround
the print_hex function with do ... end to force scoping. e.g.:

do
  local out = "..."
  function print_hex(str)
    ...
  end
end
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 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.

Thanks!
Ron


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


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]