Hey guys, One of the easiest programming languages in the World is our Python. Here this post is intended for those who want to learn the hacking techniques! Here I would like to share simple 4lines of Python hack tricks that make shutdown or restart your PC. The logic here is that have the function contains the CMD Command line 'shutdown' with forceful(/s) timeout as 1 minute.
Shutdown logic is here...
Restart logic is here
Jump to Linux VM and same thought to execute the same script then it failed! "Must be root." The solution there you need to be superuser to shutdown your Linux machine.
To have better understand about the shutdown command in Linux operating system, used the --help option.
On Linux the script will be as follows:
The output is as follows for the Linux platform.
Shutdown logic is here...
import os def shutdown(): os.system("shutdown /s /t 1") shutdown()
Restart logic is here
import os def restart(): os.system("shutdown /r /t 1") restart()
Jump to Linux VM and same thought to execute the same script then it failed! "Must be root." The solution there you need to be superuser to shutdown your Linux machine.
To have better understand about the shutdown command in Linux operating system, used the --help option.
[vagrant@mydev ~]$ sudo shutdown --help shutdown [OPTIONS...] [TIME] [WALL...] Shut down the system. --help Show this help -H --halt Halt the machine -P --poweroff Power-off the machine -r --reboot Reboot the machine -h Equivalent to --poweroff, overridden by --halt -k Don't halt/power-off/reboot, just send warnings --no-wall Don't send wall message before halt/power-off/reboot -c Cancel a pending shutdown
On Linux the script will be as follows:
import os def shutdown(): os.system("shutdown -h") shutdown()
The output is as follows for the Linux platform.
Comments
Post a Comment