Protostar format3
About
This level advances from format2 and shows how to write more than 1 or 2 bytes of memory to the process. This also teaches you to carefully control what data is being written to the process memory.
This level is at /opt/protostar/bin/format3
Source code
1#include <stdlib.h> 2#include <unistd.h> 3#include <stdio.h> 4#include <string.h> 5 6int target; 7 8void printbuffer(char *string) 9{ 10 printf(string); 11} 12 13void vuln() 14{ 15 char buffer[512]; 16 17 fgets(buffer, sizeof(buffer), stdin); 18 19 printbuffer(buffer); 20 21 if(target == 0x01025544) { 22 printf("you have modified the target :)\n"); 23 } else { 24 printf("target is %08x :(\n", target); 25 } 26} 27 28int main(int argc, char **argv) 29{ 30 vuln(); 31}