1

I'm trying to learn Buffer Overflow Here is the vulnerable code

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

int main(int argc, char const *argv[]) { char buffer[64];

if(argc &lt; 2){
    printf(&quot;The number of argument is incorrect\n&quot;);
    return 1;
}
strcpy(buffer, argv[0]);
return 0;

}

The problem is that when I try to run the code in Immunity Debugger, I don't see AAAAAAA in the source in the stack pane I see the path to my test.exe. Later, I don't see 0x41s ....obviously

What is happening ?

enter image description here

leila
  • 13
  • 2

1 Answers1

1

To get the program’s argument, you need to check argv[1] instead of argv[0]. From cppreference:

The parameters of the two-parameter form of the main function allow arbitrary multibyte character strings to be passed from the execution environment (these are typically known as command line arguments), the pointers argv[1].. argv[argc-1] point at the first characters in each of these strings. argv[0] is the pointer to the initial character of a null-terminated multibyte string that represents the name used to invoke the program itself (or an empty string "" if this is not supported by the execution environment).

Igor Skochinsky
  • 36,553
  • 7
  • 65
  • 115