当前位置: 首页>>代码示例>>Python>>正文


Python claripy.Solver方法代码示例

本文整理汇总了Python中claripy.Solver方法的典型用法代码示例。如果您正苦于以下问题:Python claripy.Solver方法的具体用法?Python claripy.Solver怎么用?Python claripy.Solver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在claripy的用法示例。


在下文中一共展示了claripy.Solver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_manyfloatsum_symbolic

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def run_manyfloatsum_symbolic(arch):
    global type_cache
    if type_cache is None:
        type_cache = parse_defns(open(os.path.join(location, 'tests_src', 'manyfloatsum.c')).read())

    p = angr.Project(os.path.join(location, 'tests', arch, 'manyfloatsum'))
    function = 'sum_doubles'
    cc = p.factory.cc(func_ty=type_cache[function])
    args = [claripy.FPS('arg_%d' % i, claripy.FSORT_DOUBLE) for i in range(len(type_cache[function].args))]
    addr = p.loader.main_object.get_symbol(function).rebased_addr
    my_callable = p.factory.callable(addr, cc=cc)
    result = my_callable(*args)
    nose.tools.assert_true(result.symbolic)

    s = claripy.Solver(timeout=15*60*1000)
    for arg in args:
        s.add(arg > claripy.FPV(1.0, claripy.FSORT_DOUBLE))
    s.add(result == claripy.FPV(27.7, claripy.FSORT_DOUBLE))

    args_conc = s.batch_eval(args, 1)[0]
    nose.tools.assert_equal(s.eval(result, 1)[0], 27.7)
    # not almost equal!! totally equal!!! z3 is magic, if kinda slow!!!!!
    for arg_conc in args_conc:
        nose.tools.assert_greater(arg_conc, 1.0)
    nose.tools.assert_equal(sum(args_conc), 27.7) 
开发者ID:angr,项目名称:angr,代码行数:27,代码来源:test_callable.py

示例2: combine

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def combine(self, others):
        other_claripy_solvers = [i.solver for i in others]
        combined = Solver(
            claripy_solver=self.solver.combine(other_claripy_solvers),
            hashes=self.hashes,
        )

        for other in others:
            for k, v in self.hashes.items():
                # Make sure the hash symbols are distinct
                if any(v is v2 for v2 in other.hashes.values()):
                    # Call regenerate_hash_symbols() on one of them first?
                    raise ValueError("Cannot combine with equivalent hashes.")

                # TODO: If some hash input are equal, we should merge the hash
                # symols here, it would be more efficient.
            combined.hashes.update(other.hashes)

        return combined 
开发者ID:palkeo,项目名称:pakala,代码行数:21,代码来源:claripy_sha3.py

示例3: __init__

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def __init__(self, plock=None, q=None, kernel_path=None):
        """
        :param kernel_path: the vmlinux path to the kernel
        """
        if plock is not None:
            self.lock = plock  # this is the lock because all instances of osok share a qemu instance
        else:
            self.lock = None
        self.queue = q

        self.kernel_path = kernel_path
        if os.path.isfile('angr_project.cache'):
            with open('angr_project.cache', 'rb') as f:
                print('[+] load kernel vmlinux binary from pickle dump')
                self.b = pickle.load(f)
        else:
            self.b = angr.Project(kernel_path)
            with open('angr_project.cache', 'wb') as f:
                pickle.dump(self.b, f)
        self.r = None
        self.statebroker = statebroker.StateBroker()
        self.claripy = claripy
        self.sol = claripy.Solver()
        self.md = Cs(CS_ARCH_X86, CS_MODE_64)
        self.md.detail = True
        self.debug_bloom_verbose = False
        self.vm = None
        self.reproduce_mode = False  # reproduce exploit and generate payload
        self.custom_rop_gadget_number = 10  # length of the rop payload we want to use 
开发者ID:ww9210,项目名称:kepler-cfhp,代码行数:31,代码来源:__init__.py

示例4: reachable

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def reachable(self):
        if self._satisfiable is not None:
            pass
        elif self.state is not None:
            self._satisfiable = self.state.solver.satisfiable()
        else:
            solver = claripy.Solver()
            solver.add(self._all_constraints)
            self._satisfiable = solver.satisfiable()

        return self._satisfiable

    #
    # Log handling
    # 
开发者ID:angr,项目名称:angr,代码行数:17,代码来源:history.py

示例5: get_claripy_solver

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def get_claripy_solver():
    # TODO: What about SolverComposite? Tried, and seems slower.
    return claripy.Solver() 
开发者ID:palkeo,项目名称:pakala,代码行数:5,代码来源:claripy_sha3.py

示例6: branch

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def branch(self):
        return Solver(claripy_solver=self.solver.branch(), hashes=self.hashes.copy()) 
开发者ID:palkeo,项目名称:pakala,代码行数:4,代码来源:claripy_sha3.py

示例7: test_ite

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_ite():
    yield raw_ite, claripy.Solver
    yield raw_ite, claripy.SolverHybrid
    yield raw_ite, claripy.SolverComposite 
开发者ID:angr,项目名称:claripy,代码行数:6,代码来源:test_expression.py

示例8: test_extract_concat_simplify

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_extract_concat_simplify():
    a = claripy.BVS("a", 32)
    assert a[31:0] is a
    assert a[31:8].concat(a[7:0]) is a  # pylint:disable=no-member
    assert a[31:16].concat(a[15:8], a[7:0]) is a  # pylint:disable=no-member
    assert a[31:24].concat(a[23:16], a[15:8], a[7:0]) is a  # pylint:disable=no-member

    a = claripy.BVS("a", 32)
    b = a + 100
    b_concat = b[31:8].concat(b[7:0])
    a100 = a + 100
    assert claripy.is_false(b_concat == a100) is False
    assert list(claripy.Solver().eval(b_concat == a100, 2)) == [ True ]
    assert b_concat is a100
    assert claripy.is_true(b_concat == a100) 
开发者ID:angr,项目名称:claripy,代码行数:17,代码来源:test_expression.py

示例9: test_signed_symbolic

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_signed_symbolic():
    solver = claripy.Solver()
    a = claripy.BVS("a", 32)
    b = claripy.BVS("b", 32)
    c = claripy.BVS("c", 32)
    d = claripy.BVS("d", 32)
    solver.add(a == 5)
    solver.add(b == -5)
    solver.add(c == 3)
    solver.add(d == -3)

    # test unsigned
    assert list(solver.eval(a / c, 2)) == [1]
    assert list(solver.eval(a / d, 2)) == [0]
    assert list(solver.eval(b / c, 2)) == [0x55555553]
    assert list(solver.eval(b / d, 2)) == [0]
    assert list(solver.eval(a % c, 2)) == [2]
    assert list(solver.eval(a % d, 2)) == [5]
    assert list(solver.eval(b % c, 2)) == [2]
    assert list(solver.eval(b % d, 2)) == [2**32-5]

    # test unsigned
    assert list(solver.eval(a.SDiv(c), 2)) == [1]
    assert list(solver.eval(a.SDiv(d), 2)) == [2**32-1]
    assert list(solver.eval(b.SDiv(c), 2)) == [2**32-1]
    assert list(solver.eval(b.SDiv(d), 2)) == [1]
    assert list(solver.eval(a.SMod(c), 2)) == [2]
    assert list(solver.eval(a.SMod(d), 2)) == [2]
    assert list(solver.eval(b.SMod(c), 2)) == [2**32-2]
    assert list(solver.eval(b.SMod(d), 2)) == [2**32-2] 
开发者ID:angr,项目名称:claripy,代码行数:32,代码来源:test_expression.py

示例10: test_arith_shift

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_arith_shift():
    bc = claripy.backends.concrete
    a = claripy.BVV(-4, 32)
    assert bc.convert(a >> 1) == -2

    solver = claripy.Solver()
    a = claripy.BVS("a", 32)
    solver.add(a == -4)
    assert list(solver.eval(a >> 1, 2)) == [2**32-2] 
开发者ID:angr,项目名称:claripy,代码行数:11,代码来源:test_expression.py

示例11: raw_minmax

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def raw_minmax(reuse_z3_solver):
    claripy._backend_z3.reuse_z3_solver = reuse_z3_solver

    s = claripy.Solver()
    x = claripy.BVS("x", 32)

    nose.tools.assert_equal(s.max(x), 2**32-1)
    nose.tools.assert_equal(s.min(x), 0)
    nose.tools.assert_true(s.satisfiable()) 
开发者ID:angr,项目名称:claripy,代码行数:11,代码来源:test_solver.py

示例12: test_model

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_model():
    x = claripy.BVS("x", 32)
    y = claripy.BVS("y", 32)
    s = claripy.Solver()

    s.add(x < 10)
    assert sorted(s.eval(x, 20)) == list(range(10))
    s.add(y == 1337)
    assert sorted(s.eval(x, 20)) == list(range(10)) 
开发者ID:angr,项目名称:claripy,代码行数:11,代码来源:test_solver.py

示例13: test_unsatness

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_unsatness():
    x = claripy.BVS("x", 32)

    s = claripy.Solver()
    s.add(x == 10)
    assert s.satisfiable()
    s.add(claripy.false)
    assert not s.satisfiable() 
开发者ID:angr,项目名称:claripy,代码行数:10,代码来源:test_solver.py

示例14: test_simplification_annotations

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_simplification_annotations():
    s = claripy.Solver()
    x = claripy.BVS("x", 32)

    s.add(x > 10)
    s.add(x > 11)
    s.add((x > 12).annotate(claripy.SimplificationAvoidanceAnnotation()))

    assert len(s.constraints) == 3
    s.simplify()
    assert len(s.constraints) == 2 
开发者ID:angr,项目名称:claripy,代码行数:13,代码来源:test_solver.py

示例15: test_unsat_core

# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import Solver [as 别名]
def test_unsat_core():
    for s in (claripy.Solver, claripy.SolverComposite, claripy.SolverCacheless, claripy.SolverHybrid):
        yield raw_unsat_core, s, True
        yield raw_unsat_core, s, False 
开发者ID:angr,项目名称:claripy,代码行数:6,代码来源:test_solver.py


注:本文中的claripy.Solver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。