metasploit-framework/Dockerfile

70 lines
2.3 KiB
Docker
Raw Normal View History

FROM ruby:2.6.6-alpine3.10 AS builder
2017-11-29 04:35:20 +08:00
LABEL maintainer="Rapid7"
2017-04-22 08:10:00 +08:00
ARG BUNDLER_ARGS="--jobs=8 --without development test coverage"
2018-10-22 04:30:01 +08:00
ENV APP_HOME=/usr/src/metasploit-framework
2017-11-29 04:35:20 +08:00
ENV BUNDLE_IGNORE_MESSAGES="true"
WORKDIR $APP_HOME
2018-10-22 04:30:01 +08:00
COPY Gemfile* metasploit-framework.gemspec Rakefile $APP_HOME/
2017-11-29 04:35:20 +08:00
COPY lib/metasploit/framework/version.rb $APP_HOME/lib/metasploit/framework/version.rb
COPY lib/metasploit/framework/rails_version_constraint.rb $APP_HOME/lib/metasploit/framework/rails_version_constraint.rb
COPY lib/msf/util/helper.rb $APP_HOME/lib/msf/util/helper.rb
2018-10-04 07:54:35 +08:00
RUN apk add --no-cache \
2017-04-22 08:10:00 +08:00
autoconf \
bison \
build-base \
ruby-dev \
2019-02-06 00:57:38 +08:00
openssl-dev \
2017-04-22 08:10:00 +08:00
readline-dev \
sqlite-dev \
postgresql-dev \
libpcap-dev \
libxml2-dev \
libxslt-dev \
yaml-dev \
zlib-dev \
ncurses-dev \
2017-07-17 22:41:47 +08:00
git \
&& echo "gem: --no-document" > /etc/gemrc \
&& gem update --system 3.0.6 \
&& bundle install --force --clean --no-cache --system $BUNDLER_ARGS \
2018-10-04 19:23:55 +08:00
# temp fix for https://github.com/bundler/bundler/issues/6680
2018-10-04 22:21:46 +08:00
&& rm -rf /usr/local/bundle/cache \
# needed so non root users can read content of the bundle
&& chmod -R a+r /usr/local/bundle
2018-10-04 07:54:35 +08:00
FROM ruby:2.6.5-alpine3.10
2018-10-04 07:54:35 +08:00
LABEL maintainer="Rapid7"
2018-10-22 04:30:01 +08:00
ENV APP_HOME=/usr/src/metasploit-framework
2018-10-04 07:54:35 +08:00
ENV NMAP_PRIVILEGED=""
2018-10-22 04:30:01 +08:00
ENV METASPLOIT_GROUP=metasploit
2018-10-04 07:54:35 +08:00
2018-10-22 04:30:01 +08:00
# used for the copy command
RUN addgroup -S $METASPLOIT_GROUP
2018-10-04 07:54:35 +08:00
RUN apk add --no-cache bash sqlite-libs nmap nmap-scripts nmap-nselibs postgresql-libs python python3 ncurses libcap su-exec
2017-04-27 16:55:03 +08:00
RUN /usr/sbin/setcap cap_net_raw,cap_net_bind_service=+eip $(which ruby)
2017-11-29 04:35:20 +08:00
RUN /usr/sbin/setcap cap_net_raw,cap_net_bind_service=+eip $(which nmap)
2017-04-27 16:55:03 +08:00
COPY --from=builder /usr/local/bundle /usr/local/bundle
RUN chown -R root:metasploit /usr/local/bundle
COPY . $APP_HOME/
RUN chown -R root:metasploit $APP_HOME/
RUN chmod 664 $APP_HOME/Gemfile.lock
2018-10-22 04:30:01 +08:00
RUN cp -f $APP_HOME/docker/database.yml $APP_HOME/config/database.yml
2018-10-04 22:21:46 +08:00
WORKDIR $APP_HOME
2018-10-22 04:30:01 +08:00
2018-02-18 03:12:35 +08:00
# we need this entrypoint to dynamically create a user
# matching the hosts UID and GID so we can mount something
# from the users home directory. If the IDs don't match
2018-10-22 04:30:01 +08:00
# it results in access denied errors.
2018-02-18 03:12:35 +08:00
ENTRYPOINT ["docker/entrypoint.sh"]
2018-10-22 04:30:01 +08:00
CMD ["./msfconsole", "-r", "docker/msfconsole.rc", "-y", "$APP_HOME/config/database.yml"]