diff --git a/20160627/bs-20160627.txt b/20160627/bs-20160627.txt new file mode 100644 index 0000000000000000000000000000000000000000..8c615f68132dfaa0d94a564e70ef489350fb8458 --- /dev/null +++ b/20160627/bs-20160627.txt @@ -0,0 +1,63 @@ +Treiber-Entwicklung, Echtzeit- und Betriebssysteme, 27.06.2016 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:) Der Bootvorgang +:) Die Unix-Shell +:) Treiber +:) Signale +:) Massenspeicher +:) Speicherverwaltung +:) Netzwerk +:) Echtzeit +:) User-Space-Treiber +:) Grafik + ? Netzwerk: Programmierung + ! Sicherheit + +Sicherheit +========== + +Angriff auf einen Rechner: + + 1. Benutzer dazu bringen, ein selbstgeschriebenes Programm auszuführen (MalWare) + Beispiel: tolles_bild.jpg.exe + + 2. Benutzer dazu bringen, ein vorhandenes Programm mit Sicherheitslücke + mit selbstgeschriebenen Daten auszuführen (MalWare) + Beispiele: Macro-, JavaScript-, Flash- und PDF-Würmer + + 3. Aus dem Netz: ein laufendes Programm mit Sicherheitslücke + mit selbstgeschriebenen Daten füttern + Beispiel: http://xkcd.com/327/ + + "Robert'); DROP TABLE Students; --" + + INSERT INTO Students (Name='Robert', Klasse='3b', Telefon='12345'); + + INSERT INTO Students (Name='Robert'); DROP TABLE Students; -- ', Klasse='3b', Telefon='12345'); + +Gegenmaßnahme: + gegen 1: Medienkompetenz + gegen 2. und 3.: keine Sicherheitlücken programmieren + +Sicherheitslücken in Programmen +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Buffer-Overflow: siehe Rechnertechnik +Gegenmaßnahmen: + + * ordentlich programmieren + - ordentlich einrücken + - Compiler-Warnungen aktivieren und beachten + + * automatische Code-Analyse + - Compiler: gcc oder llvm mit Warnungen + - statisch: [sp]lint, sparse (cgcc) + automatische Suche nach typischen Fehlern + - dynamisch: valgrind + ausführbares Programm wird auf Speicherfehler analysiert + --> finden viele, aber nicht alle Fehler + + * Speicherschutzmechanismen des Compilers und des Betriebssystems + - Hardware-Unterstützung: DEP/NX (siehe: Speicherverwaltung) + - Canary: http://www.drdobbs.com/240001832 + - ASLR: http://heise.de/-2718449 + - Austricksen: http://security.stackexchange.com/questions/20497 diff --git a/20160627/hello-1.c b/20160627/hello-1.c new file mode 100644 index 0000000000000000000000000000000000000000..1eeb73a5a81277cddef7129494645fb9e86eb74a --- /dev/null +++ b/20160627/hello-1.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ +printf ("Hauptprogramm, vor printf\n"); + printf ("Hello, world!\n"); +printf ("Hauptprogramm, nach printf\n"); + return 0; +} diff --git a/20160627/hello-10.c b/20160627/hello-10.c new file mode 100644 index 0000000000000000000000000000000000000000..fc7a4a099e7338250b38899acbd9920480c15334 --- /dev/null +++ b/20160627/hello-10.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *str1 = "Hello, world!"; + char *str2 = ""; + scanf ("%s", str2); + printf ("%s\n%s\n", str1, str2); + return 0; +} diff --git a/20160627/hello-11.c b/20160627/hello-11.c new file mode 100644 index 0000000000000000000000000000000000000000..76610d288265a9a87728cc7f32f3971a07b303df --- /dev/null +++ b/20160627/hello-11.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *str1 = "Hello, world!"; + char *str2 = "Hier ist viel Platz."; + scanf ("%s", str2); + printf ("%s\n%s\n", str1, str2); + return 0; +} diff --git a/20160627/hello-12.c b/20160627/hello-12.c new file mode 100644 index 0000000000000000000000000000000000000000..a5618d0809ed20558b9a25a8c0e706fcc8cd4844 --- /dev/null +++ b/20160627/hello-12.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char str1[] = "Hello, world!"; + char str2[] = "Hier ist viel Platz."; + scanf ("%s", str2); + printf ("%s\n%s\n", str1, str2); + return 0; +} diff --git a/20160627/hello-13.c b/20160627/hello-13.c new file mode 100644 index 0000000000000000000000000000000000000000..32c61f39937a8d88577ddc7410b0d826a364f0b8 --- /dev/null +++ b/20160627/hello-13.c @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <sys/mman.h> + +int main (void) +{ + char *str1 = "Hello, world!"; + char *str2 ="Hier ist viel Platz."; + mprotect (str1, 65536, PROT_WRITE | PROT_READ); + scanf ("%s", str2); + printf ("%s\n%s\n", str1, str2); + return 0; +} diff --git a/20160627/hello-2.c b/20160627/hello-2.c new file mode 100644 index 0000000000000000000000000000000000000000..b76f1dd4689e6c1e3d275c2efe197ad09b40e7a3 --- /dev/null +++ b/20160627/hello-2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ +/* printf ("Hauptprogramm, vor printf\n"); */ + printf ("Hello, world!\n"); +/* printf ("Hauptprogramm, nach printf\n"); + */ + return 0; +} diff --git a/20160627/hello-3.c b/20160627/hello-3.c new file mode 100644 index 0000000000000000000000000000000000000000..d55cd5b2303775532f209b4419834157ceb399ee --- /dev/null +++ b/20160627/hello-3.c @@ -0,0 +1,2 @@ +#include <stdio.h> +int main (void) { printf ("Hello, world!\n"); return 0; } diff --git a/20160627/hello-4.c b/20160627/hello-4.c new file mode 100644 index 0000000000000000000000000000000000000000..fab7a486ba1b6a73cc32af4f8fb04edab23f453d --- /dev/null +++ b/20160627/hello-4.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + int a = 3; + int b = 2; + if (b != 0) + printf ("a / b = %d\n", a / b); + else + printf ("Kann nicht durch 0 dividieren.\n"); + printf ("Ciao!\n"); + return 0; +} diff --git a/20160627/hello-5.c b/20160627/hello-5.c new file mode 100755 index 0000000000000000000000000000000000000000..18036f9386c77bcfd719a29889248b31332e2d96 --- /dev/null +++ b/20160627/hello-5.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main (void) +{ + int a = 6; + int b = 2; + if (b = 0) + { + printf ("Kann nicht durch 0 dividieren.\n"); + printf ("Ciao!\n"); + } + else + printf ("a / b = %d\n", a / b); + return 0; +} diff --git a/20160627/hello-6.c b/20160627/hello-6.c new file mode 100755 index 0000000000000000000000000000000000000000..73b48947a7d5340085e4f6db09016fdca5af7f0d --- /dev/null +++ b/20160627/hello-6.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main (void) +{ + int a = 6; + int b = 2; + if ((b = 0)) + { + printf ("Kann nicht durch 0 dividieren.\n"); + printf ("Ciao!\n"); + } + else + printf ("a / b = %d\n", a / b); + return 0; +} diff --git a/20160627/hello-7.c b/20160627/hello-7.c new file mode 100644 index 0000000000000000000000000000000000000000..cddd61e9e8fb0609c3a0c0f8e687eead3d59bca4 --- /dev/null +++ b/20160627/hello-7.c @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (void) +{ + int *a = malloc (5 * sizeof (int)); + for (int i = 1; i <= 5; i++) + a[i] = i; + for (int i = 1; i <= 5; i++) + printf ("%d\n", a[i]); + return 0; +} diff --git a/20160627/hello-8.c b/20160627/hello-8.c new file mode 100644 index 0000000000000000000000000000000000000000..6bc7342c293c6ac8ea293eb9c50870fe1b9f4188 --- /dev/null +++ b/20160627/hello-8.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *str1 = "Hello, world!"; + char *str2 = ""; + scanf ("%s", &str2); + printf ("%s\n%s\n", str1, str2); + return 0; +} diff --git a/20160627/hello-9.c b/20160627/hello-9.c new file mode 100644 index 0000000000000000000000000000000000000000..2e204f3845ec9bc7619a178c0e5edeb9fe9cc4a3 --- /dev/null +++ b/20160627/hello-9.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main (void) +{ + char *str1 = "Hello, world!"; + char *str2 = ""; + printf ("str2 = %x --> %x\n", str2, *str2); + scanf ("%s", &str2); + printf ("str2 = %x --> %x\n", str2, *str2); + printf ("%s\n%s\n", str1, str2); + return 0; +}