Protostar format4
About
format4 looks at one method of redirecting execution in a process.
Hints: objdump -TR is your friend
This level is at /opt/protostar/bin/format4
Source code
1#include <stdlib.h> 2#include <unistd.h> 3#include <stdio.h> 4#include <string.h> 5 6int target; 7 8void hello() 9{ 10 printf("code execution redirected! you win\n"); 11 _exit(1); 12} 13 14void vuln() 15{ 16 char buffer[512]; 17 18 fgets(buffer, sizeof(buffer), stdin); 19 20 printf(buffer); 21 22 exit(1); 23} 24 25int main(int argc, char **argv) 26{ 27 vuln(); 28}