()
| 33 | |
| 34 | |
| 35 | def main(): |
| 36 | try: |
| 37 | |
| 38 | try: |
| 39 | is_admin = os.getuid() == 0 |
| 40 | except AttributeError: |
| 41 | # we'll make it cross platform because it seems like a cool idea |
| 42 | is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 |
| 43 | |
| 44 | if not is_admin: |
| 45 | close("must have admin privileges to run") |
| 46 | |
| 47 | opts = AutoSploitParser().optparser() |
| 48 | |
| 49 | logo() |
| 50 | info("welcome to autosploit, give us a little bit while we configure") |
| 51 | misc_info("checking your running platform") |
| 52 | platform_running = platform.system() |
| 53 | misc_info("checking for disabled services") |
| 54 | # according to ps aux, postgre and apache2 are the names of the services on Linux systems |
| 55 | service_names = ("postgres", "apache2") |
| 56 | try: |
| 57 | for service in list(service_names): |
| 58 | while not check_services(service): |
| 59 | if "darwin" in platform_running.lower(): |
| 60 | info( |
| 61 | "seems you're on macOS, skipping service checks " |
| 62 | "(make sure that Apache2 and PostgreSQL are running)" |
| 63 | ) |
| 64 | break |
| 65 | choice = prompt( |
| 66 | "it appears that service {} is not enabled, would you like us to enable it for you[y/N]".format( |
| 67 | service.title() |
| 68 | ) |
| 69 | ) |
| 70 | if choice.lower().startswith("y"): |
| 71 | try: |
| 72 | if "linux" in platform_running.lower(): |
| 73 | cmdline("{} linux".format(START_SERVICES_PATH)) |
| 74 | else: |
| 75 | close("your platform is not supported by AutoSploit at this time", status=2) |
| 76 | |
| 77 | # moving this back because it was funky to see it each run |
| 78 | info("services started successfully") |
| 79 | # this tends to show up when trying to start the services |
| 80 | # I'm not entirely sure why, but this fixes it |
| 81 | except psutil.NoSuchProcess: |
| 82 | pass |
| 83 | else: |
| 84 | process_start_command = "`sudo service {} start`" |
| 85 | if "darwin" in platform_running.lower(): |
| 86 | process_start_command = "`brew services start {}`" |
| 87 | close( |
| 88 | "service {} is required to be started for autosploit to run successfully (you can do it manually " |
| 89 | "by using the command {}), exiting".format( |
| 90 | service.title(), process_start_command.format(service) |
| 91 | ) |
| 92 | ) |
no test coverage detected