()
| 597 | |
| 598 | |
| 599 | def main(): |
| 600 | |
| 601 | try: |
| 602 | chill() if quiet else print_banner() |
| 603 | cwd = path.dirname(path.abspath(__file__)) |
| 604 | |
| 605 | # Update utility |
| 606 | if args.update: |
| 607 | |
| 608 | updated = False |
| 609 | |
| 610 | try: |
| 611 | |
| 612 | print(f'[{INFO}] Pulling changes from the master branch...') |
| 613 | u = check_output(f'cd {cwd}&&git pull https://github.com/t3l3machus/hoaxshell main', shell=True).decode('utf-8') |
| 614 | |
| 615 | if re.search('Updating', u): |
| 616 | print(f'[{INFO}] Update completed! Please, restart hoaxshell.') |
| 617 | updated = True |
| 618 | |
| 619 | elif re.search('Already up to date', u): |
| 620 | print(f'[{INFO}] Already running the latest version!') |
| 621 | pass |
| 622 | |
| 623 | else: |
| 624 | print(f'[{FAILED}] Something went wrong. Are you running hoaxshell from your local git repository?') |
| 625 | print(f'[{DEBUG}] Consider running "git pull https://github.com/t3l3machus/hoaxshell main" inside the project\'s directory.') |
| 626 | |
| 627 | except: |
| 628 | print(f'[{FAILED}] Update failed. Consider running "git pull https://github.com/t3l3machus/hoaxshell main" inside the project\'s directory.') |
| 629 | |
| 630 | if updated: |
| 631 | sys.exit(0) |
| 632 | |
| 633 | # Provided options sanity check |
| 634 | if not args.server_ip and args.update and len(sys.argv) == 2 and not (args.localtunnel or args.ngrok): |
| 635 | sys.exit(0) |
| 636 | |
| 637 | if not args.server_ip and args.update and len(sys.argv) > 2 and not (args.localtunnel or args.ngrok): |
| 638 | exit_with_msg('Local host ip or Tunnel not provided (use -s for IP / -lt or -ng for Tunneling)') |
| 639 | |
| 640 | elif not args.server_ip and not args.update and not (args.localtunnel or args.ngrok): |
| 641 | exit_with_msg('Local host ip or Tunnel not provided (use -s for IP / -lt or -ng for Tunneling)') |
| 642 | |
| 643 | else: |
| 644 | if not args.trusted_domain and not (args.localtunnel or args.ngrok): |
| 645 | # Check if provided ip is valid |
| 646 | try: |
| 647 | ip_object = ip_address(args.server_ip) |
| 648 | |
| 649 | except ValueError: |
| 650 | exit_with_msg('IP address is not valid.') |
| 651 | |
| 652 | |
| 653 | # Check provided header name for illegal chars |
| 654 | if args.Header: |
| 655 | valid = ascii_uppercase + ascii_lowercase + '-_' |
| 656 |
no test coverage detected