Angr安装与使用之使用篇(二)

19 篇文章 4 订阅
16 篇文章 1 订阅

针对angr提供的练习题,现在进行求解01_angr_avoid,它也是关于输入密码的问题,需要使用angr求解出正确密码。但是需要提供排除地址以减少路径求解时间。

参考博客点这里

具体代码如下所示

import angr
import sys

def main(argv):
  path_to_binary = "01_angr_avoid"
  project = angr.Project(path_to_binary)
  initial_state = project.factory.entry_state()
  simulation = project.factory.simgr(initial_state)

  # Explore the binary, but this time, instead of only looking for a state that
  # reaches the print_good_address, also find a state that does not reach 
  # will_not_succeed_address. The binary is pretty large, to save you some time,
  # everything you will need to look at is near the beginning of the address 
  # space.
  # (!)
  print_good_address = 0x080485e0
  will_not_succeed_address = 0x080485f2
  simulation.explore(find=print_good_address, avoid=will_not_succeed_address)

  if simulation.found:
    solution_state = simulation.found[0]
    print(solution_state.posix.dumps(sys.stdin.fileno()))
  else:
    raise Exception('Could not find the solution')

if __name__ == '__main__':
  main(sys.argv)

我们需要确定目标地址和排除地址,此处,目标地址是0x080485e0,排除地址是0x080485f2。
在这里插入图片描述
目标是Good Job,所以需要求解它的指令地址。
在这里插入图片描述
由于try again表示再次求解,为减少路径求解时间,需要将其排除。

下面验证实验结果
执行刚刚写好的程序,保存为scaffold01.py,并将其与01_angr_avoid放于同一文件夹中,具体如下图所示。
在这里插入图片描述
再执行01_angr_avoid,然后需要我们输入angr刚刚求解出的密码即HUJOZMYS,结果为Good Job。
在这里插入图片描述
至此,求解01_angr_avoid已全部完成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值