Skip to content

Commit 1e04d7e

Browse files
committed
Working docker builds
1 parent 28278b1 commit 1e04d7e

File tree

4 files changed

+65
-22
lines changed

4 files changed

+65
-22
lines changed

Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
FROM openjdk:11-jdk-slim
22

3-
ENV VERSION 9.1.2
3+
ENV VERSION 9.1.2_PUBLIC
4+
ENV DL https://www.ghidra-sre.org/ghidra_${VERSION}_20200212.zip
45
ENV GHIDRA_SHA ebe3fa4e1afd7d97650990b27777bb78bd0427e8e70c1d0ee042aeb52decac61
56

6-
RUN apt-get update && apt-get install -y fontconfig libxrender1 libxtst6 libxi6 wget unzip --no-install-recommends \
7-
&& wget --progress=bar:force -O /tmp/ghidra.zip https://www.ghidra-sre.org/ghidra_9.1.2_PUBLIC_20200212.zip \
7+
RUN apt-get update && apt-get install -y wget unzip dnsutils --no-install-recommends \
8+
&& wget --progress=bar:force -O /tmp/ghidra.zip ${DL} \
89
&& echo "$GHIDRA_SHA /tmp/ghidra.zip" | sha256sum -c - \
910
&& unzip /tmp/ghidra.zip \
1011
&& mv ghidra_${VERSION} /ghidra \
@@ -20,6 +21,8 @@ COPY entrypoint.sh /entrypoint.sh
2021
COPY server.conf /ghidra/server/server.conf
2122

2223
EXPOSE 13100 13101 13102
24+
2325
RUN mkdir /repos
26+
2427
ENTRYPOINT ["/entrypoint.sh"]
25-
CMD [ "client" ]
28+
CMD ["server"]

Dockerfile.beta

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM gradle:jdk11 as builder
2+
3+
ENV GITHUB_URL https://github.com/NationalSecurityAgency/ghidra.git
4+
5+
RUN apt-get update && apt-get install -y curl git bison flex build-essential unzip
6+
7+
RUN echo "[+] Cloning Ghidra..." \
8+
&& git clone ${GITHUB_URL} /root/git/ghidra
9+
10+
WORKDIR /root/git/ghidra
11+
12+
RUN echo "[+] Downloading dependencies..." \
13+
&& gradle --init-script gradle/support/fetchDependencies.gradle init
14+
15+
RUN echo "[+] Building Ghidra..." \
16+
&& gradle buildNatives_linux64 \
17+
&& gradle sleighCompile \
18+
&& gradle buildGhidra
19+
20+
WORKDIR /ghidra
21+
22+
RUN echo "[+] Unzip Ghidra..." \
23+
&& unzip /root/git/ghidra/build/dist/ghidra_*_linux64.zip -d /tmp \
24+
&& mv /tmp/ghidra_*/* /ghidra \
25+
&& chmod +x /ghidra/ghidraRun \
26+
&& rm -rf /ghidra/docs /ghidra/Extensions/Eclipse /ghidra/licenses
27+
28+
##########################################################################################
29+
FROM openjdk:11-jdk-slim
30+
31+
LABEL maintainer "https://github.com/blacktop"
32+
33+
COPY --from=builder /ghidra /ghidra
34+
35+
RUN apt-get update && apt-get install -y fontconfig libxrender1 libxtst6 libxi6 dnsutils --no-install-recommends \
36+
&& echo "===> Clean up unnecessary files..." \
37+
&& apt-get clean \
38+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives /tmp/* /var/tmp/*
39+
40+
WORKDIR /ghidra
41+
42+
COPY entrypoint.sh /entrypoint.sh
43+
COPY server.conf /ghidra/server/server.conf
44+
45+
RUN mkdir /repos
46+
47+
EXPOSE 13100 13101 13102
48+
49+
ENTRYPOINT ["/entrypoint.sh"]
50+
CMD [ "server" ]

entrypoint.sh

+5-17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -e
44

55
if [ "$1" = 'server' ]; then
66
shift
7+
# Figure out public address
8+
export GHIDRA_PUBLIC_HOSTNAME=${GHIDRA_PUBLIC_HOSTNAME:-$(dig +short myip.opendns.com @resolver1.opendns.com)}
9+
710
# Add users
811
GHIDRA_USERS=${GHIDRA_USERS:-admin}
912
if [ ! -e "/repos/users" ] && [ ! -z "${GHIDRA_USERS}" ]; then
@@ -13,23 +16,8 @@ if [ "$1" = 'server' ]; then
1316
echo "-add ${user}" >> /repos/~admin/adm.cmd
1417
done
1518
fi
16-
#----------------------------------------
17-
# Ghidra Server launch
18-
#----------------------------------------
19-
exec "/ghidra/server/ghidraSvr" console
2019

21-
elif [ "$1" = 'client' ]; then
22-
shift
23-
#----------------------------------------
24-
# Ghidra launch
25-
#----------------------------------------
26-
SCRIPT_DIR=/ghidra
27-
SCRIPT_FILE=/ghidra/ghidraRun
28-
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
29-
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
30-
MAXMEM=${MAXMEM:-768M}
31-
# Launch Ghidra
32-
exec "${SCRIPT_DIR}"/support/launch.sh fg Ghidra $MAXMEM "" ghidra.GhidraRun "$@"
20+
exec "/ghidra/server/ghidraSvr" console
3321
fi
3422

35-
exec "$@"
23+
exec "$@"

server.conf

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ ghidra.repositories.dir=/repos
123123
# used to store repositories. Use of this variable to define the
124124
# repositories directory must be retained.
125125
wrapper.app.parameter.1=-a0
126-
wrapper.app.parameter.2=${ghidra.repositories.dir}
126+
wrapper.app.parameter.2=-u
127+
wrapper.app.parameter.3=-ip${GHIDRA_PUBLIC_HOSTNAME}
128+
wrapper.app.parameter.4=${ghidra.repositories.dir}
127129

128130
# Establish server process owner
129131
# This should only be used when installing as a service using a nologin

0 commit comments

Comments
 (0)