angr进阶(6)绕过反调试

2023-07-29,,

angr绕过调试,一个是通过之前的方式,使用从特定位置开始测试的方法,还有一种通过hook进行反调试的方法。

其原理就在于angr能够符号化表示函数tumctf2016_zwiebe

p.hook_symbol('ptrace', angr.SIM_PROCEDURES['stubs']['ReturnUnconstrained'](return_value=0))

另外,对于代码自修改程序,需要使用如下的方式

p = angr.Project("zwiebe", support_selfmodifying_code=True) 

另外,也可以hook到一些关键函数上,达到控制效果。

比如控制scanf就可以达到和控制返回值类似的效果。

     flag_chars = [claripy.BVS('flag_%d' % i, 32) for i in range(13)]
class my_scanf(angr.SimProcedure):
def run(self, fmt, ptr): # pylint: disable=arguments-differ,unused-argument
self.state.mem[ptr].dword = flag_chars[self.state.globals['scanf_count']]
self.state.globals['scanf_count'] += 1 proj.hook_symbol('__isoc99_scanf', my_scanf(), replace=True) sm = proj.factory.simulation_manager()
sm.one_active.options.add(angr.options.LAZY_SOLVES)
sm.one_active.globals['scanf_count'] = 0 # search for just before the printf("%c%c...")
# If we get to 0x402941, "Wrong" is going to be printed out, so definitely avoid that.
sm.explore(find=0x4028E9, avoid=0x402941) # evaluate each of the flag chars against the constraints on the found state to construct the flag
flag = ''.join(chr(sm.one_found.solver.eval(c)) for c in flag_chars)
return flag

angr进阶(6)绕过反调试的相关教程结束。

《angr进阶(6)绕过反调试.doc》

下载本文的Word格式文档,以方便收藏与打印。