Difference between revisions of "SEC520/labs/Lab 6"
Line 44: | Line 44: | ||
<li>[http://www.hscripts.com/tutorials/linux-services/index.php service] <b>or</b> [http://www.linux.com/learn/tutorials/527639-managing-services-on-linux-with-systemd systemctl] (on <u>newer</u> Linux distributions)</li> | <li>[http://www.hscripts.com/tutorials/linux-services/index.php service] <b>or</b> [http://www.linux.com/learn/tutorials/527639-managing-services-on-linux-with-systemd systemctl] (on <u>newer</u> Linux distributions)</li> | ||
<li>[http://www.ibm.com/developerworks/linux/library/l-pam/index.html PAM]</li> | <li>[http://www.ibm.com/developerworks/linux/library/l-pam/index.html PAM]</li> | ||
− | <li>[http://tommi.org/2008/08/automaticly-blacklisting-password-attempts/ Automatically Blacklist Password Attempts]</li> | + | <!--DEAD LINK<li>[http://tommi.org/2008/08/automaticly-blacklisting-password-attempts/ Automatically Blacklist Password Attempts]</li>--> |
<li>[http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php Advanced File Permissions]</li> | <li>[http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php Advanced File Permissions]</li> | ||
<li>[http://www.cyberciti.biz/tips/howot-install-ubuntu-linux-ssh-server.html SSH]</li> | <li>[http://www.cyberciti.biz/tips/howot-install-ubuntu-linux-ssh-server.html SSH]</li> | ||
− | <li>[http://linuxmanpages.com/ Online Linux Manpages]</li> | + | <!--DEAD LINK<li>[http://linuxmanpages.com/ Online Linux Manpages]</li>--> |
</ul> | </ul> | ||
Line 55: | Line 55: | ||
<ul> | <ul> | ||
<li>[http://cs.senecac.on.ca/%7Efac/sec520/slides/sec520_w3_l1.odp odp] | [http://cs.senecac.on.ca/%7Efac/sec520/slides/sec520_w3_l1.pdf pdf] | [http://cs.senecac.on.ca/%7Efac/sec520/slides/sec520_w3_l1.ppt ppt] (Slides: Linux Hardening - part 1)</li> | <li>[http://cs.senecac.on.ca/%7Efac/sec520/slides/sec520_w3_l1.odp odp] | [http://cs.senecac.on.ca/%7Efac/sec520/slides/sec520_w3_l1.pdf pdf] | [http://cs.senecac.on.ca/%7Efac/sec520/slides/sec520_w3_l1.ppt ppt] (Slides: Linux Hardening - part 1)</li> | ||
− | <li>[http://www.linuxdoc.org/HOWTO/User-Authentication-HOWTO/x115.html Why Use PAM?]</li> | + | <!--DEAD LINK<li>[http://www.linuxdoc.org/HOWTO/User-Authentication-HOWTO/x115.html Why Use PAM?]</li>--> |
<li>[http://www.ibm.com/developerworks/linux/library/l-pam/index.html Understanding and Configuring PAM]</li> | <li>[http://www.ibm.com/developerworks/linux/library/l-pam/index.html Understanding and Configuring PAM]</li> | ||
− | <li>[http://lcweb.senecac.on.ca:2063/0596003919 Linux Security Cookbook (E-book)] (Chapter 4)</li> | + | <!--<li>[http://lcweb.senecac.on.ca:2063/0596003919 Linux Security Cookbook (E-book)] (Chapter 4)</li>--> |
</ul> | </ul> | ||
Line 182: | Line 182: | ||
<li>Research on the Internet how to edit the pam_abl configuration file. Documentation for pam_abl (web-browser) is available by using the file pathname:<br /><b>/usr/share/doc/pam_abl-0.2.3/pam_abl.html</b></li> | <li>Research on the Internet how to edit the pam_abl configuration file. Documentation for pam_abl (web-browser) is available by using the file pathname:<br /><b>/usr/share/doc/pam_abl-0.2.3/pam_abl.html</b></li> | ||
<li>Configure the file <b>/etc/security/pam_abl.conf</b> to use the <b>pam_time</b> module to permit remote ssh access only during the daytime.</li> | <li>Configure the file <b>/etc/security/pam_abl.conf</b> to use the <b>pam_time</b> module to permit remote ssh access only during the daytime.</li> | ||
− | <li>Configure your system <b>to deny access for 1 day</b> to any user or host who has <u><b>5</b> invalid password attempts in an hour</u>, or <u><b>12</b> invalid password attempts in a day</u> using the <b>pam_abl</b> module.<br /><br />Here is a approximate example: [http://tommi.org/2008/08/automaticly-blacklisting-password-attempts/ Automatically Blacklist Password Attempts]<br /><br /></li> | + | <li>Configure your system <b>to deny access for 1 day</b> to any user or host who has <u><b>5</b> invalid password attempts in an hour</u>, or <u><b>12</b> invalid password attempts in a day</u> using the <b>pam_abl</b> module.<br /><!--DEAD LINK<br />Here is a approximate example: [http://tommi.org/2008/08/automaticly-blacklisting-password-attempts/ Automatically Blacklist Password Attempts]<br />--><br /></li> |
<li>Create a group named <b>development</b>.</li> | <li>Create a group named <b>development</b>.</li> | ||
<li>Create the directory <b>/var/devel1</b> and <b>/var/devel2</b> and make them accessible to all users. Set the SGID permission bit on <b>/var/devel2</b> and make that directory owned by the group called <i>development</i>.<br /><br />Here is a link to setting SGID permissions: [http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php Advanced File Permissions]<br /><br /></li> | <li>Create the directory <b>/var/devel1</b> and <b>/var/devel2</b> and make them accessible to all users. Set the SGID permission bit on <b>/var/devel2</b> and make that directory owned by the group called <i>development</i>.<br /><br />Here is a link to setting SGID permissions: [http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php Advanced File Permissions]<br /><br /></li> |
Revision as of 10:41, 1 February 2018
Contents
Linux System Hardening (Part 1)
Introduction
- In this lab, students will learn how to make their Linux servers less vulnerable to attacks (i.e. hardening the Linux system). First, students will prevent users from booting into run level 1 (super-user mode) by creating a grub boot password.
- Students will also identify and close unneccesary ports (running services) on their Linux and Windows Virtual Machines in order to make those servers less vulnerable to attacks.
- Students will then configure SSH to provide a safe "tunnel" for data to prevent from hacking, and to change the port number to help to confuse (discourage) hackers.
- Finally, students will use PAM (Plugable Authentication Modules) to further protect running applications in their VMs.
Objectives
- Setup a grub boot password to prevent users from gaining access to super-user mode during Linux system bootup.
- Close unnecessary running ports (services) to make server(s) less vulnerable to attack.
- Use SSH tunnelling to protect data from being picked up by hackers.
- Use PAM to provide authentication for APIs (application programming interfaces).
Required Materials (Bring to All Labs)
- SATA Hard Disk (in removable disk tray).
- Lab Logbook (Lab4 Reference Sheet) (to make notes and observations).
Prerequisites
Online Tools and References
Course Notes
- odp | pdf | ppt (Slides: Linux Hardening - part 1)
- Understanding and Configuring PAM
Performing Lab 6
Task #1: Locking Down Bootup / Performing System Updates
This section will demonstrate how easy it is for a regular users to gain
root user access to a newly-booted Linux system. As a safe-guard,
the student will learn how to set a grub password to make the computer
system less vulnerable.
INSTRUCTIONS:
- Boot your BrackTrack (host) system.
- Open the VirtualBox manager window.
- Prior to running your Vulnerable Linux VM, read the following link on how to enter into single-user mode:
How to Enter Single User Mode (Fedora17 - also applies to Fedora Core 5). - Boot the Vulnerable Linux VM, press any key, then press the key a to append the word single at the end of the boot command.
- After boot-up is complete, you should notice you are logged in as root (you can issue whoami to confirm.
- Navigate throughout the file system. Check the unpriviledged users in the /home directory.
- What are the consequences by NOT locking down the grub password? Record your observations in your lab log-book.
- Issue the shutdown -h or halt command to shutdown your Vulnerable Linux VM.
- Launch the Oracle VM VirtualBox application, click on the New button, and click on Next to proceed.
- Enter the name Hardened Linux for your VM name. Make certain that the OS Type is Linux, and the Version is Fedora, and then click on Next to proceed.
- Accept the defaults (like you did in lab1, including 768 MB RAM and set 10GB for the VM's Hard Disk Size), and eventually click Finish to complete the VM setup.
- Prior to starting your Hardened Linux VM, you will setup a virtual disk in order to boot from your saved Fedora17 install image.
Complete the following steps to prepare for installation:- Right-click on the VM called Hardened Linux in the VirtualBox application window, and select Settings.
- Select Network and set to Host-Only adaptor.
- Select Storage tab on the left-side of the application window.
- Click on IDE Controller near the top of the Storage Tree window, click on the green plus sign to add a new CD/DVD drive. You will be required to specify the location of that Fedora install image (i.e. Choose Disk). The installation process should start (you may need to wait and ignore system errors). Make default install selections as you did with the previous Linux installation. When completed, save your settings.
- After you have changed your settings, double-click on Hardened Linux to start the installation process.
- Make the following selections during the installation process:
- In addition to the defaults, add the Fedora F17 and Fedora F17 - Updates repository.
- Select Create a Grub Boot Password near the end of the installation in the Grub Boot section; Otherwise, accept similar defaults like you did in lab1.
NOTE: If you were unable to set the Grub password during the installation procedure, then as an option, you may search the Internet for a method to manually set the password after the installation process...
- After the installation is complete, shutdown the system, go into Settings and remove the virtual CD/DVD drive that links to your Fedora17 image file. Boot your Hardened Linux VM and try to enter single-user mode. Were you successful?
Record your findings in your lab log-book.
- When booting your Hardened Linux system for the first time, fill out a regular user account, and add to administrator's group.
- Finally, perform an update on your system by issuing: yum update.
- Record your observations in your lab log-book.
- Proceed to Task #2.
Answer the Task #1 observations / questions in your lab log book.
Task #2: Closing Unnecessary Ports / Using SSH
In this section, you will either close or prevent unnecessary ports (services) from running and mask some running services (such as SSH) in order to make your Linux system less vulnerable.
INSTRUCTIONS:
- Tighten up your Hardened Linux VM to expose the smallest possible number of services running on your Linux system.
- Verify that the minimum number of (essential) services are running on your Linux system.
- Use the Nessus application and Metasploit framework to confirm that there are no vulnerable services running on your Hardened Linux VM.
- Discuss with another classmate which software is not required to be installed. What is the minimum software configuration that will work? Try to list at least 10 applications in your lab log-book.
- With a classmate, discuss the information visible to users logged in to your system and whether the disclosure of that information presents any real security risk. For example, is it ok for users to view the information in /proc? or in /etc?
- Refer to the following link to OPS235 Lab 7 (SSH): SSH Configuration
(Note: newer versions of Fedora Linux use systemctl instead of the system command). - Configure SSH to run for a different port number.
- Use SSH to run the gedit command command from your Linux VM, but displayed on your host.
- Have your group members view the open ports on your VM, and see if they can access this running port.
- How does this technique make your Linux server less vulnerable?
- Proceed to Task #3.
Answer the Task #2 observations / questions in your lab log book.
Task #3: Using PAM
Fedora uses the Linux Pluggable Authentication Modules (PAM) system to perform authentication (and some related activities, such as account environment initialization). As the name suggests, PAM is modular and permits various modules to be plugged in or removed at the system administrator's discretion.
INSTRUCTIONS:
- Ensure that your Hardened Linux VM (i.e. Fedora17) system is running, and log-in as a user with administration priviledges.
- Open a shell terminal in your Hardened Linux VM, and change to the directory /etc/pam.d and review the names of the existing files. What do you think these represent in terms of hardening this system? Record your answer in your lab log-book. Locate the file that contains the PAM configuration for system-config-network.
- Access the PAM System Administrator's Guide in a web-browser (file pathname: /usr/share/doc/pam-1.1.5/html/Linux-PAM_SAG.html
- Make a brief list of line options for the system-config-network PAM configuration file, and record in your lab log-book.
- How could you change this PAM configuration file so that a user logged in on the console would not need to enter the root password? (read the manual or perform a NetSearch to get the answer). Record your answer in your lab log-book.
- Install the pam_abl package by issuing the following command: yum install pam_abl.
- Research on the Internet how to edit the pam_abl configuration file. Documentation for pam_abl (web-browser) is available by using the file pathname:
/usr/share/doc/pam_abl-0.2.3/pam_abl.html - Configure the file /etc/security/pam_abl.conf to use the pam_time module to permit remote ssh access only during the daytime.
- Configure your system to deny access for 1 day to any user or host who has 5 invalid password attempts in an hour, or 12 invalid password attempts in a day using the pam_abl module.
- Create a group named development.
- Create the directory /var/devel1 and /var/devel2 and make them accessible to all users. Set the SGID permission bit on /var/devel2 and make that directory owned by the group called development.
Here is a link to setting SGID permissions: Advanced File Permissions - Create three regular users. Ensure that two users are in the development group and that the third user is not.
- Have each user create a file in /var/devel1 and /var/devel2.
- Record the user and group permission for each file.
- Attempt to access each of the six files using each user's account by reading and then appending (two separate operations). What succeeds and what fails? Why?
- What would the development users have to do to make their files in /var/devel1 accessible to each other?
- Why is Fedora set up so that each user has their own group and the default umask is 0002?
- Record your findings in your lab log-book.
- Proceed to "Completing The Lab".
Answer Task #3 observations / questions in your lab log book.
Completing the Lab
Arrange evidence for each of these items on your screen, then ask your instructor to review them and sign off on the lab's completion:
- All unneccessary services turned-off.
- SSH run on a different port.
- Proof of PAM used to control access to directories.
- Completed Lab 6 notes.
Preparing for Quizzes
- Briefly explain how to access the root account (in run-level 1) from an unprotected Linux system upon boot-up.
- List the steps to setup a grub password to protect a Linux system upon boot-up.
- Explain the consequences of running unneccesary services on a server.
- List the steps to stop a running service, and describe 2 unique methods of confirming that a service is no longer running on the server?
- What is the purpose of using SSH for tunnelling while using a different port number?
- What does PAM stand for? What is the purpose of the PAM modules?
- What is the purpose of the pam_abl modules?