Skip to content

Instantly share code, notes, and snippets.

@KristobalJunta
Last active October 29, 2019 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KristobalJunta/a915e8f763e72f9882785b683fd88247 to your computer and use it in GitHub Desktop.
Save KristobalJunta/a915e8f763e72f9882785b683fd88247 to your computer and use it in GitHub Desktop.
Decode passwords stored in HeidiSQL
#!/usr/bin/env python
from __future__ import print_function
import sys
def heidi_decode(hexstr):
shift = int(hexstr[-1])
l = [int(hexstr[i:i+2], 16) for i in range(0, len(hexstr), 2)]
return ''.join(chr(v - shift) for v in l)
if __name__ == '__main__':
"""
Accepts encoded password either from stdin or as cli argument
Prints it's plaintext decoded version to stdout
"""
if len(sys.argv) < 2:
s = sys.stdin.readline().strip()
else:
s = sys.argv[1]
passwd = heidi_decode(s)
print(passwd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment