binwalk-解包工具

news2024/9/21 20:22:25

一、binwalk介绍

二、安装binwalk

# 1. 安装依赖和binwalk
​git clone https://github.com/ReFirmLabs/binwalk.git
cd binwalk
sudo python ./setup.py uninstall  # 如果您有以前安装的 Binwalk 版本,建议您在升级之前将其卸载
sudo ./deps.sh  # 安装依赖项
sudo python ./setup.py install
# 2. 对于 python2.x,还需要安装以下的库
sudo -H pip install git+https://github.com/ahupp/python-magic
sudo -H pip install git+https://github.com/sviehb/jefferson
# 3. 测试是否安装成功
hzy@ubuntu:~$ binwalk
 
Binwalk v2.1.2-c036535
Craig Heffner, ReFirmLabs
https://github.com/ReFirmLabs/binwalk
 
Usage: binwalk [OPTIONS] [FILE1] [FILE2] [FILE3] ...
 
Disassembly Scan Options:
    -Y, --disasm                 Identify the CPU architecture of a file using the capstone disassembler
... ...
    -s, --status=<int>           Enable the status server on the specified port
 
hzy@ubuntu:~$

三、binwalk工具的使用帮助

root@node1:/home/binwalk# binwalk -h
Binwalk v2.2.1+e0f9bf7   # 版本号
Craig Heffner, ReFirmLabs
https://github.com/ReFirmLabs/binwalk
Usage: binwalk [OPTIONS] [FILE1] [FILE2] [FILE3] ...
Disassembly Scan Options:
    -Y, --disasm                 Identify the CPU architecture of a file using the capstone disassembler
    -T, --minsn=<int>            Minimum number of consecutive instructions to be considered valid (default: 500)
    -k, --continue               Don't stop at the first match

Signature Scan Options:
    -B, --signature              Scan target file(s) for common file signatures 扫描目标文件以获取常见文件签名
    -R, --raw=<str>              Scan target file(s) for the specified sequence of bytes 扫描目标文件的指定字符序列
    -A, --opcodes                Scan target file(s) for common executable opcode signatures 扫描目标文件中常见可执行代码
    -m, --magic=<file>           Specify a custom magic file to use 指定要使用的自定义签名文件
    -b, --dumb                   Disable smart signature keywords  禁用智能签名关键字
    -I, --invalid                Show results marked as invalid 显示完整的扫描结果
    -x, --exclude=<str>          Exclude results that match <str>  排除与<str>匹配的结果
    -y, --include=<str>          Only show results that match <str> 只显示与<str>匹配的结果

Extraction Options:
    -e, --extract                Automatically extract known file types  自动提取已知的文件类型
    -D, --dd=<type[:ext[:cmd]]>  Extract <type> signatures (regular expression), give the files an extension of <ext>, and execute <cmd> 提取<type>签名,为文件扩展名为<ext>,然后执行<cmd>,比如:binwalk -D 'png image:png' firmware.bin
    -M, --matryoshka             Recursively scan extracted files 递归扫描提取的文件
    -d, --depth=<int>            Limit matryoshka recursion depth (default: 8 levels deep) 递归深度
    -C, --directory=<str>        Extract files/folders to a custom directory (default: current working directory) 将文件/文件夹提取到自定义目录(默认:当前工作目录)
    -j, --size=<int>             Limit the size of each extracted file 限制每个提取文件的大小
    -n, --count=<int>            Limit the number of extracted files 限制提取文件的数量
    -r, --rm                     Delete carved files after extraction 清理零大小文件和提取工具在提取期间无法处理的文件。仅当与--extract或--dd一起使用时有效。有助于清除提取期间从目标文件中复制的误报文件
    -z, --carve                  Carve data from files, but don't execute extraction utilities 从文件中读取数据,但不执行提取实用程序
    -V, --subdirs                Extract into sub-directories named by the offset

Entropy Options:
    -E, --entropy                Calculate file entropy 计算文件熵,熵分析可以帮助识别固件映像中有趣的数据部分
    -F, --fast                   Use faster, but less detailed, entropy analysis
    -J, --save                   Save plot as a PNG  自动将 --entropy 生成的熵图保存到 PNG 文件中,而不是显示它
    -Q, --nlegend                Omit the legend from the entropy plot graph 从熵图中省略图例
    -N, --nplot                  Do not generate an entropy plot graph  不生成熵图
    -H, --high=<float>           Set the rising edge entropy trigger threshold (default: 0.95)  设置上升沿熵触发阈值
    -L, --low=<float>            Set the falling edge entropy trigger threshold (default: 0.85)  设置下升沿熵触发阈值

Binary Diffing Options:
    -W, --hexdump                Perform a hexdump / diff of a file or files 比较文件
    -G, --green                  Only show lines containing bytes that are the same among all files
    -i, --red                    Only show lines containing bytes that are different among all files
    -U, --blue                   Only show lines containing bytes that are different among some files
    -u, --similar                Only display lines that are the same between all files
    -w, --terse                  Diff all files, but only display a hex dump of the first file
Raw Compression Options:
    -X, --deflate                Scan for raw deflate compression streams
    -Z, --lzma                   Scan for raw LZMA compression streams 通过暴力破解识别可能的原始 LZMA 压缩数据流
    -P, --partial                Perform a superficial, but faster, scan
    -S, --stop                   Stop after the first result
General Options:
    -l, --length=<int>           Number of bytes to scan
    -o, --offset=<int>           Start scan at this file offset
    -O, --base=<int>             Add a base address to all printed offsets
    -K, --block=<int>            Set file block size
    -g, --swap=<int>             Reverse every n bytes before scanning
    -f, --log=<file>             Log results to file  将结果记录到文件
    -c, --csv                    Log results to file in CSV format
    -t, --term                   Format output to fit the terminal window
    -q, --quiet                  Suppress output to stdout  禁止输出到标准输出
    -v, --verbose                Enable verbose output  详细输出
    -h, --help                   Show help output
    -a, --finclude=<str>         Only scan files whose names match this regex
    -p, --fexclude=<str>         Do not scan files whose names match this regex
    -s, --status=<int>           Enable the status server on the specified port 启用指定端口上的状态服务器

四、binwalk工具的基本用法介绍

4.1、获取帮助信息 -h
    
4.2、固件分析扫描
4.3、提取文件系统 -e -M -d
# 使用默认的预定义配置文件extract.conf
$ binwalk -e firmware.bin
 
# 使用指定自定义的配置文件my_extract.conf
$ binwalk --extract=./my_extract.conf firmware.bin
4.4、设置过滤选项 -y -x
4.5、显示完整的扫描结果 -I
4.6、固件文件的比较 -W
4.7、日志记录 -f
4.8、指令系统分析 -A
4.9、熵分析 -E
4.10、启发式分析 -H
4.11、使用指定插件分析扫描固件(已经去掉)
 
4.12、手动提取文件
-D, --dd=<type[:ext[:cmd]]>
提取在--signature扫描过程中识别的文件。可以指定多个--dd选项。
  • type:是包含在签名描述中的*小写*字符串(支持正则表达式)
  • ext:是保存数据磁盘时要使用的文件扩展名(默认为none)
  • cmd:是在数据保存到磁盘后执行的可选命令
默认情况下,文件名是找到签名的十六进制偏移量,除非在签名本身中指定了备用文件名。
以下示例演示使用--dd选项指定提取规则,该规则将提取包含文件扩展名为“zip”的字符串“zip archive”的任何签名,然后执行“unzip”命令。此外,PNG图像以“PNG”文件扩展名原样提取。
$ binwalk -D 'zip archive:zip:unzip %e' -D 'png image:png' firmware.bin
# 请注意“%e”占位符的使用。执行unzip命令时,此占位符将替换为提取文件的相对路径
4.13、binwalk工具的插件功能
在最新版的binwalk工具中关于插件的功能已经没有了,下图是原来有的插件功能。

五、python使用binwalk

python3 -m pip install git+https://github.com/ReFirmLabs/binwalk
binwalk.scan返回对象列表。每个对象对应于运行的模块。例如,如果您指定了 --signature--entropy,那么signature模块和entropy模块都将被执行,并且将返回一个包含两个对象的列表。
每个对象 最感兴趣的两个属性是结果和错误对象 。每个都是 binwalk.core.module.Result 和 binwalk.core.module.Error的实例。每个Result或Error实例可能包含每个模块设置的自定义属性,但保证至少具有以下属性(尽管不需要模块来填充所有属性):
Attribute
Description
offset
The file offset of the result/error (usually unused for errors)
description
The result/error description, as displayed to the user
module
Name of the module that generated the result/error
file
The file object of the scanned file
valid
Set to True if the result is valid, False if invalid (usually unused for errors)
display
Set to True to display the result to the user, False to hide it (usually unused for errors)
extract
Set to True to flag this result for extraction (not used for errors)
plot
Set to False to exclude this result from entropy plots (not used for errors)
binwalk.core.module.Error has the additional guaranteed attribute:
Attribute
Description
exception
Contains the Python exception object if the encountered error was an exception
因此,可以很容易地通过编程访问扫描结果和错误:
import binwalk
for module in binwalk.scan('firmware1.bin', 'firmware2.bin', signature=True, quiet=True): # --quiet选项,它阻止binwalk模块将其正常输出打印到屏幕
    print ("%s Results:" % module.name)
    for result in module.results:
        print ("\t%s    0x%.8X    %s" % (result.file.path, result.offset, result.description))
唯一应该引发的异常是binwalk.ModuleException异常。仅当所需模块遇到致命错误(例如,无法打开指定的目标文件之一)时,才会引发此异常:
try:
    binwalk.scan()
except binwalk.ModuleException as e:
    print ("Critical failure:", e)

六、参考

路由器逆向分析------binwalk工具的详细使用说明_binwalk unzip报错_Fly20141201的博客-CSDN博客
https://github.com/devttys0/binwalk/wiki/Usage  用法
https://github.com/ReFirmLabs/binwalk/wiki/Quick-Start-Guide  安装
Scripting With the Python API · ReFirmLabs/binwalk Wiki · GitHub  python调用binwalk
Pip install causes: ModuleNotFoundError: No module named 'binwalk.core.version' · Issue #352 · ReFirmLabs/binwalk · GitHub

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/729289.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言学习(三十五)---动态内存练习题与柔性数组

经过前面的内容&#xff0c;我们已经对动态内存的知识已经有了相当多了了解&#xff0c;今天我们再做几道有关动态内存的练习题&#xff0c;然后再介绍一下柔性数组&#xff0c;好了&#xff0c;话不多说&#xff0c;开整&#xff01;&#xff01;&#xff01; 动态内存练习题…

上海亚商投顾:沪指失守3200点 两市成交不足8000亿

上海亚商投顾前言&#xff1a;无惧大盘涨跌&#xff0c;解密龙虎榜资金&#xff0c;跟踪一线游资和机构资金动向&#xff0c;识别短期热点和强势个股。 市场情绪 沪指今日延续调整&#xff0c;失守3200点关口&#xff0c;深成指、创业板指盘中均跌超1%。AI概念股集体下挫&#…

你会做接口测试吗?接口测试面试题盲扫(附答案)

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 为什么要做接口测…

【跑实验06】如何数据集中加入图像尺寸?如何把tuple格式的坐标按顺序写成四列数据?如何把某一列放到最后?

文章目录 一、如何数据集中加入图像尺寸&#xff1f;二、如何把tuple格式的坐标按顺序写成四列数据&#xff1f;三、如何把某一列放到最后&#xff1f; 一、如何数据集中加入图像尺寸&#xff1f; 部分核心代码如下&#xff1a; image_files [filename for filename in os.l…

Windows | \\wsl.localhost无法访问

Windows | \\wsl.localhost无法访问 在地址栏输入&#xff1a;\\wsl.localhost或者\\wsl.localhost\

解决新版Pyahcrm2023.1.2版本没有manage repositories按钮无法更改依赖源的问题及使用Pycharm安装库的新理解

本文章的理解基于下面两篇文章&#xff1a; https://blog.csdn.net/henu1710252658/article/details/130918206 https://blog.csdn.net/henu1710252658/article/details/82015796 问题一&#xff1a;新版Pyahcrm2023.1.2版本没有manage repositories按钮无法更改依赖源 首先&am…

高效读深度学习代码:如何又快又好的get代码的逻辑与思想

犹豫很久要不要把读代码这个事情专门挑出来写成一篇推文。毕竟读代码嘛&#xff0c;大家可能都会读。而且笔者个人读的和写的代码量也并不足以到指导大家读代码的程度。但笔者还是决定大胆地写一点&#xff1a;就当是给自己设立今后读代码的标准&#xff0c;也将一些之前未能践…

浏览器相关面试题

1、在浏览器中输入URL并回车后发生了什么 https:www.baidu.com url > 统一资源定位发&#xff0c;&#xff08;网址&#xff09; 是IP的一个映射&#xff0c;方便记忆 https&#xff1a;传输协议&#xff08;http和TCP之间加了一层TSL或者SSL的安全层&#xff09; www&a…

在Ubuntu中禁用和启用CPU内核详解

概要 在某些情况下&#xff0c;您可能需要在Ubuntu操作系统中禁用或启用CPU内核。禁用CPU内核可以帮助您降低功耗&#xff0c;提高性能或解决一些与硬件和软件兼容性相关的问题。本文将介绍如何在Ubuntu中禁用和启用CPU内核的方法。 方法一&#xff1a;使用GRUB配置 GRUB是Ubu…

谷歌验证码kaptcha使用(包括前端获取获取解析)

1.后端 基于springboot开发。 包结构 1.导入依赖 <!--kaptcha验证码生成器--><dependency><groupId>com.github.axet</groupId><artifactId>kaptcha</artifactId><version>0.0.9</version></dependency> 2.配置类 …

从零开始:深度学习入门资料推荐

还记得几年前刚入坑的时候&#xff0c;老师给的入门资料就是一堆论文&#xff01;害的我差点放弃。。。 如今深度学习应用的开发成本越来越低&#xff0c;学习资料越来越多&#xff0c;于是对初学者来说进入了另一个相反的困境——资料过多&#xff0c;让人眼花缭乱&#xff0…

ASEMI整流桥MB6S是什么电子元件

编辑-Z 在电子工程领域&#xff0c;整流器是一种常见的电子设备&#xff0c;用于将交流电&#xff08;AC&#xff09;转换为直流电&#xff08;DC&#xff09;。其中&#xff0c;整流桥MB6S是一种广泛使用的整流器&#xff0c;以其高效、稳定和可靠的性能赢得了工程师们的青睐…

[Container]Hadoop集群镜像打包

文章目录 Docker DNS配置Linux Docker DNS设置Windows、MacOs Docker DNS设置 打包HadoopDockerfile打包文件参数声明和基础镜像引入安装相关依赖库创建普通用户下载或导入软件包环境变量配置 初始化脚本参数配置${HADOOP_CONF_DIR}/workers工作节点${HADOOP_CONF_DIR}/hadoop-…

97、基于stm32单片机智能药箱药盒温湿度体温光照时钟wifi手机APP监控(程序+原理图+PCB源文件+手机APP源码+硬件设计资料+元器件清单等)

单片机类型选择 方案一&#xff1a;可以使用现在比较主流的单片机STC89C5单片机进行数据处理。这款单片机具有的特点是内存和51的单片机相比多了4KB内存&#xff0c;但是价格和51单片机一样。并且支持数据串行下载和调试助手。此款单片机是有ATMEL公司生产&#xff0c;可用5V电…

appium自动化测试之PO模型设计

目录 PO模型 PO分层 PO模型设计框架 config目录 common目录 pages目录 function目录 case目录 logs目录 report目录 runTest.py文件 总结&#xff1a; 我们在做自动化的时候应该都听过PO模型&#xff0c;那么什么是PO模型呢&#xff1f;PO模型在自动化中的作用是什…

【链表OJ】删除链表中重复的结点

⭐️ 往期链表相关OJ &#x1f4ab;链接1&#xff1a;链表分割 &#x1f4ab;链接2&#xff1a;链表中倒数第k个结点(快慢指针问题) &#x1f4ab;链接3&#xff1a;leetcode 876.链表的中间结点(快慢指针问题) &#x1f4ab;链接4&#xff1a;leetcode 206.反转链表 &#x1…

第二章React全家桶之面向组件编程

文章目录 一、组件的基本理解和使用1-1、函数式组件1-2、类式组件 二、组件实例的三大核心属性2-1、state的基本使用2-2-1、state的总结 2-2、props的基本使用2-2-1、props的传值与批量传值2-2-2、对props进行限制2-2-3、props的简写2-2-4、类式组件中的构造器与props2-2-5、函…

使用 eKuiper 按需桥接 CAN Bus 数据至 MQTT

CAN Bus 是一种广泛应用于汽车和工业领域的通信协议&#xff0c;它能够让多个设备在同一网络中进行交互。而 MQTT 是一种广泛应用于物联网领域的通信协议&#xff0c;作为一种轻量级的发布-订阅消息传输协议&#xff0c;它有效地促进了机器之间的通信。 通过将 CAN Bus 数据桥…

Vue组件库Element-常见组件-分页

常见组件-Pagination 分页 Pagination 分页&#xff1a;当数据过多时&#xff0c;会使用分页分解数据 具体关键代码如下&#xff1a;&#xff08;重视注释&#xff09; <template><div><!-- Pagination 分页 --><el-pagination background layout"…

Etsy店铺被封的原因是什么?如何防封

ETSY是一个全球知名的在线市场和电商平台&#xff0c;专注于手工艺品、独特商品和创意艺术。它为卖家提供了一个平台来展示和销售自己的手工制品、艺术品、珠宝、家居用品、时尚配饰等各种创意产品。作为一个颇受中国商家青睐的平台&#xff0c;Etsy在账号检测方面也是不亚于亚…