Exploit databaseDownload repository ZIP
GH-c39b3e1887f73731b833b7d4c7196f9a
getpagespeed/php2shell-check
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
getpagespeed/php2shell-checkRevision 3f4566a2b470
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
tools/gen-rules.py
Python · 4,146 bytes#!/usr/bin/env python3
"""Generate the embedded Bash rules from the shared JSON source."""
import argparse
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
BEGIN = "# BEGIN GENERATED RULES"
END = "# END GENERATED RULES"
def ere(pattern: str) -> str:
"""Convert the supported JavaScript regex subset to Bash ERE.
Args:
pattern: JavaScript regular expression source.
Returns:
An equivalent Bash extended regular expression.
Raises:
ValueError: A construct has no supported translation.
"""
result = []
in_class = False
index = 0
while index < len(pattern):
char = pattern[index]
if char == "\\":
index += 1
escaped = pattern[index]
if escaped == "d":
result.append("0-9" if in_class else "[0-9]")
elif escaped in r".+*?()[]{}^$|\-":
result.append("\\" + escaped)
else:
raise ValueError(f"Unsupported regex escape: \\{escaped} in {pattern}")
elif char == "[":
in_class = True
result.append(char)
elif char == "]":
in_class = False
result.append(char)
else:
if char == "(" and pattern[index:index + 2] == "(?":
raise ValueError(f"Unsupported regex group: {pattern}")
if char in "*+?}" and pattern[index + 1:index + 2] == "?":
raise ValueError(f"Unsupported lazy quantifier: {pattern}")
result.append(char)
index += 1
return "".join(result)
def shell_quote(value: str) -> str:
"""Quote literal rule text without runtime shell expansion."""
for char in ("\\", '"', "$", "`"):
value = value.replace(char, "\\" + char)
return '"' + value + '"'
def generate() -> str:
"""Return deterministic shell declarations for all shared rules."""
data = json.loads((ROOT / "data/php2shell-data.json").read_text())
lines = [BEGIN, "# Generated by tools/gen-rules.py; edit data/php2shell-data.json instead."]
for name, value in (("UPDATED", data["updated"]), ("MIN_AFFECTED", data["min_affected"])):
lines.append(f"{name}={shell_quote(value)}")
lines.append("declare -A FIXED_UPSTREAM=() RULE_FIXED=() GPS_BRANCH=()")
for key, value in data["fixed_upstream"].items():
lines.append(f"FIXED_UPSTREAM[{shell_quote(key)}]={shell_quote(value)}")
fields = ("id", "vendor", "type", "name", "release", "upstream", "verdict", "mode", "note", "eol_note", "fix")
for field in fields:
lines.append(f"declare -a R_{field.upper()}=()")
for index, rule in enumerate(data["rules"]):
for field in fields:
value = rule.get(field, "")
if field in ("name", "release", "upstream"):
value = ere(value)
lines.append(f"R_{field.upper()}[{index}]={shell_quote(value)}")
for key, value in rule.get("fixed", {}).items():
lines.append(f"RULE_FIXED[{shell_quote(f'{index}|{key}')} ]={shell_quote(value)}".replace(" ]", "]"))
for key, value in rule.get("fix_by_branch", {}).items():
lines.append(f"GPS_BRANCH[{shell_quote(f'{index}|{key}')} ]={shell_quote(value)}".replace(" ]", "]"))
lines.extend([f"RULE_COUNT={len(data['rules'])}", END])
return "\n".join(lines)
def main() -> int:
"""Rewrite the embedded block or check whether it is current."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--check", action="store_true")
args = parser.parse_args()
script = ROOT / "php2shell-check.sh"
original = script.read_text()
before, rest = original.split(BEGIN, 1)
_, after = rest.split(END, 1)
updated = before + generate() + after
if args.check:
if updated != original:
print("php2shell-check.sh: embedded rules are stale")
return 1
print("Embedded rules are current.")
return 0
if updated != original:
script.write_text(updated)
return 0
if __name__ == "__main__":
raise SystemExit(main())