(CentOS 6.6:
Lesson 5)
{ Using a Live CD to
clear root's passwd in /etc/shadow }
Section 0. Background
Information |
- Background Information
- In this lesson, you will learn how to use a
Fedora Live CD or any Linux live CD to (1) boot into single user mode,
(2) mount the "/" directory which contains /etc, and (3) how to remove
root's password from the /etc/shadow file.
- Pre-requisites
-
CentOS 6.6: Lesson 1: Installing CentOS 6.6
-
CentOS 6.6: Lesson 2: Use CentOS 6.6 Grub to boot into single user mode
-
CentOS 6.6: Lesson 3: Hardening the Boot Loader, /boot/grub/grub.conf
-
CentOS 6.6: Lesson 4: Using a Live CD to crack a password protected
grub.conf file
-
Lab
Notes
- In this lab we will do the following:
- Boot the Operating System off a CentOS
Live CD.
- We will mount the disk partition that
contains /etc.
- We will delete root's encrypted
password from /etc/shadow.
- 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 2. 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 3. Examining
Mounted File Systems in 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.
-
Section 4. Modifying
/etc/shadow in Single User Mode. |
- Make a backup copy of /etc/shadow
- Instructions:
- cd /mnt/sysimage/etc/
- cp shadow shadow.bkp
- ls -l shadow*
- Open the shadow File
- Instructions:
- vi shadow
- Position Cursor
- Instructions:
- Cursor over one position to the right
of the first colon(:)
- Delete Encrypted Password
- Instructions:
- Type
dt:
- This will delete everything up to
the next colon.
- You should now see no password
between the first and second colon(:).
- Note(FYI):
- If you make a mistake, just press
u
to undo.
- Save the shadow file
- Instructions:
- Type :wq!
- Press <Enter>
- Reboot Machine
- 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 6. Login without a root password |
- Start the CentOS-6.6 VM
- Instructions:
- Click on the CentOS-6.6 VM
- Click on Play virtual machine
- 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
- whoami
- Note(FYI):
- su, This is the switch user command.
In this case, I am switching from user student to user root.
- whoami, The command prints the user
name associated with the current effective user ID.
- Notice you were not prompted for a root
password!!!
- Switch User to root
- Instructions:
- passwd root
- Provide a password
- Re-Enter the password
- Proof of Lab
- Instructions:
- egrep '(user root by|password
changed for root)' /var/log/secure | tail -2
- grep root /etc/shadow* | awk -F:
'{print $3}' | wc -c
- date
- echo "Your Name"
- Put in your actual name in place of
"Your Name"
- e.g., echo "John Gray"
- Note(FYI):
- egrep, is part of the grep utilities
that allows you to search and filters files and string for pattern
matches. egrep provides additional functions, whereby you can
search or filter many string using the pipe(|) as a string
separator.
- grep, see the above note.
-
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
|
 
|