Hack password on linux machine with GRUB
May 17, 2021
It happens, you need to hack or recover password on linux machine, when you even don’t know real password. You know nothing about real user, you have no clue what the password could be and other facts, but it’s not a problem!
If your situation matches with next conditions, you’re able to hack any linux machine:
- You have physical access to linux machine
- GRUB bootloader on linux machine have no password
Does it matches? Great!
Let’s start. The essence of the way is in changing OS preload script for letting us enter in root-authorized shell. To change script, you need to enter GRUB menu (in my case you should press “shift” key) when OS is loading:
GRUB menu
To enter preload script edit menu, press “e” key. Go to the “linux” line. Delete everything, that goes after “rw”. Move “ro” to “rw” and write “init=/bin/bash” after. (or path to another shell, OS uses).
We have changed hard disk access mode from “read only” to “read-write”, otherwise, we won’t be able to rewrite password.
Preload script before:
Preload script before
Preload script after:
Preload script after
Fine. Press F10 key to enter OS with edited preload script. Wait for load.
Change root password with passwd command
We appear in root shell. Enter “passwd” command, to change current (root) account password.
Congratulations! We have changed the root password without even knowing it!
Thanks for reading!
I would be grateful if you donate me on PayPal!