CoffeeMath
CoffeeMath

Reputation: 11

Crafting Input for Buffer Overflow to Print Flag and Using angr for Symbolic Execution

I'm working on a buffer overflow exercise and need help with two aspects:

  1. Crafting the correct input to overwrite a function pointer and call printflag instead of wrong.
  2. Using angr to automate the process of finding the input.

Here's the program:

#include <stdio.h>
void wrong() {
    printf(" Wrong \n");
  }
void correct() {
  printf(" You win !\n");
}
int main() {
  char buffer[64];
  long( * p)() = wrong;
  gets(buffer);
  p();
  return 0;
}

Details:

Question 1: Input Crafting

I want to create an input that overwrites the function pointer w to point to printflag. What should the exact input be?

Question 2: Using angr

I'm also trying to use angr to find this input automatically. Here's what I know about angr:

Could you help me with the angr script or guide me on how to set up the symbolic execution to find the input that forces the program to call printflag?

For Question 1 (Input Crafting):

For Question 2 (Using angr):

Upvotes: 1

Views: 52

Answers (0)

Related Questions