Project 1 Task 4 Root account password cracking and protection

1. There are two ways to enter single-user mode and modify the password of the toot account to enter single-user mode

Method 1: Use the a button to enter single-user mode

Step 1: Enter the kernel editing interface

Boot into GRUB, when counting down, press the a key twice to edit the kernel parameters.


Step 2: Edit the kernel startup parameters

Enter the kernel editing interface, after entering a space, enter the number 1 or single to tell the Linux kernel that the subsequent startup process needs to enter the single-user mode, and then press the Enter key to enter the single-user mode.


Step 3: Use the [passwd] command to change the root password

The system does not need a password to enter the single-user mode, use the [passwd] command to modify the account password.

Enter the [passwd] command, and then press the Enter key. The system waits for the new root password to be entered. After the input is complete, press the Enter key to confirm the new password again. After the input is complete, press the Enter key.


Step 4: Enter the multi-user system

Enter [init 3] to enter the multi-user mode text mode that can provide network services, enter [intit 5] to enter the multi-user mode graphical interface mode that can provide network services, and test the password just changed.

Enter the user name [root], and then press Enter to enter the new password after modification. After confirmation, you can enter the system.

Method 2 Use the e operation button to enter the single-user mode

Step 1: Enter the kernel selection interface and see the interface as shown below, and press the e key.


Step 2: Enter the kernel editing interface and press the e key again to enter the interface with 3 menus as shown in the figure below.

Step 3: Edit the kernel startup parameters

Press the ↑ and ↓ keys, move the cursor to the second line starting with "kernel" and press the e key again to edit the Linux boot level.


After entering a space, enter the number [1] or [single] at the end of the line to tell the Linux kernel that the subsequent boot process needs to enter single-user mode, and then press the Enter key, the system returns to the boot menu interface, as shown below:


Step 4: Enter Single User Mode

Press the b key, then the system starts without a password and enters the single-user mode.


Step 5: Use the [passwd] command to modify the root password

Enter the [passwd] command, and then press the Enter key. The system waits for the new root password to be entered. After the input is complete, press the Enter key to confirm the new password again. After the input is completed, press the Enter key.


After confirming that the two passwords are the same, you will see a "successfully" message indicating that the password was changed successfully.

If after entering [passwd], you find that there is no prompt to enter a new password at all, but skip directly, and you cannot change the password at all. The reason for this is that seLinux is enabled by default when CentOS6.5 is installed by default. Under seLinux, passwd cannot be applied, and seLinux must be temporarily closed. Enter [setenforce] to close seLinux, so that you can change the password in single-user mode.


2. Encrypt single-user mode

Method 1: Civilized method

Step 1: Open the /boot/grub/grub.conf file and enter the following command, open the /boot/grub/grub.conf file in the vim editor: [vim /boot/grub/grub.conf]

Step 2: Edit the /boot/grub/grub.conf file and add in the next line of the splashimage parameter: password=Password is saved and then restart the computer. When you log in to the GRUB menu page again, you will find that you cannot directly press the e key. Edit the startup label, you need to use the [p] command, and enter the correct password before you can edit the startup label



Method 2: MD5 encryption method

Step 1: Encrypt the password with md5 Enter [grub-md5-crypt] in the terminal and press Enter, then the system will ask to enter the same password twice, and then the system will output the MD5 code.

Step 2: Add the md5 ciphertext to the /etc/grub.conf file, copy the generated MD5 ciphertext, then edit the /etc/grub.conf file, and add the MD5 ciphertext to the next line of the splashimage parameter. After saving, restart the computer, and when you log in to the GRUB menu page again, you will find that you cannot directly press the e key to edit the startup label. You need to use the [p] command and enter the correct password before you can edit the startup label. edit.




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324621017&siteId=291194637