SystemRage / py-kms

KMS Server Emulator written in Python
The Unlicense
2.04k stars 618 forks source link

--hwid fails when the HWID begins or ends with 0 #52

Closed dogtopus closed 4 years ago

dogtopus commented 4 years ago

For example:

python pykms_Server.py 0.0.0.0 1688 --logfile STDOUT --hwid 7519597CB34CD5C0
Sun, 02 Feb 2020 06:50:37 ERROR    HWID '7519597CB34CD5C' is invalid. Hex string is odd length. Exiting...
python pykms_Server.py 0.0.0.0 1688 --logfile STDOUT --hwid 0000000000000000
Sun, 02 Feb 2020 06:53:47 ERROR    HWID '' is invalid. Hex string is too short. Exiting...
python pykms_Server.py 0.0.0.0 1688 --logfile STDOUT --hwid 0000000000000001
Sun, 02 Feb 2020 06:55:26 ERROR    HWID '1' is invalid. Hex string is odd length. Exiting...
dogtopus commented 4 years ago

@edgeyboy Alternatively, maybe just switch to something like codecs.encode(struct.pack('>Q', int(hwid, 16)), 'hex'). This also handles further sanitizations. Shorter HWIDs will be padded to 64-bit with 0s and longer will throw error.