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:
31
nselib/match.lua
Normal file
31
nselib/match.lua
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user