Update Dockerfile
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647FROM ubuntu:22.04# 1. Environment variablesENV GHIDRA_VERSION=11.0.1ENV GHIDRA_URL=https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.0.1_build/ghidra_11.0.1_PUBLIC_20240325.zipENV DEBIAN_FRONTEND=noninteractive# 2. Install dependencies as rootRUN apt-get update && apt-get install -y \openjdk-17-jdk \wget \unzip \python3 \&& rm -rf /var/lib/apt/lists/*# 3. Create /data directory and set permissions BEFORE switching usersRUN mkdir -p /data && chmod 777 /data# 4. Setup UserRUN useradd -m -u 1000 userWORKDIR /home/user# 5. Download and install GhidraRUN wget -q $GHIDRA_URL -O ghidra.zip && \unzip ghidra.zip && \rm ghidra.zip && \mv ghidra_* ghidra# 6. Copy project files (ensure these exist in your repo!)# If libXynna.so is missing from your git repo, the build will fail here.COPY --chown=user:user export_all.py .COPY --chown=user:user libXynna.so .# Create a dummy index pageRUN echo "<html><body style='font-family:sans-serif;'><h1>Decompiler Service</h1><p>Ghidra is processing <b>libXynna.so</b> in the background.</p><p>Check the <code>/data</code> directory for the output.</p></body></html>" > index.htmlUSER user# 7. Execution Logic# We use a subshell to run the decompiler so the web server starts immediatelyCMD python3 -m http.server 7860 & \./ghidra/support/analyzeHeadless /tmp tmp_proj \-import ./libXynna.so \-postScript ./export_all.py \-deleteProject && \echo "--- DECOMPILATION FINISHED ---" && \wait12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849FROM ubuntu:22.04# 1. System setupENV GHIDRA_URL=https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.0.1_build/ghidra_11.0.1_PUBLIC_20240325.zipENV DEBIAN_FRONTEND=noninteractive# 2. Install dependencies as rootRUN apt-get update && apt-get install -y \openjdk-17-jdk wget unzip python3 \&& rm -rf /var/lib/apt/lists/*# 3. Prepare the mount point# We create the directory and give it open permissions so the 'user' can write# to the bucket once it's mounted at runtime.RUN mkdir -p /data && chmod 777 /data# 4. Setup UserRUN useradd -m -u 1000 userWORKDIR /home/user# 5. Install GhidraRUN wget -q $GHIDRA_URL -O ghidra.zip && \unzip ghidra.zip && \mv ghidra_* ghidra && \rm ghidra.zip# 6. Copy analysis files# Ensure export_all.py and libXynna.so are in your Space's rootCOPY --chown=user:user export_all.py .COPY --chown=user:user libXynna.so .# Create the dummy UIRUN echo "<html><body style='font-family:sans-serif;'> \<h1>Ghidra Analysis Active</h1> \<p>Target: <code>libXynna.so</code></p> \<p>Output will be saved to your <b>/data</b> bucket.</p> \</body></html>" > index.htmlUSER user# 7. Start Web Server and Run Decompiler# The script now explicitly points to the /data mountCMD python3 -m http.server 7860 & \./ghidra/support/analyzeHeadless /tmp tmp_proj \-import ./libXynna.so \-postScript ./export_all.py /data/libXynna_pseudocode.cpp \-deleteProject && \echo "--- DECOMPILATION COMPLETE: Saved to /data/libXynna_pseudocode.cpp ---" && \wait
Dockerfile+20-18