渗透靶场--DC1

DC1

攻击机ip:192.168.1.164

靶机ip:192.168.1.163

目标:获取靶机上的5个flag

1.内网渗透,先利用namp扫描整个网段

image-20210123233624521

目标机为192.168.1.163

2.继续nmap嗅探端口信息,。

/1

开放了22/80/111/56771端口

3.那就访问80端口

image-20210124001251795

是一个网站

image-20210124002202206

CMS为Drupal

4.使用dirseach扫描网站目录,扫出了一个robots.txt

#
# robots.txt
#
# This file is to prevent the crawling and indexing of certain parts
# of your site by web crawlers and spiders run by sites like Yahoo!
# and Google. By telling these "robots" where not to go on your site,
# you save bandwidth and server resources.
#
# This file will be ignored unless it is at the root of your host:
# Used:    http://example.com/robots.txt
# Ignored: http://example.com/site/robots.txt
#
# For more information about the robots.txt standard, see:
# http://www.robotstxt.org/wc/robots.html
#
# For syntax checking, see:
# http://www.sxw.org.uk/computing/robots/check.html

User-agent: *
Crawl-delay: 10
# Directories
Disallow: /includes/
Disallow: /misc/
Disallow: /modules/
Disallow: /profiles/
Disallow: /scripts/
Disallow: /themes/
# Files
Disallow: /CHANGELOG.txt
Disallow: /cron.php
Disallow: /INSTALL.mysql.txt
Disallow: /INSTALL.pgsql.txt
Disallow: /INSTALL.sqlite.txt
Disallow: /install.php
Disallow: /INSTALL.txt
Disallow: /LICENSE.txt
Disallow: /MAINTAINERS.txt
Disallow: /update.php
Disallow: /UPGRADE.txt
Disallow: /xmlrpc.php
# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips/
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
Disallow: /?q=admin/
Disallow: /?q=comment/reply/
Disallow: /?q=filter/tips/
Disallow: /?q=node/add/
Disallow: /?q=search/
Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/

没有什么敏感目录/文件

5.转变方向,利用msf寻找一下是否有可用的漏洞。

image-20210124005112573

这里第四个Drupalgeddon2漏洞(CVE-2018-7600)可以成功利用。

对于默认或常见的Drupal安装来说,该漏洞允许攻击者在未经身份验证的情况下远程执行代码。

引起该漏洞的根本原因,是由于Drupal对Form API(FAPI)的AJAX请求的输入没有进行严格过滤,使得攻击者有机会将恶意荷载注入内部表单结构,从而导致Drupal在没有进行用户认证的情况下执行恶意荷载。利用该漏洞,攻击者可以接管整个网站。

6.查看参数,只有PHOSTS是需要设置的

image-20210124005708102

设置PHOSTS后直接执行

注意:这里要lport是防火墙(uwf)所允许的

image-20210124012121710

执行获得session

image-20210124012104528

7.再利用 python的一个脚本反弹shell

image-20210124012310810

得到第一个flag

image-20210124012333007

提示为每一个好的CMS都需要一个配置文件-你也是。也就是配置文件

8.百度查询drupal的默认配置文件,/sites/default/settings.php,通过shell查询

注意:要在文件前加/var/www目录

image-20210124095046884

得到flag2:暴力和字典攻击并不是获得访问权限的唯一方法(而且您需要访问权限)。你能用这些权限做什么?

和drupaldb数据库的用户名和密码

9.进入mysql,先查询库

image-20210124095316532

10.选择目标数据库,查询所有表,查询user表所有字段

use drupaldb
show tables;
select * from users;

image-20210124101528379

但是admin用户的密码显然是经过加密的

drupal不同版本对于口令(密码)加密采用的是不同算法:

drupal 5、6都是用MD5加密的,而从drupal7以后用的是SHA-512(SHA2);基本上不可解

11.接下来可以有三个方法去得到访问权限

  1. 重置admin密码,既然我们有读写/var/www下文件权限,又有数据库修改权限

    • 首先要找到drupal7默认的进入页面index.PHP,修改成如下形式,注意,加入的三句
      require_once 'includes/password.inc';
      echo user_hash_password('加密字符')[这里用123456];
      die();
      
      必须放在drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL)之后,这句话的意思就是获得函数的访问权限,如果放在前面很多函数式找不到的。
      再次访问得到$S$DzOu3nRfBMcOuMw7JP5EpXh5f.595KOADPHbZMUOTD4ZosZm3T6W
      
      • 再去连接数据库修改密码为得到的哈希值

    image-20210124104320351

    这样就可以通过admin,123456登录了

    注意:Drupal有自己对数据库的加密方法,加密脚本位置在网站根目录下的scripts下

    所以也可以调用 /var/www/scripts/password-hash.sh 生成一个密码的hashcode,然后去更改密码表即可

    image-20210124104911032

  2. 直接找到网站用户验证登录的代码,进行修改后,随意登录

    /var/www/下所有文件都具有写权限,位于/includes/password.inc文件的function user_check_password($password, $account)函数中,讲255行和257行进行修改,即密码无论输入什么都返回true。

    image-20210124105542681

    再用admin/随意密码 即可登录

  3. 添加一个管理员权限的用户

由于是一个登录页面,可以去查询是否有sql注入的利用

image-20210124113807363

需要版本<7.31

查询/var/www/moodules/system/system.info可以知道版本号为7.24

image-20210124114338341

先利用searchsploit -p 获取py路径

image-20210124115604076

了解需要的参数

image-20210124115632556

执行成功

image-20210124115703130

image-20210124115730327

再去用ly/123456登录

12.登录成功后在content中找到了flag3

特殊PERMS将有助于找到密码-但你需要-执行该命令,以解决如何得到什么在阴影中。

命令执行

image-20210124115830593

13.去查询/etc/passwd

文件内容=注册名:口令:用户标识号:组标识号:用户名:用户主目录:命令解释程序

image-20210124120838682

找到了flag4用户,他的用户目录为/home/flag4

14.访问得到flag4

image-20210124120936892

是否可以使用相同的方法在根目录中查找或访问标志?

可能。但也许没那么容易。或者可能是?

15.尝试访问/root

image-20210124133425642

可以看到权限不够

16.find / -perm -u=s -type f 2>/dev/null

查看具有root用户权限的SUID文件

/表示从文件系统的顶部(根)开始并找到每个目录
-perm 表示搜索随后的权限
-u = s表示查找root用户拥有的文件
-type表示我们正在寻找的文件类型 f 表示常规文件,而不是目录或特殊文件 2表示该进程的第二个文件描述符,即stderr(标准错误)
>表示重定向
/ dev / null是一个特殊的文件系统对象,它将丢弃写入其中的所有内容。

image-20210124134312933

可以看到find有suid权限

17.利用find提权到 root 用户权限

先查看其信息,发现其确实是root用户权限的SUID的文件

image-20210124134527164

先看一下是否能用find命令以root权限运行

find flag1.txt -exec “whoami” ;

所有通过find执行的命令都是root权限,那么使用find -exec生成一个具有root权限的shell

find -exec ‘/bin/sh’ ;

得到最后的flag,Well done!!!

0.0也可以用find -exec去执行netcat开放端口,然后再去连接也是root权限

image-20210124135542623

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值