Task 4: Cracking and Protection of the Password of the Root Account

[Subtask 1] Enter single-user mode and change the root account password
        Method 1: Enter single-user mode using the a operation button (recommended: simple operation, this is the fastest way to enter single-user mode)

[Subtask 1] Enter the single-user mode and modify the password of the toot account

There are two ways to enter single-user mode, which are described below.

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

When you see this interface, press the e key.


Step 2: Enter the kernel editing interface

Press the e key again to enter the following interface with 3 menus.


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 to return the system to the boot menu interface.

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

输入【passwd】命令,然后按Enter键,系统等待输入新的root密码,输入完成后按Enter键再次确认输入新的密码,输入完后按Enter键即可。

当确认两次密码输入一致后,会看到“successfully”即修改密码成功的信息提示。

如果在输入【passwd】后发现,根本没有提示输入新密码,而是直接跳过去,根本没法更改密码,出现这种情况的原因是,默认安装CentOS6.5时seLinux是默认开启的。在seLinux下,passwd是没法应用的,要临时关闭seLinux。

输入【setenforce】关闭seLinux,这样就可以在单用户模式下更改密码了。


子任务二   给单用户模式加密

方式一:文明方式

第一步:打开/boot/grub/grub.conf文件

输入如下命令,在vim编辑器打开/boot/grub/grub.conf文件:【vim /boot/grub/grub.conf】

第二步:编辑/boot/grub/grub.conf文件

在splashimage这个参数下一行添加:password=密码


保存后重新启动计算机,再次登录到GRUB菜单页面的时候会发现,这时已经不能直接按e键编辑启动标签了,需要使用【p】命令,输入正确的密码后才能够对启动标签进行编辑

方式二:MD5加密方式

第一步:给密码进行md5加密

在终端中输入【grub-md5-crypt】后按Enter键,这时系统会要求输入两次相同的密码,之后系统便会输出MD5码。

第二步:添加md5密文到/etc/grub.conf文件中

将生成的MD5密文复制下来,然后编辑/etc/grub.conf文件,在splashimage这个参数下一行添加MD5密文。

保存后重新启动计算机,再次登录到GRUB菜单页面的时候就会发现,这时也不能直接按e键编辑启动标签了,需先使用【p】命令,输入正确的密码后才能够对启动标签进行编辑。


Guess you like

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