run msfconsole as non root user in docker

bug/bundler_fix
Christian Mehlmauer 2017-04-27 10:36:56 +02:00
parent 7a6a124272
commit e93ed889df
No known key found for this signature in database
GPG Key ID: DCF54A05D6E62591
2 changed files with 12 additions and 3 deletions

View File

@ -12,7 +12,7 @@ services:
ports: ports:
- 4444:4444 - 4444:4444
volumes: volumes:
- $HOME/.msf4:/root/.msf4 - $HOME/.msf4:/home/msf/.msf4
db: db:
image: postgres:9.6 image: postgres:9.6

View File

@ -3,6 +3,7 @@ MAINTAINER Rapid7
ARG BUNDLER_ARGS="--jobs=8 --without development test coverage" ARG BUNDLER_ARGS="--jobs=8 --without development test coverage"
ENV APP_HOME /usr/src/metasploit-framework/ ENV APP_HOME /usr/src/metasploit-framework/
ENV MSF_USER msf
WORKDIR $APP_HOME WORKDIR $APP_HOME
COPY Gemfile* m* Rakefile $APP_HOME COPY Gemfile* m* Rakefile $APP_HOME
@ -16,6 +17,7 @@ RUN apk update && \
# needed as long as metasploit-framework.gemspec contains a 'git ls' # needed as long as metasploit-framework.gemspec contains a 'git ls'
git \ git \
ncurses \ ncurses \
libcap \
&& apk add --virtual .ruby-builddeps \ && apk add --virtual .ruby-builddeps \
autoconf \ autoconf \
bison \ bison \
@ -32,12 +34,19 @@ RUN apk update && \
yaml-dev \ yaml-dev \
zlib-dev \ zlib-dev \
ncurses-dev \ ncurses-dev \
bison \
autoconf \
&& echo "gem: --no-ri --no-rdoc" > /etc/gemrc \ && echo "gem: --no-ri --no-rdoc" > /etc/gemrc \
&& bundle install --system $BUNDLER_ARGS \ && bundle install --system $BUNDLER_ARGS \
&& apk del .ruby-builddeps \ && apk del .ruby-builddeps \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*
# fix for robots gem not readable (known bug)
# https://github.com/rapid7/metasploit-framework/issues/6068
RUN chmod o+r /usr/local/bundle/gems/robots-*/lib/robots.rb
RUN adduser -g msfconsole -D $MSF_USER
USER $MSF_USER
ADD ./ $APP_HOME ADD ./ $APP_HOME
CMD ["./msfconsole", "-r", "docker/msfconsole.rc"] CMD ["./msfconsole", "-r", "docker/msfconsole.rc"]