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

WIP: Add Docker Support #26

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
131 changes: 131 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
ghidra_9.0.4_PUBLIC_20190516.zip
/dist/
/build/
/.vscode/
__pycache__/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:16.04

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
ADD https://isrc.iscas.ac.cn/mirror/help/mirror/xlab_ubuntu18.04.list /etc/apt/sources.list.d/xlab_ubuntu18.04.list

RUN apt-get update

RUN apt-get install -y \
build-essential \
python3.6 python3.6-dev python3-pip python3-virtualenv \
wget git screen docker.io default-jdk lrzsz binwalk vim unzip sudo

# install ghidra
ADD ghidra_9.0.4_PUBLIC_20190516.zip /tmp/ghidra.zip
RUN unzip /tmp/ghidra.zip -d /ghidra

# update pip and install python library
RUN python3.6 -m pip install pip --upgrade
COPY requirements /tmp/
RUN python3.6 -m pip install wheel -r /tmp/requirements

RUN git clone https://github.com/radare/radare2.git && ./radare2/sys/install.sh

# RUN echo 'export PATH=$PATH:/fwslap/bin:/ghidra/ghidra_9.0.4/support/' > /entrypoint.sh && chmod +x /entrypoint.sh
COPY ./entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
VOLUME [ "/data" ]
WORKDIR /data
ENV FWSLAP_BROKER_URL=pyamqp://guest:guest@rabbit//
COPY . /fwslap
RUN cd /fwslap && python3 /fwslap/setup.py install
# export PATH=$PATH:/fwslap/bin:/ghidra/ghidra_9.0.4/support/
RUN echo 'export PATH=/fwslap/bin:/ghidra/ghidra_9.0.4/support:$PATH:/usr/local/bin' >> /etc/profile
ENV PATH=/fwslap/bin:/ghidra/ghidra_9.0.4/support:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN pip install -U scipy
78 changes: 78 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: "3.7"
services:
rabbit:
image: rabbitmq:3.8
networks:
- fw-net
# celery:
# image: celery:4
# networks:
# - fw-net
# command: celery -A firmware_slap.celery_tasks worker --loglevel=info
fwslap:
build:
context: "."
dockerfile: "Dockerfile"
image: fwslap
networks:
- fw-net
volumes:
- "${PWD}:/fwslap"
- "/var/run/docker.sock:/var/run/docker.sock"
command: ["sleep","inf"]

# redis:
# build:
# context: "./redis"
# dockerfile: "Dockerfile"
# image: "sec-srv:9005/redis:5.0-alpine"
# restart: always
# ports:
# - "127.0.0.1:6379:6379"
# networks:
# - inner
# volumes:
# - "/data/redis:/data"
# # command: ["--appendonly","yes"] # no need to save to disk
# monitor:
# build:
# context: ./monitor
# dockerfile: Dockerfile
# args:
# SENTRYEYE_DBUG: 1
# network: host
# image: sec-srv:9005/sentryeye_monitor:dev
# depends_on:
# - redis
# network_mode: "host"
# restart: always
# volumes:
# - "/data:/data"
# # - "./monitor:/SentryEye"
# env_file:
# - sentryeye.env
# # environment:
# # - SENTRYEYE_DBUG=0
# # - MAX_trimmed_SPACE=1G
# # - MAX_RAW_SPACE=2G
# # command: ["/bin/sleep","10000000"]
# command: ["/usr/bin/python3","/SentryEye/SentryEyeDaemon.py"]
# privileged: true

# capture:
# build:
# context: "./capture"
# dockerfile: "Dockerfile"
# image: sec-srv:9005/sentryeye_capture:dev
# network_mode: "host"
# restart: always
# depends_on:
# - monitor
# env_file:
# - sentryeye.env
# volumes:
# - "/data:/data"
# privileged: true

networks:
fw-net:
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -x
set -e
export PATH=$PATH:/fwslap/bin:/ghidra/ghidra_9.0.4/support/
alias python="/usr/bin/python3"
exec "$@"
26 changes: 13 additions & 13 deletions requirements
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
tqdm
python-magic
IPython
tqdm
sklearn
matplotlib
r2pipe
matplotlib
angr
psutil
termcolor
celery
flower
tqdm==4.36.1
python-magic==0.4.15
ipython==7.8.0
sklearn==0.0
matplotlib==3.1.1
r2pipe==1.4.2
angr==8.19.7.25
psutil==5.6.3
termcolor==1.1.0
celery==4.4.0rc3
flower==0.9.3
elasticsearch==7.0.5
decorator>=4.3.0