mirror of
https://github.com/nmap/nmap.git
synced 2025-12-16 04:39:03 +00:00
fixed a bug in a loop where the script would wait for a condition that was
supposed to be signalled by other threads which were no longer running.
This commit is contained in:
@@ -694,10 +694,12 @@ Helper = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for t in pairs(threads) do
|
for t in pairs(threads) do
|
||||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until( next(threads) == nil )
|
until( next(threads) == nil )
|
||||||
|
|
||||||
for name, answer in pairs(answers) do
|
for name, answer in pairs(answers) do
|
||||||
|
|||||||
@@ -192,10 +192,12 @@ action = function()
|
|||||||
|
|
||||||
-- wait until all threads are done
|
-- wait until all threads are done
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
local response = {}
|
local response = {}
|
||||||
|
|||||||
@@ -104,12 +104,14 @@ action = function(host, port)
|
|||||||
|
|
||||||
-- wait until the probes are all done
|
-- wait until the probes are all done
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then
|
if coroutine.status(thread) == "dead" then
|
||||||
threads[thread] = nil
|
threads[thread] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
return stdnse.format_output(true, result)
|
return stdnse.format_output(true, result)
|
||||||
|
|||||||
@@ -251,10 +251,12 @@ action = function()
|
|||||||
local condvar = nmap.condvar(astab)
|
local condvar = nmap.condvar(astab)
|
||||||
-- Wait for the listening threads to finish
|
-- Wait for the listening threads to finish
|
||||||
repeat
|
repeat
|
||||||
condvar("wait")
|
for thread in pairs(lthreads) do
|
||||||
for thread in pairs(lthreads) do
|
if coroutine.status(thread) == "dead" then lthreads[thread] = nil end
|
||||||
if coroutine.status(thread) == "dead" then lthreads[thread] = nil end
|
end
|
||||||
end
|
if ( next(lthreads) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
until next(lthreads) == nil;
|
until next(lthreads) == nil;
|
||||||
|
|
||||||
if #astab > 0 then
|
if #astab > 0 then
|
||||||
|
|||||||
@@ -309,10 +309,12 @@ action = function(host, port)
|
|||||||
local condvar = nmap.condvar(responses)
|
local condvar = nmap.condvar(responses)
|
||||||
-- Wait for the listening threads to finish
|
-- Wait for the listening threads to finish
|
||||||
repeat
|
repeat
|
||||||
condvar("wait")
|
|
||||||
for thread in pairs(lthreads) do
|
for thread in pairs(lthreads) do
|
||||||
if coroutine.status(thread) == "dead" then lthreads[thread] = nil end
|
if coroutine.status(thread) == "dead" then lthreads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(lthreads) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
until next(lthreads) == nil;
|
until next(lthreads) == nil;
|
||||||
|
|
||||||
-- Output useful info from the responses
|
-- Output useful info from the responses
|
||||||
|
|||||||
@@ -265,12 +265,14 @@ action = function()
|
|||||||
|
|
||||||
-- wait for all threads to finish sniffing
|
-- wait for all threads to finish sniffing
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then
|
if coroutine.status(thread) == "dead" then
|
||||||
threads[thread] = nil
|
threads[thread] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
local out_outer = {}
|
local out_outer = {}
|
||||||
|
|||||||
@@ -113,12 +113,14 @@ action = function()
|
|||||||
|
|
||||||
-- wait until the probes are all done
|
-- wait until the probes are all done
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then
|
if coroutine.status(thread) == "dead" then
|
||||||
threads[thread] = nil
|
threads[thread] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
table.sort(responses, function(a,b) return a.name < b.name end)
|
table.sort(responses, function(a,b) return a.name < b.name end)
|
||||||
|
|||||||
@@ -255,10 +255,12 @@ action = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
-- generate output
|
-- generate output
|
||||||
|
|||||||
@@ -86,11 +86,13 @@ action = function()
|
|||||||
local done
|
local done
|
||||||
-- wait for all threads to finish
|
-- wait for all threads to finish
|
||||||
while( not(done) ) do
|
while( not(done) ) do
|
||||||
condvar("wait")
|
|
||||||
done = true
|
done = true
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||||
end
|
end
|
||||||
|
if ( not(done) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ( results ) then
|
if ( results ) then
|
||||||
|
|||||||
@@ -235,11 +235,13 @@ action = function(host)
|
|||||||
local done
|
local done
|
||||||
-- wait for all threads to finish
|
-- wait for all threads to finish
|
||||||
while( not(done) ) do
|
while( not(done) ) do
|
||||||
condvar("wait")
|
|
||||||
done = true
|
done = true
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||||
end
|
end
|
||||||
|
if ( not(done) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if(dosrv) then
|
if(dosrv) then
|
||||||
@@ -257,11 +259,13 @@ action = function(host)
|
|||||||
local done
|
local done
|
||||||
-- wait for all threads to finish
|
-- wait for all threads to finish
|
||||||
while( not(done) ) do
|
while( not(done) ) do
|
||||||
condvar("wait")
|
|
||||||
done = true
|
done = true
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||||
end
|
end
|
||||||
|
if ( not(done) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,12 @@ action = function()
|
|||||||
|
|
||||||
local condvar = nmap.condvar(result)
|
local condvar = nmap.condvar(result)
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for t in pairs(threads) do
|
for t in pairs(threads) do
|
||||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until( next(threads) == nil )
|
until( next(threads) == nil )
|
||||||
|
|
||||||
if ( 0 == #result ) then
|
if ( 0 == #result ) then
|
||||||
|
|||||||
@@ -167,10 +167,12 @@ action = function(host)
|
|||||||
|
|
||||||
local condvar = nmap.condvar(result)
|
local condvar = nmap.condvar(result)
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for t in pairs(threads) do
|
for t in pairs(threads) do
|
||||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until( next(threads) == nil )
|
until( next(threads) == nil )
|
||||||
|
|
||||||
table.sort(result, function(a,b) return a.name < b.name end)
|
table.sort(result, function(a,b) return a.name < b.name end)
|
||||||
|
|||||||
@@ -239,7 +239,6 @@ local function worker_scheduler(host, port)
|
|||||||
while not DOSed and not StopAll do
|
while not DOSed and not StopAll do
|
||||||
-- keep creating new threads, in case we want to run the attack indefinitely
|
-- keep creating new threads, in case we want to run the attack indefinitely
|
||||||
repeat
|
repeat
|
||||||
condvar("wait")
|
|
||||||
if StopAll then
|
if StopAll then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -252,6 +251,9 @@ local function worker_scheduler(host, port)
|
|||||||
stdnse.print_debug(SCRIPT_NAME .. " [SCHEDULER]: starting new thread")
|
stdnse.print_debug(SCRIPT_NAME .. " [SCHEDULER]: starting new thread")
|
||||||
local co = stdnse.new_thread(do_half_http, host, port, obj)
|
local co = stdnse.new_thread(do_half_http, host, port, obj)
|
||||||
Threads[co] = true
|
Threads[co] = true
|
||||||
|
if ( next(Threads) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
until next(Threads) == nil;
|
until next(Threads) == nil;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -389,10 +389,12 @@ action = function( host, port )
|
|||||||
|
|
||||||
-- wait for all threads to finish up
|
-- wait for all threads to finish up
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for t in pairs(threads) do
|
for t in pairs(threads) do
|
||||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until( next(threads) == nil )
|
until( next(threads) == nil )
|
||||||
|
|
||||||
if ( #result > 0 ) then
|
if ( #result > 0 ) then
|
||||||
|
|||||||
@@ -308,10 +308,12 @@ action = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
-- generate output
|
-- generate output
|
||||||
|
|||||||
@@ -237,12 +237,14 @@ action = function(host, port)
|
|||||||
|
|
||||||
local condvar = nmap.condvar(result)
|
local condvar = nmap.condvar(result)
|
||||||
repeat
|
repeat
|
||||||
condvar "wait";
|
|
||||||
for thread in pairs(lthreads) do
|
for thread in pairs(lthreads) do
|
||||||
if coroutine.status(thread) == "dead" then
|
if coroutine.status(thread) == "dead" then
|
||||||
lthreads[thread] = nil
|
lthreads[thread] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if ( next(lthreads) ) then
|
||||||
|
condvar "wait";
|
||||||
|
end
|
||||||
until next(lthreads) == nil;
|
until next(lthreads) == nil;
|
||||||
|
|
||||||
-- Check the result and set the port version.
|
-- Check the result and set the port version.
|
||||||
|
|||||||
@@ -125,10 +125,12 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for t in pairs(threads) do
|
for t in pairs(threads) do
|
||||||
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
if ( coroutine.status(t) == "dead" ) then threads[t] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until( next(threads) == nil )
|
until( next(threads) == nil )
|
||||||
|
|
||||||
-- urls that could not be retrieved due to low level errors, such as
|
-- urls that could not be retrieved due to low level errors, such as
|
||||||
|
|||||||
@@ -169,10 +169,12 @@ action = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
return format_output(results)
|
return format_output(results)
|
||||||
|
|||||||
@@ -201,10 +201,12 @@ action = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
return format_output(results)
|
return format_output(results)
|
||||||
|
|||||||
@@ -166,10 +166,12 @@ action = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
return format_output(results)
|
return format_output(results)
|
||||||
|
|||||||
@@ -251,10 +251,12 @@ action = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
condvar "wait"
|
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
if coroutine.status(thread) == "dead" then threads[thread] = nil end
|
||||||
end
|
end
|
||||||
|
if ( next(threads) ) then
|
||||||
|
condvar "wait"
|
||||||
|
end
|
||||||
until next(threads) == nil
|
until next(threads) == nil
|
||||||
|
|
||||||
return format_output(results)
|
return format_output(results)
|
||||||
|
|||||||
@@ -75,11 +75,13 @@ action = function(host, port)
|
|||||||
local done
|
local done
|
||||||
-- wait for all threads to finish
|
-- wait for all threads to finish
|
||||||
while( not(done) ) do
|
while( not(done) ) do
|
||||||
condvar("wait")
|
|
||||||
done = true
|
done = true
|
||||||
for thread in pairs(threads) do
|
for thread in pairs(threads) do
|
||||||
if (coroutine.status(thread) ~= "dead") then done = false end
|
if (coroutine.status(thread) ~= "dead") then done = false end
|
||||||
end
|
end
|
||||||
|
if ( not(done) ) then
|
||||||
|
condvar("wait")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ( results ) then
|
if ( results ) then
|
||||||
|
|||||||
Reference in New Issue
Block a user