1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-22 03:54:20 -05:00

added a terminal server and bad netcat clone

This commit is contained in:
XeonSquared 2019-01-09 16:23:30 +11:00
parent 59abb31fee
commit a29fc154a0
3 changed files with 57 additions and 1 deletions

16
exec/nc.lua Normal file
View File

@ -0,0 +1,16 @@
local minitel = require "minitel"
local tA = {...}
host, port = tA[1], tA[2]
local socket = minitel.open(host,port)
if not socket then return false end
local b = ""
repeat
io.write(socket:read("*a"))
coroutine.yield()
b = io.read(nil,true) or ""
if b:len() > 0 then
socket:write(b.."\n")
end
until socket.state ~= "open"

View File

@ -1,7 +1,11 @@
local shenv = {} local shenv = {}
function shenv.quit()
os.setenv("run",nil)
end
setmetatable(shenv,{__index=function(_,k) if _G[k] then return _G[k] elseif fs.exists("/boot/exec/"..k..".lua") then return loadfile("/boot/exec/"..k..".lua") end end}) setmetatable(shenv,{__index=function(_,k) if _G[k] then return _G[k] elseif fs.exists("/boot/exec/"..k..".lua") then return loadfile("/boot/exec/"..k..".lua") end end})
print(_VERSION) print(_VERSION)
while true do os.setenv("run",true)
while os.getenv("run") do
io.write((os.getenv("PWD") or _VERSION).."> ") io.write((os.getenv("PWD") or _VERSION).."> ")
tResult = {pcall(load(io.read(),"shell","t",shenv))} tResult = {pcall(load(io.read(),"shell","t",shenv))}
if tResult[1] == true then table.remove(tResult,1) end if tResult[1] == true then table.remove(tResult,1) end

36
service/termsrv.lua Normal file
View File

@ -0,0 +1,36 @@
print(pcall(function()
local minitel = require "minitel"
local port = 22
local logfile = "/boot/termsrv.log"
if logfile then
local log = io.open(logfile,"a")
os.setenv("t",log.fd)
end
while true do
local sock = minitel.listen(port)
print(string.format("[%s] Connection from %s:%d",os.date("%Y-%m-%d %H:%M"),sock.addr,sock.port))
os.spawn(function() _G.worked = {pcall(function()
local fdi, fdo = io.newfd()
function fdo.read(d)
return sock:read(d)
end
function fdo.write(d)
return sock:write(d)
end
function fdo.close()
sock:close()
end
fd[fdi] = fdo
os.setenv("t",fdi)
sock:write(string.format("Connected to %s on port %d\n",computer.address():sub(1,8),sock.port))
local pid = spawnfile("/boot/exec/shell.lua",string.format("shell [%s:%d]",sock.addr,sock.port))
repeat
coroutine.yield()
until sock.state ~= "open" or not tTasks[pid]
fdo.close()
sock:close()
os.kill(pid)
end)} end,string.format("remote login [%s:%d]",sock.addr,sock.port))
end
end))