Ubuntu Strings 是一个用于提取二进制文件中的可读字符串的工具
安装 Ubuntu Strings:
在终端中运行以下命令以安装 Ubuntu Strings:
sudo apt-get update
sudo apt-get install ubuntustreams
基本用法:
以下是一些基本的 Ubuntu Strings 命令,用于从二进制文件中提取字符串:
提取所有字符串:
strings <binary_file>
提取特定类型的字符串(例如,只提取 ASCII 字符串):
strings -t x <binary_file>
提取最小长度为 n 的字符串(例如,提取长度大于等于 4 的字符串):
strings -n 4 <binary_file>
将提取的字符串输出到文件:
strings <binary_file> > 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!” 字符串。
这只是一个简单的示例,你可以根据需要修改脚本以满足你的需求。例如,你可以遍历一个目录中的所有二进制文件,或者根据其他条件过滤字符串。