Top Level
#1
Posted 18 April 2013 - 02:06 AM
I have seen some programs which allow you to kill the parent shell but I am not understanding the code used. What steps are taken and what needs to be done to kill the parent shell?
#2
Posted 18 April 2013 - 02:41 AM
#4
Posted 18 April 2013 - 04:21 PM
#5
Posted 21 April 2013 - 02:54 AM
#6
Posted 21 April 2013 - 03:42 AM
The first step to his code is looking through the pile of dirty dishes for the shell. The shell is the thing you see when you start the computer up (CraftOS basically). When he finds it, he tells it to exit, which basically means it tells the shell to clean all the dishes on top of it, then clean itself, so the shell or anything run inside of it is no longer on the stack.
You know when you type exit into CraftOS, and it says press any key to continue, then shuts down the computer? The next step is to override the key press and shutdown methods (os.pullEvent and os.shutdown) and basically simulate them, and make the computer believe they've behaved normally. Note, he doesn't actually shut the computer down, he just makes the shell think the computer's shut down, but it actually hasn't.
Then he resets everything back to normal, and voila! The program is now above CraftOS, above Rednet, etc...
#8
Posted 22 April 2013 - 01:27 AM
#10
#11
Posted 22 April 2013 - 07:11 PM
os.shutdown = function() do sleep(0) end end
Wont work?
#12
Posted 22 April 2013 - 08:29 PM
GravityScore, on 22 April 2013 - 02:14 PM, said:
Espen, on 22 April 2013 - 01:51 AM, said:
Yes, but you can't just override os.shutdown and call it, because it won't shut anything down. NeverCast's method is basically the only way I can think of, unless there's another method of getting the computer to shut down.
Forcing the shell exit is making the bios.lua continue with its code after the parallel.waitForAny() that startet the top level shell.
Then the bios.lua presents the user with a message to "Press any key to continue" and wait for a key event, which we intercept and simply return just that event.
After that the bios.lua's last step would be to call os.shutdown(), which we intercept as well and instead recover everything to our heart's desire.
So after our successful injection bios.lua is waiting for its last call to return, namely that one from os.shutdown()
I didn't go into all the other necessary steps in my previous answer, because I was trying to give a direct answer to his question, concentrating only on the difference between actually shutting down the computer and making it only think we shut it down.
That's what I meant with "you need to trick the computer into thinking it shut down".
It was just a clarification of Imque's misunderstanding that we actually shut down the computer. Which we don't, we just make it think we did.
#13
Posted 22 April 2013 - 09:22 PM
prev = {
shutdown = os.shutdown
}
os.shutdown = function()
term.clear()
term.setCursorPos(1, 1)
print("Booted before shell")
shell.run("rom/programs/shell")
os.shutdown = prev.shutdown
end
#14
Posted 23 April 2013 - 12:06 AM
I'm afraid it wouldn't. The only thing you're essentially doing is to start another shell on top of your running program.
And when that shell ends, you'll be back in your program, which then would end and land you right back in the top level shell, from which your program started to begin with.
Let me try to explain how to do it ...
Edited by Espen, 23 April 2013 - 01:03 AM.
#15
Posted 23 April 2013 - 12:30 AM
Espen, on 22 April 2013 - 08:29 PM, said:
GravityScore, on 22 April 2013 - 02:14 PM, said:
Espen, on 22 April 2013 - 01:51 AM, said:
Yes, but you can't just override os.shutdown and call it, because it won't shut anything down. NeverCast's method is basically the only way I can think of, unless there's another method of getting the computer to shut down.
Forcing the shell exit is making the bios.lua continue with its code after the parallel.waitForAny() that startet the top level shell.
Then the bios.lua presents the user with a message to "Press any key to continue" and wait for a key event, which we intercept and simply return just that event.
After that the bios.lua's last step would be to call os.shutdown(), which we intercept as well and instead recover everything to our heart's desire.
So after our successful injection bios.lua is waiting for its last call to return, namely that one from os.shutdown()
I didn't go into all the other necessary steps in my previous answer, because I was trying to give a direct answer to his question, concentrating only on the difference between actually shutting down the computer and making it only think we shut it down.
That's what I meant with "you need to trick the computer into thinking it shut down".
It was just a clarification of Imque's misunderstanding that we actually shut down the computer. Which we don't, we just make it think we did.
I'm sorry, I quoted the wrong post
I was directing it to Imque, just to make sure he/she understood that the way NeverCast did it is probably the only way.
#16
Posted 23 April 2013 - 12:32 AM
GravityScore, on 23 April 2013 - 12:30 AM, said:
I was directing it to Imque, just to make sure he/she understood that the way NeverCast did it is probably the only way.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











