def generate_medium_reassembler_binary(self, test_bin=True): try: nr = NetworkRules() backend = ReassemblerBackend(self.infile) patches = [] patches.extend(IndirectCFI(self.infile, backend).get_patches()) patches.extend( TransmitProtection(self.infile, backend).get_patches()) patches.extend(ShiftStack(self.infile, backend).get_patches()) patches.extend(Adversarial(self.infile, backend).get_patches()) patches.extend(Backdoor(self.infile, backend).get_patches()) # patches.extend(NxStack(self.infile,backend).get_patches()) patches.extend( MallocExtPatcher(self.infile, backend).get_patches()) patches.extend( StackRetEncryption(self.infile, backend).get_patches()) patches.extend( UninitializedPatcher(self.infile, backend).get_patches()) patches.extend( NoFlagPrintfPatcher(self.infile, backend).get_patches()) backend.apply_patches(patches) final_content = backend.get_final_content() if test_bin: test_bin_with_qemu(self.infile, final_content) res = (final_content, "") except PatcherexError, e: traceback.print_exc(e) res = (None, None)
def generate_medium_reassembler_optimized_binary(self, test_bin=True): try: intermediate = tempfile.mktemp(prefix='%s_' % os.path.basename(self.infile)) optimize_it(self.infile, intermediate) nr = NetworkRules() backend = ReassemblerBackend(intermediate) patches = [] patches.extend(IndirectCFI(intermediate, backend).get_patches()) patches.extend( TransmitProtection(intermediate, backend).get_patches()) patches.extend(ShiftStack(intermediate, backend).get_patches()) patches.extend(Adversarial(intermediate, backend).get_patches()) patches.extend(Backdoor(intermediate, backend).get_patches()) # patches.extend(NxStack(intermediate,backend).get_patches()) patches.extend( MallocExtPatcher(intermediate, backend).get_patches()) patches.extend( StackRetEncryption(intermediate, backend).get_patches()) patches.extend( UninitializedPatcher(intermediate, backend).get_patches()) patches.extend( NoFlagPrintfPatcher(intermediate, backend).get_patches()) backend.apply_patches(patches) final_content = backend.get_final_content() if test_bin: test_bin_with_qemu(self.infile, final_content) res = (final_content, "") except PatcherexError, e: traceback.print_exc(e) res = (None, None)
def generate_indirectcfi_binary(self, test_bin=None): # new backend = ReassemblerBackend(self.infile) patches = [] patches.extend(IndirectCFI(self.infile, backend).get_patches()) backend.apply_patches(patches) final_content = backend.get_final_content() return (final_content, "")
def generate_stackretencryption_binary(self, test_bin=None): backend = ReassemblerBackend(self.infile) patches = [] patches.extend(StackRetEncryption(self.infile, backend).get_patches()) backend.apply_patches(patches) final_content = backend.get_final_content() return (final_content, "")
def generate_shiftstack_binary(self, test_bin=None): # new backend = ReassemblerBackend(self.infile) patches = [] patches.extend(ShiftStack(self.infile, backend).get_patches()) backend.apply_patches(patches) final_content = backend.get_final_content() return (final_content, "")