Protostar Format3 Walkthrough

Walkthrough

Hello Guyz, Today, Here I am going to share with you my walkthrough exploitation research, tools Stuff and Exploit That Can help you in completing Exploit-Exercise Protostar Level.

Basically, My Goal is Just to provide you hints, so that you can Understand all concepts on your own.

But If still after reading this hint post, you are not understanding concepts clearly and want to see Exploit Code And Other Details then you can visit my blog posts. click here

Source Code

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int target;

void printbuffer(char *string)
{
  printf(string);
}

void vuln()
{
  char buffer[512];

  fgets(buffer, sizeof(buffer), stdin);

  printbuffer(buffer);
  
  if(target == 0x01025544) {
      printf("you have modified the target :)\n");
  } else {
      printf("target is %08x :(\n", target);
  }
}

int main(int argc, char **argv)
{
  vuln();
}

Hints

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

Plan

As we know:
     printf family function can be exploit with format string vulnerability if programmer don't used these function carefully.

    | String Buffer                            |

Step 1:
    --------------------------------------------
    |  AAAAAA %x%x%x%x%x%x%x%x%x%x%x%x          |
    --------------------------------------------
	%x will print arguments from the top of stack
	check exact padding between the starting of our string Onto the top of stack through printf vulnerability %x

Step 2:
	%5$x : Here, $ sign helps in selecting exact index of string. so, we can use this advantage.
	%5$n : n, expression can write number of bytes onto pointing address.
	
    --------------------------------------------
    |  Address1, Address2 %number_of_bytesx%1$n %number_of_bytesx%2$n          |
    --------------------------------------------
	
	

For Working Exploit Script And Other Complete Details. Check here


Thanks For Visiting

Have a nice day.

Written on May 11, 2018