Protostar Format2 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 vuln()
{
  char buffer[512];

  fgets(buffer, sizeof(buffer), stdin);
  printf(buffer);
  
  if(target == 64) {
      printf("you have modified the target :)\n");
  } else {
      printf("target is %d :(\n", target);
  }
}

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

Hints

This level moves on from format1 and shows how specific values can be written in memory.

This level is at /opt/protostar/bin/format2

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