php - 两个字符串之间的 sha256 哈希冲突
问题描述
我必须找到两个作为参数'str1'和'str2'在URL中传递并满足这些条件的字符串?
if($_GET['str1'] !== $_GET['str2'] and $_GET['str1'] and $_GET['str2'])
{
$hash1 = hash('sha256', $salt . $_GET['str1']);
$hash2 = hash('sha256', $salt . $_GET['str2']);
if($hash1 === $hash2) {
#print str1 and str2
}
}
我将如何发现?
解决方案
唯一可能的解决方案是使散列函数不起作用。
散列函数需要字符串输入(或类型转换为字符串),因此将输入作为数组将破坏散列并且两者都返回假/不工作。
这意味着两者是完全相同的。
这是一个作弊,但它满足当前代码的所有部分。
<?php
$_GET['str1'] = ["a"];
$_GET['str2'] = ["b"];
$salt = "aaabdnelnFnekknfn";
if($_GET['str1'] !== $_GET['str2'] and $_GET['str1'] and $_GET['str2'])
{
$hash1 = hash('sha256', $salt . $_GET['str1']);
$hash2 = hash('sha256', $salt . $_GET['str2']);
if($hash1 === $hash2) {
var_dump($_GET['str1'],$_GET['str2']);
}
}
推荐阅读
- javascript - 如何对对象的嵌套 JSON 数组进行转义和解析?
- f#-fake - Paket 依赖组不仅仅是解决版本冲突的一种方式吗?
- java - 无法在泛型类型的类中将 Double 转换为 Float
- java - 带有@Controller 注释的类是单个对象吗?
- android - 为什么在使用实例调用执行方法但没有实例时 AsyncTask 不执行正常工作?
- git - git checkout 文件已过时
- c# - 如何从 C# 中的 dataGridView 更新 mysql 数据库
- angular - Angular、Karma 和 Jasmine 报告颜色
- c# - CORS 问题 Angular4 & c# web api
- electron - 如何在 Electron 中将透明图像写入剪贴板