Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

This is how they do it!- 849

Flamingo-TechPosted 3 Years Ago
  • The author of this posts does not like DRM put onto filters. So, he wanted to be able to create his own filters and save the world from waste.
  • The Xiaomi filter relies upon a password for communication between the filter and purifier. This communication is done via NFC. The reverse engineering of this is shown at xiaomi-air-purifier-reverse-engineering.
  • The generation for the passcode is based upon the UUID (because it's unique) of each filter. Some mystery gentleman sent the author of the blog a code snippet that generates the keys. It uses selective bytes from SHA1 of the uid in order to do so. The author does not go into how they figured this out though.
  • The code for this is shown below:
    import sys
    import hashlib
    
    # Usage: pwd.py 04A03CAA1E7080
    def getpwd(uid):
        uid = bytearray.fromhex(uid)
        h = bytearray.fromhex(hashlib.sha1(uid).hexdigest())
        pwd = ""
        pwd += "%02X" % h[h[0] % 20]
        pwd += "%02X" % h[(h[0]+5) % 20]
        pwd += "%02X" % h[(h[0]+13) % 20]
        pwd += "%02X" % h[(h[0]+17) % 20]
        return pwd
    
    assert getpwd("04A03CAA1E7080") == "CD91AFCC"
    assert getpwd("04112233445566") == "EC9805C8"
    print("PWD:", getpwd(sys.argv[1]))