mirror of
https://github.com/nmap/nmap.git
synced 2026-11-11 22:34:37 +00:00
Use receive_buf to simplify receiving a known length
This commit is contained in:
parent
6e7b60c83d
commit
c691f47baf
1 changed files with 3 additions and 9 deletions
|
|
@ -4,6 +4,7 @@ local nmap = require "nmap"
|
|||
local shortport = require "shortport"
|
||||
local stdnse = require "stdnse"
|
||||
local string = require "string"
|
||||
local match = require "match"
|
||||
|
||||
local openssl = stdnse.silent_require "openssl"
|
||||
|
||||
|
|
@ -34,15 +35,8 @@ categories = {"brute", "intrusive"}
|
|||
portrule = shortport.port_or_service(9929, "nping-echo")
|
||||
|
||||
local function readmessage(socket, length)
|
||||
local msg = ""
|
||||
while #msg < length do
|
||||
local status, tmp = socket:receive_bytes(1)
|
||||
if not status then
|
||||
return nil
|
||||
end
|
||||
msg = msg .. tmp
|
||||
end
|
||||
return msg
|
||||
local status, msg = socket:receive_buf(match.numbytes(length), true)
|
||||
return status and msg or nil
|
||||
end
|
||||
|
||||
Driver =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue