aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/scan.sh
blob: bb4f77c0191c3086a615ff8968a17722f362938e (plain) (blame)
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
#!/bin/bash

if [ "$#" -ne 1 ]
then
    printf "Usage: %s <tracee_pid>\n" "$0"
    exit 1
fi

echo '
                                                       /$$      
                                                      | $$      
  /$$$$$$$  /$$$$$$$  /$$$$$$  /$$$$$$$       /$$$$$$$| $$$$$$$ 
 /$$_____/ /$$_____/ |____  $$| $$__  $$     /$$_____/| $$__  $$
|  $$$$$$ | $$        /$$$$$$$| $$  \ $$    |  $$$$$$ | $$  \ $$
 \____  $$| $$       /$$__  $$| $$  | $$     \____  $$| $$  | $$
 /$$$$$$$/|  $$$$$$$|  $$$$$$$| $$  | $$ /$$ /$$$$$$$/| $$  | $$
|_______/  \_______/ \_______/|__/  |__/|__/|_______/ |__/  |__/
'

pid="$1"
scanfile=${SCANFILE:-/tmp/scanfile}
rm -f ${scanfile}

while true
do
    read -p "Scan pattern (hex): " pattern
    newscan=$(mktemp)
    ./trainer ${pid} scan ${pattern} > ${newscan} 2> /dev/null
    if [ ! -f ${scanfile} ]
    then
	mv ${newscan} ${scanfile}
    else
	temp=$(mktemp)
	cat ${newscan} ${scanfile} | sort | uniq -d > ${temp}
	mv ${temp} ${scanfile}
	rm ${newscan}
    fi
done