AutoRoot – Automatically Reset The root Password On Linux Machines

Python 1 Comment

AutoRoot will scan for any logical volume containing the word root or for block devices starting from /dev/sda1…/dev/sda10, /dev/sdb1…/dev/sdb10, /dev/sdc1…/dev/sdc10, it will then try to mount the volume and check for the password file,if found, it will change the root password to: vNugget.com

This started as a simple exercise to get familiar with the python subprocess module, then things got interesting. I thought it ill be useful if I can automate the reset of the root password on various Linux distribution.

Demo

How it Work ?

The script is written in python and need to be added to the iso image of system rescue cd which can be found on http://www.system-rescue-cd.org.
To automate the script execution, an autorun file need also to be added to the iso image, this autorun file is used to run AutoRoot.py.

autorun content

#!/bin/bash
python /livemnt/boot/AutoRoot.py

After the machine reboot using the iso file, the AutoRoot script will take care of looking for the root file system, chroot to it and then change the password, after that all you need to do is reboot your machine without the cdrom attached.

On which Linux distribution it work ?

I have tested it, and it successfully/automatically reset the root password on the following distribution, using Logical Volume or block devices

  • Debian 8.5.0
  • Linux Mint 17.3 cinnamon 32bit
  • Ubuntu 16.04 server
  • Fedora 23
  • CentOS 6.7

How to Use it ?

You have two options here:

  1. I have already prepared an iso image of system rescue cd which contain the required files (AutoRoot.py and autorun), I have also modified the isolinux.cfg file so the machine will reboot without needing your interaction. You can download the ready-to-use iso image.
  2. Download the iso image directly from http://www.system-rescue-cd.org and then put AutoRoot.py and autorun on the root directory of the iso image, for Windows users, you can use a tool like WinISO to do this, then reboot, auto-hack and enjoy.

If everything goes perfectly, you should see a screen like this

reset root password on linux centos

To-Do List

  • The fun part: Adding Windows support 😀
  • Rewrite the script
  • Stripe down the system rescue CD size.
  • Add more Linux distribution/configuration support
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading...

One thought on “AutoRoot – Automatically Reset The root Password On Linux Machines

Leave a Reply

Your email address will not be published. Required fields are marked *