Exploit databaseDownload repository ZIP
GH-e76a3d3d0be61d55e6620c59c6a75b15
cumakurt/php2shell-scan
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
cumakurt/php2shell-scanRevision 7f4ea41c2e62
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
internal/stack/stack_test.go
Go · 4,960 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.
package stack
import (
"net/http"
"strings"
"testing"
"php2shell-scan/internal/httpx"
"php2shell-scan/internal/model"
)
func response(headers map[string]string, cookies []string, body string) *httpx.Response {
h := http.Header{}
for k, v := range headers {
h.Set(k, v)
}
for _, c := range cookies {
h.Add("Set-Cookie", c)
}
return &httpx.Response{Status: 200, Header: h, Body: []byte(body)}
}
func item(s *model.TechStack, name string) model.TechItem {
for _, i := range s.Items {
if i.Name == name {
return i
}
}
return model.TechItem{}
}
func TestServerAndVersion(t *testing.T) {
s := Detect(response(map[string]string{
"Server": "nginx/1.24.0",
"X-Powered-By": "PHP/8.4.26",
}, nil, "<html></html>"))
if s.Server != "nginx" || s.ServerVersion != "1.24.0" {
t.Fatalf("unexpected server: %q %q", s.Server, s.ServerVersion)
}
if s.Runtime != "PHP" {
t.Errorf("unexpected runtime: %s", s.Runtime)
}
php := item(s, "PHP")
if php.Version != "8.4.26" || php.Confidence != model.ConfidenceMedium {
t.Errorf("unexpected PHP item: %+v", php)
}
if len(php.Evidence) == 0 {
t.Error("PHP detection must record its evidence")
}
}
func TestApacheVersionFromBanner(t *testing.T) {
s := Detect(response(map[string]string{"Server": "Apache/2.4.69 (Debian)"}, nil, ""))
if s.Server != "Apache HTTP Server" {
t.Fatalf("unexpected server name: %q", s.Server)
}
if s.ServerVersion != "2.4.69" {
t.Errorf("unexpected server version: %q", s.ServerVersion)
}
}
func TestIISAndASPNet(t *testing.T) {
s := Detect(response(map[string]string{
"Server": "Microsoft-IIS/10.0",
"X-AspNet-Version": "4.0.30319",
}, []string{"ASP.NET_SessionId=abc"}, ""))
if s.Server != "Microsoft IIS" || s.ServerVersion != "10.0" {
t.Errorf("unexpected server: %q %q", s.Server, s.ServerVersion)
}
if item(s, "ASP.NET").Version != "4.0.30319" {
t.Errorf("expected ASP.NET version from its own header: %+v", item(s, "ASP.NET"))
}
}
func TestCDNDetection(t *testing.T) {
s := Detect(response(map[string]string{"cf-ray": "8a1b2c3d", "Server": "cloudflare"}, nil, ""))
cdn := item(s, "Cloudflare")
if cdn.Category != "cdn" || cdn.Confidence != model.ConfidenceHigh {
t.Fatalf("unexpected CDN item: %+v", cdn)
}
}
func TestCMSAndGenerator(t *testing.T) {
body := `<html><head><meta name="generator" content="WordPress 6.4.3">` +
`<link rel="stylesheet" href="/wp-content/themes/x/style.css"></head></html>`
s := Detect(response(nil, nil, body))
wp := item(s, "WordPress")
if wp.Name == "" {
t.Fatalf("expected WordPress, got %+v", s.Items)
}
if wp.Version != "6.4.3" {
t.Errorf("expected generator version, got %q", wp.Version)
}
}
func TestBodyOnlyMatchIsLowConfidence(t *testing.T) {
s := Detect(response(nil, nil, `<script src="/js/jquery.min.js"></script>`))
jq := item(s, "jQuery")
if jq.Category != "library" {
t.Fatalf("expected jQuery, got %+v", s.Items)
}
if jq.Confidence != model.ConfidenceLow {
t.Errorf("single generic marker must be low confidence, got %s", jq.Confidence)
}
}
func TestNoEvidenceIsReported(t *testing.T) {
s := Detect(response(nil, nil, "plain text"))
if len(s.Items) != 0 {
t.Fatalf("expected no items, got %+v", s.Items)
}
if len(s.Limitations) == 0 {
t.Error("empty detection must explain itself")
}
if got := Summary(s); got != "not identified" {
t.Errorf("Summary() = %q", got)
}
}
func TestDuplicateItemsAreMerged(t *testing.T) {
s := Detect(response(map[string]string{
"X-Powered-By": "PHP/8.4.26",
}, []string{"PHPSESSID=abc"}, ""))
count := 0
for _, i := range s.Items {
if i.Name == "PHP" {
count++
}
}
if count != 1 {
t.Fatalf("expected one merged PHP item, got %d (%+v)", count, s.Items)
}
php := item(s, "PHP")
if php.Confidence != model.ConfidenceMedium {
t.Errorf("merged item should keep the strongest confidence, got %s", php.Confidence)
}
if len(php.Evidence) < 2 {
t.Errorf("merged item should keep both evidence lines: %v", php.Evidence)
}
}
func TestSummaryOrdering(t *testing.T) {
s := Detect(response(map[string]string{
"Server": "nginx/1.25.3",
"X-Powered-By": "PHP/8.3.10",
"cf-ray": "x",
}, nil, "/wp-content/"))
got := Summary(s)
if !strings.HasPrefix(got, "nginx 1.25.3") {
t.Errorf("summary should start with the server, got %q", got)
}
if !strings.Contains(got, "PHP 8.3.10") || !strings.Contains(got, "WordPress") || !strings.Contains(got, "Cloudflare") {
t.Errorf("summary missing components: %q", got)
}
}