-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp_base.py
86 lines (75 loc) · 2.96 KB
/
app_base.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
#!/usr/bin/env python3
#
# Copyright 2016 (c) Avital Kelman
#
# Exfiltrate documents from http://anom.archivesnationales.culture.gouv.fr
# without their filthy Java applet.
# This is the app UI base component. It is meant to be subclassed.
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
#
import sys
sys.dont_write_bytecode = True
import threading
import tkinter as tk
import webbrowser
class TextRedirector(object):
def __init__(self, widget, err=False):
self.widget = widget
self.err = err
self.widget.tag_config('err', foreground='red')
self.lock = threading.Lock()
def flush(self):
pass
def write(self, txt):
with self.lock:
self.widget.see("end")
if self.err:
self.widget.insert("end", txt, 'err')
else:
self.widget.insert("end", txt)
class App(tk.Tk):
def hyperlink(self, event):
widget = self.winfo_containing(event.x_root, event.y_root)
if widget == event.widget:
webbrowser.open(event.widget.cget("text"))
self.unhighlight(event)
def highlight(self, event):
event.widget.config(fg="red")
def unhighlight(self, event):
event.widget.config(fg="blue")
def __init__(self):
tk.Tk.__init__(self)
self.title("ANOM Exfiltrator")
self.bottombar = tk.Frame(self, padx=5, pady=5)
self.bottombar.pack(side="bottom", fill="x")
self.quitbutton = tk.Button(self.bottombar,
text="Quit ANOM Exfiltrator",
command=self.quit, padx=10, pady=10)
self.quitbutton.pack(side="right")
self.statusbox = tk.Frame(self)
scrollbar = tk.Scrollbar(self.statusbox)
scrollbar['width'] = max(18, int(scrollbar['width']))
self.statustext = tk.Text(self.statusbox, wrap="word",
yscrollcommand=scrollbar.set)
scrollbar['command'] = self.statustext.yview
scrollbar.pack(side="right", fill="y")
self.statustext.pack(side="left", fill="both", expand=True)
self.statusbox.pack(side="bottom", fill="both", expand=True)
sys.stdout = TextRedirector(self.statustext) # stdout to the text box
print("Informational messages will appear here.")
print("----------------------------------------")