I'm creating a program which is a modified router, while allows me to go all NSA and log everything, but i'd still like access to the shell so does anyone know of a way I could integrate a Daemon? Or link to me a way I could integrate a Daemon? I'd prefer to avoid coroutines as I don't understand them.
Simple way to do Daemons?
Started by LDShadowLord, Apr 06 2014 01:26 AM
4 replies to this topic
#1
Posted 06 April 2014 - 01:26 AM
#2
Posted 06 April 2014 - 01:34 AM
LDShadowLord, on 06 April 2014 - 01:26 AM, said:
I'm creating a program which is a modified router, while allows me to go all NSA and log everything, but i'd still like access to the shell so does anyone know of a way I could integrate a Daemon? Or link to me a way I could integrate a Daemon? I'd prefer to avoid coroutines as I don't understand them.
local function daemon()
-- This will run in the background
-- I would not advise writing anything to the screen :P/>
end
parallel.waitForAny(daemon, function() shell.run("/rom/programs/shell") end)
Edited by 1lann, 06 April 2014 - 01:34 AM.
#3
Posted 06 April 2014 - 01:40 AM
Essentially the same approach, but a bit different syntactically (it just breaks the shell down into its own function outside of the parallel call):
local function foregroundShell()
shell.run("shell")
end
local function myMainFunction()
<your main program loop>
<this runs in the background>
<do not write to the screen>
end
parallel.waitForAny(myMainFunction,foregroundShell)
Edited by Dog, 06 April 2014 - 01:51 AM.
#4
Posted 06 April 2014 - 01:53 AM
One way is to write a modified version of os.pullEvent, and have it record whatever data you're interested in.
For eg, the default one looks something like this:
You can see that it's basically a wrapper for os.pullEventRaw - it returns whatever that returns, unless it returns a terminate event, in which case it kills your script.
If you declared your own version of that function, which eg looked for key events and saved them into a hidden text file somewhere, then hey presto! Key logger. You literally just take something like the above code block, alter it to taste, run it on startup, then otherwise allow the computer to work "normally".
The code demonstrated here functions under this concept, though it may be a little complex for you to read at this stage.
For eg, the default one looks something like this:
function os.pullEvent(eventType)
myEvent = {os.pullEventRaw(eventType)}
if myEvent[1] == "terminate" then error("Ctrl+T pressed") end
return myEvent
end
You can see that it's basically a wrapper for os.pullEventRaw - it returns whatever that returns, unless it returns a terminate event, in which case it kills your script.
If you declared your own version of that function, which eg looked for key events and saved them into a hidden text file somewhere, then hey presto! Key logger. You literally just take something like the above code block, alter it to taste, run it on startup, then otherwise allow the computer to work "normally".
The code demonstrated here functions under this concept, though it may be a little complex for you to read at this stage.
Edited by Bomb Bloke, 06 April 2014 - 01:54 AM.
#5
Posted 06 April 2014 - 01:53 AM
Excellent, thankyou very much, folks.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











