some more playlist stuff
This commit is contained in:
BIN
mochis_tale/binary_exploitation/picker_4/picker-IV
Executable file
BIN
mochis_tale/binary_exploitation/picker_4/picker-IV
Executable file
Binary file not shown.
49
mochis_tale/binary_exploitation/picker_4/picker-IV.c
Executable file
49
mochis_tale/binary_exploitation/picker_4/picker-IV.c
Executable file
@@ -0,0 +1,49 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
void print_segf_message(){
|
||||
printf("Segfault triggered! Exiting.\n");
|
||||
sleep(15);
|
||||
exit(SIGSEGV);
|
||||
}
|
||||
|
||||
int win() {
|
||||
FILE *fptr;
|
||||
char c;
|
||||
|
||||
printf("You won!\n");
|
||||
// Open file
|
||||
fptr = fopen("flag.txt", "r");
|
||||
if (fptr == NULL)
|
||||
{
|
||||
printf("Cannot open file.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Read contents from file
|
||||
c = fgetc(fptr);
|
||||
while (c != EOF)
|
||||
{
|
||||
printf ("%c", c);
|
||||
c = fgetc(fptr);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fclose(fptr);
|
||||
}
|
||||
|
||||
int main() {
|
||||
signal(SIGSEGV, print_segf_message);
|
||||
setvbuf(stdout, NULL, _IONBF, 0); // _IONBF = Unbuffered
|
||||
|
||||
unsigned int val;
|
||||
printf("Enter the address in hex to jump to, excluding '0x': ");
|
||||
scanf("%x", &val);
|
||||
printf("You input 0x%x\n", val);
|
||||
|
||||
void (*foo)(void) = (void (*)())val;
|
||||
foo();
|
||||
}
|
||||
Reference in New Issue
Block a user