mirror of
https://github.com/nmap/nmap.git
synced 2026-02-07 14:06:33 +00:00
Set the math.randomseed value in nse_main.lua on behalf of scripts.
Since Lua uses the C rand and srand functions, which have a static seed for the entire program, we don't want scripts doing this themselves.
This commit is contained in:
@@ -82,9 +82,6 @@ end
|
||||
--end
|
||||
|
||||
local function go(host, port)
|
||||
-- We're going to need some low quality random numbers
|
||||
math.randomseed(os.time())
|
||||
|
||||
-- Set up a fake host for prerule
|
||||
if(not(host)) then
|
||||
host = {}
|
||||
|
||||
@@ -280,7 +280,6 @@ function corruptAndSend (host, port, query)
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
math.randomseed(os.time())
|
||||
local endT
|
||||
local timelimit, err
|
||||
local retStr
|
||||
|
||||
@@ -180,7 +180,6 @@ Driver =
|
||||
}
|
||||
|
||||
action = function(host, port)
|
||||
math.randomseed(nmap.clock())
|
||||
local engine = brute.Engine:new(Driver, host, port)
|
||||
engine.options.firstonly = true
|
||||
engine.options:setOption("passonly", true)
|
||||
|
||||
@@ -79,13 +79,6 @@ local function get_random_string(length, set)
|
||||
|
||||
local str = ""
|
||||
|
||||
-- Seed the random number, if we haven't already
|
||||
if (not(nmap.registry.oracle_enum_users) or not(nmap.registry.oracle_enum_users.seeded)) then
|
||||
math.randomseed(os.time())
|
||||
nmap.registry.oracle_enum_users = {}
|
||||
nmap.registry.oracle_enum_users.seeded = true
|
||||
end
|
||||
|
||||
for i = 1, length, 1 do
|
||||
local random = math.random(#set)
|
||||
str = str .. string.sub(set, random, random)
|
||||
|
||||
@@ -73,7 +73,6 @@ Driver = {
|
||||
-- was successful which makes it impossible to tell successfull logins
|
||||
-- from non-existing accounts apart.
|
||||
local function checkBadUser(host, port)
|
||||
math.randomseed( os.time() )
|
||||
local user = "baduser-" .. math.random(10000)
|
||||
local pass = "badpass-" .. math.random(10000)
|
||||
local helper = sip.Helper:new(host, port, { expires = 0 })
|
||||
@@ -103,4 +102,4 @@ action = function(host, port)
|
||||
local engine = brute.Engine:new(Driver, host, port)
|
||||
local status, result = engine:start()
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
@@ -172,13 +172,6 @@ local function get_random_string(length, set)
|
||||
|
||||
local str = ""
|
||||
|
||||
-- Seed the random number, if we haven't already
|
||||
if not nmap.registry.smbbrute or not nmap.registry.smbbrute.seeded then
|
||||
math.randomseed(os.time())
|
||||
nmap.registry.smbbrute = {}
|
||||
nmap.registry.smbbrute.seeded = true
|
||||
end
|
||||
|
||||
for i = 1, length, 1 do
|
||||
local random = math.random(#set)
|
||||
str = str .. string.sub(set, random, random)
|
||||
|
||||
@@ -693,7 +693,6 @@ local function get_config(host, config)
|
||||
elseif(nmap.registry.args.key) then
|
||||
config.key = nmap.registry.args.key
|
||||
else
|
||||
math.randomseed( os.time() )
|
||||
config.key = ""
|
||||
for i = 1, 127, 1 do
|
||||
config.key = config.key .. string.char(math.random(0x20, 0x7F))
|
||||
|
||||
Reference in New Issue
Block a user