1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-11 08:59:04 +00:00

o The NSE http library now supports chunked encoding. [Sven Klemm]

This commit is contained in:
fyodor
2008-08-29 09:24:24 +00:00
parent 5c12162dd6
commit 8b29c19a76
2 changed files with 30 additions and 7 deletions

View File

@@ -1,5 +1,11 @@
# Nmap Changelog ($Id$); -*-text-*-
o The NSE http library now supports chunked encoding. [Sven Klemm]
o Fix a number of NSE scripts which used print_debug()
incorrectly. See
http://seclists.org/nmap-dev/2008/q3/0470.html. [Sven Klemm].
o Improve the nebtios-smb-os-discovery NSE script to improve target
port selection and to also decode the system's timestamp from an SMB
response. [Ron at SkullSecurity]

View File

@@ -143,7 +143,7 @@ request = function( host, port, data, options )
return result
end
local buffer = stdnse.make_buffer( socket, "\r?\n" )
local buffer = stdnse.make_buffer( socket, "\r\n" )
local line, _
local header, body = {}, {}
@@ -184,15 +184,32 @@ request = function( host, port, data, options )
end
end
-- body loop
while true do
line = buffer()
if not line then break end
table.insert(body,line)
-- handle body
if result.header['transfer-encoding'] == 'chunked' then
-- if the server used chunked encoding we have to 'dechunk' the answer
local counter, chunk_size
counter = 0; chunk_size = 0
while true do
if counter >= chunk_size then
counter = 0
chunk_size = tonumber( buffer(), 16 )
if chunk_size == 0 or not chunk_size then break end
end
line = buffer()
if not line then break end
counter = counter + #line + 2
table.insert(body,line)
end
else
while true do
line = buffer()
if not line then break end
table.insert(body,line)
end
end
socket:close()
result.body = table.concat( body, "\n" )
result.body = table.concat( body, "\r\n" )
return result