Exemple #1
0
    def installer(self):
        '''Install all HackerMode packages and modules'''

        # Install the basics packages:
        for PACKAGE_NAME, SETUP in PACKAGES.items():
            for COMMANDS in SETUP[System.PLATFORME]:
                os.system(COMMANDS)

        # Install the basics python3 modules:
        for MODULES in PYHTON_MODULES.keys():
            if System.PLATFORME == 'linux':
                os.system(f'sudo pip3 install {MODULES}')
            elif System.PLATFORME == 'termux':
                os.system(f'pip install {MODULES}')

        # Install tools packages:
        if Config.get('actions', 'DEBUG', default=False):
            print('# In debug mode can"t run setup.sh')
            return
        tempPath = os.getcwd()
        run = f"python3 {os.path.abspath(os.path.join(HACKERMODE_PATH, 'base/bin/run.py'))}"
        TOOLS_PATH = os.path.abspath(os.path.join(HACKERMODE_PATH, 'base/tools'))
        try:
            for tool in os.listdir(TOOLS_PATH):
                os.chdir(os.path.join(TOOLS_PATH, tool))
                if os.path.isfile('setup.sh'):
                    os.system(f'{run} setup.sh')
        finally:
            os.chdir(tempPath)
Exemple #2
0
 def update(self):
     if not Config.get('actions', 'DEBUG', cast=bool, default=False):
         os.system(
             f'cd {System.TOOL_PATH} && rm -rif {System.TOOL_NAME} && git clone https://github.com/Arab-developers/{System.TOOL_NAME}')
         tempPath = os.getcwd()
         run = f"python3 {os.path.abspath(os.path.join(HACKERMODE_PATH, 'base/bin/run.py'))}"
         TOOLS_PATH = os.path.abspath(os.path.join(HACKERMODE_PATH, 'base/tools'))
         try:
             for tool in os.listdir(TOOLS_PATH):
                 os.chdir(os.path.join(TOOLS_PATH, tool))
                 if os.path.isfile('setup.sh'):
                     os.system(f'{run} setup.sh')
         finally:
             os.chdir(tempPath)
     else:
         print("# can't update in the DEUBG mode!")
Exemple #3
0
    def install(self):
        if not System.PLATFORME in ('termux', 'linux'):
            if System.PLATFORME == 'unknown':
                print("# The tool could not recognize the system!")
                print("# Do You want to continue anyway?")
                while True:
                    if input('# [Y/N]: ').lower() == 'y':
                        break
                    else:
                        print('# good bye :D')
                        return
            else:
                print(f"# The tool does not support {System.PLATFORME}")
                print('# good bye :D')
                return

        self.installer()

        # check:
        print('\n# checking:')
        self.check()

        if System.PLATFORME == "termux":
            try:
                os.listdir("/sdcard")
            except PermissionError:
                os.system("termux-setup-storage")

        if Config.get('actions', 'IS_INSTALLED', cast=bool, default=False):
            return

        # Move the tool to "System.TOOL_PATH"
        if not all(self.InstalledSuccessfully['base']):
            print(f'# {RED}Error:{NORMAL} some of the basics package not installed!')
            return

        if Config.get('actions', 'DEBUG', cast=bool, default=True):
            print('# In DEBUG mode can"t move the tool\n# to "System.TOOL_PATH"!')
            return

        if os.path.isdir(System.TOOL_NAME):
            HackerMode = '#!/usr/bin/python3\n'
            HackerMode += 'import sys,os\n'
            HackerMode += f'path=os.path.join("{System.TOOL_PATH}","{System.TOOL_NAME}")\n'
            HackerMode += "try:os.system(f'python3 -B {path} '+' '.join(sys.argv[1:]))\n"
            HackerMode += "except:pass"
            try:
                with open(os.path.join(System.BIN_PATH, System.TOOL_NAME), 'w') as f:
                    f.write(HackerMode)
                chmod = 'chmod' if System.PLATFORME == 'termux' else 'sudo chmod'
                os.system(f'{chmod} 777 {os.path.join(System.BIN_PATH, System.TOOL_NAME)}')
            except Exception as e:
                print(e)
                print('# installed failed!')
                return
            Config.set('actions', 'IS_INSTALLED', True)
            try:
                shutil.move(System.TOOL_NAME, System.TOOL_PATH)
                print(f'# {GREEN}HackerMode installed successfully...{NORMAL}')
            except shutil.Error as e:
                print(e)
                print('# installed failed!')
        else:
            print(f'{RED}# Error: the tool path not found!')
            print(f'# try to run tool using\n# {GREEN}"python3 HackerMode install"{NORMAL}')
            print('# installed failed!')