This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
FREAX/bin/nmap

50 lines
1.2 KiB
Text
Raw Normal View History

2022-07-18 19:33:40 +02:00
--Initializing IP address generator
local tArgs = {...}
if #tArgs < 4 then
kerneldraw.printAppInfo("nmap", "No IP address specified")
else
kerneldraw.printAppSuccess("nmap", "Scanning for specified IP")
end
if #tArgs == 5 then
kerneldraw.printAppSuccess("nmap", "Specified DNS record")
end
local ip, node
if #tArgs < 4 then
local x = tostring(math.random(0, 255))
local y = tostring(math.random(0, 255))
local z = tostring(math.random(0, 255))
local r = tostring(math.random(0, 255))
ip = x.."."..y.."."..z.."."..r
elseif #tArgs >= 4 then
ip = tArgs[1].."."..tArgs[2].."."..tArgs[3].."."..tArgs[4]
end
if not fs.exists("/network") or not fs.isDir("/network") then
fs.makeDir("/network")
end
--node = "/network/"..ip
kerneldraw.printAppInfo("nmap", "Found "..ip)
if #tArgs == 5 then
kerneldraw.printAppSuccess("nmap", "Assigned DNS record "..tArgs[5])
node = "/network/"..tArgs[5]
else
kerneldraw.printAppWarning("nmap", "No DNS record found, defaulting to IP")
node = "/network/"..ip
end
if fs.exists(node) and fs.isDir(node) then
kerneldraw.printAppInfo("nmap", ip.." already known")
else
fs.makeDir(node)
fs.makeDir(node.."/sys")
fs.makeDir(node.."/home")
fs.makeDir(node.."/bin")
kerneldraw.printAppSuccess("nmap", ip.." added to network")
end