Skip to content

Instantly share code, notes, and snippets.

@sujit
Last active February 7, 2025 21:04
Show Gist options
  • Select an option

  • Save sujit/578d577c3f5a74a9f183c92a2c18c5b5 to your computer and use it in GitHub Desktop.

Select an option

Save sujit/578d577c3f5a74a9f183c92a2c18c5b5 to your computer and use it in GitHub Desktop.

Revisions

  1. sujit revised this gist Jul 12, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions bypass_ssl_insecurities.py
    Original file line number Diff line number Diff line change
    @@ -27,11 +27,10 @@
    options.add_argument('--disable-web-security')
    options.add_argument('--disable-features=VizDisplayCompositor')
    options.add_argument('--disable-breakpad')
    options.add_argument('--acceptInsecureCerts=true')
    # Set desired capabilities to ignore SSL stuffs
    desired_capabilities = options.to_capabilities()
    # desired_capabilities['acceptSslCerts'] = True
    desired_capabilities['acceptInsecureCerts'] = True
    # desired_capabilities['acceptSslCerts'] = True

    driver = webdriver.Chrome(
    options=options,
  2. sujit revised this gist Jul 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bypass_ssl_insecurities.py
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    from selenium import webdriver
    from selenium.common.exceptions import TimeoutException
    from selenium.common.exceptions import WebDriverException
    from selenium.webdriver.common.keys import Keys
    from eliot import start_action, to_file, log_call
    # from selenium.webdriver.common.keys import Keys
    # from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    # from selenium.webdriver.common.by import By
    # from selenium.webdriver.support import expected_conditions as EC
  3. sujit created this gist Jul 12, 2019.
    72 changes: 72 additions & 0 deletions bypass_ssl_insecurities.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@
    import sys
    from time import sleep
    from selenium import webdriver
    from selenium.common.exceptions import TimeoutException
    from selenium.common.exceptions import WebDriverException
    from selenium.webdriver.common.keys import Keys
    from eliot import start_action, to_file, log_call
    # from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    # from selenium.webdriver.common.by import By
    # from selenium.webdriver.support import expected_conditions as EC
    # from selenium.webdriver.support.ui import WebDriverWait
    to_file(open("debug.log", "w")) # Eliot logs


    options = webdriver.ChromeOptions()
    # options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    options.add_argument('--mute-audio')
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--ignore-ssl-errors')
    options.add_argument('--disable-infobars')
    options.add_argument('--ignore-certificate-errors-spki-list')
    options.add_argument('--no-sandbox')
    options.add_argument('--no-zygote')
    options.add_argument('--log-level=3')
    options.add_argument('--allow-running-insecure-content')
    options.add_argument('--disable-web-security')
    options.add_argument('--disable-features=VizDisplayCompositor')
    options.add_argument('--disable-breakpad')
    options.add_argument('--acceptInsecureCerts=true')
    # Set desired capabilities to ignore SSL stuffs
    desired_capabilities = options.to_capabilities()
    # desired_capabilities['acceptSslCerts'] = True
    desired_capabilities['acceptInsecureCerts'] = True

    driver = webdriver.Chrome(
    options=options,
    service_args=["--verbose", "--log-path=chromerun.log"],
    desired_capabilities=desired_capabilities)

    driver.implicitly_wait(10)
    driver.set_page_load_timeout(5)


    @log_call
    def ignore_insecure_certs():
    ips = ['http://10.255.255.1', 'http://wikisecure.net/',
    'https://self-signed.badssl.com/', 'https://revoked.badssl.com/']
    for eachHost in ips:
    try:
    with start_action(action_type="urlOpen",
    domain=eachHost,
    drv_desired_caps=driver.desired_capabilities):
    try:
    print('\nURL:\t{}'.format(eachHost))
    driver.get(eachHost)
    sleep(3)
    if driver.title:
    print("Title:\t{}".format(driver.title))
    except TimeoutException as pyexp:
    print(pyexp)
    pass
    except WebDriverException as webdrvexcp:
    print(webdrvexcp)
    pass
    except Exception as excp:
    print(excp)
    pass


    ignore_insecure_certs()
    driver.quit()