How to use the triton.getSymbolicExpressionFromId function in triton

To help you get started, we’ve selected a few triton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kamou / pimp / pimp.py View on Github external
def string_constraint(self):
        cstr = selg.triton.getAstContest().equal(self.triton.getAstContext().bvtrue(), self.triton.getAstContext().bvtrue())
        addrs = [self.inputs for inpt in self.inputs.values()]
        for inpt in addrs[0:-1]:
            symExp = triton.getSymbolicExpressionFromId(inpt.getId()).getAst()
            cstr = triton.getAstContext().land(
                [
                    cstr,
                    self.triton.getAstContext().land(
                        [
                            ast.bvuge(symExp, bv(0x20,  8)),
                            ast.bvuge(symExp, bv(0x7E,  8))
                        ]
                    )
                ]
            )
        # last char should be 0
        symExp = triton.getSymbolicExpressionFromId(addrs[-1]).getAst()
        cstr = self.triton.getAstContext().land([cstr, self.triton.getAstContext().lnot(self.triton.getAstContext().equal(symExp, self.triton.getAstContext().bv(0, 8)))])
        return cstr
github radareorg / radare2-extras / pimp / pimp.py View on Github external
taken = branch["isTaken"]
                    src = branch["srcAddr"]
                    dst = branch["dstAddr"]
                    bcstr = branch["constraint"]

                    isPreviousBranchConstraint = (src != _pc) and taken
                    isBranchToTake =  src == _pc and dst == target

                    if isPreviousBranchConstraint or isBranchToTake:
                        cstr = triton.ast.land(cstr, bcstr)

        if self.input_type == "string":
            addrs = [self.inputs[inpt] for inpt in self.inputs]
            for inpt in addrs[0:-1]:
                symExp = triton.getSymbolicExpressionFromId(inpt.getId()).getAst()
                cstr = triton.ast.land(cstr, triton.ast.lnot(triton.ast.equal(symExp, triton.ast.bv(0, 8))))

        cstr = triton.ast.assert_(cstr)
        return cstr
github kamou / pimp / pimp.py View on Github external
if isPreviousBranchConstraint or isBranchToTake:
                        cstr = self.triton.getAstContext().land([cstr, bcstr])

        if self.input_type == "nonnull":
            addrs = [self.inputs[inpt] for inpt in self.inputs]
            for inpt in addrs[0:-1]:
                symExp = triton.getSymbolicExpressionFromId(inpt.getId()).getAst()
                cstr = self.triton.getAstContext().land([cstr, self.triton.getAstContext().lnot(self.triton.getAstContext().equal(symExp, self.triton.getAstContext().bv(0, 8)))])
            # last char should be 0
            symExp = triton.getSymbolicExpressionFromId(addrs[-1]).getAst()
            cstr = self.triton.getAstContext().land([cstr, self.triton.getAstContext().lnot(self.triton.getAstContext().equal(symExp, self.triton.getAstContext().bv(0, 8)))])

        elif self.input_type == "string":
            addrs = [self.inputs[inpt] for inpt in self.inputs]
            for inpt in addrs[0:-1]:
                symExp = triton.getSymbolicExpressionFromId(inpt.getId()).getAst()
                cstr = self.triton.getAstContext().land(
                    [
                        cstr,
                        self.triton.getAstContext().land(
                            ast.bvuge(symExp, bv(0x20,  8)),
                            ast.bvuge(symExp, bv(0x7E,  8))
                        )
                    ]
                )
            # last char should be 0
            symExp = triton.getSymbolicExpressionFromId(addrs[-1]).getAst()
            cstr = self.triton.getAstContext().land([cstr, self.triton.getAstContext().lnot(self.triton.getAstContext().equal(symExp, self.triton.getAstContext().bv(0, 8)))])

        # cstr = self.triton.getAstContext().assert_(cstr)
        return cstr
github kamou / pimp / pimp.py View on Github external
addrs = [self.inputs for inpt in self.inputs.values()]
        for inpt in addrs[0:-1]:
            symExp = triton.getSymbolicExpressionFromId(inpt.getId()).getAst()
            cstr = triton.getAstContext().land(
                [
                    cstr,
                    self.triton.getAstContext().land(
                        [
                            ast.bvuge(symExp, bv(0x20,  8)),
                            ast.bvuge(symExp, bv(0x7E,  8))
                        ]
                    )
                ]
            )
        # last char should be 0
        symExp = triton.getSymbolicExpressionFromId(addrs[-1]).getAst()
        cstr = self.triton.getAstContext().land([cstr, self.triton.getAstContext().lnot(self.triton.getAstContext().equal(symExp, self.triton.getAstContext().bv(0, 8)))])
        return cstr
github kamou / pimp / pimp.py View on Github external
elif self.input_type == "string":
            addrs = [self.inputs[inpt] for inpt in self.inputs]
            for inpt in addrs[0:-1]:
                symExp = triton.getSymbolicExpressionFromId(inpt.getId()).getAst()
                cstr = self.triton.getAstContext().land(
                    [
                        cstr,
                        self.triton.getAstContext().land(
                            ast.bvuge(symExp, bv(0x20,  8)),
                            ast.bvuge(symExp, bv(0x7E,  8))
                        )
                    ]
                )
            # last char should be 0
            symExp = triton.getSymbolicExpressionFromId(addrs[-1]).getAst()
            cstr = self.triton.getAstContext().land([cstr, self.triton.getAstContext().lnot(self.triton.getAstContext().equal(symExp, self.triton.getAstContext().bv(0, 8)))])

        # cstr = self.triton.getAstContext().assert_(cstr)
        return cstr