Vulnhub靶机DC-2 writeup

135 阅读2分钟

靶机介绍

靶机介绍:https : //download.vulnhub.com/dc/DC-2.zip 在这里插入图片描述

信息搜集

  1. 获取IP地址
扫描靶机的IP的方法
1. nmap -sP 192.168.142.0/24  #nmap进行ping扫描发现存活主机
2. arp-scan -l   #基于ARP发现内网存活主机
3. netdiscover -r 192.168.142.0/24 -i eth0
参考文章:
nmap思维导图:https://mp.weixin.qq.com/s/42dNv-q7K_XcJ7cv23LNSA
arp-scan:https://blog.csdn.net/qq_41453285/article/details/100942591
          https://www.kali.org/tools/arp-scan/
netdiscover:https://blog.csdn.net/u010698107/article/details/115288643

image

  1. 扫描靶机开放端口

    使用nmap扫描:nmap -A -O -sV -p- 192.168.142.130
    使用masscan扫描:masscan -p1-65535,U:1-65535 192.168.142.130 --rate=1000
    
    masscan参考文章:https://blog.csdn.net/qq_59923059/article/details/124902967
    

    image​ 看到靶机开放了80和7744端口对应的http和ssh服务

  2. 访问http服务 image​ 发现被重定向到 http://dc-2/

  3. 修改hosts文件

    Win10hosts文件位置:C:\Windows\System32\drivers\etc\hosts
    Linux hosts文件位置:/etc/host
    
    /etc/hosts参考文章:https://www.jianshu.com/p/476a92a39b45
    

    image

  4. 重新访问http服务,得到flag1

    image拿到flag1 得到提示

    1. 这个网站是wordpress搭建的
    2. 需要使用cewl
    3. 登录之后就可以看到下一个flag 使用网站指纹识别工具whatweb扫描发现确实是WordPress
    Whatweb使用方法 https://cloud.tencent.com/developer/article/1966438?areaSource=&traceId=
    

    image

    wordpress介绍:
    https://zh.wikipedia.org/wiki/WordPress
    https://zhuanlan.zhihu.com/p/60461351
    https://www.mezgy.com/203.html
    
  5. 使用cewl生成密码字典

    cewl参考文章:https://www.freebuf.com/articles/network/190128.html
    

    image

  6. 使用wpscan 暴力枚举用户名

    wpscan参考文章:https://www.jianshu.com/p/a0143cc79215
    

    imageimage​ 得到了三个用户名分别是admin,jerry,tom

  7. 使用wpsan爆破wordpress用户名密码 imageimageimage得到两个用户名密码

    jerry / adipiscing                                                                                                                                                                
    tom / parturient  
    
  8. 使用获得的账号密码登录wordpress 使用jerry / adipiscing登录 image​ 得到flag2,提示需要找到另外一个入口

getshell

  1. 使用刚刚获得的账号密码登录ssh

    image​ 登录成功

rbash绕过

  1. 输入命令发现有rbash限制

    rbash绕过方法
    https://www.freebuf.com/articles/system/188989.html
    https://blog.csdn.net/weixin_43705814/article/details/111879362
    http://www.manongjc.com/detail/57-nifycdjdwjjbmqw.html
    

    绕过

    BASH_CMDS[a]=/bin/sh;a    #把/bin/bash给a变量
    export PATH=$PATH:/bin/      #注:将 /bin 作为PATH环境变量导出
    export PATH=$PATH:/usr/bin   #注:将 /usr/bin 作为PATH环境变量导出
    
  2. 得到flag3 ​image​ 提示要切换到jerry

提权

  1. 切换jerry用户 查看/etc/passwd文件看到有jerry用户 使用之前爆破到的密码切换到jerry用户 ​image

  2. 得到flag4 ​image

  3. 寻找root用户拥有的文件,并将错误写入/dev/null

    find / -user root -perm /4000 2>/dev/null
    

    image​ 看到拥有sudo权限 使用sudo -l 显示当前用户可以用 sudo 执行那些命令 image​ 发现可以利用sudo执行git命令

    查看提权命令网站:https://gtfobins.github.io/
    

    查看提权命令工具

image

 成功提权到root

在这里插入图片描述 得到最后一个flag 在这里插入图片描述