-
Notifications
You must be signed in to change notification settings - Fork 1
/
Nagato-Sakura-SMS-Checker-GUI-CPU.py
981 lines (921 loc) · 58.8 KB
/
Nagato-Sakura-SMS-Checker-GUI-CPU.py
1
2
3
4
5
6
7
8
9
10
11
12
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
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
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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
import tkinter as tk
from tkinter import messagebox, scrolledtext, Menu, filedialog
import torch
import torch.nn as nn
import json
from pathlib import Path
from PIL import Image, ImageTk
import re
import requests
import ssl
import socket
import threading
from urllib.parse import urlparse
import webbrowser
# 設置運算裝置、檢測環境
device = torch.device("cpu")
current_directory = Path(__file__).resolve().parent
print("<環境檢測>")
print(f"PyTorch 版本: {torch.__version__}")
print(f"運行模式: {device}")
# 定義神經網路模型
class SMSClassifier(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(SMSClassifier, self).__init__()
self.fc1 = nn.Linear(input_size, int(hidden_size * 0.66))
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(int(hidden_size * 0.66), int(hidden_size * 0.66))
self.relu2 = nn.ReLU()
self.fc3 = nn.Linear(int(hidden_size * 0.66), output_size)
self.softmax = nn.Softmax(dim=-1)
def forward(self, x):
x = self.fc1(x) # 輸入層到第一個隱藏層
x = self.relu1(x)
x = self.fc2(x) # 第一個隱藏層到第二個隱藏層
x = self.relu2(x)
x = self.fc3(x) # 最後一個隱藏層到輸出層
x = self.softmax(x)
return x
# 加載模型和詞彙表
def load_model(model_path, vocab_path, config_path, label_path, device):
with open(vocab_path, 'r') as json_file:
vocab = json.load(json_file)
with open(config_path, 'r') as json_file:
model_config = json.load(json_file)
with open(label_path, 'r') as labels_file:
label_mapping = {}
for line in labels_file:
label, index = line.strip().split(': ')
label_mapping[label] = int(index)
model = SMSClassifier(model_config['input_size'], model_config['hidden_size'], model_config['output_size'])
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
model = model.to(device)
model.eval()
return model, vocab, label_mapping
# 設定路徑並將模型、詞彙表和標籤映射到裝置
VOCAB_PATH = current_directory / "models" / "tokenizer.json"
MODEL_PATH = current_directory / "models" / "SMS_model.bin"
CONFIG_PATH = current_directory / "models" / "config.json"
LABEL_PATH = current_directory / "models" / "labels.txt"
BLACKLIST_PATH = current_directory / "data" / "blacklist.txt"
model, vocab, label_mapping = load_model(MODEL_PATH, VOCAB_PATH, CONFIG_PATH, LABEL_PATH, device)
# 將文本轉換為向量
def text_to_vector(text):
vector = [0] * len(vocab)
for word in text:
if word in vocab:
vector[vocab.index(word)] = 1
return vector
# 獲取使用者輸入的簡訊內容
def predict_and_display():
language = current_language
user_input = entry.get()
if user_input == "":
if language == "繁體中文":
messagebox.showinfo("提醒", "請輸入簡訊內容!")
elif language == "English":
messagebox.showinfo("Reminder", "Please enter the SMS content!")
elif language == "日本語":
messagebox.showinfo("リマインダー", "メッセージ内容を入力してください!")
else:
predict_SMS(user_input, safety_text_box)
# 預測簡訊類別並顯示結果
def predict_SMS(text, text_widget):
language = current_language
input_vector = text_to_vector(text)
input_vector = torch.tensor(input_vector, dtype=torch.float).unsqueeze(0).to(device)
output = model(input_vector)
predicted_class = torch.argmax(output).item()
predicted_probs = output.squeeze().tolist()
predicted_label = [label for label, index in label_mapping.items() if index == predicted_class][0]
phone_numbers = re.findall(r'(\(?0\d{1,2}\)?[-\.\s]?\d{3,4}[-\.\s]?\d{3,4})', text)
urls = re.findall(r'\b(?:https?://)?(?:www\.)?[\w\.-]+\.[a-zA-Z]{2,}(?:/[^\s]*)?(?![\w\.-])\b', text)
verification_codes = re.findall(r'(?<!\d)(\d{4,6})(?!\d)(?<!/)', text)
if language == "繁體中文":
print(f"【簡訊內容】: {text}")
text_widget.insert(tk.END, f"【簡訊內容】: {text}\n")
print(f"【預測概率】: {predicted_probs}")
text_widget.insert(tk.END, f"【預測概率】: {predicted_probs}\n")
print(f"【預測結果】: {predicted_label}")
text_widget.insert(tk.END, f"【預測結果】: {predicted_label}\n")
if phone_numbers:
print(f"【偵測電話】: {phone_numbers}")
text_widget.insert(tk.END, f"【偵測電話】: {phone_numbers}\n")
if urls:
for url in urls:
if current_blacklist == "開啟":
with open(BLACKLIST_PATH, "r", encoding="utf-8") as file:
blacklist = set(line.strip() for line in file)
for blacklisted_url in blacklist:
if blacklisted_url in urls:
print(f"【黑名單】: {urls} 在黑名單中")
text_widget.insert(tk.END, f"【黑名單】: {urls} 在黑名單中\n")
break
threading.Thread(target=check_url_safety, args=(url, text_widget)).start()
if predicted_label == 'Captcha SMS':
if verification_codes:
print(f"【驗證碼】: {verification_codes}")
text_widget.insert(tk.END, f"【驗證碼】: {verification_codes}\n")
else:
print("【驗證碼】: 未找到驗證碼。")
text_widget.insert(tk.END, "【驗證碼】: 未找到驗證碼\n")
elif language == "English":
print(f"【SMS Content】: {text}")
text_widget.insert(tk.END, f"【SMS Content】: {text}\n")
print(f"【Prediction Probabilities】: {predicted_probs}")
text_widget.insert(tk.END, f"【Prediction Probabilities】: {predicted_probs}\n")
print(f"【Prediction Result】: {predicted_label}")
text_widget.insert(tk.END, f"【Prediction Result】: {predicted_label}\n")
if phone_numbers:
print(f"【Detected Phone Numbers】: {phone_numbers}")
text_widget.insert(tk.END, f"【Detected Phone Numbers】: {phone_numbers}\n")
if urls:
for url in urls:
if current_blacklist == "開啟":
with open(BLACKLIST_PATH, "r", encoding="utf-8") as file:
blacklist = set(line.strip() for line in file)
for blacklisted_url in blacklist:
if blacklisted_url in urls:
print(f"【Blacklist】: {urls} is in the blacklist\n")
text_widget.insert(tk.END, f"【Blacklist】: {urls} is in the blacklist\n")
break
threading.Thread(target=check_url_safety, args=(url, text_widget)).start()
if predicted_label == 'Captcha SMS':
if verification_codes:
print(f"【Verification Codes】: {verification_codes}")
text_widget.insert(tk.END, f"【Verification Codes】: {verification_codes}\n")
else:
print("【Verification Codes】: No verification code found.")
text_widget.insert(tk.END, "【Verification Codes】: No verification code found.\n")
elif language == "日本語":
print(f"【SMS コンテンツ】: {text}")
text_widget.insert(tk.END, f"【SMS コンテンツ】: {text}\n")
print(f"【予測確率】: {predicted_probs}")
text_widget.insert(tk.END, f"【予測確率】: {predicted_probs}\n")
print(f"【予測結果】: {predicted_label}")
text_widget.insert(tk.END, f"【予測結果】: {predicted_label}\n")
if phone_numbers:
print(f"【検出電話】: {phone_numbers}")
text_widget.insert(tk.END, f"【検出電話】: {phone_numbers}\n")
if urls:
for url in urls:
if current_blacklist == "開啟":
with open(BLACKLIST_PATH, "r", encoding="utf-8") as file:
blacklist = set(line.strip() for line in file)
for blacklisted_url in blacklist:
if blacklisted_url in urls:
print(f"【ブラックリスト】: {urls} はブラックリストにあります\n")
text_widget.insert(tk.END, f"【ブラックリスト】: {urls} はブラックリストにあります\n")
break
threading.Thread(target=check_url_safety, args=(url, text_widget)).start()
if predicted_label == 'Captcha SMS':
if verification_codes:
print(f"【確認コード】: {verification_codes}")
text_widget.insert(tk.END, f"【確認コード】: {verification_codes}\n")
else:
print("【確認コード】: 確認コードが見つかりませんでした。")
text_widget.insert(tk.END, "【確認コード】: 確認コードが見つかりませんでした。\n")
return predicted_label, predicted_probs, predicted_class, phone_numbers, urls, verification_codes
# 檢查網址安全性
def check_url_safety(url, text_widget):
language = current_language
show_hostname = current_hostname
show_cert = current_cert
try:
# 若網址不是以 http:// 或 https:// 開頭,則加上 https://
if not url.startswith(("http://", "https://")):
url = "https://" + url
# 若網址不是以 https:// 開頭,則印出警告訊息
if not url.startswith("https://"):
if language == "繁體中文":
print(f"【警告】: {url} 使用不安全的協議")
result = f"【警告】: {url} 使用不安全的協議\n"
elif language == "English":
print(f"【Warning】: {url} is using an insecure protocol")
result = f"【Warning】: {url} is using an insecure protocol\n"
elif language == "日本語":
print(f"【警告】: {url} は安全でないプロトコルを使用しています")
result = f"【警告】: {url} は安全でないプロトコルを使用しています\n"
else:
print(f"【警告】: Unknown language: {language}")
result = f"【警告】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
# 檢查網址中是否有可疑模式
suspicious_patterns = ["phishing", "malware", "hack", "top"]
if any(pattern in url.lower() for pattern in suspicious_patterns):
if language == "繁體中文":
print(f"【警告】: {url} 的路徑包含可疑模式")
result = f"【警告】: {url} 的路徑包含可疑模式\n"
elif language == "English":
print(f"【Warning】: The path of {url} contains suspicious patterns")
result = f"【Warning】: The path of {url} contains suspicious patterns\n"
elif language == "日本語":
print(f"【警告】: {url} のパスには疑わしいパターンが含まれています")
result = f"【警告】: {url} のパスには疑わしいパターンが含まれています\n"
else:
print(f"【警告】: Unknown language: {language}")
result = f"【警告】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
# 發送 HTTP 請求並檢查回應狀態碼
response = requests.get(url, timeout=3)
if response.status_code == 200:
if language == "繁體中文":
print(f"【安全】: {url} 伺服器已處理請求並正常響應")
result = f"【安全】: {url} 伺服器已處理請求並正常響應\n"
elif language == "English":
print(f"【Safe】: {url} The server has successfully processed the request and responded normally")
result = f"【Safe】: {url} The server has successfully processed the request and responded normally\n"
elif language == "日本語":
print(f"【安全】: {url} サーバーはリクエストを正常に処理し、正常に応答しました")
result = f"【安全】: {url} サーバーはリクエストを正常に処理し、正常に応答しました\n"
else:
result = f"【安全】: Unknown language\: {language}\n"
text_widget.insert(tk.END, result)
else:
if language == "繁體中文":
print(f"【警告】: {url} 可能有風險 (狀態碼: {response.status_code}).")
result = f"【警告】: {url} 可能有風險 (狀態碼: {response.status_code}).\n"
elif language == "English":
print(f"【Warning】: {url} may be at risk (status code: {response.status_code}).")
result = f"【Warning】: {url} may be at risk (status code: {response.status_code}).\n"
elif language == "日本語":
print(f"【警告】: {url} はリスクがある可能性があります(ステータスコード: {response.status_code}).")
result = f"【警告】: {url} はリスクがある可能性があります(ステータスコード: {response.status_code}).\n"
else:
print(f"【警告】: Unknown language: {language}")
result = f"【警告】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
except requests.exceptions.RequestException as e:
if language == "繁體中文":
print(f"【錯誤】: {url} 請求錯誤 ({str(e)})")
result = f"【錯誤】: {url} 請求錯誤 ({str(e)})\n"
elif language == "English":
print(f"【Error】: {url} Request error ({str(e)})")
result = f"【Error】: {url} Request error ({str(e)})\n"
elif language == "日本語":
print(f"【エラー】: {url} リクエストエラー ({str(e)})")
result = f"【エラー】: {url} リクエストエラー ({str(e)})\n"
else:
print(f"【Error】: Unknown language: {language}")
result = f"【Error】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
except ssl.SSLError as ssl_error:
if language == "繁體中文":
print(f"【警告】: {url} SSL 握手失敗 ({ssl_error.strerror})")
result = f"【警告】: {url} SSL 握手失敗 ({ssl_error.strerror})\n"
elif language == "English":
print(f"【Warning】: {url} SSL handshake failed ({ssl_error.strerror})")
result = f"【Warning】: {url} SSL handshake failed ({ssl_error.strerror})\n"
elif language == "日本語":
print(f"【警告】: {url} SSL ハンドシェイクに失敗しました ({ssl_error.strerror})")
result = f"【警告】: {url} SSL ハンドシェイクに失敗しました ({ssl_error.strerror})\n"
else:
print(f"【警告】: Unknown language: {language}")
result = f"【警告】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
except socket.timeout:
if language == "繁體中文":
print(f"【錯誤】: {url} 連接超時")
result = f"【錯誤】: {url} 連接超時\n"
elif language == "English":
print(f"【Error】: {url} Connection timeout")
result = f"【Error】: {url} Connection timeout\n"
elif language == "日本語":
print(f"【エラー】: {url} 接続がタイムアウトしました")
result = f"【エラー】: {url} 接続がタイムアウトしました\n"
else:
print(f"【Error】: Unknown language: {language}")
result = f"【Error】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
except socket.error as socket_error:
if language == "繁體中文":
print(f"【錯誤】: {url} 連接錯誤 ({str(socket_error)})")
result = f"【錯誤】: {url} 連接錯誤 ({str(socket_error)})\n"
elif language == "English":
print(f"【Error】: {url} Connection error ({str(socket_error)})")
result = f"【Error】: {url} Connection error ({str(socket_error)})\n"
elif language == "日本語":
print(f"【エラー】: {url} 接続エラー ({str(socket_error)})")
result = f"【エラー】: {url} 接続エラー ({str(socket_error)})\n"
else:
print(f"【Error】: Unknown language: {language}")
result = f"【Error】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
except Exception as request_error:
if language == "繁體中文":
print(f"【錯誤】: {url} {str(request_error)}")
result = f"【錯誤】: {url} {str(request_error)}\n"
elif language == "English":
print(f"【Error】: {url} {str(request_error)}")
result = f"【Error】: {url} {str(request_error)}\n"
elif language == "日本語":
print(f"【エラー】: {url} {str(request_error)}")
result = f"【エラー】: {url} {str(request_error)}\n"
else:
print(f"【Error】: Unknown language: {language}")
result = f"【Error】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
finally:
try:
# 解析網址並取得主機名稱和 IP 地址
parsed_url = urlparse(url)
hostname = parsed_url.hostname
ip_address = socket.gethostbyname(hostname)
hostname_from_ip = socket.gethostbyaddr(ip_address)
if show_hostname == "開啟":
if language == "繁體中文":
print(f"【主機名稱】: {hostname}")
text_widget.insert(tk.END, f"【主機名稱】: {hostname}\n")
print(f"【IP 位址】: {ip_address}")
text_widget.insert(tk.END, f"【IP 位址】: {ip_address}\n")
print(f"【從 IP 位址取得的主機名稱】: {hostname_from_ip}")
text_widget.insert(tk.END, f"【從 IP 位址取得的主機名稱】: {hostname_from_ip}\n")
elif language == "English":
print(f"【Hostname】: {hostname}")
text_widget.insert(tk.END, f"【Hostname】: {hostname}\n")
print(f"【IP Address】: {ip_address}")
text_widget.insert(tk.END, f"【IP Address】: {ip_address}\n")
print(f"【Hostname from IP Address】: {hostname_from_ip}")
text_widget.insert(tk.END, f"【Hostname from IP Address】: {hostname_from_ip}\n")
elif language == "日本語":
print(f"【ホスト名】: {hostname}")
text_widget.insert(tk.END, f"【ホスト名】: {hostname}\n")
print(f"【IPアドレス】: {ip_address}")
text_widget.insert(tk.END, f"【IPアドレス】: {ip_address}\n")
print(f"【IPアドレスからのホスト名】: {hostname_from_ip}")
text_widget.insert(tk.END, f"【IPアドレスからのホスト名】: {hostname_from_ip}\n")
# 建立 SSL 連線並取得伺服器憑證
context = ssl.create_default_context()
context.check_hostname = False
with context.wrap_socket(socket.socket(), server_hostname=url) as s:
s.settimeout(5)
s.connect((hostname, 443))
cert = s.getpeercert()
cert_start_date = cert['notBefore']
cert_end_date = cert['notAfter']
if show_cert == "開啟":
if language == "繁體中文":
print(f"【憑證起始日期】: {cert_start_date}")
text_widget.insert(tk.END, f"【憑證起始日期】: {cert_start_date}\n")
print(f"【憑證結束日期】: {cert_end_date}")
text_widget.insert(tk.END, f"【憑證結束日期】: {cert_end_date}\n")
elif language == "English":
print(f"【Certificate Start Date】: {cert_start_date}")
text_widget.insert(tk.END, f"【Certificate Start Date】: {cert_start_date}\n")
print(f"【Certificate End Date】: {cert_end_date}")
text_widget.insert(tk.END, f"【Certificate End Date】: {cert_end_date}\n")
elif language == "日本語":
print(f"【証明書開始日】: {cert_start_date}")
text_widget.insert(tk.END, f"【証明書開始日】: {cert_start_date}\n")
print(f"【証明書終了日】: {cert_end_date}")
text_widget.insert(tk.END, f"【証明書終了日】: {cert_end_date}\n")
except Exception as e:
if language == "繁體中文":
print(f"【錯誤】: {url} {str(e)}")
result = f"【錯誤】: {url} {str(e)}\n"
elif language == "English":
print(f"【Error】: {url} {str(e)}")
result = f"【Error】: {url} {str(e)}\n"
elif language == "日本語":
print(f"【エラー】: {url} {str(e)}")
result = f"【エラー】: {url} {str(e)}\n"
else:
print(f"【Error】: Unknown language: {language}")
result = f"【Error】: Unknown language: {language}\n"
text_widget.insert(tk.END, result)
# 清除鍵
def clear_input():
entry.delete(0, tk.END)
safety_text_box.delete('1.0', tk.END)
# 開啟檔案
def open_json_file():
file_path = filedialog.askopenfilename(filetypes=[("JSON files", "*.json")])
if file_path:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
safety_text_box.delete('1.0', tk.END)
safety_text_box.insert(tk.END, content)
# 儲存檔案
def save_to_json():
save_path = filedialog.asksaveasfilename(defaultextension=".json", filetypes=[("JSON files", "*.json")])
if save_path:
with open(save_path, 'w', encoding='utf-8') as file:
content = safety_text_box.get('1.0', tk.END)
file.write(content)
# 語言選單
def set_language(language, theme, blacklist, show_hostname, show_cert):
global current_language
current_language = language
global current_theme
current_theme = theme
global current_blacklist
current_blacklist = blacklist
global current_hostname
current_hostname = show_hostname
global current_cert
current_cert = show_cert
global version
global predict_button
global clear_button
global file_menu
global language_menu
global theme_menu
global root
global menu_bar
global help_menu
if language == "繁體中文":
predict_button.config(text="預測")
clear_button.config(text="清除")
root.config(menu=None)
menu_bar = Menu(root)
root.config(menu=menu_bar)
file_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="檔案", menu=file_menu)
file_menu.add_command(label="開啟", command=open_json_file)
file_menu.add_command(label="儲存", command=save_to_json)
file_menu.add_separator()
file_menu.add_command(label="退出", command=root.quit)
language_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="語言", menu=language_menu)
language_menu.add_command(label="☑ 繁體中文", command=lambda: set_language("繁體中文", current_theme, current_blacklist, current_hostname, current_cert))
language_menu.add_command(label="☐ English", command=lambda: set_language("English", current_theme, current_blacklist, current_hostname, current_cert))
language_menu.add_command(label="☐ 日本語", command=lambda: set_language("日本語", current_theme, current_blacklist, current_hostname, current_cert))
help_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="說明", menu=help_menu)
help_menu.add_command(label="開啟網站", command=open_github)
help_menu.add_separator()
help_menu.add_command(label="版本資訊", command=show_version_info)
theme_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="主題", menu=theme_menu)
if theme == "現代淺色":
theme_menu.add_command(label="☑ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "現代深色":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☑ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "緋紅之翼":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☑ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "青色陰影":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☑ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "暗度藏青":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☑ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "可愛次元":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☑ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "次元重生":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☑ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ 賽博朋克", command=lambda: set_theme("賽博朋克"))
elif theme == "賽博朋克":
theme_menu.add_command(label="☐ 現代淺色", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ 現代深色", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅之翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 青色陰影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 暗度藏青", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ 可愛次元", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ 次元重生", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☑ 賽博朋克", command=lambda: set_theme("賽博朋克"))
setting_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="設定", menu=setting_menu)
if blacklist == "開啟":
setting_menu.add_command(label="☑ 黑名單", command=lambda: enable_blacklist("關閉"))
elif blacklist == "關閉":
setting_menu.add_command(label="☐ 黑名單", command=lambda: enable_blacklist("開啟"))
if show_hostname == "開啟":
setting_menu.add_command(label="☑ 顯示主機名稱及IP", command=lambda: enable_hostname("關閉"))
elif show_hostname == "關閉":
setting_menu.add_command(label="☐ 顯示主機名稱及IP", command=lambda: enable_hostname("開啟"))
if show_cert == "開啟":
setting_menu.add_command(label="☑ 顯示憑證日期", command=lambda: enable_cert("關閉"))
elif show_cert == "關閉":
setting_menu.add_command(label="☐ 顯示憑證日期", command=lambda: enable_cert("開啟"))
elif language == "English":
predict_button.config(text="Predict")
clear_button.config(text="Clear")
root.config(menu=None)
menu_bar = Menu(root)
root.config(menu=menu_bar)
file_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="Open", command=open_json_file)
file_menu.add_command(label="Save", command=save_to_json)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=root.quit)
language_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Language", menu=language_menu)
language_menu.add_command(label="☐ 繁體中文", command=lambda: set_language("繁體中文", current_theme, current_blacklist, current_hostname, current_cert))
language_menu.add_command(label="☑ English", command=lambda: set_language("English", current_theme, current_blacklist, current_hostname, current_cert))
language_menu.add_command(label="☐ 日本語", command=lambda: set_language("日本語", current_theme, current_blacklist, current_hostname, current_cert))
help_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Help", menu=help_menu)
help_menu.add_command(label="Open Website", command=open_github)
help_menu.add_separator()
help_menu.add_command(label="Version Information", command=show_version_info)
theme_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Theme", menu=theme_menu)
if theme == "現代淺色":
theme_menu.add_command(label="☑ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "現代深色":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☑ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "緋紅之翼":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☑ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "青色陰影":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☑ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "暗度藏青":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☑ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "可愛次元":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☑ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "次元重生":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☑ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ Cyberpunk", command=lambda: set_theme("賽博朋克"))
elif theme == "賽博朋克":
theme_menu.add_command(label="☐ Light Mode", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ Dark Mode", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ Crimson Wings", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ Azure Shadow", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ Midnight Indigo", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ Cute Dimension", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ Dimension Rebirth", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☑ Cyberpunk", command=lambda: set_theme("賽博朋克"))
setting_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Settings", menu=setting_menu)
if blacklist == "開啟":
setting_menu.add_command(label="☑ Blacklist", command=lambda: enable_blacklist("關閉"))
elif blacklist == "關閉":
setting_menu.add_command(label="☐ Blacklist", command=lambda: enable_blacklist("開啟"))
if show_hostname == "開啟":
setting_menu.add_command(label="☑ Show Hostname and IP", command=lambda: enable_hostname("關閉"))
elif show_hostname == "關閉":
setting_menu.add_command(label="☐ Show Hostname and IP", command=lambda: enable_hostname("開啟"))
if show_cert == "開啟":
setting_menu.add_command(label="☑ Show Certificate Dates", command=lambda: enable_cert("關閉"))
elif show_cert == "關閉":
setting_menu.add_command(label="☐ Show Certificate Dates", command=lambda: enable_cert("開啟"))
elif language == "日本語":
predict_button.config(text="予測")
clear_button.config(text="クリア")
root.config(menu=None)
menu_bar = Menu(root)
root.config(menu=menu_bar)
file_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="ファイル", menu=file_menu)
file_menu.add_command(label="開く", command=open_json_file)
file_menu.add_command(label="保存", command=save_to_json)
file_menu.add_separator()
file_menu.add_command(label="出口", command=root.quit)
language_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="言語", menu=language_menu)
language_menu.add_command(label="☐ 繁體中文", command=lambda: set_language("繁體中文", current_theme, current_blacklist, current_hostname, current_cert),)
language_menu.add_command(label="☐ English", command=lambda: set_language("English", current_theme, current_blacklist, current_hostname, current_cert))
language_menu.add_command(label="☑ 日本語", command=lambda: set_language("日本語", current_theme, current_blacklist, current_hostname, current_cert))
help_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="ヘルプ", menu=help_menu)
help_menu.add_command(label="ウェブサイトを開く", command=open_github)
help_menu.add_separator()
help_menu.add_command(label="バージョン情報", command=show_version_info)
theme_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="テーマ", menu=theme_menu)
if theme == "現代淺色":
theme_menu.add_command(label="☑ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "現代深色":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☑ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "緋紅之翼":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☑ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "青色陰影":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☑ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "暗度藏青":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☑ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "可愛次元":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☑ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "次元重生":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☑ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☐ サイバーパンク", command=lambda: set_theme("賽博朋克"))
elif theme == "賽博朋克":
theme_menu.add_command(label="☐ ライトモード", command=lambda: set_theme("現代淺色"))
theme_menu.add_command(label="☐ ダークモード", command=lambda: set_theme("現代深色"))
theme_menu.add_command(label="☐ 緋紅の翼", command=lambda: set_theme("緋紅之翼"))
theme_menu.add_command(label="☐ 蒼影", command=lambda: set_theme("青色陰影"))
theme_menu.add_command(label="☐ 真夜中の藍", command=lambda: set_theme("暗度藏青"))
theme_menu.add_command(label="☐ キュートディメンション", command=lambda: set_theme("可愛次元"))
theme_menu.add_command(label="☐ ディメンションリバース", command=lambda: set_theme("次元重生"))
theme_menu.add_command(label="☑ サイバーパンク", command=lambda: set_theme("賽博朋克"))
setting_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="設定", menu=setting_menu)
if blacklist == "開啟":
setting_menu.add_command(label="☑ ブラックリスト", command=lambda: enable_blacklist("關閉"))
elif blacklist == "關閉":
setting_menu.add_command(label="☐ ブラックリスト", command=lambda: enable_blacklist("開啟"))
if show_hostname == "開啟":
setting_menu.add_command(label="☑ ホスト名とIPを表示", command=lambda: enable_hostname("關閉"))
elif show_hostname == "關閉":
setting_menu.add_command(label="☐ ホスト名とIPを表示", command=lambda: enable_hostname("開啟"))
if show_cert == "開啟":
setting_menu.add_command(label="☑ 証明書の日付を表示", command=lambda: enable_cert("關閉"))
elif show_cert == "關閉":
setting_menu.add_command(label="☐ 証明書の日付を表示", command=lambda: enable_cert("開啟"))
# 開啟網站
def open_github():
webbrowser.open("https://github.com/AmanoShizukikun/Nagato-Sakura-SMS-Checker")
# 版本資訊
def load_model_version(config_path):
with open(config_path, 'r') as json_file:
config_data = json.load(json_file)
model_version = config_data.get("version", "Unknown")
return model_version
def show_version_info():
language = current_language
model_version = load_model_version(CONFIG_PATH)
if language == "繁體中文":
messagebox.showinfo("版本資訊", f"運行模式: {device}\nGUI 版本: {version}\n模型版本: {model_version}")
elif language == "English":
messagebox.showinfo("Version Information", f"Operating Mode: {device}\nGUI Version: {version}\nModel Version: {model_version}")
elif language == "日本語":
messagebox.showinfo("バージョン情報", f"動作モード: {device}\nGUI バージョン: {version}\nモデルバージョン: {model_version}")
# 主題
def set_theme(theme):
global current_theme
current_theme = theme
if theme == "現代深色":
root.config(bg='#1E1E1E')
image_label.config(bg='#1E1E1E')
entry.config(bg='#1F1F1F', fg='white', insertbackground='white')
button_frame.config(bg='#1E1E1E')
safety_text_box.config(bg='#1F1F1F', fg='white')
predict_button.config(bg='#1E1E1E', fg='white')
clear_button.config(bg='#1E1E1E', fg='white')
empty_label.config(bg='#1E1E1E')
menu_bar.config(bg='#1E1E1E')
elif theme == "現代淺色":
root.config(bg='white')
image_label.config(bg='white')
entry.config(bg='white', fg='black')
button_frame.config(bg='white')
safety_text_box.config(bg='white', fg='black')
predict_button.config(bg='white', fg='black')
clear_button.config(bg='white', fg='black')
empty_label.config(bg='white')
menu_bar.config(bg='white')
elif theme == "緋紅之翼":
root.config(bg='#330000')
image_label.config(bg='#330000')
entry.config(bg='#390000', fg='white', insertbackground='white')
button_frame.config(bg='#330000')
safety_text_box.config(bg='#390000', fg='white')
predict_button.config(bg='#330000', fg='white')
clear_button.config(bg='#330000', fg='white')
empty_label.config(bg='#330000')
menu_bar.config(bg='#330000')
elif theme == "青色陰影":
root.config(bg='#00212B')
image_label.config(bg='#00212B')
entry.config(bg='#002B36', fg='white', insertbackground='white')
button_frame.config(bg='#00212B')
safety_text_box.config(bg='#002B36', fg='white')
predict_button.config(bg='#00212B', fg='white')
clear_button.config(bg='#00212B', fg='white')
empty_label.config(bg='#00212B')
menu_bar.config(bg='#00212B')
elif theme == "暗度藏青":
root.config(bg='#001C40')
image_label.config(bg='#001C40')
entry.config(bg='#002451', fg='white', insertbackground='white')
button_frame.config(bg='#001C40')
safety_text_box.config(bg='#002451', fg='white')
predict_button.config(bg='#001C40', fg='white')
clear_button.config(bg='#001C40', fg='white')
empty_label.config(bg='#001C40')
menu_bar.config(bg='#001C40')
elif theme == "可愛次元":
root.config(bg='#FCC2FD')
image_label.config(bg='#FCC2FD')
entry.config(bg='#FCCFFE', fg='black', insertbackground='black')
button_frame.config(bg='#FCC2FD')
safety_text_box.config(bg='#FCCFFE', fg='black')
predict_button.config(bg='#FCC2FD', fg='black')
clear_button.config(bg='#FCC2FD', fg='black')
empty_label.config(bg='#FCC2FD')
menu_bar.config(bg='#FCC2FD')
elif theme == "次元重生":
root.config(bg='#B5EDEF')
image_label.config(bg='#B5EDEF')
entry.config(bg='#FDE5FA', fg='black', insertbackground='black')
button_frame.config(bg='#B5EDEF')
safety_text_box.config(bg='#FDE5FA', fg='black')
predict_button.config(bg='#B5EDEF', fg='black')
clear_button.config(bg='#B5EDEF', fg='black')
empty_label.config(bg='#B5EDEF')
menu_bar.config(bg='#B5EDEF')
elif theme == "賽博朋克":
root.config(bg='#F2EA65')
image_label.config(bg='#F2EA65')
entry.config(bg='#65D0FC', fg='black', insertbackground='black')
button_frame.config(bg='#F2EA65')
safety_text_box.config(bg='#65D0FC', fg='black')
predict_button.config(bg='#F2EA65', fg='black')
clear_button.config(bg='#F2EA65', fg='black')
empty_label.config(bg='#F2EA65')
menu_bar.config(bg='#F2EA65')
set_language(current_language, current_theme, current_blacklist, current_hostname, current_cert)
# 黑名單
def enable_blacklist(blacklist):
global current_blacklist
current_blacklist = blacklist
set_language(current_language, current_theme, current_blacklist, current_hostname, current_cert)
# 顯示憑證日期
def enable_hostname(show_hostname):
global current_hostname
current_hostname = show_hostname
set_language(current_language, current_theme, current_blacklist, current_hostname, current_cert)
# 顯示憑證日期
def enable_cert(show_cert):
global current_cert
current_cert = show_cert
set_language(current_language, current_theme, current_blacklist, current_hostname, current_cert)
# 貼上功能
def paste_text():
entry.event_generate("<<Paste>>")
# 建立 tkinter 視窗
version = "1.0.6"
root = tk.Tk()
root.title(f"Nagato-Sakura-SMS-Checker-GUI-Ver.{version}")
root.geometry("820x580")
icon_path = current_directory / "assets" / "icon" / f"{version}.ico"
root.iconbitmap(icon_path)
# 圖片
image_path = current_directory / "assets" / "4K" / f"{version}.jpg"
img = Image.open(image_path)
img_width, img_height = img.size
window_width = 700
new_img_width = window_width-100
new_img_height = int(img_height * (new_img_width / img_width))
img = img.resize((new_img_width, new_img_height), Image.LANCZOS)
photo = ImageTk.PhotoImage(img)
image_label = tk.Label(root, image=photo)
image_label.pack(fill="both", expand=True, padx=30)
# 輸入框
entry = tk.Entry(root, width=60)
entry.pack(fill="x", expand=True, padx=60)
# 右鍵選單
right_click_menu = tk.Menu(root, tearoff=0)
right_click_menu.add_command(label="貼上", command=paste_text)
def on_right_click(event):
right_click_menu.post(event.x_root, event.y_root)
entry.bind("<Button-3>", on_right_click)
# 預測和清除按鈕
button_frame = tk.Frame(root)
button_frame.pack()
predict_button = tk.Button(button_frame, text="預測", command=predict_and_display)
predict_button.pack(side="left", padx=5)
clear_button = tk.Button(button_frame, text="清除", command=clear_input)
clear_button.pack(side="left")
empty_label = tk.Label(root, text="")
empty_label.pack()
# 滾動文字框
safety_text_box = scrolledtext.ScrolledText(root, wrap=tk.WORD, font=("Arial", 11))
safety_text_box.pack(fill="both", expand=True, padx=20, pady=15)
# 選單列
menu_bar = Menu(root)
root.config(menu=menu_bar)
set_language("繁體中文","現代淺色","開啟","關閉","關閉")
# GUI 主迴圈
root.mainloop()