Exploit databaseDownload repository ZIP
GH-70e1418b70a5811a70083de092e1d639
adzoic/php2shell-check
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files7
adzoic/php2shell-checkRevision a241de28fe9c
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
internal/probe/pool.go
Go · 4,855 bytespackage probe
import (
"bufio"
"regexp"
"strings"
)
// PoolPatterns are the usual PHP-FPM pool config locations per OS.
// FPM does not run on Windows.
func PoolPatterns(goos string) []string {
switch goos {
case "windows":
return nil
case "darwin":
return []string{
"/opt/homebrew/etc/php/*/php-fpm.d/*.conf", "/opt/homebrew/etc/php-fpm.d/*.conf",
"/usr/local/etc/php/*/php-fpm.d/*.conf", "/usr/local/etc/php-fpm.d/*.conf",
}
default:
return []string{
"/etc/php/*/fpm/pool.d/*.conf", // Debian/Ubuntu
"/etc/php-fpm.d/*.conf", // RHEL/Fedora
"/etc/php*/php-fpm.d/*.conf", // Alpine (php83/php-fpm.d)
"/usr/local/etc/php-fpm.d/*.conf", // official Docker images
"/etc/opt/remi/php*/php-fpm.d/*.conf",
"/opt/cpanel/ea-php*/root/etc/php-fpm.d/*.conf",
"/opt/plesk/php/*/etc/php-fpm.d/*.conf",
"/opt/alt/php*/etc/php-fpm.d/*.conf",
}
}
}
var poolDirectiveRe = regexp.MustCompile(`^php_(?:admin_)?(?:value|flag)\[([^\]]+)\]\s*=\s*(.*)$`)
// PoolOverrides holds php_value / php_admin_value overrides from one pool file.
type PoolOverrides struct {
File string `json:"file"`
Values map[string]string `json:"values"`
Unreadable bool `json:"unreadable,omitempty"`
}
// ParsePoolConfig extracts php_[admin_]{value,flag}[directive] = value lines.
// Later lines win, matching FPM semantics. Comments (; and #) are ignored.
func ParsePoolConfig(content string) map[string]string {
res := map[string]string{}
sc := bufio.NewScanner(strings.NewReader(content))
sc.Buffer(make([]byte, 64*1024), 1024*1024)
for sc.Scan() {
line := strings.TrimSpace(sc.Text())
if line == "" || line[0] == ';' || line[0] == '#' {
continue
}
m := poolDirectiveRe.FindStringSubmatch(line)
if m == nil {
continue
}
val := strings.TrimSpace(m[2])
if i := strings.IndexAny(val, ";#"); i >= 0 && !strings.HasPrefix(val, `"`) {
val = strings.TrimSpace(val[:i])
}
res[strings.TrimSpace(m[1])] = strings.Trim(val, `"'`)
}
return res
}
// PoolSection is one [name] section of an FPM config file and its php_*
// overrides. Lines before any section header belong to the section "".
type PoolSection struct {
Name string
Values map[string]string
}
var sectionRe = regexp.MustCompile(`^\[([^\]]+)\]$`)
// ParsePoolSections splits an FPM config file into its sections, in order.
// A name repeated within the file is one section; later lines win.
func ParsePoolSections(content string) []PoolSection {
var out []PoolSection
idx := map[string]int{}
cur := ""
var body strings.Builder
flush := func() {
vals := ParsePoolConfig(body.String())
body.Reset()
i, ok := idx[cur]
if !ok {
if cur == "" && len(vals) == 0 {
return // nothing before the first header
}
idx[cur], i = len(out), len(out)
out = append(out, PoolSection{Name: cur, Values: map[string]string{}})
}
for k, v := range vals {
out[i].Values[k] = v
}
}
for _, line := range strings.Split(content, "\n") {
if m := sectionRe.FindStringSubmatch(strings.TrimSpace(line)); m != nil {
flush()
cur = strings.TrimSpace(m[1])
continue
}
body.WriteString(line)
body.WriteByte('\n')
}
flush()
return out
}
var branchHintRe = regexp.MustCompile(`(?:php|/)(\d)\.?(\d)(?:/|[^\d])`)
// BranchHint extracts "8.3" from paths like /etc/php/8.3/fpm/pool.d/www.conf,
// /etc/opt/remi/php83/php-fpm.d or /opt/cpanel/ea-php83/... Empty if none.
func BranchHint(p string) string {
m := branchHintRe.FindStringSubmatch(p + "/")
if m == nil {
return ""
}
return m[1] + "." + m[2]
}
// PoolsFor returns the pools that belong to an FPM install of branch: pools
// whose path names that branch, plus pools whose path names no branch.
func PoolsFor(pools []PoolOverrides, branch string) []PoolOverrides {
var out []PoolOverrides
for _, p := range pools {
if h := BranchHint(p.File); h == "" || h == branch {
out = append(out, p)
}
}
return out
}
// MergePools computes a conservative effective value for directive across
// every pool: if any pool ends up with a value other than safe, that value is
// returned so a single unprotected pool is never hidden. ok=false means the
// directive is unknown in the base and not set by any pool.
func MergePools(base string, baseKnown bool, pools []PoolOverrides, directive string, isSafe func(string) bool) (string, bool) {
if len(pools) == 0 {
return base, baseKnown
}
anyUnknown := false
result := ""
for _, p := range pools {
if p.Unreadable {
anyUnknown = true
continue
}
v, set := p.Values[directive]
if !set {
if !baseKnown {
anyUnknown = true
continue
}
v = base
}
if !isSafe(v) {
return v, true
}
result = v
}
if anyUnknown {
// At least one pool's value is unknown; never report "all safe".
return "", false
}
return result, true
}