| Server IP : 101.53.144.229 / Your IP : 216.73.216.181 Web Server : Apache System : Linux host.gdigitalindia.in 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : digitalshiksha ( 1179) PHP Version : 5.6.40 Disable Function : eval,show_source,system,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,show_source,curl_multi_exechellcmd, ini_restore,apache_get_modules,get_cfg_var,passthru, exec ,proc_get_status,fpassthru,c999_buff_prepare,c999_sess_put,c99_buff_prepare,c99_sess_put,proc_close,ini_alter,dl,symlink,link,proc_close,ini_alter,dl,symlink,link,mail MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/nmap/nselib/ |
Upload File : |
---
-- Buffered network I/O helper functions.
--
-- The functions in this module can be used for delimiting data received by the
-- <code>nmap.receive_buf</code> function in the Network I/O API (which see).
-- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
local pcre = require "pcre"
local stdnse = require "stdnse"
_ENV = stdnse.module("match", stdnse.seeall)
--various functions for use with nse's nsock:receive_buf - function
-- e.g.
-- sock:receive_buf(regex("myregexpattern")) - does a match using pcre- regular-
-- - expressions
-- sock:receive_buf(numbytes(80)) - is the buffered version of
-- sock:receive_bytes(80) - i.e. it returns
-- exactly 80 bytes and no more
--- Return a function that allows delimiting with a regular expression.
--
-- This function is a wrapper around <code>pcre.exec</code>. Its purpose is to
-- give script developers the ability to use regular expressions for delimiting
-- instead of Lua's string patterns.
-- @param pattern The regex.
-- @usage sock:receive_buf(match.regex("myregexpattern"))
-- @see nmap.receive_buf
-- @see pcre.exec
regex = function(pattern)
local r = pcre.new(pattern, 0,"C")
return function(buf)
local s,e = r:exec(buf, 0,0);
return s,e
end
end
--- Return a function that allows delimiting at a certain number of bytes.
--
-- This function can be used to get a buffered version of
-- <code>sock:receive_bytes(n)</code> in case a script requires more than one
-- fixed-size chunk, as the unbuffered version may return more bytes than
-- requested and thus would require you to do the parsing on your own.
-- @param num Number of bytes.
-- @usage sock:receive_buf(match.numbytes(80))
-- @see nmap.receive_buf
numbytes = function(num)
local n = num
return function(buf)
if(#buf >=n) then
return n, n
end
return nil
end
end
return _ENV;