0

I'm trying to use the Docker metasploit image within my own Dockerfile config which is this one:

FROM metasploitframework/metasploit-framework

WORKDIR /usr/src/my-awesome-tool

COPY . .

RUN pip3 install --upgrade pip
RUN pip3 install --editable .

RUN echo 'alias msfconsole="/usr/src/metasploit-framework/msfconsole"' >> ~/.bashrc
RUN echo 'alias msfvenom=/usr/src/metasploit-framework/msfvenom"' >> ~/.bashrc

# The metasploit-framework docker image needs to stay here.
WORKDIR /usr/src/metasploit-framework

ENTRYPOINT ["my-awesome-tool"]

The image is created perfectly with sudo docker build -t my-awesome-tool . and I run it as sudo docker run -it --rm --privileged --network=host my-awesome-tool but, if I check if the alias msfconsole was created, it was not.

Andrés Montoya
  • 4,079
  • 4
  • 18
  • 33

1 Answers1

1

First you should add your user to the docker group instead of using sudo all the time.

Apparently the image does change the entrypoint. The .bashrc file gets written to root which we can't access at runtime and we are a different user when running compared to while building. I tried writing the alaises to /etc/profile but that is not picked up. Without changing the entrypoint of the image the simplest solution is probably something similar to this:

RUN echo "alias msfconsole='/usr/src/metasploit-framework/msfconsole'" >>/usr/src/metasploit-framework/.profile
RUN echo "alias msfvenom='/usr/src/metasploit-framework/msfvenom'" >>/usr/src/metasploit-framework/.profile

and running . .profile on startup.

SuperSandro2000
  • 581
  • 10
  • 20