Example #1
0
    def receive(self, num_int_digits=3):
        """
        receives a message from server
        """
        strLength = self.client.recv(num_int_digits)
        server_answer = self.client.recv(int(strLength))

        if server_answer[-2:].find('=') != -1:
            # data that is send through socket is crypted by server.
            # Decryption is needed
            printc('<--A<--#')
            Cipher = AESCipher()
            server_answer = Cipher.decrypt(server_answer)

        return server_answer
Example #2
0
    def send(self, message, crypt=False):
        """
        send length at first and then send message
        """

        try:
            if crypt:
                Cipher = AESCipher()
                message = Cipher.encrypt(message)
                self.client.send(str(len(message)))
            else:
                self.client.send(str(len(message)))

            self.client.send(message)
            answer = True
        except:
            answer = False

        return answer
Example #3
0
def getConfigData(configfile, boolCrypt=True):
    import xml.etree.ElementTree as ET
    from vardef import serverdata
    from Crypt.mrcrypto import AESCipher

    tree = ET.parse(configfile)
    root = tree.getroot()

    for server in root.findall('server'):
        serverdata.name = server.get('name')
        serverdata.url = server.find('url').text
        if boolCrypt:
            serverdata.user = server.find('user').text
            serverdata.passw = server.find('pass').text

    if boolCrypt:
        #decrypt information
        Cipher = AESCipher()
        try:
            serverdata.user = Cipher.decrypt(serverdata.user)
            serverdata.passw = Cipher.decrypt(serverdata.passw)
            serverDataDC = serverdata #save decrypted information in a global var to bypass decryption routine (time saving)
        except:
            raise
            #wx.MessageDialog(None, 'Failed to receive settings information. Proof settings', 'Crypt Error', wx.OK | wx.ICON_INFORMATION).ShowModal()

    for storage in root.findall('storage'):
        storage.name = storage.get('name')
        storage.extracted = storage.find('extracted').text
        storage.zipfiles = storage.find('zipfiles').text

    if storage.extracted == None:
        storage.extracted = ''
        storage.zipfiles = ''

    return serverdata, storage