1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-13 11:19:02 +00:00

adding nselib nselib-bin second (should work on unix now)

This commit is contained in:
diman
2007-11-27 22:18:59 +00:00
parent 335ec2868f
commit c0f07c99ac
32 changed files with 93217 additions and 21 deletions

31
nselib/match.lua Normal file
View File

@@ -0,0 +1,31 @@
-- See nmaps COPYING for licence
module(..., package.seeall)
require "pcre"
--various functions for use with nse's nsock:receive_buf - function
-- e.g.
-- sock:receivebuf(regex("myregexpattern")) - does a match using pcre- regular-
-- - expressions
-- sock:receivebuf(numbytes(80)) - is the buffered version of
-- sock:receive_bytes(80) - i.e. it returns
-- exactly 80 bytes and no more
regex = function(pattern)
local r = pcre.new(pattern, 0,"C")
return function(buf)
s,e = r:exec(buf, 0,0);
return s,e
end
end
numbytes = function(num)
local n = num
return function(buf)
if(string.len(buf) >=n) then
return n, n
end
return nil
end
end