SEC 440 SELinux Deepdive - JadenGil/Jaden-Tech-Journal GitHub Wiki
Getting Started:
In Web01 I had some things to do before getting the lab fully underway.
To start I cleared out the /var/www/html
directory so I had a clean start. I used rm -rf mediakwiki/
to force remove the MediaWiki dir from the directory and used rm
to remove any other files.
Aside from clearing the directory I also had to use nano /etc/httpd/conf/httpd.conf
to change the main directory in the file from /var/httpd/conf/mediawiki
to /var/httpd/conf/
After all that, I went back into /var/httpd/conf/
and made a new index file using index.html
and made this for the web page:
Deliverable 1:
SELinux Packages:
To get started here I began by installing the SELinux utils and other important features using the following command:
Adding Users:
I added the users regularuser, switcheduser, guestuser, and restricteduser on web01 using the following commands:
Deliverable 2:
This is the process for sshd on SELinux
)
Deliverable 3:
Deliverable 4:
Deliverable 5:
to copy the contents of /etc/redhat-releases I used the command cat /etc/redhat-releases >> /var/www/html/index.html
the version reflected is 8.6 and from what I can tell the command pastes exactly what is in the given file to the index file and it is displayed as normal text on the webpage.
When I look at the index.html file this is what it looks like:
This suggests that all that is happening is a simple copy-paste from the file and nothing more
Using my sudo user "Jaden" I made the file userhost.txt and moved it into /var/www/html
And when I navigate to that page on the 10.0.5.100
website it says I don't have permissions
Deliverable 6a:
The file type on userhost.txt
is user_home_t
which is not the correct file type that should be used in a web directory.
Deliverable 6b:
When moving the file userhost.txt
the SELinux context stays the same as it was before the file was moved. So since it was originally made in my home directory it has the context of user_home_t
after moving it into /var/www/html
Deliverable 7:
This change was made using the command sudo restorecon -v /var/www/html/userhost.txt
followed by sudo chcon -t httpd_sys_content_t /var/www/html/userhost.txt
Enabling user directories for apache:
To start I checked the books by using the commands sudo getsebool httpd_enable_homedirs
sudo getsebool httpd_read_user_content
They should both be off at the moment so to turn them on I used the following commands sudo setsebool -P httpd_enable_homedirs on
sudo setsebool -P httpd_read_user_content on
In the file highlighted in the photo make sure the circled content is uncommented (It should be by default but it's better to check)
Make the dir public_html
I made it using the command mkdir /home/Jaden/public_html
Running the commands chmod 755 /home/Jaden
and chmod 755 /home/Jaden/public_html
will ensure that the correct permissions are set.
Running sudo semanage fcontext -a -t httpd_user_content_t "/home/*/public_html(/.*)?"
is used to modify the SELinux file context configuration.
Follow this command with sudo restorecon -Rv /home/*/public_html
Finally enter the command sudo chcon -R -t httpd_user_content_t /home/*/public_html
and systemctl restart httpd
And the directory will be read on the website
Deliverable 8:
Changing to SSH port 2222
To start this section go into sshd_config file using sudo vi /etc/ssh/sshd_config
and uncomment and change the port as shown in the picture:
Check and update the ssh port using sudo semanage port -l | grep ssh
and sudo semanage port -a -t ssh_port_t -p tcp 2222
Update the firewall to allow port 2222:
Deliverable 9:
Preventing SU:
Deliverable 10:
Removing Guest EXE privs:
Deliverable 11: