(CentOS 6.6:
Lesson 4)
{ Using a Live CD to
crack a password protected grub.conf file }
Section 0. Background
Information |
- Background Information
- In
Lesson 3 you learned how to password protect the grub menu.
- This lesson teaches you how to circumvent a
password protected grub menu using a CentOS Live CD. Actually, you
can use just about any Linux Live CD (e.g., Hiren's, BackTrack, etc).
- Pre-requisites
-
CentOS 6: Lesson 1: Installing CentOS 6.6
-
CentOS 6.6: Lesson 3: Hardening the Boat Loader, /boot/grub/grub.conf
-
Lab
Notes
- In this lab we will do the following:
- We will circumvent password protected
Grub with a CentOS-6.6 Live CD.
- We will mount the boot partition
- We will removed the password directive
that protects the grub.conf file.
- We will test our handy work.
- Legal Disclaimer
- As a
condition of your use of this Web site, you warrant to
computersecuritystudent.com that you will not use this Web site for any
purpose that is unlawful or that is prohibited
by these terms, conditions, and notices.
- In accordance with UCC § 2-316, this
product is provided with "no warranties, either express or implied." The
information contained is provided "as-is", with "no guarantee of
merchantability."
- In addition, this is a teaching website
that does not condone malicious behavior of
any kind.
- You are on notice, that continuing
and/or using this lab outside your "own" test environment
is considered malicious and is against the law.
- © 2015 No content replication of any
kind is allowed without express written permission.
Section 1. Configure
CentOS-6.6 Virtual Machine Settings |
- Open Your VMware Player
- Instructions:
- On Your Host Computer, Go To
- Start --> All Program -->
VMWare --> VMWare Player
- Edit CentOS-6.6 Virtual Machine Settings
- Instructions:
- Highlight CentOS-6.6
- Click Edit virtual machine
settings
- Set Machine to Boot From CD/DVD
-
Instructions:
- Select CD/DVD (IDE)
- Device status: Check the
Connect at power on checkbox.
- Select the "Use ISO image file"
radio button.
- Click the Browse Button and Navigate to the location of
your CentOS-6.6-i386-bin-DVD1.iso or other Live CD.
- Click the OK Button
- Edit Network Adapter
- Instructions:
- Highlight Network Adapter
- Select Bridged
- Click the OK Button
Section 3. Play
Virtual Machine |
- Start the CentOS-6.6 VM
- Instructions:
- Click on the CentOS-6.6 VM
- Click on Play virtual machine
- Obtain Boot Menu
- Instructions
- Once you see the below vmware screen,
(1) Left Click in the screen and (2) press the "<Esc>"
key
- Note(FYI):
- This might take you a few times so be
patient!!!
- Boot Menu Options
- Instructions:
- Arrow Down to CD-ROM Drive
- Press <Enter>
- Rescue
- Instructions:
- Arrow Down to "Rescue installed system"
- Press <Enter>
- Choose Language
- Instructions:
- Arrow Down English or your language of
choice
- Press the
<Tab>
key, which will move focus to the OK Button
- Press the
<Enter>
key
- Choose Keyboard Type
- Instructions:
- Arrow Down to us or desired keyboard
and press the
<Tab>
key
- Once the OK button is highlighted, press the
<Enter>
key
- Setup Networking
- Instructions:
- Press the
<Tab>
key
- Once the No button is highlighted, press the
<Enter>
key
- Continue Mounting File Systems
- Instructions:
- Press the
<Tab>
key
- Once the Continue button is
highlighted, press the
<Enter>
key
- chroot information
- Instructions:
- Press the
<Enter>
key
- Mount Information
- Instructions:
- Press the
<Enter>
key
- Shell Access
- Instructions:
- Make sure cursor is on "shell
Start shell"
- Press the
<Tab>
key
- Press the
<Enter>
key
Section 4. Editing
the grub.conf from single user mode. |
- Working in Single User Mode
- Instructions:
- whoami
- Notice you are the root user.
- df -k
- Notice all the File Systems and
Volume Groups are mounted on /mnt/sysimage
- /mnt/sysimage is where CentOS
mounts all the installation file systems and volume groups it
discovers in the /etc/fstab.
- Note(FYI):
- whoami, this command displays the user
name associated with the current effective user ID.
- df -k, this command displays the amount
of disk space available on each of the file systems.
- View the /mnt/sysimage contents
- Instructions:
- cd /mnt/sysimage
- ls --file-type
- Strings that end with a
backslash(/) are directories, else it is a file.
- Note(FYI):
- cd /mnt/sysimage, Change Directory to
the /mnt/sysimage directory.
- ls --file-type, list directory contents
and show the file type.
- View the boot/grub/ contents
- Instructions:
- cd boot/grub/
- ls -l
- Note(FYI):
- cd boot/grub/, Change Directory into
the /mnt/sysimage/boot/grub directory.
- ls -l, This provides a long or detailed
listing of all the files.
- Removing the password from grub.conf
- Instructions:
- cp grub.conf grub.conf.bkp2
- grep password grub.conf
- sed -i '/password/d' grub.conf
- ls -l grub.conf
- grep password grub.conf
- Note(FYI):
- cp, is the copy command, grub.conf.bkp2
is a copy of grub.conf.
- grep, is a pattern matching utility
that can search files and input streams.
- sed is a stream editor for filtering or
transforming text. In this case, we will use sed to remove the
line that contains the string password.
- -i, means edit files in place.
- /password/d, means delete all lines
that contain the string password.
- Notice that grep does not result a line
that contains password because we removed it with sed.
- Power Off Operating System
- Instructions:
- cd /
- poweroff
Section 5.
Configure Virtual
Settings |
- Edit CentOS-6.6 Virtual Machine Settings
- Instructions:
- Highlight CentOS-6.6
- Click Edit virtual machine settings
- Auto Detect Hard Drive
- Instructions:
- Click on CD/DVD(IDE)
- Click the Use physical drive: radio
button
- Make sure Auto detect is selected
- Edit Network Adapter
- Instructions:
- Highlight Network Adapter
- Select Bridged
- Click the OK Button
Section 5.
Configure the
grub.conf to provide a root prompt at single user
mode |
- Start the CentOS-6.6 VM
- Instructions:
- Click on the CentOS-6.6 VM
- Click on Play virtual machine
- Boot to Grub 2 Menu
- Instructions
- Once you see the below vmware screen,
(1) Left Click in the screen and (2) press the "e"
key
- Note(FYI):
- This might take you a few times so be
patient!!!
- Physical Machine Instructions
(Optional)
- Physically power off the machine.
- Physically power on the machine.
- During the boot process, either hit
the "e" or "down arrow" key
Section 6. Configure grub to provide single user root prompt |
- Access the Grub Menu
- Note(FYI):
- Section 1, Step 3 should produce the
below screen.
- Instructions:
- Press the "e" key to access the kernel
selection.
- Access the Kernel
- Instructions:
- Make sure the kernel line is
highlighted
- Press the "e"
key to edit the kernel.
- Note(FYI): What is
the kernel?
- The kernel is the part of the operating
system that allocates machine resources, including memory, disk
space, and CPU cycles, to all other programs that run on a
computer. The kernel includes the low-level hardware interfaces (a.k.a
drivers) and manages processes, the means by which Linux executes
programs.
- You should see the below screen.
- Instructions:
- Proceed to step 4.
- Prepare Operating System to Boot into Single
User Mode
- Instructions:
- Press the <Spacebar> and Type
1 after the word quiet (See Below)
- Press Enter.
- Note(FYI):
- This is how we will put the system into
single user mode.
- Boot the System
- Instructions:
- Make sure the kernel line is
highlighted
- Type "b" to boot.
- Note(FYI):
- The below screen is the result of
pressing enter in step 4.
Section 7. Single User Mode |
- Got Root?
- Note(FYI):
- Now your system is in single user mode.
- Create a new root password
- Instructions:
- passwd root
- New password: <Supply a new password>
- Retype new password: <Re-Supply the new
password>
- Note(FYI):
- Notice you were not prompted for the
old root password.
- Boot machine into the Graphical Multiuser
Interface
- Instructions:
- init 5
- Note(FYI):
Below are all the run levels.
- init 0 - Halt
- init 1 - Single User, File Systems are
Mounted, Network Down.
- init 2 - Multi User, No NFS, File
Systems Mounted, Network Up.
- init 3 - Multi User, File Systems are
Mounted, Network Up.
- init 4 - User defined.
- init 5 - Graphical Multiuser, File
Systems Mounted, Network Up.
- init 6 - Reboot.
-
- Login to CentOS
- Note(FYI):
- Until you click the user, in this case
Security Student, the Password field will not be displayed.
- Instructions:
- Click on Security Student
- This will display the password text
box.
- Supply its' password
- Click the Log In Button
- Open a Terminal
- Instructions:
- Applications --> System Tools -->
Terminal
- Switch User to Root
- Instructions:
- su - root
- Provide the Root Password
- Proof of Lab
- Instructions:
- cd /boot/grub/
- ls -l grub.conf*
- grep password grub.conf*
- date
- echo "Your Name"
- Put in your actual name in place of
"Your Name"
- e.g., echo "John Gray"
-
Proof of Lab
Instructions
- Press the <Ctrl> and <Alt> key at the
same time.
- Press the <PrtScn> key.
- Paste into a word document
- Upload to Moodle
|
 
|