Skip to content

Instantly share code, notes, and snippets.

@debedb
Created August 25, 2015 18:39
Show Gist options
  • Save debedb/1be9793a880ca00d886c to your computer and use it in GitHub Desktop.
Save debedb/1be9793a880ca00d886c to your computer and use it in GitHub Desktop.
mod_uid hex to cookie
import base64
import struct
import sys
def main():
"""
http://www.lexa.ru/programs/mod-uid-eng.html
Sample input: 'F705D40AACC48C54571D9D7A02CAFA59'
yields sample output: 'CtQF91SMxKx6nR1XWfrKAg=='
"""
x = sys.argv[1]
l1 = int(x[:8],16)& 0xffffffff
l2 = int(x[8:16],16) & 0xffffffff
l3 = int(x[16:24],16) & 0xffffffff
l4 = int(x[24:],16) & 0xffffffff
s = struct.pack("<IIII", l1, l2, l3, l4)
print base64.b64encode(s)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment