Created
January 31, 2024 13:35
-
-
Save p4p1/e585c1c4ebe7a3ae694acb8f51642944 to your computer and use it in GitHub Desktop.
🛡️🛡️🛡️🛡️
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
#!/opt/automation/wazuh/bin/python | |
# Set environement variables | |
# This is made to work properly with a custom wazuh dashboard | |
# | |
# WAZUH_user=username | |
# WAZUG_PASSWORD=password | |
# | |
# intall command: | |
# python -m venv /folder/of/this/script | |
# ./bin/pip install selenium | |
# ./bin/python wazuh_rpi.py | |
import os | |
from selenium import webdriver | |
from selenium.webdriver.common.action_chains import ActionChains | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.chrome.service import Service | |
from selenium.webdriver.chrome.options import Options | |
import time | |
import json | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
chrome_path = "/home/p4p1/Documents/tutorials/rpi_soc/chromedriver" | |
username=os.environ["WAZUH_USER"] | |
password=os.environ["WAZUH_PASSWORD"] | |
# Start the ChromeDriver service | |
service = Service(chrome_path) | |
service.start() | |
options = Options() | |
options.add_argument('--ignore-ssl-errors=yes') | |
#options.add_argument("--start-fullscreen"); | |
options.add_argument("--kiosk"); | |
options.add_argument('--ignore-certificate-errors') | |
driver = webdriver.Chrome(service=service, options=options) | |
driver.get('https://localhost:8081/app/dashboards#/view/80032c20-bbcf-11ee-af38-b95896fe7630') | |
time.sleep(15) | |
username_xpath = '/html/body/div[1]/div/div[2]/div/div[2]/div/ul/form/div[1]/div/div/div/input' | |
username_input = driver.find_element(By.XPATH, username_xpath) | |
username_input.send_keys(username) | |
time.sleep(1) | |
password_xpath = '/html/body/div[1]/div/div[2]/div/div[2]/div/ul/form/div[2]/div/div/div/input' | |
password_input = driver.find_element(By.XPATH, password_xpath) | |
password_input.send_keys(password) | |
time.sleep(1) | |
buttonli_xpath = '/html/body/div[1]/div/div[2]/div/div[2]/div/ul/form/div[3]/div/button/span' | |
buttonli_input = driver.find_element(By.XPATH, buttonli_xpath) | |
buttonli_input.click() | |
while True: | |
#time.sleep(300) | |
# every 5 min click on the refresh button | |
time.sleep(15) | |
refresh_xpath = '/html/body/div[1]/div/div/div/div[2]/div/div/div/dashboard-app/div[1]/span/div/div[1]/div[3]/div/div/div/div/div[2]/span/button/span/span' | |
refresh_input = driver.find_element(By.XPATH, refresh_xpath) | |
refresh_input.click() | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment