Skip to content

Commit

Permalink
fix #143
Browse files Browse the repository at this point in the history
Signed-off-by: ふぁ <yuki@yuki0311.com>
  • Loading branch information
fa0311 committed Nov 26, 2024
1 parent 029e13f commit 6fc74ab
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions DMMGamePlayerFastLauncher/lib/DGPSessionV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ def write(self):
aes_key = self.get_aes_key()
for cookie_row in self.db.cursor().execute("select * from cookies"):
try:
value = self.cookies.get(cookie_row[3], domain=cookie_row[1], path=cookie_row[6]) or ""
v10, nonce, _, _ = self.split_encrypted_data(cookie_row[5])
cookie = self.cookies.get(cookie_row[3], domain=cookie_row[1], path=cookie_row[6]) or ""
v10, nonce, data, mac = self.split_encrypted_data(cookie_row[5])
cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
decrypt_data, mac = cipher.encrypt_and_digest(value.encode())
value = cipher.decrypt_and_verify(data, mac)
head, body = value[:32], value[32:]

cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
decrypt_data, mac = cipher.encrypt_and_digest(head + cookie.encode())
data = self.join_encrypted_data(v10, nonce, decrypt_data, mac)
self.db.execute(
"update cookies set encrypted_value = ? where name = ?",
Expand All @@ -125,12 +129,14 @@ def read(self):
aes_key = self.get_aes_key()
for cookie_row in self.db.cursor().execute("select * from cookies"):
try:
_, nonce, data, mac = self.split_encrypted_data(cookie_row[5])
v10, nonce, data, mac = self.split_encrypted_data(cookie_row[5])
cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
value = cipher.decrypt_and_verify(data, mac).decode()
value = cipher.decrypt_and_verify(data, mac)
head, body = value[:32], value[32:]

cookie_data = {
"name": cookie_row[3],
"value": value,
"value": body.decode(),
"domain": cookie_row[1],
"path": cookie_row[6],
"secure": cookie_row[8],
Expand Down

0 comments on commit 6fc74ab

Please sign in to comment.