Ubuntu Strings 是一个用于提取二进制文件中的可读字符串的工具
-
安装 Ubuntu Strings:
在终端中运行以下命令以安装 Ubuntu Strings:
sudo apt-get update sudo apt-get install ubuntustreams -
基本用法:
以下是一些基本的 Ubuntu Strings 命令,用于从二进制文件中提取字符串:
-
提取所有字符串:
strings -
提取特定类型的字符串(例如,只提取 ASCII 字符串):
strings -t x -
提取最小长度为 n 的字符串(例如,提取长度大于等于 4 的字符串):
strings -n 4 -
将提取的字符串输出到文件:
strings> output.txt
-
-
在自动化脚本中使用 Ubuntu Strings:
你可以在 Bash 脚本或其他自动化工具中使用 Ubuntu Strings。以下是一个简单的示例,该脚本检查二进制文件中是否包含特定的字符串:
#!/bin/bash binary_file="example_binary" search_string="Hello, World!" # 使用 Ubuntu Strings 提取二进制文件中的所有字符串,并将结果存储在临时文件中 strings "$binary_file" > temp_strings.txt # 检查搜索字符串是否在临时文件中 if grep -q "$search_string" temp_strings.txt; then echo "Found the string '$search_string' in the binary." else echo "Did not find the string '$search_string' in the binary." fi # 删除临时文件 rm temp_strings.txt将此脚本保存为
check_string.sh,并使用chmod +x check_string.sh命令使其可执行。然后运行脚本,它将检查指定的二进制文件中是否包含 “Hello, World!” 字符串。
这只是一个简单的示例,你可以根据需要修改脚本以满足你的需求。例如,你可以遍历一个目录中的所有二进制文件,或者根据其他条件过滤字符串。
以上就是关于“Ubuntu Strings在自动化脚本中的使用”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm