Beispiel #1
0
    def create_key(self):
        self.count += 1
        print self.count
        duration = datetime.datetime.now() - startTime
        # if duration.seconds == 5:
        #     self.random_key = os.urandom(16)
        #     crypto = AES.AESCipher(self.random_key)
        #
        #     text = 'key:' + self.random_key
        #     self.s.send(text)
        #     print self.random_key
        while True:
            time.sleep(10)
            random_key = os.urandom(16)
            text = "key:" + random_key
            self.send(text)
            self.crypto = AES.AESCipher(random_key)
            print text

        return
Beispiel #2
0
 def recv(self):
     while True:
         try:
             data = self.s.recv(1024)
             data = self.crypto.decrypt(data)
             textRecv = StringIO.StringIO(data)
             prin = textRecv.read(4)
             print prin
             if prin == 'key:':
                 newKey = textRecv.read()
                 self.crypto = AES.AESCipher(newKey)
                 print newKey
             elif data:
                 data = 'Other : ' + data + '\n'
                 start = self.history.index('end') + "-1l"
                 self.history.insert("end", data)
                 end = self.history.index('end') + "-1l"
                 self.history.tag_add("SENDBYOTHER", start, end)
                 self.history.tag_config("SENDBYOTHER", foreground='green')
         except Exception as e:
             print(e, 'recv')
Beispiel #3
0
 def __encrypt(self):
     password, ok = QtGui.QInputDialog.getText(self.MainWindow, "Encrypt",
                                               "Password:"******"utf-8"))
             return True
         except UnicodeError as error:
             logger.error(error)
             QtGui.QMessageBox.critical(
                 self.MainWindow, "Message", "I can encrypt only ascii"
                 " characters")
         except Exception as error:
             logger.error(error)
             QtGui.QMessageBox.critical(self.MainWindow, "Message",
                                        str(error))
     return False
Beispiel #4
0
 def get_config(self):
     # load configuration
     print("Enter configuration file:")
     enc_config_file = input()
     self.filename, _ = os.path.splitext(enc_config_file)
     try:
         with open(enc_config_file, "r") as f:
             encryptedconfig = f.read()
             try:
                 print("Enter configuration password:"******"base64"))
                 self.config = config
             except:
                 print(
                     "Reading configuration failed. Make sure the file is properly encrypted and you are using the correct password."
                 )
     except:
         print("Could not find configuration file")
Beispiel #5
0
    def __decrypt(self):
        password, ok = QtGui.QInputDialog.getText(self.MainWindow, "Decrypt",
                                                  "Password:"******"utf-8"))
                return True
            except UnicodeError as error:
                logger.error(error)
                QtGui.QMessageBox.critical(self.MainWindow, "Message",
                                           "Wrong password!")
                self.decrypt()

            except Exception as error:
                logger.error(error)
                QtGui.QMessageBox.critical(self.MainWindow, "Message",
                                           str(error))
        return False
Beispiel #6
0
 def __init__(self):
     self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     print("[+] Socket Is Now Created")
     self.crypto = AES.AESCipher('mysecretpassword')
Beispiel #7
0
 def __init__(self):
     self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.count = 0
     self.crypto = AES.AESCipher('mysecretpassword')
print("Sell cap:")
config["sell-cap"] = input() # 200
print("Buy cap:")
config["buy-cap"] = input() # 200
print("Polling time in seconds:")
config["polling-time"] = input() # 120
print("E-mail address for notifications:")
config["mail-notification"] = input()
#print("Use PGP (Y/N)")
#config["PGP"] = True if input() == "Y" else False
config["timestamp"] = str(datetime.now())
create_db(filename)

# bitvavo kay and secret:
print("Enter bitvavo API key")
config["bitvavokey"] = getpass.getpass()
print("Enter bitvavo API secret")
config["bitvavosecret"] = getpass.getpass()

# serialize object and convert is to base 64 string
pickledconfig_b64 = codecs.encode(pickle.dumps(config), "base64").decode()

# encrypt bytes
print("Configuration password:"******".enc", "w") as f:
	f.write(encryptedconfig.decode())