blob: b844300fe31fb7792aecd298cabbd2e708a5d359 (
plain)
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
|
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
#
# ghidra_analyze.sh - import a library into a Ghidra project and run the full
# auto-analysis once. The project is kept, so later decompilations are cheap:
#
# scripts/ghidra_decompile_project.sh <hex-vaddr> [outfile]
#
# Full analysis of a ~70 MB library can take a long time; run it in the
# background and log to run/ghidra-analyze.log.
#
# Usage: scripts/ghidra_analyze.sh <binary>
# env: GHIDRA_HOME (default /snap/ghidra/current/ghidra)
# PROJECT_DIR (default ../run/ghidra-proj)
# PROJECT_NAME (default cuda-analysis)
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$HERE/.." && pwd)"
RUN="$ROOT/run"
BIN="${1:?usage: $0 <binary>}"
GHIDRA_HOME="${GHIDRA_HOME:-/snap/ghidra/current/ghidra}"
ANALYZE="$GHIDRA_HOME/support/analyzeHeadless"
PROJECT_DIR="${PROJECT_DIR:-$RUN/ghidra-proj}"
PROJECT_NAME="${PROJECT_NAME:-cuda-analysis}"
[ -x "$ANALYZE" ] || { echo "analyzeHeadless not found at $ANALYZE"; exit 1; }
mkdir -p "$PROJECT_DIR"
echo "[*] importing + analyzing $BIN (this can take a long time)"
"$ANALYZE" "$PROJECT_DIR" "$PROJECT_NAME" \
-import "$BIN" \
-overwrite \
-scriptPath "$ROOT/ghidra" \
-analysisTimeoutPerFile 0
echo "[ok] analysis complete"
|