Exemple #1
0
    def generate_medium_detour_binary(self, test_bin=True):
        try:
            nr = NetworkRules()
            backend = DetourBackend(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)
Exemple #2
0
    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)