Python Challenge[26]

[Level 26]

Python Challenge[26]_第1张图片

Title: be a man - apologize!

Hurry up, I'm missing the boat

源码中有一提示:you've got his e-mail,指的是[Level 19]中的[email protected]。但没想出来有什么用。

这个邮件存在,需要我们以sorryapology(或其他?)为主题发个邮件过去。邮件回复:

Never mind that.
Have you found my broken zip?
md5: bbb8b499a0eef99b52c7f13f4e78c24b
Can you believe what one mistake can lead to?

一个错误,什么错误?缺少了一个字节,穷举验证:

import hashlib
data = open('mybroken.zip','rb').read()
for i in range(len(data)):
  for j in range(256):
    new = data[:i]+bytes([j])+data[i+1:]
    if hashlib.md5(new).hexdigest()=='bbb8b499a0eef99b52c7f13f4e78c24b':
      open('repaired.zip','wb').write(new)
      exit()

打开修复的压缩包里的图片,显示speed,但 speed.html 不存在。网页中的提示派上用场了,speedboat才对,[Level 27]

小结

  • [hash.hexdigest()] [1]返回16进制摘要。
    [1]: https://docs.python.org/3/library/hashlib.html#hashlib.hash.hexdigest

或许还应注意到:

bytes(iterable_of_ints) -> bytes
bytes(int) -> bytes object of size given by the parameter initialized with null bytes

Python Challenge Wiki

Pythonic 的方式发送邮件:

import email.message, smtplib
apology = email.message.Message()
apology.add_header('To', '[email protected]')
apology.add_header('From', from_addr)
apology.add_header('Subject', 'Apology')
apology.set_payload('Sorry!')

server = smtplib.SMTP_SSL('smtp.gmail.com')
server.login(from_addr, pw)
server.sendmail(apology['from'], apology['to'], apology.as_string())
server.quit()

More

你可能感兴趣的:(Python Challenge[26])