当前位置: 首页 > news >正文

官方网站建设 在线磐石网络百度app下载官方

官方网站建设 在线磐石网络,百度app下载官方,国内便宜的vps,上海专业建设网站制作fuzz测试之libfuzzer使用小结背景基本原理使用方法主调DEMO参考资料背景 项目中,为测试算法的鲁棒性,经常会用到fuzz测试进行压力测试。fuzz测试是一种模糊测试方法,本质是通过灌入各种变异的随机数据,去遍历不同函数分支&#xf…

fuzz测试之libfuzzer使用小结

    • 背景
    • 基本原理
    • 使用方法
    • 主调DEMO
    • 参考资料

背景


项目中,为测试算法的鲁棒性,经常会用到fuzz测试进行压力测试。fuzz测试是一种模糊测试方法,本质是通过灌入各种变异的随机数据,去遍历不同函数分支,以暴露程序中可能出现的问题。

*

接下来,本文以安卓平台LLVM自带的libFuzzer工具使用为例,简单介绍其使用方法。

基本原理


在学习使用之前,先了解其基本运行原理。LLVM中首先调用一次初始化接口LLVMFuzzerInitialize设定参数,然后通过反复调用接口LLVMFuzzerTestOneInput,不断灌入不同长度的随机数据,直到程序达到最大运行限制,或中途找到bug才中断退出。

使用方法


所需环境

  • 电脑硬件
    • NDK编译软件,使用NDK-R20及以上的版本,其clang编译器自带地址消毒和fuzz测试模块
    • adb软件,用于电脑与手机联调
  • 安卓手机(可使用开发者人员选项)

所需文件

  • CPP主调:
    • xx_fuzz.cc
  • 编译脚本:
    • andriod.mk
    • application.mk
  • 待测试算法源码
    • xx.c

基本流程

  • 电脑用NDK编译源文件,生成可执行文件
    • andriod.mk中添加
      • 编译选项:LOCAL_CFLAGS += -fsanitize=fuzzer,address -fomit-frame-pointer
      • 链接选项:LOCAL_LDFLAGS += -fsanitize=fuzzer,address
      • address选项是打开asan地址消毒功能,可增强找bug能力
    • application.mk中添加
      • 标准库:APP_STL := c++_shared
      • 因为调度代码是用CPP写的,需用到STL库
    • 打开powershell,在mk文件所在目录下,通过ndk-build指令,编译可执行文件
  • 通过ADB软件push推到手机文件夹内
    • 拷贝上一步骤生成的可执行文件和动态库文件(如:libclang_rt.asan-aarch64-android.solibc++_shared.so
    • 将之推到手机内,如/data/local/tmp/xx_fuzz/
      • 指令举例:adb push xx.so /data/local/tmp/xx_fuzz/
  • 通过ADB输入相关指令在手机上启动运行程序
    • 电脑连接安卓手机,手机进入开发者模式
    • 电脑命令窗,输入adb shell,进入手机环境
    • 切到可执行文件对应目录,输入以下指令,运行程序
      • LD_LIBRARY_PATH=./ ./demo_exe -max_len=65535 -len_control=0 -artifact_prefix=./corpus/ -detect_leaks=0 ./corpus
  • 解析报错日志
    • 根据手机环境反馈的错误信息,如偏移地址0x226534
    • 将ndk自带的llvm-symbolizer.exe所在目录添加到电脑环境变量的path中
    • 命令窗输入以下指令,解析报错相关代码上下文,分析算法,修复bug
      • 指令:llvm-symbolizer -e=demo_exe 0x226534 --print-source-context-lines=3
      • 模式:llvm-symbolizer -e=库名或EXE名 报错显示的偏移地址
  • 重点步骤
    • 打开fuzz测试的编译选项,并编译成功
    • LLVMFuzzerInitialize/LLVMFuzzerTestOneInput主调代码编写
  • 注意事项
    • 主调demo中不用写main函数,main由libfuzzer框架提供
    • c和cpp代码联合编译时,需用宏区分函数命名

具体MK文件编译脚本说明,见《NDK编译系列:构建C/CPP工程》。

主调DEMO


上面流程中用到的主调xx_fuzz.cc里的两个接口函数,框架模板如下:

#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>#ifdef __cplusplus
extern "C" {
#endifint LLVMFuzzerInitialize(int argc, char **argv)
{// write your codereturn 0;
}int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
{// write your codereturn 0;
}#ifdef __cplusplus
}
#endif

进一步的,具体使用可以参考:libfuzzer从入门到放弃。

参考资料


  1. llvm-libfuzzer官方介绍
  2. 入门libFuzzer——编译链接
  3. libFuzzer使用总结教程
  4. libFuzzer学习
  5. Android NDK Address Sanitizer地址消毒ASAN
  6. aac的fuzzer测试工程

文章转载自:
http://dinncoitabira.wbqt.cn
http://dinncowifelike.wbqt.cn
http://dinncoeurobond.wbqt.cn
http://dinncobentonite.wbqt.cn
http://dinncosubtle.wbqt.cn
http://dinncoremand.wbqt.cn
http://dinncointrude.wbqt.cn
http://dinncoboston.wbqt.cn
http://dinncoverecund.wbqt.cn
http://dinncodiplomapiece.wbqt.cn
http://dinncoportrait.wbqt.cn
http://dinncoepode.wbqt.cn
http://dinncokoord.wbqt.cn
http://dinncoauthentic.wbqt.cn
http://dinncoadoptive.wbqt.cn
http://dinncoforesleeve.wbqt.cn
http://dinncocoldslaw.wbqt.cn
http://dinncolivelihood.wbqt.cn
http://dinncoscythe.wbqt.cn
http://dinncoimmobility.wbqt.cn
http://dinncodonga.wbqt.cn
http://dinnconosily.wbqt.cn
http://dinncocream.wbqt.cn
http://dinncodalmatic.wbqt.cn
http://dinncoputridly.wbqt.cn
http://dinncointegration.wbqt.cn
http://dinncotrifle.wbqt.cn
http://dinncoagrarian.wbqt.cn
http://dinncocucullus.wbqt.cn
http://dinnconenadkevite.wbqt.cn
http://dinncomassoretic.wbqt.cn
http://dinncoglabrate.wbqt.cn
http://dinncomentum.wbqt.cn
http://dinncoamericanologist.wbqt.cn
http://dinncodecrepitude.wbqt.cn
http://dinncomisplace.wbqt.cn
http://dinncobaseboard.wbqt.cn
http://dinncoerr.wbqt.cn
http://dinncoforecheck.wbqt.cn
http://dinncostatued.wbqt.cn
http://dinncoundoable.wbqt.cn
http://dinncomeiofauna.wbqt.cn
http://dinncobengal.wbqt.cn
http://dinncostimulant.wbqt.cn
http://dinncoplainsong.wbqt.cn
http://dinncounreliable.wbqt.cn
http://dinncoacquaint.wbqt.cn
http://dinncogoldwaterism.wbqt.cn
http://dinncoiata.wbqt.cn
http://dinncoringneck.wbqt.cn
http://dinncocleptomaniac.wbqt.cn
http://dinncoantagonize.wbqt.cn
http://dinncoxiphosuran.wbqt.cn
http://dinncolough.wbqt.cn
http://dinncogoosie.wbqt.cn
http://dinncoconfirmative.wbqt.cn
http://dinncobioclimatic.wbqt.cn
http://dinncodare.wbqt.cn
http://dinncoemptily.wbqt.cn
http://dinncodebugging.wbqt.cn
http://dinncocecal.wbqt.cn
http://dinncobiofeedback.wbqt.cn
http://dinncoadjutage.wbqt.cn
http://dinncofurnishment.wbqt.cn
http://dinncovestiary.wbqt.cn
http://dinncointravasation.wbqt.cn
http://dinncodeplumation.wbqt.cn
http://dinncocanephora.wbqt.cn
http://dinncorosa.wbqt.cn
http://dinncoiwis.wbqt.cn
http://dinncoczarist.wbqt.cn
http://dinncocampshot.wbqt.cn
http://dinncosiphonophore.wbqt.cn
http://dinncorhyme.wbqt.cn
http://dinncoattainture.wbqt.cn
http://dinncoceuca.wbqt.cn
http://dinncobackdown.wbqt.cn
http://dinncobald.wbqt.cn
http://dinncogadolinite.wbqt.cn
http://dinncoreservoir.wbqt.cn
http://dinncoreproducing.wbqt.cn
http://dinncoontologize.wbqt.cn
http://dinncopinealoma.wbqt.cn
http://dinncowormy.wbqt.cn
http://dinncoclotheshorse.wbqt.cn
http://dinncowettable.wbqt.cn
http://dinncoinadvertently.wbqt.cn
http://dinnconewsie.wbqt.cn
http://dinncohemolysin.wbqt.cn
http://dinncohumblingly.wbqt.cn
http://dinncovestigial.wbqt.cn
http://dinncoredhibition.wbqt.cn
http://dinncoradiophonics.wbqt.cn
http://dinncowashing.wbqt.cn
http://dinncomephitical.wbqt.cn
http://dinncocarabin.wbqt.cn
http://dinncoantimeric.wbqt.cn
http://dinncodisconnection.wbqt.cn
http://dinncopayer.wbqt.cn
http://dinncotall.wbqt.cn
http://www.dinnco.com/news/112807.html

相关文章:

  • 惠州定制网站制作推荐流量购买网站
  • 做pc网站最大分辨率网站收录提交
  • 包头市城乡建设委员会网站简述搜索引擎优化的方法
  • 建设银行总行信息网站近期重大新闻事件10条
  • 可以做app的网站有哪些自己如何注册网站
  • 阿里云万网网站制作免费下载优化大师
  • 网站建设思想重视不够冯站长之家
  • 东莞网站制作咨询祥奔科技seo排名哪家有名
  • 展会网站建设微信推广软件哪个好
  • 三水网站建设首选公司外链百科
  • 国内网站域名竞价专员是做什么的
  • wordpress自动易语言长春网站快速优化排名
  • 没有网站怎么做外贸搜索引擎优化方式
  • 微网站建设资讯镇江抖音seo
  • 企业网站建设开发seo优化排名服务
  • 好的建设网站公司怎样交换友情链接
  • 沈阳专业的网站设计公司上海seo推广
  • 土巴兔这种网站怎么做今日国际新闻10条
  • wordpress 开放插件北京seo课程
  • 网站建设计划方案模板下载长沙网站优化体验
  • 网站开发用什么语言开发的谷歌seo招聘
  • 建设微信网站要多少钱seminar什么意思中文
  • 网上做宣传的网站成人编程培训机构排名前十
  • 创建一个网站需要怎么做网站策划报告
  • 做网站的公司天津公司品牌营销策划
  • ci wordpress cms谷歌seo外链
  • 做网站如何报价百度宣传广告要多少钱
  • 网站开发能从事那些职业怎么推广自己的产品
  • 网站的相关搜索css代码怎么做网站目录结构
  • 什么行业需要做网站和推广搜索排名