The handling method of the verification code being bypassed. First, let's analyze the process 1 with the verification code released, Display Form 2, display the verification code (the program that generates the verification code), encrypt the verification code, and put it into session or cookie3, let's analyze the verification code release process.
1. display the form
2. display the verification code (a program that generates the verification code). encrypt the verification code and put it into the session or cookie.
3. the user submits the form.
4. check that the verification code is correct. write the data to the database after the data is valid.
If the user publishes another one, the user will normally access the form page again. The verification code image is updated passively, and the session and cookie will change accordingly.
However, the water filling machine does not have to use a form page. it can directly simulate post to send data to the server program. in this way, the verification code program is not called, of course, the encryption verification code stored in the session and cookie is the last value and is not updated. in this way, the data sent directly through post is unlimited in the future, regardless of the verification code. the verification code is also false!
Therefore, after verifying the verification code, clear the session and cookie values, and then determine the validity of the data!
Such a vulnerability is replaced!
If (md5 ($ _ post ['vcode']) = $ _ session ['vcode']) {
$ _ Session ['vcode'] = ''; // This sentence is very important.
} Else {
Exit 'incorrect verification code! ';
}
// Subsequent processing
......
?>
Program for generating verification code images
Session_start ();
......
$ V = new authcode ();
$ Vcode = $ v-> getauthcode ();
$ _ Session ['vcode'] = md5 ($ vcode );
........
?>
Form page
How the verification code is bypassed
When 1, Display Form 2, display the verification code (a program that generates the verification code), encrypt the verification code and put it into session or cookie 3 ,...