Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capa Analyzer - auto-download latest capa binary #1301

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions analyzers/Capa/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3
WORKDIR /worker
COPY . Capa

# Install required tools
RUN apt-get update && apt-get install -y \
curl \
jq \
unzip && \
rm -rf /var/lib/apt/lists/*

# Add a script to fetch the latest capa release and extract it
COPY fetch_capa.sh /worker/fetch_capa.sh
RUN chmod +x /worker/fetch_capa.sh && /worker/fetch_capa.sh

RUN test ! -e Capa/requirements.txt || pip install --no-cache-dir -r Capa/requirements.txt
ENTRYPOINT "Capa/CapaAnalyze.py"
Binary file removed analyzers/Capa/capa
Binary file not shown.
26 changes: 26 additions & 0 deletions analyzers/Capa/fetch_capa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status
set -x # Print commands and their arguments as they are executed

# Fetch the latest release version
LATEST_VERSION=$(curl -s https://api.github.com/repos/mandiant/capa/releases/latest | jq -r '.tag_name')

# Validate the version
if [ -z "$LATEST_VERSION" ]; then
echo "Failed to fetch the latest version."
exit 1
fi

echo "Latest version is $LATEST_VERSION"

# Construct the download URL
DOWNLOAD_URL="https://github.com/mandiant/capa/releases/download/${LATEST_VERSION}/capa-${LATEST_VERSION}-linux.zip"
echo "Downloading from $DOWNLOAD_URL"

# Download and extract capa
curl -L -o capa.zip "$DOWNLOAD_URL" || { echo "Download failed"; exit 1; }
unzip capa.zip -d /worker/capa || { echo "Extraction failed"; exit 1; }

# Clean up
rm capa.zip
echo "Capa downloaded and extracted successfully."