【发布时间】:2020-09-29 06:40:56
【问题描述】:
我正在尝试解决应该使用杂耍类型的 CTF。代码是:
if ($_GET["hash"] == hash("ripemd160", $_GET["hash"]))
{
echo $flag;
}
else
{
echo "<h1>Bad Hash</h1>";
}
我在 python 中编写了一个脚本,它检查ripemd160 中以“0e”开头并仅以数字结尾的随机散列。代码是:
def id_generator(size, chars=string.digits):
return ''.join(random.choice(chars) for _ in range(size))
param = "0e"
results = []
while True:
h = hashlib.new('ripemd160')
h.update("{0}".format(str(param)).encode('utf-8'))
hashed = h.hexdigest()
if param not in results:
print(param)
if hashed.startswith("0e") and hashed[2:].isdigit():
print(param)
print(hashed)
break
results.append(param)
else:
print("CHECKED")
param = "0e" + str(id_generator(size=10))
关于如何解决它的任何建议?谢谢!
【问题讨论】:
-
说实话,我不知道你的实际问题是什么。你正在用 Python 制作一堆东西并用 PHP 测试它们。一个或另一个不起作用?
-
是一个 CTF 挑战。此质询需要 GET 发送的特定哈希参数。根据我所阅读的关于杂耍的内容,当比较两个以“0e”开头后跟数字的字符串时,比较是正确的,无论字符串是否不同,它总是正确的。这个 CTF 的目的是找到满足这些条件的特定字符串。
-
This answer 应该会为你指明一条道路,希望
-
是类似的,但是在这个ctf中是用同一个字符串进行验证,所以一定要具体,并且满足上面提到的条件。感谢您的回复!
-
杂耍?我不知道你说的杂耍是什么意思。您的 php 代码似乎正在寻找成熟的 160 哈希的固定点。这不会发生。
标签: php hash cryptography ctf ripemd