Nmap Development mailing list archives
Re: [NSE Script] IRC Server Info
From: doug () hcsw org
Date: Mon, 25 Jun 2007 16:49:04 -0700
Hi Eddie! On Mon, Jun 25, 2007 at 10:12:18AM +0100 or thereabouts, Eddie Bell wrote:
Cool script but have you thought about adding your make_buffer function to nselib/stdnse.lua so all scripts have access to it? I think they would find it useful.
Good idea. Done. Here are the new docs: -- Generic buffer implementation using lexical closures -- -- Pass make_buffer a socket and a separator lua pattern [1]. -- -- Returns a function bound to your provided socket with behaviour identical -- to receive_lines() except it will return AT LEAST ONE [2] and AT MOST ONE -- "line" at a time. -- -- [1] Use the pattern "\r?\n" for regular newlines -- [2] Except where there is trailing "left over" data not terminated by a -- pattern (in which case you get the data anyways) -- [3] The data is returned WITHOUT the pattern/newline on the end. -- [4] Empty "lines" are returned as "". With the pattern in [1] you will -- receive a "" for each newline in the stream. -- [5] Errors/EOFs are delayed until all "lines" have been processed. Here is how it's used: require("stdnse") sd = nmap.new_socket() sd:connect(host.ip, port.number) my_buffer = stdnse.make_buffer(sd, "\r?\n") while true do status, line = my_buffer() ...
I was playing with pcre and couldn't get it to work, nice to know it was broken and not me :)
Ya, the PCRE interface was broken but thanks to gdb it was easy to track down the problems. Probably the biggest problem IS STILL THE DOCUMENTATION though! Here is the bare minimum info for using it (and make sure you are using the soc07 branch with the PCRE fixes): my_regex = pcre.new("my PCRE pattern", 0, "C") my_regex:exec(string_to_match_against, 0, 0) If you want to use any regexp modifiers you must look up the PCRE bitmasks in the C header file, OR them, and use the numeric constant instead of one of those 0s. Also, changing the locale is completely useless for our regexps (where you want to match OCTETS) and it's easy to forget the "C" parameter so I think it should be removed. Given the current docs, nobody can be blamed for not getting PCRE working. :) Best, Doug
Attachment:
signature.asc
Description: Digital signature
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [NSE Script] IRC Server Info doug (Jun 24)
- <Possible follow-ups>
- [NSE Script] IRC Server Info doug (Jun 25)
- Re: [NSE Script] IRC Server Info Eddie Bell (Jun 25)
- Re: [NSE Script] IRC Server Info doug (Jun 25)
- Re: [NSE Script] IRC Server Info Eddie Bell (Jun 25)