PHP expresses two different strings to be the same [duplicate]
2016-12-23 15:13
417 查看
ctf遇到一题,绕过 == 操作符判断的 php:md5 相等验证原理在 stackoverflow上找到了答案stackoverflow php-expresses-two-different-strings-to-be-the-same why-md5240610708-is-equal-to-md5qnkcdzoWhy does the following statement return
true?
"608E-4234" == "272E-3063"
"608E-4234"isthe float number format, so they will cast into number when they compares.
608E-4234and
272E-3063willboth be
float(0)becausethey are too small.For
==inphp,If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.http://php.net/manual/en/language.operators.comparison.phpand
var_dump(md5('240610708') == md5('QNKCDZO'));Output:
bool(true)
md5('240610708')'sresult is 0e462097431906509019562988736854. md5('QNKCDZO')'sresult is 0e830400451993494058024219903391.They are both float number format strings (numerical strings), and if you use ==inphp, when compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.Both of the strings are converted to 0whencompared with ==,if you want to compare them as string, remember to use ===(strictcomparison) instead. |
类似
PHP 探测任意网站密码明文/加密手段办法: md5('240610708') == md5('QNKCDZO')
var_dump(md5('240610708') == md5('QNKCDZO'));var_dump(md5('aabg7XSs') == md5('aabC9RqS'));var_dump(sha1('aaroZmOk') == sha1('aaK1STfY'));var_dump(sha1('aaO8zKZF') == sha1('aa3OFF9m'));var_dump('0010e2' == '1e3');var_dump('0x1234Ab' == '1193131');var_dump('0xABCdef' == ' 0xABCdef');https://news.ycombinator.com/item?id=9484757相关文章推荐
- PHP处理0e开头md5哈希字符串缺陷/bug & PHP expresses two different strings to be the same [duplicate]
- Solution For "could not be located or a different control is assigned to the same ID after postback"
- CXF报错[1 counts of IllegalAnnotationExceptions]and[Two classes have the same XML type name]and[Use @XmlType.name and @XmlType.namespace to assign different names to them]
- It is not possible to run two different versions of ASP.NET in the same IIS process:IIS
- It is not possible to run two different versions of ASP.NET in the same IIS process
- It is not possible to run two different versions of ASP.NET in the same IIS process.问题的解决
- Solution to "The breakpoint will not currently be hit. The source code is different from the original version."
- Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
- add cool toolbar 256corler is easy,only two file and onCreate func is needed also the MainFrame.toolbar must resize to what real need and also the load width is same to it.
- Configure PHP and Django (Python) to run on the same Apache site.
- Details of different phases of a spam-saint update and the logs that needs to be checked while impor
- Two output file names resolved to the same output path
- JS两栏等高:Javascript set two columns to have the same height
- Fuel for openstack:untagged networks can not be assigned to the same interface
- The PHP cURL extension must be installed to use Guzzle 错误: ubuntu 安装 php-curl 拓展
- How to make two <div>…</div> in the same row?
- [Oracle Mgmt]Use RMAN to Duplicate Database in the Same Host (Based on Windows Platform)
- [未解决] The username entered must be the same as the database accesss account for the server farm you wish to join.
- Reference to Different Versions of the Same Assembly
- How to Backup Different Release Databases with the Same Catalog Database