Skip to content

Commit

Permalink
Update to v1.3.1.3
Browse files Browse the repository at this point in the history
1. The system of processing command line arguments has been completely rewritten.
Now it is possible to specify not only boolean arguments but also with data

2. Added command line argument --custom-browser-location
Read more here: https://github.com/rzc0d3r/ESET-KeyGen/blob/main/wiki/CommandLineArguments.md
  • Loading branch information
rzc0d3r committed Feb 22, 2024
1 parent 29a44b9 commit fa7820b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
34 changes: 23 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LOGO = """
███████╗███████╗███████╗████████╗ ██╗ ██╗███████╗██╗ ██╗ ██████╗ ███████╗███╗ ██╗
██╔════╝██╔════╝██╔════╝╚══██╔══╝ ██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔════╝ ██╔════╝████╗ ██║
█████╗ ███████╗█████╗ ██║ █████╔╝ █████╗ ╚████╔╝ ██║ ███╗█████╗ ██╔██╗ ██║
███████╗███████╗███████╗████████╗ ██╗ ██╗███████╗██╗ ██╗ ██████╗ ███████╗███╗ ██╗
██╔════╝██╔════╝██╔════╝╚══██╔══╝ ██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔════╝ ██╔════╝████╗ ██║
█████╗ ███████╗█████╗ ██║ █████╔╝ █████╗ ╚████╔╝ ██║ ███╗█████╗ ██╔██╗ ██║
██╔══╝ ╚════██║██╔══╝ ██║ ██╔═██╗ ██╔══╝ ╚██╔╝ ██║ ██║██╔══╝ ██║╚██╗██║
███████╗███████║███████╗ ██║ ██║ ██╗███████╗ ██║ ╚██████╔╝███████╗██║ ╚████║
╚══════╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝
Expand All @@ -23,6 +23,7 @@
import traceback
import platform
import datetime
import argparse
import sys
import os

Expand Down Expand Up @@ -93,31 +94,42 @@ def webdriver_installer_menu(edge=False): # auto updating or installing google c

if __name__ == '__main__':
logger.console_log(LOGO)
args_parser = argparse.ArgumentParser()
args_parser.add_argument('--account', action='store_true')
args_parser.add_argument('--force', action='store_true')
args_parser.add_argument('--cli', action='store_true')
args_parser.add_argument('--firefox', action='store_true')
args_parser.add_argument('--edge', action='store_true')
args_parser.add_argument('--no-headless', action='store_true')
args_parser.add_argument('--skip-webdriver-menu', action='store_true')
args_parser.add_argument('--only-update', action='store_true')
args_parser.add_argument('--custom-browser-location', type=str, default='')
try:
# Init
if platform.release() == '7' and webdriver_installer.get_platform()[0] == 'win': # fix for Windows 7
sys.argv.append('--no-headless')
if '--cli' in sys.argv:
sys.argv.append('--force')
args = vars(args_parser.parse_args())
driver = None
webdriver_path = None
browser_name = 'chrome'
if '--firefox' in sys.argv:
if args['firefox']:
browser_name = 'firefox'
if '--edge' in sys.argv:
if args['edge']:
browser_name = 'edge'
if '--skip-webdriver-menu' not in sys.argv and browser_name != 'firefox':
webdriver_path = webdriver_installer_menu('--edge' in sys.argv)
if not args['skip_webdriver_menu'] and browser_name != 'firefox':
webdriver_path = webdriver_installer_menu(args['edge'])
if webdriver_path is not None:
os.chmod(webdriver_path, 0o777)
driver = shared_tools.initSeleniumWebDriver(browser_name, webdriver_path, headless=('--no-headless' not in sys.argv))
if '--only-update' in sys.argv:
if '--cli' not in sys.argv:
driver = shared_tools.initSeleniumWebDriver(browser_name, webdriver_path, browser_path=args['custom_browser_location'], headless=(not args['no_headless']))
if args['only_update']:
if not args['cli']:
print('Press Enter...')
sys.exit(0)
# Work
only_account = False
if '--account' in sys.argv:
if args['account']:
logger.console_log('\n-- Account Generator --\n')
only_account = True
else:
Expand Down
7 changes: 5 additions & 2 deletions modules/shared_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ def untilConditionExecute(chrome_driver_obj: Chrome, js: str, delay=DEFAULT_DELA
def createPassword(length):
return ''.join(['Xx0$']+[random.choice(string.ascii_letters) for _ in range(length)])

def initSeleniumWebDriver(browser_name: str, webdriver_path = None, headless=True):
def initSeleniumWebDriver(browser_name: str, webdriver_path = None, browser_path = '', headless=True):
driver_options = None
driver = None
if browser_name.lower() == 'chrome':
driver_options = ChromeOptions()
driver_options.binary_location = browser_path
driver_options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver_options.add_argument("--log-level=3")
driver_options.add_argument("--lang=en-US")
Expand All @@ -86,6 +87,7 @@ def initSeleniumWebDriver(browser_name: str, webdriver_path = None, headless=Tru
driver = Chrome(options=driver_options, service=driver_service)
elif browser_name.lower() == 'firefox':
driver_options = FirefoxOptions()
driver_options.binary_location = browser_path
driver_service = FirefoxService(executable_path=webdriver_path)
driver_options.set_preference('intl.accept_languages', 'en-US')
if headless:
Expand All @@ -99,10 +101,11 @@ def initSeleniumWebDriver(browser_name: str, webdriver_path = None, headless=Tru
driver_options.add_argument("--disable-dev-shm-usage")
else:
console_log('Initializing firefox-webdriver for Windows', INFO)
driver = Firefox(options=driver_options, service=driver_service)
driver = Firefox(options=driver_options, service=driver_service,)
elif browser_name.lower() == 'edge':
driver_options = EdgeOptions()
driver_options.use_chromium = True
driver_options.binary_location = browser_path
driver_options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver_options.add_argument("--log-level=3")
driver_options.add_argument("--lang=en-US")
Expand Down

0 comments on commit fa7820b

Please sign in to comment.