Exploit databaseDownload repository ZIP
GH-e76a3d3d0be61d55e6620c59c6a75b15
cumakurt/php2shell-scan
Sources for CVE-2026-109618
411 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
cumakurt/php2shell-scanRevision 7f4ea41c2e62
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
cmd/php2shell-scan/main.go
Go · 7,044 bytes// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 Cuma KURT <[email protected]>
//
// php2shell-scan is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version. It is distributed WITHOUT ANY WARRANTY; see the LICENSE file
// for the full text.
// Command php2shell-scan performs a bounded, read-only assessment of PHP
// targets for CVE-2026-109618 / CVE-2026-109619 exposure indicators.
package main
import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"os"
"os/signal"
"strings"
"syscall"
"php2shell-scan/internal/about"
"php2shell-scan/internal/baseline"
"php2shell-scan/internal/cli"
"php2shell-scan/internal/execprobe"
"php2shell-scan/internal/httpx"
"php2shell-scan/internal/model"
"php2shell-scan/internal/report"
"php2shell-scan/internal/scanner"
"php2shell-scan/internal/targetset"
"php2shell-scan/internal/ui"
)
// Exit codes are documented in the README.
const (
exitOK = 0
exitFindings = 1
exitUsage = 2
exitInterrupted = 3
)
func main() {
os.Exit(run(os.Args[1:], os.Stdout, os.Stderr))
}
func run(args []string, stdout, stderr io.Writer) int {
cfg, err := cli.Parse(args, stderr)
if err != nil {
if errors.Is(err, flag.ErrHelp) {
return exitOK
}
fmt.Fprintf(stderr, "error: %v\n\n", err)
cli.Usage(stderr)
return exitUsage
}
if cfg.ShowVersion {
fmt.Fprint(stdout, versionText())
return exitOK
}
console := ui.New(stdout, stderr, cfg.Color, cfg.Verbose)
console.Quiet = cfg.JSONStdout
targets, targetErrs := targetset.Parse(cfg.Targets, cfg.File)
allowed, allowErrs := targetset.FilterAllowed(targets, cfg.AllowHosts)
targets = allowed
targetErrs = append(targetErrs, allowErrs...)
// Load the baseline before scanning so a broken file fails fast.
var baseFile *baseline.File
if cfg.BaselinePath != "" {
loaded, err := baseline.Load(cfg.BaselinePath)
if err != nil {
console.Error("%v", err)
return exitUsage
}
baseFile = loaded
}
if !cfg.JSONStdout {
console.Banner(len(targets))
}
for _, e := range targetErrs {
console.Warn("%v", e)
}
if len(targets) == 0 {
console.Error("no valid targets to scan")
return exitUsage
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
s := scanner.New(scanner.Options{
Timeout: cfg.Timeout,
TargetTimeout: cfg.TargetTimeout,
Concurrency: cfg.Concurrency,
TargetWorkers: cfg.TargetWorkers,
MaxEndpoints: cfg.MaxEndpoints,
RequestsPerSecond: cfg.Rate,
Paths: cfg.Paths,
ExcludePaths: cfg.ExcludePaths,
Discover: !cfg.NoDiscover,
WAFProbe: cfg.WAFProbe,
POC: cfg.POC,
Exec: execOptions(cfg),
HTTP: httpOptions(cfg),
OnTargetStart: console.TargetStart,
TargetReport: console.TargetBlock,
Log: func(level scanner.LogLevel, format string, a ...any) {
switch level {
case scanner.LevelDetail:
console.Detail(format, a...)
case scanner.LevelWarn:
console.Warn(format, a...)
case scanner.LevelError:
console.Error(format, a...)
default:
console.Info(format, a...)
}
},
})
result := s.Scan(ctx, targets)
result.Requests = s.Requests()
result.InsecureTLS = cfg.Insecure
if suppressed := baseline.Apply(result, baseFile); suppressed > 0 {
result.BuildSummary()
if !cfg.JSONStdout {
console.Hint("baseline suppressed %d accepted finding(s)", suppressed)
}
}
if cfg.OutPrefix != "" {
jsonPath := cfg.OutPrefix + ".json"
textPath := cfg.OutPrefix + ".txt"
if err := report.WriteJSON(jsonPath, result); err != nil {
console.Error("%v", err)
}
if err := report.WriteText(textPath, result); err != nil {
console.Error("%v", err)
}
if !cfg.JSONStdout {
console.Hint("reports written: %s, %s", jsonPath, textPath)
}
}
if cfg.SARIFPath != "" {
if err := report.WriteSARIF(cfg.SARIFPath, result); err != nil {
console.Error("%v", err)
} else if !cfg.JSONStdout {
console.Hint("SARIF report written: %s", cfg.SARIFPath)
}
}
if cfg.WriteBaseline != "" {
file := baseline.Build(result, "accepted during baseline creation")
if err := baseline.Write(cfg.WriteBaseline, file); err != nil {
console.Error("%v", err)
} else if !cfg.JSONStdout {
console.Hint("baseline written: %s (%d finding(s))", cfg.WriteBaseline, len(file.Entries))
}
}
if cfg.JSONStdout {
enc := json.NewEncoder(stdout)
enc.SetIndent("", " ")
enc.SetEscapeHTML(false)
if err := enc.Encode(result); err != nil {
fmt.Fprintf(stderr, "error: encode JSON: %v\n", err)
return exitUsage
}
} else {
console.Summary(result)
console.ResultsTable(result)
}
if ctx.Err() != nil {
return exitInterrupted
}
if result.Summary.Failed > 0 || result.Summary.Partial > 0 {
return exitFindings
}
if failsThreshold(result, cfg.FailOn) {
return exitFindings
}
return exitOK
}
// severityRank orders severities from least to most severe.
var severityRank = map[model.Severity]int{
model.SeverityInfo: 1,
model.SeverityLow: 2,
model.SeverityMedium: 3,
model.SeverityHigh: 4,
model.SeverityCritical: 5,
}
// failsThreshold reports whether any unsuppressed finding meets the configured
// --fail-on severity. An empty or "none" threshold never fails the run.
func failsThreshold(r *model.Report, threshold string) bool {
if threshold == "" || threshold == "none" {
return false
}
want, ok := severityRank[model.Severity(threshold)]
if !ok {
return false
}
for _, target := range r.Targets {
for _, f := range target.Findings {
if f.Suppressed {
continue
}
if severityRank[f.Severity] >= want {
return true
}
}
}
return false
}
func execOptions(cfg *cli.Config) execprobe.Options {
return execprobe.Options{
Enabled: cfg.ExecCheck,
URLs: cfg.ExecURLs,
Param: cfg.ExecParam,
Method: cfg.ExecMethod,
OS: cfg.ExecOS,
}
}
// versionText renders the full identity block printed by --version.
func versionText() string {
return fmt.Sprintf(`%s %s
%s
Author: %s <%s>
LinkedIn: %s
Source: %s
License: %s (%s)
`,
about.Name, about.Version, about.Summary,
about.Author, about.AuthorEmail,
about.AuthorLinked,
about.Repository,
about.LicenseName, about.LicenseSPDX)
}
// httpOptions maps authentication, proxy, TLS, retry, and budget settings.
func httpOptions(cfg *cli.Config) httpx.Options {
opts := httpx.Options{
Timeout: cfg.Timeout,
MaxAttempts: cfg.Retries,
MaxRequests: cfg.MaxRequests,
ProxyURL: cfg.Proxy,
CACertFile: cfg.CACert,
InsecureSkipVerify: cfg.Insecure,
Headers: cfg.Headers,
}
if cfg.BasicAuth != "" {
user, pass, _ := strings.Cut(cfg.BasicAuth, ":")
opts.BasicAuthUser = user
opts.BasicAuthPassword = pass
}
return opts
}