SOAdvancedDissector

SOAdvancedDissector Git Source Tree

Root/InterfaceDiscovery.sh

1#!/bin/bash
2
3function check_tool()
4{
5 tool=$1
6 cmd=$2
7
8 a=`${cmd} 2>/dev/null`
9 if [ ! $? -eq 0 ] ; then
10echo "${tool} is missing"
11exit 1
12 fi
13}
14
15function check_tools()
16{
17 check_tool "readelf" "readelf --version"
18 check_tool "objdump" "objdump --version"
19 check_tool "c++filt" "c++filt --version"
20
21 if [ ! -e ./vtable-dumper ] ; then
22check_tool "git" "git --version"
23check_tool "make" "make --version"
24check_tool "g++" "g++ --version"
25 fi
26}
27
28TARGET=$1
29readelf_target="${TARGET}.readelf"
30sections_target="${TARGET}.sections"
31vtable_target="${TARGET}.vtable"
32
33if [ ! -f "${TARGET}" ] ; then
34 echo "$0 <target>"
35 exit 1
36fi
37
38check_tools
39
40if [ ${TARGET} -nt ${readelf_target} ] ; then
41 echo "Regenerating ${readelf_target}"
42 $((readelf -sW ${TARGET}|c++filt > ${readelf_target}))
43fi
44
45if [ ${TARGET} -nt ${sections_target} ] ; then
46 echo "Regenerating ${sections_target}"
47 $((readelf --sections ${TARGET}|c++filt > ${sections_target}))
48fi
49
50VTABLE_ARG="-V ${vtable_target}"
51if [ ${TARGET} -nt ${vtable_target} ] ; then
52 `objdump -d ${TARGET} 2>/dev/null`
53 if [ ! $? -eq 0 ]; then
54echo "Unable to do objdump, maybe ${TARGET} is for another platform"
55VTABLE_ARG=""
56 else
57if [ ! -e ./vtable-dumper/vtable-dumper ] ; then
58 git clone XXX || exit 1
59 cd ./vtable-dumper
60 make
61 cd -
62fi
63if [ -x ./vtable-dumper/vtable-dumper ] ; then
64 echo "Regenerating ${vtable_target}"
65 $((./vtable-dumper/vtable-dumper --demangle ${TARGET}|c++filt > ${vtable_target}))
66else
67 echo "./vtable-dumper not available"
68 VTABLE_ARG=""
69fi
70 fi
71fi
72
73./InterfaceDiscovery.py -f ${TARGET} -S ${readelf_target} -s ${sections_target} ${VTABLE_ARG} -c

Archive Download this file

Branches