-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathblobs.sh
More file actions
executable file
·40 lines (34 loc) · 1.12 KB
/
blobs.sh
File metadata and controls
executable file
·40 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
###########################################################################################
#
# parses a blob and prints all its dependencies - and dependencies of those, too
#
# Copyright 2020-2023: steadfasterX <steadfasterX | gmail - com>
#
###########################################################################################
[ -z "$DEBUG" ] && DEBUG=0
spath="$1"
FOUND="$2"
BLOBS=()
if [ -z "$spath" ]||[ ! -f "$FOUND" ];then echo "ERROR. usage: $0 <search path> <full-path-to-blob>"; exit 4;fi
lib_lookup() {
readelf -d $1 | grep NEEDED | cut -d "[" -f2 | cut -d"]" -f 1
}
so_search() {
for file in `lib_lookup $1`; do
find $spath -iname "$file" 2>/dev/null
done
}
global_search() {
RESULT=$(so_search $1 | grep -Ev "^${FOUND}" | grep -v "libc.so\|libdl.so\|libc++.so\|libm.so\|liblog.so\|libcutils.so")
for blob in `echo -n $RESULT`; do
CNT=$((CNT+1))
echo $blob
FOUND=$1\|$FOUND
BLOBS[1]+="$blob "
global_search $blob
[ $CNT -gt 20 ] && break
done
}
[ "$DEBUG" -eq 1 ] && echo "starting search on $spath for $FOUND"
global_search "$FOUND"