SELinux Flashcards

1
Q

SELinux

A

If a service such as httpd is compromised, then, the attacker could have access to all open permissions files on a system.
SELinux defines a set of rules that determine what process can access specific files and locations on a file system

SELinux determines if a specific process has permissions or the proper authority to edit or communicate with other resources on the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Conf file where policies are defined (SELINUX mode and SELINUXTYPE)

A

/etc/selinux/config

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

View current SELinux mode

A

getenforce

se status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Set SELinux mode

A

setenforce enforcing= setenforce 1

setenforce permissive= setenforce 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Relable files on a system with SELinux labeling

A

touch /.autorelabel

and reboot the PC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Labels, SELinux context

A

ls -Z
netstat -lZ
ps -auxZ

user _u
role _r
type _t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Change SELinux context

A
  1. chcon -t httpd_sys_content_t /var/www/html/index.html
    Note, chcon will not survive a relabeling process
  2. If we are not sure what type should be, we can reference to a good known file and copy its context:
    chcon –reference /var/www/html /var/www/html/index.html
    3.
    semanage fcontext -a -t httpd_sys_content_t /var/www/html/index.html
    +
    restorecon -v httpd_sys_content_t /var/www/html/index.html
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Restore context to default type

A

restorecon -vR /var/www/html
R-recursive
v-verbose

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

List all SE booleans

List booleans with descriptions

A

getsebool -a
semanage boolean -l

getsebool -a | grep httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Enable/Disable SE booleans

A

setsebool -P

-P-Persistent
setsebool -P ftpd_anon_write on
setsebool -P ftpd_anon_write off

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Generate a report with SELinux issues

Troubleshooting SE with journalctl

A
  1. sealert -a /var/log/audit/audit.log
  2. journalctl -xe
    - x-add explanation text
    - e- jump to the end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

View mapping of Linux to SELinux users

A

semanage login -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Map existing Linux user to SELinux user

A

semanage login -a -s [SELinux user] [Linux User]
-a- add
-m -modify
semanage login -a -s “staff_u” cloud_user

semanage login -m -S targeted -s “user_u” -r s) __default__

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Identify Linux user mapped to SELinux user

A

id -Z

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Delete SELinux user

A

semanage login -d [SELinux user]
-d -delete
semanage login -d cloud_user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Check SE users configured

A

semanage user -l

17
Q

SE booleans

A

A conditional rule that allows runtime modification

of the security policy without having to load a new policy.

18
Q

List all available context on a system

A

semanage fcontext -l

19
Q

Restore context of index.html file being copied from home dir to /var/www/html dir

A
  1. cd ~
  2. echo Hello world > index.html
  3. cp index.html /var/www/html/
  4. open in browser HTTP://localhost/index.html => forbidden
  5. ls -Z /var/www/html => context of the file is not starting with httpd
  6. restorecon /var/www/html/index.html
  7. open in browser HTTP://localhost/index.html => secuss
20
Q

Apply httpd_sys_content_t content to /new_www dir

A
semanage -a -t httpd_sys_content_t '/new_www(/.*)?'
restorecon -Rv /new_www - to make this persistent
21
Q

Delete context from /new_www dir

A
semanage fcontext -d "/new_www(/.*)?"
restorecon -Rv /new_www
22
Q

Enable home dirs

A
1. vim /etc/httpd/conf.d/userdir.conf
UserDir public_html
2. mkdir ~/public_html
3. chmod 711 /home/cloud_user
4. echo "Hello world" > ./cloud_user/index.html
5. chmod -R 755 ./public_html
6. systemctl restart httpd
7. semanage setsebool -P httpd_enable_homedirs on
8. elinks http://1.2.3.4/cloud_user
23
Q

Install sealert

A

yum install setroubleshoot

24
Q

Look into selinux alert journal

A

sealert -a /var/log/audit/audit.log