Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

Commit

Permalink
增加exe调用版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xhlove committed Jul 30, 2021
1 parent 3357ee9 commit 4d9ed8e
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
guesskey
mingw64
.vscode
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ pip install wasmer_compiler_cranelift==1.0.0

- `python -m wvguesser.main`

**当前是单线程版本**
调用exe的版本,相对更快

# TODO
- `python -m wvguesser.mainv2`

- 多线程
根据现有算法,只能是单线程

# 推荐更好的方案

Expand Down
Binary file added wvguesser/main.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion wvguesser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# 初始化实例 内存+模块+外部导入函数
instance = Instance(module, store)

config = json.loads(Path('wvguesser/offline_config.json').read_text(encoding='utf-8'))
config = json.loads(Path('wvguesser/offline_config_yk.json').read_text(encoding='utf-8'))

clear_session_key = instance.run(config['enc_session_key'])
instance.decrypt_license_keys(clear_session_key, config['enc_key'], config['key_infos'])
Expand Down
95 changes: 95 additions & 0 deletions wvguesser/mainv2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import subprocess
import json
import math
import time
import binascii
from pathlib import Path
from Crypto.Cipher import AES
from Crypto.Hash import CMAC


def guessInput(text: str):
resp = subprocess.check_output(f'./wvguesser/main.exe guessInput {text}')
return resp.decode('utf-8').strip()


def getDeoaep(text: str):
resp = subprocess.check_output(f'./wvguesser/main.exe getDeoaep {text}')
return resp.decode('utf-8').strip()


def run(hex_session_key: str):
ts = time.time()
encKey = binascii.a2b_hex(hex_session_key)
print(hex_session_key)
buf = [0] * 1026
offset = 2
while offset < 1026:
print(f'当前进度 {(offset - 2) / 1024 * 100:.2f}% 耗时 {time.time() - ts:.2f}s')
bt = math.floor((offset - 2) / 4)
offs = math.floor((offset - 2) % 4)
desired = (encKey[len(encKey) - bt - 1] >> (offs * 2)) & 3
destail = hex_session_key[len(hex_session_key) - bt * 2:len(hex_session_key)]
j = buf[offset]
while j < 8:
buf[offset] = j
st = binascii.b2a_hex(bytes(buf)).decode('utf-8')
# print(st)
val = guessInput(st)
# print(val)
sub = int(val[len(val) - bt * 2 - 2:len(val) - bt * 2], 16)
got = (sub >> (offs * 2)) & 3
gtail = val[len(hex_session_key) - bt * 2:len(hex_session_key) + bt * 2]
if got == desired and gtail == destail:
if offset % 16 == 2:
print(val)
break
j += 1
if j == 8:
buf[offset] = 0
offset -= 1
if offset < 2:
print('Could not match input')
assert 1 == 0, "Could not find proper input encoding"
buf[offset] += 1
while buf[offset] == 8:
buf[offset] = 0
offset -= 1
if offset < 2:
print('Could not match input')
assert 1 == 0, "Could not find proper input encoding"
buf[offset] += 1
else:
offset += 1
print(f'==> 耗时 {time.time() - ts:.2f}s')
print("Output", buf)
st = binascii.b2a_hex(bytes(buf)).decode('utf-8')
outp = getDeoaep(st)
print(outp)
if len(outp) < 10:
assert 1 == 0, 'Could not remove padding, probably invalid key'
print(st)
return outp


def decrypt_license_keys(session_key: str, context_enc: str, key_infos: dict):
cmac_obj = CMAC.new(binascii.a2b_hex(session_key), ciphermod=AES)
cmac_obj.update(binascii.a2b_hex(context_enc))

enc_cmac_key = cmac_obj.digest()

for index, [keyId, keyData, keyIv] in key_infos.items():
cipher = AES.new(enc_cmac_key, AES.MODE_CBC, iv=binascii.a2b_hex(keyIv))
decrypted_key = cipher.decrypt(binascii.a2b_hex(keyData))
# clear_key = Padding.unpad(decrypted_key, 16)
print(f'<id>:<k> {keyId}:{decrypted_key.hex()}')


def main():
config = json.loads(Path('wvguesser/offline_config.json').read_text(encoding='utf-8'))
clear_session_key = run(config['enc_session_key'])
decrypt_license_keys(clear_session_key, config['enc_key'], config['key_infos'])


if __name__ == '__main__':
main()
11 changes: 11 additions & 0 deletions wvguesser/offline_config_yk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"enc_session_key": "ae48042923b8fc5b9820894b01a6962709dff70700c9eeb489485b891897183be486b14cb0b47103dbd268492e4007000f2930c248081301950fd2ef268e902695622783a5ea3c65fb90d3fbacd9bbfd69fdc748a06d7c6d2c9e22e08ca04cc59ea5944dec74998b8c5d990aa3830a9bac227d4cd94f9a381e18952430c32b8d5b4746bf054b27519d8ea93164ea2766b92aa9e07e2ea5f3c5a4470b8b673056576e83679ea58e455ed75b90de2b9379f5374c07e3664ac651cff2ad4fa060a79de58b015a3b0da69b03296d9e1e79f9d9cf8b907f133eae3e5348101f18985d6b91f867cda3b73a5fbe37d7bbf36225cfad99ef5ded7b2bd403f644fb1822e5",
"enc_key": "01454e4352595054494f4e0012420a400a2a1210632a7a677ee3c30cf3ba81d5f880a4df1210632a7a677ee3c30cf3ba81d5f880a4df48f3c6899b0610011a1098657ff1e3c6b3896a58cae203b1bdd418012098878f88063015389cb4cacf0542e41e0a08796f756b752e636e121053d7b458e70ee6626cf9e992c5675f8f1ab01cbe26a70334b2907ed82a0d0925b9c297d5ddff62789f8b7a7acabed3b62cba740f26a75ddb35f29dc782b9493cfad1af8e72a1bcf35da584c4c52497299e4e818f73e0559c46ed17a83489cc7827f4457f57bfef7f0b09834e6abdd5197602a54b928fde5f6267c3788df1847a7ac0efb713de226fc76abfa0e3497bff97df2a1bd9674336edda4fc20213eafe2af12b3c9da698594c3be444c033d9fe17ef696d0db6313b9b4e59d29b98c185cdaebd5ea798647c1a0db8411b986f7cafa103d37393f9cee22864e64f6d40e8044ed873dc2fd2d6baf39695424d53dc151c7ef5292e358cd718c84463af8b89e1928db511e281b1e07c519e63cf991177d9d5bc0a92ee5a5c295154f85211e0c3c1fb635045953ef0152a3599fc7df4b1aa6aa83036d100d114354852bd16bdeb73081625b54ac2a5f82c6c3ec2120de6769a1dedecb05f23f25629683abbdb20c2badec38ef4eb1a946d4ad71fb8eabbad5a10fd94ee3a4c67aca815c025800c4f69b4678be86385c3b0ddbae250243230a931961cc26a607f387639a22acbff7c4da021026091c95ee2fa48bfe776dd3e519e3a2d27077cc847e260694edbc635c574cecf8b512665a1ce2279661d76c847b8890e3ffef2c3ea22e1fb855fda5157b88d30ea76d8e9fc2b3aa7b4295e331dcdbb1dbb4731cbe829c3dfb968049736e42c04957ef39d5c59043d076052b574f111307c3ce3229be29b16bf46a76712821c6d10e26987576aabaee0fe3e9aec4274b6cbd47147e72da032e0a19282d6f31180894ddde245b2c2eb6e0572068e7ed03ed2d48ee653fc1594a380a0381d7ab4006040b6ee06df293c35cecbd70ee4c20544965ff58059ce2aa914f087c6a7751b17fb2f51b4f881942311e95649a9b71b399ac779af7f8ac88bfa205279768cb0695b7e585c49df706093b91e6c3b716b5ce9e63b51c7990917c9ea852ce293ce8f9dc0317ce39f6eb8680715e4f231c2889c505b3e03030fe1679a3a20fef826a04be0679f3fd668b9a365f8e56e31f448b27232c88b1c4e6a18815802c9432b89fba0432e8be79562021852f06307c174df535134b47c8e78bcc8f51ce867ab97c7248b15fba1769a1149e46f295203ee13821c1c4443f487e12f26209a927d7a83525cf4e0adc26915099292cd3713345086ec24ec756d24790e0bd95c838072d32d32dc72e0b1eb724cd776ca2599f8506e689ae4aa123e96763d333abdef0ea17b60fac821113126074676adb66c78495e437d275993edfda4a900f83097a58445906a7db9c0f2926542a266f7349c2f2d29a5d3096ed3b9561fc78901ebbbcae6c26175b15c49f83cb65b7c1ef88c7e9d59e07acf80f5e3d2b11d44ed220b5bb8ddfc990512ac3f4d04e5e5d9217a2eff67acacf9187f07681133247adb075c92f429917a16667cb56b679b236f38a30285956efc73dae4144a564c023eb32fe3939d31132861d73cb4bea49ad13730238d0df98ee77a42e3fd4b388a27e45e5029f401981e272195ed74a76b4aa5e84536489b333c16c8beb78c15b2deddfd95ece444648e40aa94696793e85907ad4e4c8fca75ee37e6c1a2b43ca588b2b6df96e96d0e0afca4eaa8051868103d56a197b9f6ba283b8cdcf50516a818a49241e41ccd6de9808581db7bb959c73976601a4164558c8f4ed4795905f988aac23772ee39851b1954a959f136f2db5b60009a8affa4ffdfd6e1ec408ffad30841340370094ac9d9ddc0c27867fd11797ce2e942c614b3d2beaac27c877653d505d736cf76384c0cc0de843a07a58b9bdb9d5e928d76cf4646b1db84cc9b5e09f30d90038c9ee0f9137c45945e31b9f750f6afaeef2d73269d44d7e80c43f998359d86c700408b363678fd4a3a1054ebbe3674b0011668465bee3e2a2ba3e324d158aec33567f8968e9c1e075902f9e3b53953f794933b1eec17544db007b7930d603dd0e083a25c1f48c964336f549d7c2c228b754d1322814f08c6f531dd8e21536f4db16f9833f0099dc33aa8fe78c0e51acccff30235ba684b2a33a3ec9d55e032244d284c56812273e50565bb11b602abddcd061d882c01272a6736912512fa73f336bc4eccf00bf586dcc843cada18b0862e8be3a79490e965df9c0214efac0a833b43e690343b064165c97320edbe1ba100129835a9c8a324f22c0e51953709c2797e3dcf8a6a81d1a95d40ffe3ee935254aa6a773a8caf2f9904efb26ecd0c288c37c60409421a434b63240c961e2c8143f51b5af5aaf1b9f25fd946cedc404e669079373ecb94a8db577b86a50a28d2df8bea28bf38c916911886b64248a8e612b687831abf9138becd67283d34a9fc5781397437a7fd510d9ff690f61a7d6545221c28f3f854c2333f0a1b6329c93728d0716c7919f45c442d2c379b1045225f84cd791e9705f6bad9597baf12819a4d5568c105426b10f426cd202e47519f933ce322db0e1b85313e66a5e07b8e3c8c08fae27bc9744527b9c9c43de77a4697c448cd02322b216c9968ed0a9c3f3fdcbadb5468a79d1a147cb074e0071e2bb79a62c248599359da8b3e956bd57f7f4802292229bbe3931e4a80ba46ab251b017b1219d8c86987ef110e27171967a7e2a28434fca4d75c995e3d996e7247cbb8c70a5dc436b144ecc79b71b7a19876a642fe8e5dba4e20f5d5ddaa36ffab0fd4aeeca3d7b7d761550109529e29a1ba42dcda28486a0b76cf072462f94594a8fd34f81d0646dd4ce7d8ccaabf49f9af95c06af122fe400ff2dc039d052f3800c9d09b2c34593c86e36839ba23ae43af3a17b244774f266a3e842875c68ad707db1fbd1306cbc7c4e37ceb0e3b008e441e3d89b6632fd7e288449e8d33715be53561fc22e793f2ace9008710007a39f07cc2e30a381c82e7f658796f854ca9b96bde55bc149d235e112448ab945ea2a6d19d392fedeeec30cfdddb19eafebc9e88ac17d2e3308f402f529741dc285508390f3835294ea2c1535ed1c5e349bead667f4f09c6cc26cbf261d02f101f5c8bda12a07a10bfd43929678e99c77d42d8c245e5335b87d0e2071e8e63ee6db2fc71269762c11abc1134d97418c49ef75e8c67b5222237fff357fe772e8d44e3f9a6631c657505b3a83038f60ff718d2afa77cdd23901dc4fc4606a139b51469de7d4db13d0edc67cc860591550dd2cd84608eefbfff5203c7e01ddf66cfffd7e5c173bb639b8d98375584329899d14040168961cb29c0a59fbb3b564533472277e8fbb1018fc2013c8ab0373fb7604eadf6cf278e554b1983eda56292595bcdc425522729cdbecca4422a230f6da627362307ee1b32a337e2a8e8c225ee9663e635da41fc3568e3079c2542cf314e8f8767657fba206a2b9727195207154ba88e78ec148a74e7d525897382327ce84b352a88bcfa672cb388883264c241d34d833e702272eb98fd287a1fb4497bd49e6c7eeea5f35def3516449459649c3cc458ada4c334840c7b47539033a6b772bf03e39f843514dc347dc126bfa91396e87180b3685bbd5499d3fd3afbbe95c5de4ddb1219c71b05e46b36e8067cf295ebef6e695cc49536aa61acc2e22a98fa55f25ac3982949bc0d4530fc1efb04243883f8ec4b615309430c446f2f340b35bf0127862f7b6ece2fccfb3764d79d556f9d1a0ce4b455f15abfb9473a2a289de9e0e00b05c96ad72f1fac823a0806147a6689292a74d5371bcad75e3abf6f41c24edc0e5093808766a8153a07a8bb1a0cda4acec3f81101e9b8489772b19c357ad5ca108405cf746447738d0c741aaf21343628f1df208332475a6b172b0260601791c9e436b55155e30c2c3e635c3899c74c0dfcb0b21f2a495ebbb9a31854d272fdb3e6da3699ce6df8406368b30ac15841779a99504a381d4092371ebeced03c198c90e455ff3a23a2bed2b9b96506c4c6f03dc660a9e9ecd9122df4cf0171a47b1d08d9de2c131cef35c159b6fab4515d2700a15e67799a7be6da97ccbed22a9ede5256ef25f6549dd5c768d24d668b1dbc9cd721b40c2bed704224fb4b4a41192c2d6572a36f9a39f3543fbafe2d8f24ffa3d1d07117f193e371e30b27fdefedb5cab20403ce473511f6b790da8b9f90b462581ee345f02e82e6a1175333580e5220f8c0c3fd21e72c48a3a147b11889b852f294717ade7e6aeafcd9666be6ebb37ea6093a6d0f34abc9c601372bf3bb2c2c110235bedffad3ba4b6590e0a0420eb008b1aec5220ac0f9bdd3deea40ce5f7fc8093fc3bbddabbf4b4238b9e236aa2496388d90b85c5951013e925cd14809cb99676337a2f2180e72c1993240997224933d9628b4d08bf5b87f0fdfec54a201997e054ac0f4d272e2fa1e98b5b24ba3bfb9204eac32c83a3a3cf32b20aef80ae3358c3749b9039c0798de5ac6cd4755ac89cd09dff35d11cd69b7c02ec369f511d90f48a4cbdb33e330f33ccf52b82e34ecec4d1fcccd18dc5a607f5ac965647493e60abfb6690d93518706b7c143d397cfbd79451fe44e4051f534c8376a139b521cd444f7a2bc009ba8a2ceb33f8f1ae55ae5c8907e65dfc9998d3f7e88b9347208d32cf8149cbac712661640febbd803add6ba073748c0bfc3a4d91e4c94315049a8fe0a2c108d51d1ff27ec906863e4722d9d4a50ff28d430eeaf9171edd5870eb4ea5d999a2b5398da08f84ebc28693c4f97ececea4d6f11108e9bc494f5825115b4aa084215f6b60d29903d982319adc8292062780a47b34f17b575e813782382a79620b0eea56f554de0c65d35df9b011c3f758db303cf80bb4f7c57882dff12ee6adb536dcb3c3e07e06cfdf6f4d0823d99f0ed66ba68fd626c36c8e02005be589072c7a9488374e02ef554b41eb97eb468648ce559fe2d6b84e1bf4853d39c982e2d5f36a3540bf21fe51380ea0a72b1890e099b3273546b5e38a143bff8d431bf49650fb790620514944a537a97c5d9ef102d4f3be8d5732353dd004284ff281b08efa6138ecd6603b3c894cc796ac18c806837093fadf5698947d277ecdd46be9277f64e6b9cacd7631fb0b97f7334e6fed5326ed26c803b291ec483a3d5ccbe2db054af4bb73706c22a2b3a091d0bc2250e1239667955052b98066741045d2210a14f0e4c6ca7e3611c14f75a0c24b2292a800271215c326c1f609939598875ae04d0da899b516f1a3d18820a03dc8e0715790eccfe73f42f7bc4757479186365bdc155fdca0cff101059fcb924ab7e4178cbe28240dc6c52aa56fa707fb7b00332034a8250b193aae582e4b66b1b05e33ebada3dee8062021a15204c034324c960c7b37a6153e58533814a475b7a93efc423976f9a7402cc5b191bd38ba6606b21acdf95d83ca5069aae76ff7e2bdedfb570e25eb3e53dd54b9930a466189b0b3df37cd559a240dfc8a2049e703b1d2a8e62db2255e3f4d8875a77b546837e9f117399eb12feaf3eb1dbf5110f601e7ddf88c192259634a6a273bbd4cce5bc9b9e8e249d1eeeed4a6aa954f45933e92f9718a100000080",
"key_infos": {
"0": [
"632a7a677ee3c30cf3ba81d5f880a4df",
"c413e19cde84e9e5acfb17dfa7fcbcb2",
"8f36a4250fdc6d8e45476e1a3d6abe72"
]
}
}
2 changes: 2 additions & 0 deletions wvguesser/wasm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def run(self, hex_session_key: str):
while j < 8:
buf[offset] = j
st = binascii.b2a_hex(bytes(buf)).decode('utf-8')
print(st)
val = self.guessInput(st)
print(val)
sub = int(val[len(val) - bt * 2 - 2:len(val) - bt * 2], 16)
got = (sub >> (offs * 2)) & 3
gtail = val[len(hex_session_key) - bt * 2:len(hex_session_key) + bt * 2]
Expand Down

0 comments on commit 4d9ed8e

Please sign in to comment.