mirror of
https://github.com/Mas0nShi/typoraCracker.git
synced 2023-07-10 13:41:20 +08:00
Compare commits
2 Commits
backup-raw
...
dev-1.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
768f9e870a | ||
|
|
4d15e2a665 |
13
typora.py
13
typora.py
@@ -28,7 +28,8 @@ if DEBUG:
|
||||
else:
|
||||
log.add(sys.stderr, level="INFO")
|
||||
|
||||
AES_KEY = struct.pack("<4Q", *[0x4B029A9482B3E14E, 0xF157FEB4B4522F80, 0xE25692105308F4BE, 0x6DD58DDDA3EC0DC2])
|
||||
AES_KEY = struct.pack("<4Q", *[0x252A4C7BD0B85281, 0xA31BD92CE099F719, 0x13E283392646D82D, 0x118BDE501CF74120])
|
||||
AES_IV = struct.pack("<4L", *[0x33706964, 0x5387CDD2, 0xD05F336D, 0x53F82468])
|
||||
|
||||
|
||||
def _mkDir(_path):
|
||||
@@ -43,10 +44,10 @@ def _mkDir(_path):
|
||||
|
||||
def decScript(b64: bytes, prettify: bool):
|
||||
lCode = b64decode(b64)
|
||||
# iv: the first 16 bytes of the file
|
||||
aesIv = lCode[0:16]
|
||||
# iv
|
||||
aesIv = AES_IV
|
||||
# cipher text
|
||||
cipherText = lCode[16:]
|
||||
cipherText = lCode[:]
|
||||
# AES 256 CBC
|
||||
ins = AES.new(key=AES_KEY, iv=aesIv, mode=AES.MODE_CBC)
|
||||
code = unpad(ins.decrypt(cipherText), 16, 'pkcs7')
|
||||
@@ -106,10 +107,10 @@ def extractWdec(asarPath, path, prettify):
|
||||
def encScript(_code: bytes, compress):
|
||||
if compress:
|
||||
_code = jsmin(_code.decode(), quote_chars="'\"`").encode()
|
||||
aesIv = urandom(16)
|
||||
aesIv = AES_IV
|
||||
cipherText = _code
|
||||
ins = AES.new(key=AES_KEY, iv=aesIv, mode=AES.MODE_CBC)
|
||||
enc = aesIv + ins.encrypt(pad(cipherText, 16, 'pkcs7'))
|
||||
enc = ins.encrypt(pad(cipherText, 16, 'pkcs7'))
|
||||
lCode = b64encode(enc)
|
||||
return lCode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user