-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpervert
executable file
·103 lines (77 loc) · 1.79 KB
/
pervert
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Check command line usage
if [ $# -eq 0 ];
then
echo "Incorrect usage!"
echo $0" <binary> <args>"
exit 1
fi
# Check paths to component programs
HERE=$(dirname $0)
SERVER_PATH=$HERE/backend
PIN=$HERE/pintool/pin
PIN_PLUGIN=$HERE/pintool/source/tools/Pervert/obj-intel64/pervert.so
SERVER=$SERVER_PATH/server
CURL=/usr/bin/curl
OBJDUMP=/usr/bin/objdump
if [ ! -e $PIN ];
then
echo "Unable to locate pintool!"
echo "This is bad... pintool ships with this."
exit 2
fi
if [ ! -e $PIN_PLUGIN ];
then
echo "Unable to locate pintool plugin!"
echo "Rebuild plugin: cd pintool/source/tools/Pervert && make"
exit 3
fi
if [ ! -e $SERVER ];
then
echo "Unable to locate server!"
echo "Rebuild backend: cd backend/ && make"
exit 4
fi
if [ ! -e $CURL ];
then
echo "Unable to locate curl!"
echo "Try installing libcurl"
exit 5
fi
if [ ! -e $OBJDUMP ];
then
echo "Unable to locate objdump!"
echo "Try installing binutils"
exit 6
fi
# TODO: Put this on a command line switch -- kill the server if it's running
killall server
# Bring up the server if it isn't already running
RESPONSE=`$CURL localhost:8083/ping 2>/dev/null`
if [ "$RESPONSE" != "pong" ];
then
cd $SERVER_PATH
./server --daemon
cd -
# TODO: Check that server has come up?
fi
# Initialize output paths
PROGRAM=$(basename $1)
OUTPATH=/var/tmp/$PROGRAM
mkdir -p $OUTPATH
# Initialize output filenames
NAME=`date +%s`
OBJDUMP_OUT=$OUTPATH/$NAME.line
PIN_OUT=$OUTPATH/$NAME.trace
# Run tools
$OBJDUMP -WL $1 > $OBJDUMP_OUT
$PIN -injection child -t $PIN_PLUGIN -o $PIN_OUT -- $@
# Tell the server what it needs to hear
URL="localhost:8083/pp/update?exec="$PROGRAM"&logs="$OUTPATH"/"$NAME
$CURL $URL > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "Error sending update message to server!"
exit 7
fi
exit 0