本文整理汇总了Python中angr.SimState.register_plugin方法的典型用法代码示例。如果您正苦于以下问题:Python SimState.register_plugin方法的具体用法?Python SimState.register_plugin怎么用?Python SimState.register_plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angr.SimState
的用法示例。
在下文中一共展示了SimState.register_plugin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copy
# 需要导入模块: from angr import SimState [as 别名]
# 或者: from angr.SimState import register_plugin [as 别名]
def test_copy():
s = SimState(arch="AMD64")
s.memory.store(0x100, b"ABCDEFGHIJKLMNOP")
s.memory.store(0x200, b"XXXXXXXXXXXXXXXX")
x = s.solver.BVS('size', s.arch.bits)
s.add_constraints(s.solver.ULT(x, 10))
s.memory.copy_contents(0x200, 0x100, x)
nose.tools.assert_equal(sorted(s.solver.eval_upto(x, 100)), list(range(10)))
result = s.memory.load(0x200, 5)
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes)), [ b"ABCDE", b"ABCDX", b"ABCXX", b"ABXXX", b"AXXXX", b"XXXXX" ])
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes, extra_constraints=[x==3])), [ b"ABCXX" ])
s = SimState(arch="AMD64")
s.register_plugin('posix', SimSystemPosix(stdin=SimFile(name='stdin', content=b'ABCDEFGHIJKLMNOP', has_end=True)))
s.memory.store(0x200, b"XXXXXXXXXXXXXXXX")
x = s.solver.BVS('size', s.arch.bits)
s.add_constraints(s.solver.ULT(x, 10))
s.posix.get_fd(0).read(0x200, x)
nose.tools.assert_equal(sorted(s.solver.eval_upto(x, 100)), list(range(10)))
result = s.memory.load(0x200, 5)
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes)), [ b"ABCDE", b"ABCDX", b"ABCXX", b"ABXXX", b"AXXXX", b"XXXXX" ])
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes, extra_constraints=[x==3])), [ b"ABCXX" ])
s = SimState(arch="AMD64")
s.register_plugin('posix', SimSystemPosix(stdin=SimFile(name='stdin', content=b'ABCDEFGHIJKLMNOP')))
s.memory.store(0x200, b"XXXXXXXXXXXXXXXX")
x = s.solver.BVS('size', s.arch.bits)
s.add_constraints(s.solver.ULT(x, 10))
read_proc = SIM_PROCEDURES['posix']['read']()
ret_x = read_proc.execute(s, arguments=(0, 0x200, x)).ret_expr
nose.tools.assert_equal(sorted(s.solver.eval_upto(x, 100)), list(range(10)))
result = s.memory.load(0x200, 5)
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes)), [ b"ABCDE", b"ABCDX", b"ABCXX", b"ABXXX", b"AXXXX", b"XXXXX" ])
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes, extra_constraints=[x==3])), [ b"ABCXX" ])
nose.tools.assert_equal(sorted(s.solver.eval_upto(ret_x, 100)), list(range(10)))
nose.tools.assert_equal(sorted(s.solver.eval_upto(result, 100, cast_to=bytes, extra_constraints=[ret_x==3])), [ b"ABCXX" ])
示例2: make_state_with_stdin
# 需要导入模块: from angr import SimState [as 别名]
# 或者: from angr.SimState import register_plugin [as 别名]
def make_state_with_stdin(content):
s = SimState(arch='AMD64', mode='symbolic')
stdin_storage = angr.storage.file.SimFile('stdin', content=content)
stdin = angr.storage.file.SimFileDescriptor(stdin_storage)
s.register_plugin('posix', angr.state_plugins.SimSystemPosix(stdin=stdin_storage, fd={0: stdin}))
return s