How to handle verification code bypass

Source: Internet
Author: User
Check that the verification code is correct. after the data is valid, the data is written to the database. if you release another verification code, the system normally accesses the form page again. the verification code image is passively updated, and the session and cookie will change accordingly, however, water filling machine operations

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. after the data is valid, the data is written to the database. if you release another one, the system will normally access the form page again. the verification code image is passively updated, the session and cookie also change, but the water filling machine operation does not have to use the form page, it can directly simulate the 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!

  1. If (md5 ($ _ post ['vcode']) = $ _ session ['vcode']) {
  2. $ _ Session ['vcode'] = ''; // This sentence is very important.
  3. } Else {
  4. Exit 'incorrect verification code! ';
  5. }
  6. // Subsequent processing
  7. ......
  8. ?>

Program for generating verification code images

  1. Session_start ();
  2. ......
  3. $ V = new authcode ();
  4. $ Vcode = $ v-> getauthcode ();
  5. $ _ Session ['vcode'] = md5 ($ vcode );
  6. ........
  7. ?>

Form page

  1. ......
  2.  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.