Lost Password

From Initq
Jump to: navigation, search

This is not really a hack because you need physical access to the machine. If you just happen to be be in the server room and have physical access to the servers then do the following to change the root password. This works for any linux distro.

Reboot the machine, since you don't have the password you may just have to pull the plug. Hopefully you have not corrupted the file system. When it boots up see if they use LILO or Grub.

  • Hot key for grub menu is SHIFT. Hold down the SHIFT key to enter grub2.0. For Grub1.0 it is ESC.
  • type linux init=/bin/bash for lilo.
  • type 1 init=/bin/bash for grub, you have to go in edit mode by pressing e and then enter and then b for boot. Enter text at the and on the kernel line, not initrd.

You will get the famous # in a few seconds. The root file system will be mounted read only. so do the following:

  • mount -o remount,rw / to mount the filesystem read/write.

now you can run your passwd command to change the root password. after changing the password, create yourself an account also, call it apache2, sysadmins never suspect this account and think its part of apache. don't just reboot yet, do the following:

  • mount -o remount,ro / to make the filesystem read only. now you can just pull the plug or reboot. after the system has booted up, get the ip and now you are set to remotely do what ever you like.

The reason we created an account is because many ssh servers will not allow root to come in this is why you will use apache2 account to ssh in and then su to root and get intimate with the system.

If you want to be ruthless then change everyones shell to /bin/false except apache2. change apache2's uid and gid to zero.

  • apache2:x:0:0::/home/apache2:/bin/sh

This will buy you some time to do your work in peace until the sysadmin pulls the power cord.

Personal tools