vault backup: 2023-06-28 14:13:22
This commit is contained in:
Binary file not shown.
@@ -75,26 +75,6 @@ c) Erstellen Sie eine Datei `print_hello_world.sh` mit dem Inhalt `cat hello_wor
|
||||
echo "cat hello_world.txt" > print_hello_world.sh
|
||||
```
|
||||
|
||||
Nun setzen wir die Berechtigungen entsprechend der Anforderungen. In Linux repräsentieren die Ziffern 4, 2 und 1 die Berechtigungen zum Lesen, Schreiben und Ausführen. Der Eigentümer (user), die Gruppe (group) und andere (other) haben jeweils eine dieser Ziffern.
|
||||
|
||||
Zum Beispiel: Die Berechtigung 7 (4+2+1) bedeutet, dass der Eigentümer lesen, schreiben und ausführen kann. Die Berechtigung 6 (4+2) bedeutet, dass der Eigentümer lesen und schreiben kann, aber nicht ausführen.
|
||||
|
||||
Gemäß der Zugriffskontrollmatrix:
|
||||
|
||||
- Alice kann `hello_world.txt` lesen und schreiben, `check_world.sh` lesen und ausführen und `print_hello_world.sh` ausführen.
|
||||
- Bob kann `hello_world.txt` lesen, `check_world.sh` lesen und schreiben und hat keinen Zugriff auf `print_hello_world.sh`.
|
||||
|
||||
Nehmen wir an, Alice und Bob gehören zur gleichen Gruppe, dann könnten die Berechtigungen wie folgt gesetzt werden:
|
||||
|
||||
|
||||
``` bash
|
||||
chmod 640 hello_world.txt # Alice (der Eigentümer) kann lesen und schreiben, Bob (in der Gruppe) kann nur lesen
|
||||
chmod 750 check_world.sh # Alice kann lesen und ausführen, Bob kann lesen und schreiben
|
||||
chmod 700 print_hello_world.sh # Alice kann lesen, schreiben und ausführen, Bob hat keinen Zugriff
|
||||
|
||||
```
|
||||
|
||||
|
||||
d) Erstellen Sie die Benutzer Alice und Bob mithilfe des Werkzeugs `adduser`.
|
||||
|
||||
```bash
|
||||
@@ -130,26 +110,73 @@ Jetzt setzen wir die Berechtigungen entsprechend der Anforderungen.
|
||||
|
||||
```bash
|
||||
sudo chmod 640 hello_world.txt # Alice (Eigentümer) kann lesen und schreiben, Gruppe (shared) kann nur lesen
|
||||
sudo chmod 760 check_world.sh # Alice kann lesen, schreiben und ausführen, Gruppe (shared) kann lesen und ausführen
|
||||
sudo chmod 700 print_hello_world.sh # Alice kann lesen, schreiben und ausführen, Gruppe (shared) und andere haben keinen Zugriff
|
||||
sudo chmod 560 check_world.sh # Alice kann lesen und ausführen, Gruppe (shared) kann lesen und schreiben
|
||||
sudo chmod 100 print_hello_world.sh # Alice kann nur ausführen, Gruppe (shared) und andere haben keinen Zugriff
|
||||
```
|
||||
|
||||
h) Testen Sie die von Ihnen erstellten Dateisystemberechtigungen.
|
||||
|
||||
Wir können testen, ob die Berechtigungen korrekt gesetzt sind, indem wir versuchen, die Dateien als Benutzer Alice und Bob zu lesen, zu schreiben und auszuführen. Angenommen, die Passwörter für Alice und Bob sind jeweils `alicepassword` und `bobpassword`, dann können wir die `su` (switch user) Befehle verwenden, um die Tests durchzuführen.
|
||||
Als Alice:
|
||||
`su <username>`
|
||||
|
||||
Als Alice:
|
||||
|
||||
Read:
|
||||
```bash
|
||||
su - alice -c "cat hello_world.txt" # Sollte "Hello, world!" ausgeben
|
||||
su - alice -c "echo 'Goodbye, world!' >> hello_world.txt" # Sollte erfolgreich sein
|
||||
su - alice -c "./check_world.sh" # Sollte "'world' found" ausgeben, da 'world' in der Datei hello_world.txt existiert
|
||||
su - alice -c "./print_hello_world.sh" # Sollte den Inhalt der Datei hello_world.txt ausgeben
|
||||
alice@LAPTOP-UVV3KEQR:~$ cat hello_world.txt
|
||||
Hello, world!
|
||||
alice@LAPTOP-UVV3KEQR:~$ cat check_world.sh
|
||||
cat hello_world.txt | grep -q 'world' && echo world found
|
||||
alice@LAPTOP-UVV3KEQR:~$ cat print_hello_world.sh
|
||||
cat: print_hello_world.sh: Permission denied
|
||||
```
|
||||
|
||||
Als Bob:
|
||||
|
||||
Write:
|
||||
```bash
|
||||
su - bob -c "cat hello_world.txt" # Sollte "Hello, world!" ausgeben
|
||||
su - bob -c "echo 'Goodbye, world!' >> hello_world.txt" # Sollte einen Fehler ausgeben, da Bob nicht schreiben darf
|
||||
su - bob -c "./check_world.sh" # Sollte "'world' found" ausgeben, da 'world' in der Datei hello_world.txt existiert
|
||||
su - bob -c "./print_hello_world.sh" # Sollte einen Fehler ausgeben, da Bob nicht auf die Datei zugreifen darf
|
||||
alice@LAPTOP-UVV3KEQR:~$ echo "Hello, world!" > hello_world.txt
|
||||
alice@LAPTOP-UVV3KEQR:~$ echo "text" > check_world.sh
|
||||
bash: check_world.sh: Permission denied
|
||||
alice@LAPTOP-UVV3KEQR:~$ echo "text" > print_hello_world.sh
|
||||
bash: print_hello_world.sh: Permission denied
|
||||
```
|
||||
|
||||
Execute:
|
||||
```bash
|
||||
alice@LAPTOP-UVV3KEQR:~$ ./hello_world.txt
|
||||
bash: ./hello_world.txt: Permission denied
|
||||
alice@LAPTOP-UVV3KEQR:~$ ./check_world.sh
|
||||
world found
|
||||
alice@LAPTOP-UVV3KEQR:~$ ./print_hello_world.sh
|
||||
bash: ./print_hello_world.sh: Permission denied
|
||||
```
|
||||
---
|
||||
|
||||
Bob:
|
||||
Read:
|
||||
```bash
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ cat hello_world.txt
|
||||
Hello, world!
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ cat check_world.sh
|
||||
cat hello_world.txt | grep -q 'world' && echo world found
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ cat print_hello_world.sh
|
||||
cat: print_hello_world.sh: Permission denied
|
||||
```
|
||||
|
||||
Write:
|
||||
```
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ echo "Hello, world!" > hello_world.txt
|
||||
bash: hello_world.txt: Permission denied
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ echo "cat hello_world.txt | grep -q 'world' && echo world found" > check_world.sh
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ echo "test" > print_hello_world.sh
|
||||
bash: print_hello_world.sh: Permission denied
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$
|
||||
```
|
||||
|
||||
Execute:
|
||||
```bash
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ ./hello_world.txt
|
||||
bash: ./hello_world.txt: Permission denied
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ ./check_world.sh
|
||||
bash: ./check_world.sh: Permission denied
|
||||
bob@LAPTOP-UVV3KEQR:/home/alice$ ./print_hello_world.sh
|
||||
bash: ./print_hello_world.sh: Permission denied
|
||||
```
|
||||
BIN
Informationssicherheit/Ueb9/UEB_09.pdf
Normal file
BIN
Informationssicherheit/Ueb9/UEB_09.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user