28 lines
635 B
Bash
Executable file
28 lines
635 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
pid="$1"
|
|
target_soname="$2"
|
|
|
|
echo "pid: $pid"
|
|
echo "soname: $target_soname"
|
|
|
|
lines=()
|
|
|
|
IFS='
|
|
'
|
|
for line in $(cat /proc/$pid/maps); do
|
|
region=${line%% *}
|
|
region_file=/proc/$pid/map_files/$region
|
|
if [[ -e $region_file ]]; then
|
|
soname=$(objdump -p "$region_file" 2>/dev/null | grep SONAME ||:)
|
|
if [[ $(echo "$soname" | awk '{print $2}') == $target_soname ]]; then
|
|
lines+=($line)
|
|
fi
|
|
fi
|
|
done
|
|
|
|
for line in ${lines[@]}; do
|
|
dd if="/proc/$pid/map_files/$(echo "$line" | awk '{print $1}')" seek="$((16#$(echo "$line" | awk '{print $3}')))" of=$target_soname
|
|
done
|