首先说明下我做这个bash脚本的目的
我需要从根目录下筛选出所有ELF文件,并将这类文件的路径整理成一个text文件,逐行读取text文件内的路径,依次将目标文件反汇编,并筛选将符合条件的文件路径输出到另一个text文件中
#!/bin/sh
find / -type f -exec file {} \; | grep "\<ELF\>" | awk -F ':' '{print $1}' >>ELFfile
cat ELFfile | while read line
do
if objdump -d $line | grep "\<aesenc\>\|\<aesenclast\>";then
printf "%s\n" $line >>test3
fi
done
line1:声明这是sh文件
line3:利用find函数,/ 表示从根目录开始搜索,-type f 表示查找普通文件 (-type b/d/c/p/l/f #分别表示查找块设备、目录、字符设备、管道、符号链接、普通文件)
-exec file {} \; 表示