def encode(self): data = self.xor_string() encoded_payload, key = data if self.exec_type in self.acceptable_exec_types: payload = self.payload_starts[self.exec_type] else: payload = "" if payload == "": raise UnacceptableExecType("{} is unable to be encrypted into xor".format(self.exec_type)) payload = payload.format(encoded_payload, key) is_inserted = insert_payload(payload, self.payload_type, self.exec_type, self.cursor) return payload, is_inserted
def encode(self): encoded_payload = base64.b64encode(self.payload) acceptable_exec_types = ("powershell", "php", "python", "perl", "ruby", "bash") if self.exec_type.lower() in acceptable_exec_types: payload = self.payload_starts[self.exec_type] else: payload = "" if payload == "": raise UnacceptableExecType("{} is not able to be encoded into Base64".format(self.exec_type)) retval = payload.format(encoded_payload) is_inserted = insert_payload(retval, self.payload_type, self.exec_type, self.cursor) return retval, is_inserted
def encode(self): hexlify = lambda x: "".join([hex(ord(c))[2:].zfill(2) for c in x]) acceptable_exec_types = ("powershell", "php", "python", "perl", "ruby", "bash") encoded_payload = hexlify(self.payload) if self.exec_type in acceptable_exec_types: payload = self.payload_starts[self.exec_type] else: payload = "" if payload == "": raise UnacceptableExecType("{} cannot be encoded into hex".format( self.exec_type)) payload = payload.format(encoded_payload) is_inserted = insert_payload(payload, self.payload_type, self.exec_type, self.cursor) return payload, is_inserted
def encode(self): if self.exec_type in self.acceptable_exec_types: usable_payload = [] for c in self.payload: if c == '"': c = r'\"' usable_payload.append(c) self.payload = "".join(usable_payload) payload = self.payload_starts[self.exec_type] else: payload = "" if payload == "": raise UnacceptableExecType( "{} cannot be encoded into atbash".format(self.exec_type)) encoded_payload = self.atbash() retval = payload.format(encoded_payload) is_inserted = insert_payload(retval, self.payload_type, self.exec_type, self.cursor) return retval, is_inserted
def encode(self): tmp = [] for char in list(self.payload): if char == '"': char = r'\"' tmp.append(char) usable_payload = "".join(tmp) encoded_payload = usable_payload.encode("rot13") if self.exec_type.lower() in self.acceptable_exec_types: payload = self.payload_starts[self.exec_type] else: payload = "" if payload == "": raise UnacceptableExecType( "# {} is not able to be encoded into Rot13".format( self.exec_type)) retval = payload.format(encoded_payload) is_inserted = insert_payload(retval, self.payload_type, self.exec_type, self.cursor) return retval, is_inserted
def encode(self): if self.exec_type.lower() in self.acceptable_exec_types: if self.exec_type == "python": print( "# be sure that the target has PyCrypto on their system!") payload = self.payload_starts[self.exec_type] iv = Random.new().read(AES.block_size) iv_int = int(binascii.hexlify(iv), 16) ctr = Counter.new(AES.block_size * 8, initial_value=iv_int) key = Random.new().read(self.key_bytes) aes = AES.new(key, AES.MODE_CTR, counter=ctr) encoded_payload = base64.b64encode(aes.encrypt(self.payload)) else: payload = "" if payload == "": raise UnacceptableExecType( "{} cannot be encoded into AES-256".format(self.exec_type)) retval = payload.format(encoded_payload, base64.b64encode(key), base64.b64encode(iv)) is_inserted = insert_payload(retval, self.payload_type, self.exec_type, self.cursor) return retval, is_inserted