- How to Hack Your Own Linux System
- Hack Your Linux System Without Using Single User Mode
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How to Reset Ubuntu Password in 2 Minutes
- Reset Ubuntu password from recovery mode
- Step 1: Boot into recovery mode
- Step 2: Drop to root shell prompt
- Step 3: Remount the root with write access
- Step 4: Reset username or password
- Possible Troubleshoot:
- Alternate method to reset Ubuntu pasword
- Step 1
- Step 2
- Step 3
- Step 4
- If resetting Ubuntu passwords is this easy, isn’t this a security risk?
- Bonus Tip: Handling the possible keyring issue after changing password
How to Hack Your Own Linux System
Passwords are the sole criteria of system Security for most of the System. And when it comes to Linux, if you know the root password you owns the machine. Passwords are as a Security measure for BIOS, Login, Disk, Application, etc.
Linux is considered to be the most Secure Operating System to be hacked or cracked and in reality it is, still we will be discussing some of the loop-holes and exploits of a Linux System. We will be using CentOS Linux throughout the article as an article to crack our own machine’s security.
Press any key to interrupt the boot, as soon as Linux machine boots and you will get a GRUB menu.
Linux Boot Screen
Press ‘e‘ to edit and go to the line starting with kernel (Generally 2nd Line).
Switch to Single User Mode
Now press ‘e‘ to edit the kernel and add ‘1‘ at the end of line (after one blank space) forcing it to start in single user mode and thus prohibiting it to enter default run-level. Press ‘Enter’ to close the kernel editing and then boot to the altered option. For booting You need to press ‘b‘
Logged into Single User Mode
Now you are logged in to single-user mode.
Set root Password
Yeah! Now using ‘passwd‘ command we can change the root password. And once you have root password you owns the Linux Machine – Don’t you Remember? You can now switch to graphical screen to edit anything and everything.
Add new root Password
Note: In case the above ‘passwd‘ command doesn’t work for you and you didn’t get any output, it simply means that your SELinux is in enforcing mode and you need to disable it first, before proceeding further. Run following command at your prompt.
An then run the ‘passwd‘ command, to change root password. Moreover command.
Switch to X Windows
Use command “init 5” (Fedora Based) systems and “gdm3” (Debian Based) systems.
Switch to X Window
So was this not a cake-walk to hack a Linux box? Think about the scenario if somebody did this to your server, Panic! Now we will be learning how to safeguard our Linux Machine from being modified using single user mode.
How we breaked into the system? Using Single-user mode. OK, so the loophole here was – logging into single user mode without the need of entering any password.
Fixing this loophole i.e., password protecting the single user mode.
open file “/etc/rc1.d/S99single” in your favourite editor and search for line.
Just add the following line above it. save it an exit.
Before
After
Now before entering single user mode you will need to provide root password to proceed. Check again trying to enter single user mode after these changing above said file.
Enter Root Password for Single User Mode
Why don’t you check it, Yourself.
Hack Your Linux System Without Using Single User Mode
OK, so now you will be feeling better that your system is secure. However this is partially true. It is true that your Linux Box can’t be cracked using single user mode but still it can be hacked the other way.
In the above step we modified the kernel to enter single user mode. This time also we will be editing the kernel but with a different parameter, let us see how ?
As a kernel parameter we added ‘1‘ in the above process however now we will be adding ‘init=/bin/bash’ and boot using ‘b‘.
Add ‘init=/bin/bash’
And OOPS you again hacked into your system and the prompt is enough to justify this.
Hacked into Your System
Now Trying to change the root password using the same process as stated in the first method using ‘passwd‘ command, we got something like.
Changing Root Password
Reason and Solution?
- Reason: The root (/) partition is mounted Read only. (Hence password was not written).
- Solution: Mount the root (/) partition with read-write permission.
To mount the root partition with read-write permission. Type the following command exactly.
Mount / Partition in Read Write
Now again try to change the password of root using ‘passwd‘ command.
Change Password of root
Hurrah! You hacked into your Linux System once again. Ohhh man is the system so easy to exploit. No! the answer is no. All you need is to configure your system.
All the above two process involved tweaking and passing parameters to kernel. So if we do something to stop kernel tweaking obviously our Linux box would be Secure and not that easy to break. And in order to stop kernel editing at boot we must provide password to boot loader, i.e., password protect the grub (Lilo is another bootloader for Linux but we won’t be discussing it here) boot loader.
Provide encrypted password to bootloader using ‘grub-md5-crypt‘ followed with your password. First encrypt the password
Password Protect Boot Loader
Copy the above encrypted password, exactly as it is and keep it safe we will be using it in our next step. Now open your ‘grub.conf‘ file using your favourite editor (location might be: /etc/grub.conf) and add the line.
Change “$1$t8JvC1$8buXiBsfANd79/X3elp9G1” with your encrypted password which you generated above and copied it safely to some other location.
The “grub.conf” file after inserting the above line, save and exit.
grub.conf Preview
Now Cross Checking, editing the kernel at boot, we got.
Cross Cheking Boot Loader
Now you would be breathing that you system is fully secure now and not prone to hack, however still the game is not over.
You better know that you can enforce rescue mode to remove and modify the password using a bootable image.
Just put your installation CD/DVD in your drive and select Rescue Installed System or use any other rescue image, you could even use a Live Linux Distro, mount the HDD and edit the ‘grub.conf‘ file to remove password line, reboot and again you are logged in.
Note: In rescue mode Your HDD is mounted under ‘/mnt/sysimage‘.
I know you would be asking- so where is the end. Well i would say is to.
- Password protect your BIOS.
- Change you Boot order to HDD first, followed by rest (cd/dvd, network, usb).
- Use Password sufficiently Long, Easy to remember, Hard to guess.
- Never write Your Password to anywhere.
- Obviously use Uppercase, Lowercase, Numbers and Special Character in your password thus making it hard to break.
This guide was just to make you aware of facts and tell you how to secure your System. Tecmint.com and the writer of this article strongly discourage this guide as a base of exploiting other’s system. It is the sole responsibility of the reader if they engage in any such activity and for such kind of act neither the write nor Tecmint.com will be responsible.
Your positive comments makes us feel good and encourages us and that is always sought from you. Enjoy and Stay Tuned.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How to Reset Ubuntu Password in 2 Minutes
Last updated August 4, 2020 By Abhishek Prakash 375 Comments
Brief: If you forgot your user password on Ubuntu, don’t worry. You can reset an Ubuntu password very easily. This guide explains an easy method for changing the root password on Ubuntu. The method should also be applicable to other Linux distributions.
Forgot your Ubuntu login password? It happens.
If you haven’t used Ubuntu for some time, it’s only natural to not remember the password. The good news is that you don’t need to reinstall the entire operating system because of it. You can recover Ubuntu passwords easily.
The method mentioned here works for resetting an Ubuntu password in VMware, dual boot or single install. All you need is a little bit of patience and to run a couple of commands. You’ll reset the root password within minutes.
Using Linux on WSL?
It’s a bit different for WSL. You may follow the steps for resetting Linux password in WSL here.
Reset Ubuntu password from recovery mode
If you prefer watching videos to reading text, I’ve also made a video of this tutorial. Don’t forget to subscribe to our YouTube channel for more Linux tutorial videos.
Step 1: Boot into recovery mode
Switch the computer on. Go to the grub menu. Generally, it appears automatically – if not, then hold down the shift key or press Esc key until the boot menu appears.
If you’re using Oracle VirtualBox or VMware, you have to hold down the shift key when the logo of Oracle or VMware appears.
In the grub menu, select the “Advanced Options for Ubuntu”:
In here, you’ll see the option to go to recovery mode:
It will bring you to a black screen with several lines of output being displayed in a flash. Wait for a few seconds here.
Step 2: Drop to root shell prompt
Now you’ll be presented with different options for recovery mode. Here you need to choose “Root – Drop to root shell prompt“. Just press the enter key to select this option. Like in the picture below:
You’ll see that when you select the root shell prompt option, an option to enter commands appears at the bottom. This is your root shell prompt and this is where you’ll use the commands to reset the password.
Step 3: Remount the root with write access
You need to have write access to the root partition. By default, it has read-only access.
Use the command below to remount it with write access:
Step 4: Reset username or password
Here, you’ll be given root access. Use the following command to list all the users available:
Based on this command, choose the “username” for which you want to reset or (say) hack the password. Now, use the following command to reset the password for the selected “username“:
It prompts for a new password. Enter the new password twice:
Voilà! There you go. You have just successfully reset the password. Now exit the root shell prompt:
When you exit, you’ll be back at the recovery mode menu. Select the normal boot option here.
There will be a warning about graphics mode compatibility. Don’t worry. A complete reboot will fix any issues with this.
You should now be able to log in with the new password.
Possible Troubleshoot:
While entering the new password you might be prompted with Authentication token manipulation error like this:
The reason for this error is that the file system is mounted with read access only. Change the access and remount the file system in the following manner:
Now try to reset the password again. It should work now.
As you can see, it is extremely easy to change Ubuntu password even if you’ve forgotten it. It will barely take a few minutes.
Alternate method to reset Ubuntu pasword
If for some reason you have difficulty dropping to the root shell and changing the password, you can try these steps.
Step 1
Reboot your computer. Hold shift to bring up the grub screen (if it doesn’t appear automatically). Press E at the grub prompt to edit the grub screen.
Step 2
Find the line starting with linux, change the ro to rw and append init=/bin/bash at the end of that line.
Change ro to rw and add init=/bin/bash at the end of this line
Step 3
Press ctrl-x to save your changes and boot.
Now you are booting into the Linux kernel with read and write permissions, and instead of going to a graphical user interface, you’ll use the bash shell.
In other words, your system will boot up to a passwordless root shell.
Step 4
Type in the passwd command with your username. If you don’t know the username, check with ls /home command (as mentioned in method 1).
Set your new password.
Once you’ve set the new password, exit the terminal. Just type reboot in the terminal or use the shutdown command.
Your password should be changed now.
If resetting Ubuntu passwords is this easy, isn’t this a security risk?
That’s a fair question. One of the main advantages of Linux over Windows is its security. But if “anyone” can reset the password, how come Ubuntu or other Linux distributions can be considered secure?
Let me explain a few things here. The main security risk is if someone hacks into your account from a remote location via the internet. That’s not happening here.
If anyone has physical access to your computer, the data in your computer is already at risk. Unless the entire disk is encrypted, anyone can “steal” your data using a live USB without even entering your installed operating system.
By default, Ubuntu doesn’t have a root password and the root account is locked. The user account you set up while installing Ubuntu is included as an admin with sudo rights. But that doesn’t mean that you are root.
This lack of root password is a deliberate feature The “advanced options for Ubuntu” in the boot menu allow you to perform some specific root-related tasks from the “root shell prompt”. This is why you’re able to reset the Ubuntu password through this method.
If you want to make your system more secure, you can either encrypt the disk (to save your data) or setup a password for root user in Ubuntu.
Bonus Tip: Handling the possible keyring issue after changing password
There is a keyring feature in Ubuntu that is used for keeping passwords locked and safe.
When you reset the forgotten password, the keyring remains unlocked and you may see an error message like this.
Open the Passwords and Keys application and here, delete the Login passwords.
When you try to use Google Chrome again in Ubuntu, it will ask you to create a new keyring. Use the new login password as the keyring password.
Did it help you?
I hope I made things clear about resetting forgotten passwords in Ubuntu.
Did this quick tip help you recover your admin password? Do share in the comments below.
Like what you read? Please share it with others.
Источник