这涉及到一个关于hackthebox.eu“语法”的黑客挑战:我已经填充了一个文本文件,将散列比较,在PHP中松散比较。
<?php
$handle = fopen("test-md5", "r");
if ($handle) {
while (($line = fgets($handle)) !==false) {
$targethash = $line;
if ($targethash == 'ff6d0a568d61e5a03bcdb04509d5885d') {
echo "\n---yes, these match"; exit(0);
}
else {print " "; print "ff6d0a568d61e5a03bcdb04509d5885d !== ".$targethash;}
}
fclose($handle);
echo "\nTesting Complete\n";
} else {
// error opening the file.
echo "error";
}
我的文本文件在一行中包含了与主代码中相同的md5散列,但在输出中与true不同:
ff6d0a568d61e5a03bcdb04509d5885d !== B73C2D22763D1CE2143A3755C1D0AD3A
ff6d0a568d61e5a03bcdb04509d5885d !== 3DB1A73A245AA55C61204C56C8D99F6D
ff6d0a568d61e5a03bcdb04509d5885d !== ff6d0a568d61e5a03bcdb04509d5885d
Testing Complete
我是编程新手,但这个脚本是从下面的一个简单的测试脚本中发展而来的:
<?php
if (('ff6d0a568d61e5a03bcdb04509d5885d')
==
('ff6d0a568d61e5a03bcdb04509d5885d'))
{ print "Yes, these are the same values.\n";}
else {print "no match\n" ;}
?>
在Netbeans-IDE中重新输入代码后,我看不到任何语法错误,但似乎不明白为什么在文本文件中找不到相同的散列。谢谢
发布于 2018-06-12 02:40:39
从u_mulder post到使用函数trim(),更新后的代码是:
<?php
$handle = fopen("test-md5", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
$targethash = trim($line);
$target = (int)$targethash;
if ( $target == "ff6d0a568d61e5a03bcdb04509d5885d" ) {
print "-----Yes, these are the same values.-"." ".$targethash."\n";
}
else {print "not a match "; print $line;}
}
fclose($handle);
echo "\nTesting complete\n";
} else {
// error opening the file.
echo "error";
}
?>
在“trim”将其修复为比较它从md5散列列表中读取的每一行之后,它需要将接收到的散列读取为一个数字,以触发松散比较。必须在MAC中使用类似的类型更改,以完成HTB上的挑战,从而触发授权cookie中的松散比较弱点。
https://stackoverflow.com/questions/50803828
复制相似问题