-
Notifications
You must be signed in to change notification settings - Fork 4
/
run-ida.sh
executable file
·58 lines (48 loc) · 1.27 KB
/
run-ida.sh
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
#!/bin/bash
set -e -o pipefail
shopt -s extglob
if [[ -z "$IDAENV" || -z "$IDAHOME" ]]; then
echo "IDA environment vars not set."
exit 1;
fi
name=$( basename "$0" )
case $name in
ida|ida32)
ida_pat="ida?(q)"
;;
ida64)
ida_pat="ida?(q)64"
;;
*)
echo "Unknown target executable"
exit 1;
esac
# Look for the appropriate ida binary in $IDAHOME
ida_bin=("$IDAHOME"/$ida_pat)
if [[ ! -e "$ida_bin" ]]; then
echo "IDA binary not found: $ida_bin"
exit 1
fi
# Check if this is actually an idaenv install
if [[ ! -e "$IDAENV/bin/idaenv" ]]; then
echo "idaenv not found in virtual environment"
# Start IDA without further effort
"$ida_bin" "$@"
exit
fi
# Activate the virtualenv
source "$IDAENV/bin/activate"
# Configure IDAUSR
export IDAUSR="$HOME/.idapro:$( "$IDAENV/bin/idaenv" prefix )"
# Try to find libpython for preload
LIBPYTHON="$(python -c 'import sysconfig; print("%s/%s" % (
sysconfig.get_config_var("LIBPL"),
sysconfig.get_config_var("LDLIBRARY")))' 2>&1)"
# Start the target IDA binary
if [[ -f "$LIBPYTHON" && -f "/lib64/ld-linux-x86-64.so.2" ]]; then
# Preload correct libpython
LD_PRELOAD="$LIBPYTHON" "$ida_bin" "$@"
else
# Hope for the best
"$ida_bin" "$@"
fi