Repository navigation
Expand file tree
/
Copy pathuser.py
More file actions
53 lines (48 loc) · 2.24 KB
/
Copy pathuser.py
File metadata and controls
53 lines (48 loc) · 2.24 KB
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
import re
import random
import string
import time
from playwright.sync_api import Playwright, sync_playwright, expect
from basic import *
target = call_target()
username, password = call_credentials()
def generate_username():
characters = string.ascii_letters + string.digits + '._-'
username = ''.join(random.choice(characters) for _ in range(random.randint(5, 32)))
return username
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context(no_viewport=True)
page = context.new_page()
page.goto(f"{target}/wp-login.php")
page.get_by_label("Username or Email Address").click()
page.get_by_label("Username or Email Address").fill(username)
page.get_by_label("Password", exact=True).click()
page.get_by_label("Password", exact=True).fill(password)
page.get_by_role("button", name="Log In").click()
page.goto(f"{target}/wp-admin/user-new.php")
page.get_by_label("Username (required)").click()
page.get_by_label("Username (required)").fill(generate_username())
#page.get_by_label("Username (required)").press("Tab")
page.get_by_label("Email (required)").click()
page.get_by_label("Email (required)").fill(f"{generate_username()}@wp.local")
page.get_by_label("First Name").click()
page.get_by_label("First Name").fill(f"first_{generate_username()}")
page.get_by_label("Last Name").click()
page.get_by_label("Last Name").fill(f"last_{generate_username()}")
page.get_by_label("Website").click()
page.get_by_label("Website").fill("https://example.com/")
page.get_by_label("Password (required)", exact=True).click()
page.get_by_label("Password (required)", exact=True).press("ArrowRight")
page.get_by_label("Password (required)", exact=True).fill("password")
page.locator("td").filter(has_text="Confirm use of weak password").click()
page.get_by_label("Confirm use of weak password").check()
page.get_by_label("Send the new user an email").uncheck()
page.get_by_label("Role").select_option("administrator")
page.get_by_role("button", name="Add New User").click()
time.sleep(5)
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)