I am trying to create a buffer overflow with C # for a school project:
unsafe { fixed (char* ptr_str = new char[6] {'H', 'a', 'l', 'l', 'o', ','}) { fixed (char* ptr_str2 = new char[6] {'W', 'e', 'r', 'e', 'l', 'd'}) { fixed (char* ptr_str3 = new char[6] {'!', '!', '!', '!', '!', '!'}) { for (int i = 0; i < 8; i++) { ptr_str2[i] = 'a'; } for (int i = 0; i < 6; i++) { this.Label2.Text += ptr_str[i]; this.Label3.Text += ptr_str2[i]; this.Label4.Text += ptr_str3[i]; } } } } }
I thought it was a flood of ptr_str2 and thus rewriting the characters in ptr_str . However, this does not happen. It is executed, but the values ββin ptr_str not overwritten.
Can anyone help to achieve this? I do not understand what I am doing wrong.
Bigchief
source share