美文网首页程序员
Python Challenge[26]

Python Challenge[26]

作者: Recgat | 来源:发表于2017-02-28 22:14 被阅读0次

    [Level 26]


    Title: be a man - apologize!

    Hurry up, I'm missing the boat

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

    这个邮件存在,需要我们以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]

    小结

    或许还应注意到:

    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', 'leopold.moz@pythonchallenge.com')
    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]

        本文链接:https://www.haomeiwen.com/subject/ucpxgttx.html