Array returns null bypass

Source: Internet
Author: User
Tags ereg

bugku:http://120.24.86.145:9009/19.php

Haven't finished reading the source code, I have directly added a password[]=1 result to get flag. Then look at the source code I do not understand why you can get the source code. Really, don't believe you see.

1<?PHP2$flag ="Flag";3 4 if(Isset ($_get['Password'])) {5 if(Ereg ("^[a-za-z0-9]+$", $_get['Password']) ===FALSE)6Echo'You password must be alphanumeric';7 Else if(Strpos ($_get['Password'],'--') !==FALSE)8Die'Flag:'. $flag);9 ElseTenEcho'Invalid Password'; One } A?>

Let's talk about the standard answer first:

First condition:

Must start with a number or letter (actually see Ereg can think of%00 truncation)

Second condition:

Must be found in the password parameter--。

So the following positive solutions are obtained:

index.php?password=a%00--

Then again, why direct password[]=a can bypass it?

1.ereg can only handle characters, and you are an array, so the return is null, and the three equals sign does not convert the type. So null is not equal to false.

The 2.strpos parameter is also not an array, so the return is still null,null not equal to False is also correct.

So we can get flag.

Summary:

1. Returns a null value if the function's argument does not meet its function requirements

Array returns null bypass

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.