Files
metasploit-gs/Dockerfile
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

103 lines
3.2 KiB
Docker
Raw Normal View History

2025-05-20 10:26:46 +01:00
FROM ruby:3.3.8-alpine3.21 AS builder
2017-11-28 21:35:20 +01:00
LABEL maintainer="Rapid7"
ARG BUNDLER_CONFIG_ARGS="set force_ruby_platform 'true' set no-cache 'true' set system 'true' set without 'development test coverage'"
ARG BUNDLER_FORCE_CLEAN="true"
2018-10-21 22:30:01 +02:00
ENV APP_HOME=/usr/src/metasploit-framework
2021-03-08 17:33:32 -06:00
ENV TOOLS_HOME=/usr/src/tools
2017-11-28 21:35:20 +01:00
ENV BUNDLE_IGNORE_MESSAGES="true"
WORKDIR $APP_HOME
2018-10-21 22:30:01 +02:00
COPY Gemfile* metasploit-framework.gemspec Rakefile $APP_HOME/
2017-11-28 21:35:20 +01: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 01:54:35 +02:00
RUN apk add --no-cache \
2017-04-22 02:10:00 +02:00
autoconf \
2021-03-08 17:33:32 -06:00
bash \
2017-04-22 02:10:00 +02:00
bison \
build-base \
2021-03-08 17:33:32 -06:00
curl \
2017-04-22 02:10:00 +02:00
ruby-dev \
2019-02-05 17:57:38 +01:00
openssl-dev \
2017-04-22 02:10:00 +02:00
readline-dev \
sqlite-dev \
postgresql-dev \
2025-05-20 10:26:46 +01:00
libffi-dev \
2017-04-22 02:10:00 +02:00
libpcap-dev \
libxml2-dev \
libxslt-dev \
yaml-dev \
zlib-dev \
ncurses-dev \
2017-07-17 09:41:47 -05:00
git \
2023-12-08 16:43:40 +02:00
go \
2019-12-16 10:05:07 -06:00
&& echo "gem: --no-document" > /etc/gemrc \
2020-10-02 12:56:38 -05:00
&& gem update --system \
&& bundle config $BUNDLER_CONFIG_ARGS \
2020-10-20 10:38:08 -05:00
&& bundle install --jobs=8 \
&& if [ "${BUNDLER_FORCE_CLEAN}" == "true" ]; then \
bundle clean --force; \
fi \
2018-10-04 13:23:55 +02:00
# temp fix for https://github.com/bundler/bundler/issues/6680
2018-10-04 16:21:46 +02: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
ENV GO111MODULE=off
2021-03-08 17:33:32 -06:00
RUN mkdir -p $TOOLS_HOME/bin && \
cd $TOOLS_HOME/bin && \
2025-05-20 10:26:46 +01:00
curl -O https://dl.google.com/go/go1.24.0.src.tar.gz && \
tar -zxf go1.24.0.src.tar.gz && \
rm go1.24.0.src.tar.gz && \
2021-03-08 17:33:32 -06:00
cd go/src && \
./make.bash
2018-10-04 01:54:35 +02:00
2025-05-20 10:26:46 +01:00
FROM ruby:3.3.8-alpine3.21
2018-10-04 01:54:35 +02:00
LABEL maintainer="Rapid7"
2023-12-08 16:43:40 +02:00
ARG TARGETARCH
2018-10-04 01:54:35 +02:00
2018-10-21 22:30:01 +02:00
ENV APP_HOME=/usr/src/metasploit-framework
2021-03-08 17:33:32 -06:00
ENV TOOLS_HOME=/usr/src/tools
2018-10-04 01:54:35 +02:00
ENV NMAP_PRIVILEGED=""
2018-10-21 22:30:01 +02:00
ENV METASPLOIT_GROUP=metasploit
2018-10-04 01:54:35 +02:00
2018-10-21 22:30:01 +02:00
# used for the copy command
RUN addgroup -S $METASPLOIT_GROUP
2018-10-04 01:54:35 +02:00
2024-10-18 21:33:02 +01:00
RUN apk add --no-cache curl bash sqlite-libs nmap nmap-scripts nmap-nselibs \
postgresql-libs python3 py3-pip py3-impacket py3-requests ncurses libcap su-exec alpine-sdk \
2023-12-08 16:43:40 +02:00
openssl-dev nasm
RUN\
if [ "${TARGETARCH}" = "arm64" ];\
then apk add --no-cache gcc musl-dev python3-dev libffi-dev gcompat;\
else apk add --no-cache mingw-w64-gcc;\
fi
2017-04-27 10:55:03 +02:00
RUN /usr/sbin/setcap cap_net_raw,cap_net_bind_service=+eip $(which ruby)
2017-11-28 21:35:20 +01:00
RUN /usr/sbin/setcap cap_net_raw,cap_net_bind_service=+eip $(which nmap)
2017-04-27 10:55:03 +02:00
COPY --from=builder /usr/local/bundle /usr/local/bundle
RUN chown -R root:metasploit /usr/local/bundle
COPY . $APP_HOME/
2021-03-08 17:33:32 -06:00
COPY --from=builder $TOOLS_HOME $TOOLS_HOME
RUN chown -R root:metasploit $APP_HOME/
2019-09-09 12:59:19 +02:00
RUN chmod 664 $APP_HOME/Gemfile.lock
RUN gem update --system
2018-10-21 22:30:01 +02:00
RUN cp -f $APP_HOME/docker/database.yml $APP_HOME/config/database.yml
2021-03-08 17:33:32 -06:00
ENV GOPATH=$TOOLS_HOME/go
ENV GOROOT=$TOOLS_HOME/bin/go
ENV PATH=${PATH}:${GOPATH}/bin:${GOROOT}/bin
2018-10-21 22:30:01 +02:00
2018-10-04 16:21:46 +02:00
WORKDIR $APP_HOME
2018-10-21 22:30:01 +02:00
2018-02-17 20:12:35 +01: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-21 22:30:01 +02:00
# it results in access denied errors.
2018-02-17 20:12:35 +01:00
ENTRYPOINT ["docker/entrypoint.sh"]
2018-10-21 22:30:01 +02:00
CMD ["./msfconsole", "-r", "docker/msfconsole.rc", "-y", "$APP_HOME/config/database.yml"]