sticker-convert 2.13.3.0__py3-none-any.whl → 2.17.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sticker_convert/__main__.py +24 -27
- sticker_convert/auth/__init__.py +0 -0
- sticker_convert/auth/auth_base.py +19 -0
- sticker_convert/{utils/auth/get_discord_auth.py → auth/auth_discord.py} +149 -118
- sticker_convert/{utils/auth/get_kakao_auth.py → auth/auth_kakao_android_login.py} +331 -330
- sticker_convert/auth/auth_kakao_desktop_login.py +327 -0
- sticker_convert/{utils/auth/get_kakao_desktop_auth.py → auth/auth_kakao_desktop_memdump.py} +281 -263
- sticker_convert/{utils/auth/get_line_auth.py → auth/auth_line.py} +98 -80
- sticker_convert/{utils/auth/get_signal_auth.py → auth/auth_signal.py} +139 -135
- sticker_convert/auth/auth_telethon.py +161 -0
- sticker_convert/{utils/auth/get_viber_auth.py → auth/auth_viber.py} +250 -235
- sticker_convert/{utils/auth → auth}/telegram_api.py +736 -675
- sticker_convert/cli.py +623 -608
- sticker_convert/converter.py +1093 -1084
- sticker_convert/definitions.py +4 -0
- sticker_convert/downloaders/download_band.py +111 -110
- sticker_convert/downloaders/download_base.py +171 -166
- sticker_convert/downloaders/download_discord.py +92 -91
- sticker_convert/downloaders/download_kakao.py +417 -404
- sticker_convert/downloaders/download_line.py +484 -475
- sticker_convert/downloaders/download_ogq.py +80 -79
- sticker_convert/downloaders/download_signal.py +108 -105
- sticker_convert/downloaders/download_telegram.py +56 -55
- sticker_convert/downloaders/download_viber.py +121 -120
- sticker_convert/gui.py +788 -873
- sticker_convert/gui_components/frames/comp_frame.py +180 -166
- sticker_convert/gui_components/frames/config_frame.py +156 -113
- sticker_convert/gui_components/frames/control_frame.py +32 -30
- sticker_convert/gui_components/frames/cred_frame.py +232 -233
- sticker_convert/gui_components/frames/input_frame.py +139 -137
- sticker_convert/gui_components/frames/output_frame.py +112 -110
- sticker_convert/gui_components/frames/right_clicker.py +25 -23
- sticker_convert/gui_components/windows/advanced_compression_window.py +757 -757
- sticker_convert/gui_components/windows/base_window.py +7 -2
- sticker_convert/gui_components/windows/discord_get_auth_window.py +79 -82
- sticker_convert/gui_components/windows/kakao_get_auth_window.py +511 -321
- sticker_convert/gui_components/windows/line_get_auth_window.py +94 -102
- sticker_convert/gui_components/windows/signal_get_auth_window.py +84 -89
- sticker_convert/gui_components/windows/viber_get_auth_window.py +168 -168
- sticker_convert/ios-message-stickers-template/.github/FUNDING.yml +3 -3
- sticker_convert/ios-message-stickers-template/README.md +10 -10
- sticker_convert/ios-message-stickers-template/stickers/Info.plist +43 -43
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Info.plist +31 -31
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Contents.json +6 -6
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Contents.json +20 -20
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Contents.json +9 -9
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Contents.json +9 -9
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Contents.json +9 -9
- sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Contents.json +91 -91
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.pbxproj +364 -364
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
- sticker_convert/ios-message-stickers-template/stickers.xcodeproj/xcuserdata/niklaspeterson.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
- sticker_convert/job.py +166 -130
- sticker_convert/job_option.py +1 -0
- sticker_convert/locales/en_US/LC_MESSAGES/base.mo +0 -0
- sticker_convert/locales/ja_JP/LC_MESSAGES/base.mo +0 -0
- sticker_convert/locales/zh_CN/LC_MESSAGES/base.mo +0 -0
- sticker_convert/locales/zh_TW/LC_MESSAGES/base.mo +0 -0
- sticker_convert/py.typed +0 -0
- sticker_convert/resources/NotoColorEmoji.ttf +0 -0
- sticker_convert/resources/help.ja_JP.json +88 -0
- sticker_convert/resources/help.json +10 -7
- sticker_convert/resources/help.zh_CN.json +88 -0
- sticker_convert/resources/help.zh_TW.json +88 -0
- sticker_convert/resources/input.ja_JP.json +74 -0
- sticker_convert/resources/input.json +121 -121
- sticker_convert/resources/input.zh_CN.json +74 -0
- sticker_convert/resources/input.zh_TW.json +74 -0
- sticker_convert/resources/output.ja_JP.json +38 -0
- sticker_convert/resources/output.zh_CN.json +38 -0
- sticker_convert/resources/output.zh_TW.json +38 -0
- sticker_convert/uploaders/compress_wastickers.py +186 -177
- sticker_convert/uploaders/upload_base.py +44 -35
- sticker_convert/uploaders/upload_signal.py +218 -203
- sticker_convert/uploaders/upload_telegram.py +353 -338
- sticker_convert/uploaders/upload_viber.py +178 -169
- sticker_convert/uploaders/xcode_imessage.py +295 -286
- sticker_convert/utils/callback.py +238 -6
- sticker_convert/utils/emoji.py +16 -4
- sticker_convert/utils/files/json_resources_loader.py +24 -19
- sticker_convert/utils/files/metadata_handler.py +3 -3
- sticker_convert/utils/translate.py +108 -0
- sticker_convert/utils/url_detect.py +40 -37
- sticker_convert/version.py +1 -1
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/METADATA +89 -74
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/RECORD +91 -74
- sticker_convert/utils/auth/telethon_setup.py +0 -97
- sticker_convert/utils/singletons.py +0 -18
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/WHEEL +0 -0
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/entry_points.txt +0 -0
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/licenses/LICENSE +0 -0
- {sticker_convert-2.13.3.0.dist-info → sticker_convert-2.17.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,263 +1,281 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
import os
|
|
3
|
-
import platform
|
|
4
|
-
import re
|
|
5
|
-
import subprocess
|
|
6
|
-
import time
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
|
|
10
|
-
from
|
|
11
|
-
|
|
12
|
-
from sticker_convert.utils.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
self
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
"-o",
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
import re
|
|
5
|
+
import subprocess
|
|
6
|
+
import time
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Optional, Tuple, Union, cast
|
|
9
|
+
|
|
10
|
+
from sticker_convert.auth.auth_base import AuthBase
|
|
11
|
+
from sticker_convert.utils.process import find_pid_by_name, get_mem, killall
|
|
12
|
+
from sticker_convert.utils.translate import I
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AuthKakaoDesktopMemdump(AuthBase):
|
|
16
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
17
|
+
self.MSG_NO_BIN = I(
|
|
18
|
+
"Kakao Desktop not detected.\n"
|
|
19
|
+
"Download and install Kakao Desktop,\n"
|
|
20
|
+
"then login to Kakao Desktop and try again."
|
|
21
|
+
)
|
|
22
|
+
self.MSG_NO_AUTH = I(
|
|
23
|
+
"Kakao Desktop installed,\n"
|
|
24
|
+
"but kakao_auth not found.\n"
|
|
25
|
+
"Please login to Kakao Desktop and try again."
|
|
26
|
+
)
|
|
27
|
+
self.MSG_SIP_ENABLED = I(
|
|
28
|
+
"You need to disable SIP:\n"
|
|
29
|
+
"1. Restart computer in Recovery mode\n"
|
|
30
|
+
"2. Launch Terminal from the Utilities menu\n"
|
|
31
|
+
"3. Run the command `csrutil disable`\n"
|
|
32
|
+
"4. Restart your computer"
|
|
33
|
+
)
|
|
34
|
+
self.MSG_LAUNCH_FAIL = I("Failed to launch Kakao")
|
|
35
|
+
self.MSG_PERMISSION_ERROR = I("Failed to read Kakao process memory")
|
|
36
|
+
|
|
37
|
+
super().__init__(*args, **kwargs)
|
|
38
|
+
|
|
39
|
+
def launch_kakao(self, kakao_bin_path: str) -> None:
|
|
40
|
+
if platform.system() == "Windows":
|
|
41
|
+
subprocess.Popen([kakao_bin_path])
|
|
42
|
+
elif platform.system() == "Darwin":
|
|
43
|
+
subprocess.Popen(["open", kakao_bin_path])
|
|
44
|
+
else:
|
|
45
|
+
subprocess.Popen(["wine", kakao_bin_path])
|
|
46
|
+
|
|
47
|
+
def relaunch_kakao(self, kakao_bin_path: str) -> Optional[int]:
|
|
48
|
+
killed = killall("kakaotalk")
|
|
49
|
+
if killed:
|
|
50
|
+
time.sleep(5)
|
|
51
|
+
|
|
52
|
+
self.launch_kakao(kakao_bin_path)
|
|
53
|
+
time.sleep(20)
|
|
54
|
+
|
|
55
|
+
return find_pid_by_name("kakaotalk")
|
|
56
|
+
|
|
57
|
+
def get_auth_by_pme(
|
|
58
|
+
self, kakao_bin_path: str, relaunch: bool = True
|
|
59
|
+
) -> Tuple[Optional[str], str]:
|
|
60
|
+
from PyMemoryEditor import OpenProcess # type: ignore
|
|
61
|
+
|
|
62
|
+
auth_token = None
|
|
63
|
+
|
|
64
|
+
if relaunch:
|
|
65
|
+
kakao_pid = self.relaunch_kakao(kakao_bin_path)
|
|
66
|
+
else:
|
|
67
|
+
kakao_pid = find_pid_by_name("kakaotalk")
|
|
68
|
+
if kakao_pid is None:
|
|
69
|
+
return None, self.MSG_LAUNCH_FAIL
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
with OpenProcess(pid=int(kakao_pid)) as process:
|
|
73
|
+
for address in process.search_by_value( # type: ignore
|
|
74
|
+
str, 15, "authorization: "
|
|
75
|
+
):
|
|
76
|
+
auth_token_addr = cast(int, address) + 15
|
|
77
|
+
auth_token_bytes = process.read_process_memory(
|
|
78
|
+
auth_token_addr, bytes, 200
|
|
79
|
+
)
|
|
80
|
+
auth_token_term = auth_token_bytes.find(b"\x00")
|
|
81
|
+
if auth_token_term == -1:
|
|
82
|
+
continue
|
|
83
|
+
auth_token_candidate = auth_token_bytes[:auth_token_term].decode(
|
|
84
|
+
encoding="ascii"
|
|
85
|
+
)
|
|
86
|
+
if len(auth_token_candidate) > 150:
|
|
87
|
+
auth_token = auth_token_candidate
|
|
88
|
+
break
|
|
89
|
+
except PermissionError:
|
|
90
|
+
return None, self.MSG_PERMISSION_ERROR
|
|
91
|
+
|
|
92
|
+
if auth_token is None:
|
|
93
|
+
return None, self.MSG_NO_AUTH
|
|
94
|
+
else:
|
|
95
|
+
msg = "(Note: auth_token will be invalid if you quit Kakao Desktop)"
|
|
96
|
+
msg += "Got auth_token successfully:\n"
|
|
97
|
+
msg += f"{auth_token=}\n"
|
|
98
|
+
|
|
99
|
+
return auth_token, msg
|
|
100
|
+
|
|
101
|
+
def get_auth_by_dump(
|
|
102
|
+
self, kakao_bin_path: str, relaunch: bool = True
|
|
103
|
+
) -> Tuple[Optional[str], str]:
|
|
104
|
+
auth_token = None
|
|
105
|
+
kakao_pid: Union[str, int, None]
|
|
106
|
+
if platform.system() == "Windows":
|
|
107
|
+
is_wine = False
|
|
108
|
+
if relaunch:
|
|
109
|
+
kakao_pid = self.relaunch_kakao(kakao_bin_path)
|
|
110
|
+
else:
|
|
111
|
+
kakao_pid = find_pid_by_name("kakaotalk")
|
|
112
|
+
if kakao_pid is None:
|
|
113
|
+
return None, self.MSG_LAUNCH_FAIL
|
|
114
|
+
else:
|
|
115
|
+
is_wine = True
|
|
116
|
+
kakao_pid = "KakaoTalk.exe"
|
|
117
|
+
if relaunch and self.relaunch_kakao(kakao_bin_path) is None:
|
|
118
|
+
return None, self.MSG_LAUNCH_FAIL
|
|
119
|
+
|
|
120
|
+
def pw_func(msg: str) -> str:
|
|
121
|
+
return self.cb.put(
|
|
122
|
+
(
|
|
123
|
+
"ask_str",
|
|
124
|
+
None,
|
|
125
|
+
{
|
|
126
|
+
"message": msg,
|
|
127
|
+
"password": True,
|
|
128
|
+
},
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
s = get_mem(kakao_pid, pw_func, is_wine)
|
|
133
|
+
|
|
134
|
+
if s is None:
|
|
135
|
+
return None, "Failed to dump memory"
|
|
136
|
+
|
|
137
|
+
auth_token = None
|
|
138
|
+
for i in re.finditer(b"authorization: ", s):
|
|
139
|
+
auth_token_addr = i.start() + 15
|
|
140
|
+
|
|
141
|
+
auth_token_bytes = s[auth_token_addr : auth_token_addr + 200]
|
|
142
|
+
auth_token_term = auth_token_bytes.find(b"\x00")
|
|
143
|
+
if auth_token_term == -1:
|
|
144
|
+
continue
|
|
145
|
+
auth_token_candidate = auth_token_bytes[:auth_token_term].decode(
|
|
146
|
+
encoding="ascii"
|
|
147
|
+
)
|
|
148
|
+
if len(auth_token_candidate) > 150:
|
|
149
|
+
auth_token = auth_token_candidate
|
|
150
|
+
break
|
|
151
|
+
|
|
152
|
+
if auth_token is None:
|
|
153
|
+
return None, self.MSG_NO_AUTH
|
|
154
|
+
else:
|
|
155
|
+
msg = "Got auth_token successfully:\n"
|
|
156
|
+
msg += f"{auth_token=}\n"
|
|
157
|
+
|
|
158
|
+
return auth_token, msg
|
|
159
|
+
|
|
160
|
+
def get_auth_darwin(self, kakao_bin_path: str) -> Tuple[Optional[str], str]:
|
|
161
|
+
csrutil_status = subprocess.run(
|
|
162
|
+
["csrutil", "status"], capture_output=True, text=True
|
|
163
|
+
).stdout
|
|
164
|
+
|
|
165
|
+
if "enabled" in csrutil_status:
|
|
166
|
+
return None, self.MSG_SIP_ENABLED
|
|
167
|
+
|
|
168
|
+
killall("kakaotalk")
|
|
169
|
+
|
|
170
|
+
subprocess.run(
|
|
171
|
+
[
|
|
172
|
+
"lldb",
|
|
173
|
+
kakao_bin_path,
|
|
174
|
+
"-o",
|
|
175
|
+
"b ptrace",
|
|
176
|
+
"-o",
|
|
177
|
+
"r",
|
|
178
|
+
"-o",
|
|
179
|
+
"thread return",
|
|
180
|
+
"-o",
|
|
181
|
+
"con",
|
|
182
|
+
"-o",
|
|
183
|
+
"process save-core /tmp/memdump.kakaotalk.dmp",
|
|
184
|
+
"-o",
|
|
185
|
+
"con",
|
|
186
|
+
"-o",
|
|
187
|
+
"quit",
|
|
188
|
+
],
|
|
189
|
+
stdout=subprocess.DEVNULL,
|
|
190
|
+
stderr=subprocess.DEVNULL,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
with open("/tmp/memdump.kakaotalk.dmp", "rb") as f:
|
|
194
|
+
mem = f.read()
|
|
195
|
+
|
|
196
|
+
os.remove("/tmp/memdump.kakaotalk.dmp")
|
|
197
|
+
|
|
198
|
+
auth_token = None
|
|
199
|
+
for i in re.finditer(b"]mac/", mem):
|
|
200
|
+
auth_token_term = i.start()
|
|
201
|
+
|
|
202
|
+
auth_token_bytes = mem[auth_token_term - 200 : auth_token_term]
|
|
203
|
+
auth_token_start = auth_token_bytes.find(b"application/json_\x10\x8a") + 19
|
|
204
|
+
if auth_token_start == -1:
|
|
205
|
+
continue
|
|
206
|
+
try:
|
|
207
|
+
auth_token_candidate = auth_token_bytes[auth_token_start:].decode(
|
|
208
|
+
encoding="ascii"
|
|
209
|
+
)
|
|
210
|
+
except UnicodeDecodeError:
|
|
211
|
+
continue
|
|
212
|
+
|
|
213
|
+
if 150 > len(auth_token_candidate) > 100:
|
|
214
|
+
auth_token = auth_token_candidate
|
|
215
|
+
break
|
|
216
|
+
|
|
217
|
+
if auth_token is None:
|
|
218
|
+
return None, self.MSG_NO_AUTH
|
|
219
|
+
else:
|
|
220
|
+
msg = "Got auth_token successfully:\n"
|
|
221
|
+
msg += f"{auth_token=}\n"
|
|
222
|
+
|
|
223
|
+
return auth_token, msg
|
|
224
|
+
|
|
225
|
+
def get_kakao_desktop(self) -> Optional[str]:
|
|
226
|
+
if platform.system() == "Windows":
|
|
227
|
+
kakao_bin_path = os.path.expandvars(
|
|
228
|
+
"%programfiles(x86)%\\Kakao\\KakaoTalk\\KakaoTalk.exe"
|
|
229
|
+
)
|
|
230
|
+
if Path(kakao_bin_path).exists() is False:
|
|
231
|
+
kakao_bin_path = os.path.expandvars(
|
|
232
|
+
"%programfiles%\\Kakao\\KakaoTalk\\KakaoTalk.exe"
|
|
233
|
+
)
|
|
234
|
+
elif platform.system() == "Darwin":
|
|
235
|
+
kakao_bin_path = "/Applications/KakaoTalk.app"
|
|
236
|
+
else:
|
|
237
|
+
wineprefix = os.environ.get("WINEPREFIX")
|
|
238
|
+
if not (wineprefix and Path(wineprefix).exists()):
|
|
239
|
+
wineprefix = os.path.expanduser("~/.wine")
|
|
240
|
+
kakao_bin_path = f"{wineprefix}/drive_c/Program Files (x86)/Kakao/KakaoTalk/KakaoTalk.exe"
|
|
241
|
+
|
|
242
|
+
if Path(kakao_bin_path).exists():
|
|
243
|
+
return kakao_bin_path
|
|
244
|
+
|
|
245
|
+
return None
|
|
246
|
+
|
|
247
|
+
def get_cred(
|
|
248
|
+
self,
|
|
249
|
+
kakao_bin_path: Optional[str] = None,
|
|
250
|
+
) -> Tuple[Optional[str], str]:
|
|
251
|
+
# get_auth_by_dump()
|
|
252
|
+
# + Fast
|
|
253
|
+
# - Requires downloading procdump, or builtin method that needs admin
|
|
254
|
+
|
|
255
|
+
# get_auth_by_pme()
|
|
256
|
+
# + No admin (If have permission to read process)
|
|
257
|
+
# - Slow
|
|
258
|
+
# - Cannot run on macOS
|
|
259
|
+
|
|
260
|
+
msg = I(
|
|
261
|
+
"Getting Kakao authorization token by Desktop memdump...\n(This may take a minute)"
|
|
262
|
+
)
|
|
263
|
+
self.cb.put(("msg_dynamic", (msg,), None))
|
|
264
|
+
if not kakao_bin_path:
|
|
265
|
+
kakao_bin_path = self.get_kakao_desktop()
|
|
266
|
+
|
|
267
|
+
if not kakao_bin_path:
|
|
268
|
+
return None, self.MSG_NO_BIN
|
|
269
|
+
|
|
270
|
+
if platform.system() == "Windows":
|
|
271
|
+
kakao_auth, msg = self.get_auth_by_dump(kakao_bin_path)
|
|
272
|
+
if kakao_auth is None:
|
|
273
|
+
kakao_auth, msg = self.get_auth_by_pme(kakao_bin_path, False)
|
|
274
|
+
elif platform.system() == "Darwin":
|
|
275
|
+
kakao_auth, msg = self.get_auth_darwin(kakao_bin_path)
|
|
276
|
+
else:
|
|
277
|
+
kakao_auth, msg = self.get_auth_by_dump(kakao_bin_path)
|
|
278
|
+
|
|
279
|
+
self.cb.put(("msg_dynamic", (None,), None))
|
|
280
|
+
|
|
281
|
+
return kakao_auth, msg
|