Exemplo n.º 1
0
 def _create_mysql_monitor(self):
     monitors = self._monitor.get_template_list()
     filtered = [monitor for monitor in monitors
                 if monitor.template_name == self.MONITOR_NAME]
     if filtered:
         msg = '  - mysql_monitor already exists'
         utils.print_yellow(msg)
     else:
         # TODO(retr0h): How to upload a custom monitor.  Once uploaded
         # can configure an external template.
         msg = '  - need to upload and configure mysql_monitor'
         utils.print_red(msg)
Exemplo n.º 2
0
 def _set_time_zone(self):
     """
     TODO(retr0h): How to set the time zone.  Cannot find API docs on how
     to do this.  The current timezone can be obtained via:
       ``self._pc.System.SystemInfo.get_time_zone().time_zone``
     """
     system_info = self._pc.System.SystemInfo
     result = system_info.get_time_zone()
     if result.time_zone == 'UTC':
         msg = '  - already has UTC time'
         utils.print_yellow(msg)
     else:
         msg = '  - need to set device to UTC time'
         utils.print_red(msg)
Exemplo n.º 3
0
    def work(self):
        lat = self.fort['latitude']
        lng = self.fort['longitude']

        self.api.fort_details(fort_id=self.fort['id'],
                              latitude=lat,
                              longitude=lng)
        response_dict = self.api.call()
        if 'responses' in response_dict \
                and'FORT_DETAILS' in response_dict['responses'] \
                and 'name' in response_dict['responses']['FORT_DETAILS']:
            fort_details = response_dict['responses']['FORT_DETAILS']
            fort_name = fort_details['name'].encode('utf8', 'replace')
        else:
            fort_name = 'Unknown'
        logger.log('[#] Now at Pokestop: ' + fort_name + ' - Spinning...',
                   'yellow')
        sleep(2)
        self.api.fort_search(fort_id=self.fort['id'],
                             fort_latitude=lat,
                             fort_longitude=lng,
                             player_latitude=f2i(self.position[0]),
                             player_longitude=f2i(self.position[1]))
        response_dict = self.api.call()
        if 'responses' in response_dict and \
                'FORT_SEARCH' in response_dict['responses']:

            spin_details = response_dict['responses']['FORT_SEARCH']
            if spin_details['result'] == 1:
                logger.log("[+] Loot: ", 'green')
                experience_awarded = spin_details.get('experience_awarded',
                                                      False)
                if experience_awarded:
                    logger.log("[+] " + str(experience_awarded) + " xp",
                               'green')

                items_awarded = spin_details.get('items_awarded', False)
                if items_awarded:
                    tmp_count_items = {}
                    for item in items_awarded:
                        item_id = item['item_id']
                        if not item_id in tmp_count_items:
                            tmp_count_items[item_id] = item['item_count']
                        else:
                            tmp_count_items[item_id] += item['item_count']

                    for item_id, item_count in tmp_count_items.iteritems():
                        item_name = self.item_list[str(item_id)]

                        logger.log("[+] " + str(item_count) +
                                    "x " + item_name +
                                    " (Total: " + str(self.bot.item_inventory_count(item_id)) + ")", 'green')

                        # RECYCLING UNWANTED ITEMS
                        if str(item_id) in self.config.item_filter:
                            logger.log("[+] Recycling " + str(item_count) + "x " + item_name + "...", 'green')
                            #RECYCLE_INVENTORY_ITEM
                            response_dict_recycle = self.bot.drop_item(item_id=item_id, count=item_count)

                            if response_dict_recycle and \
                                'responses' in response_dict_recycle and \
                                'RECYCLE_INVENTORY_ITEM' in response_dict_recycle['responses'] and \
                                    'result' in response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']:
                                result = response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['result']
                            if result is 1: # Request success
                                logger.log("[+] Recycling success", 'green')
                            else:
                                logger.log("[+] Recycling failed!", 'red')
                else:
                    logger.log("[#] Nothing found.", 'yellow')

                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    logger.log('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))

                if not items_awarded and not experience_awarded and not pokestop_cooldown:
                    message = (
                        'Stopped at Pokestop and did not find experience, items '
                        'or information about the stop cooldown. You are '
                        'probably softbanned. Try to play on your phone, '
                        'if pokemons always ran away and you find nothing in '
                        'PokeStops you are indeed softbanned. Please try again '
                        'in a few hours.')
                    raise RuntimeError(message)
            elif spin_details['result'] == 2:
                logger.log("[#] Pokestop out of range")
            elif spin_details['result'] == 3:
                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    logger.log('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))
            elif spin_details['result'] == 4:
                print_red("[#] Inventory is full, switching to catch mode...")
                self.config.mode = 'poke'

            if 'chain_hack_sequence_number' in response_dict['responses'][
                    'FORT_SEARCH']:
                time.sleep(2)
                return response_dict['responses']['FORT_SEARCH'][
                    'chain_hack_sequence_number']
            else:
                print_yellow('[#] may search too often, lets have a rest')
                return 11
        sleep(8)
        return 0
    def work(self):
        lat = self.fort["latitude"]
        lng = self.fort["longitude"]
        unit = self.config.distance_unit  # Unit to use when printing formatted distance

        fortID = self.fort["id"]
        dist = distance(self.position[0], self.position[1], lat, lng)

        logger.log("[#] Found fort {} at distance {}".format(fortID, format_dist(dist, unit)))

        if dist > 0:
            logger.log("[#] Need to move closer to Pokestop")
            position = (lat, lng, 0.0)

            if self.config.walk > 0:
                self.stepper.walk_to(self.config.walk, *position)
            else:
                self.api.set_position(*position)
            self.api.player_update(latitude=lat, longitude=lng)
            logger.log("[#] Arrived at Pokestop")
            sleep(2)

        self.api.fort_details(fort_id=self.fort["id"],
                              latitude=lat,
                              longitude=lng)
        response_dict = self.api.call()
        fort_details = response_dict.get("responses", {}).get("FORT_DETAILS", {})
        fort_name = fort_details.get("name").encode("utf8", "replace")
        fort_name = fort_name if fort_name is not None else "Unknown"
        logger.log("[#] Now at Pokestop: " + fort_name + " - Spinning...",
                   "yellow")
        sleep(3)
        self.api.fort_search(fort_id=self.fort["id"],
                             fort_latitude=lat,
                             fort_longitude=lng,
                             player_latitude=f2i(self.position[0]),
                             player_longitude=f2i(self.position[1]))
        response_dict = self.api.call()
        spin_details = response_dict.get("responses", {}).get("FORT_SEARCH", {})
        spin_result = spin_details.get("result")
        if spin_result == 1:
            logger.log("[+] Loot: ", "green")
            experience_awarded = spin_details.get("experience_awarded",
                                                  False)
            if experience_awarded:
                logger.log("[+] " + str(experience_awarded) + " xp",
                           "green")

            items_awarded = spin_details.get("items_awarded", False)
            if items_awarded:
                tmp_count_items = {}
                for item in items_awarded:
                    item_id = item["item_id"]
                    if item_id not in tmp_count_items:
                        tmp_count_items[item_id] = item["item_count"]
                    else:
                        tmp_count_items[item_id] += item["item_count"]

                for item_id, item_count in tmp_count_items.iteritems():
                    item_id = str(item_id)
                    item_name = self.item_list[item_id]

                    logger.log("[+] " + str(item_count) + "x " + item_name,
                               "green")

            else:
                logger.log("[#] Nothing found.", "yellow")

            pokestop_cooldown = spin_details.get(
                "cooldown_complete_timestamp_ms")
            if pokestop_cooldown:
                seconds_since_epoch = time.time()
                logger.log("[#] PokeStop on cooldown. Time left: " + str(
                    format_time((pokestop_cooldown / 1000) -
                                seconds_since_epoch)))

            if not items_awarded and not experience_awarded and not pokestop_cooldown:
                message = (
                    "Stopped at Pokestop and did not find experience, items "
                    "or information about the stop cooldown. You are "
                    "probably softbanned. Try to play on your phone, "
                    "if pokemons always ran away and you find nothing in "
                    "PokeStops you are indeed softbanned. Please try again "
                    "in a few hours.")
                raise RuntimeError(message)
        elif spin_result == 2:
            logger.log("[#] Pokestop out of range")
        elif spin_result == 3:
            pokestop_cooldown = spin_details.get(
                "cooldown_complete_timestamp_ms")
            if pokestop_cooldown:
                seconds_since_epoch = time.time()
                logger.log("[#] PokeStop on cooldown. Time left: " + str(
                    format_time((pokestop_cooldown / 1000) -
                                seconds_since_epoch)))
        elif spin_result == 4:
            print_red("[#] Inventory is full, switching to catch mode...")
            self.config.mode = "poke"

        if "chain_hack_sequence_number" in fort_details:
            time.sleep(2)
            return fort_details[
                "chain_hack_sequence_number"]
        else:
            print_yellow("[#] may search too often, lets have a rest")
            return 11
        sleep(10)
        return 0
Exemplo n.º 5
0
    def work(self):
        lat = self.fort['latitude']
        lng = self.fort['longitude']
        unit = self.config.distance_unit  # Unit to use when printing formatted distance

        fortID = self.fort['id']
        dist = distance(self.position[0], self.position[1], lat, lng)

        # print('[#] Found fort {} at distance {}m'.format(fortID, dist))
        logger.log('[#] Found fort {} at distance {}'.format(
            fortID, format_dist(dist, unit)))

        if dist > 10:
            logger.log('[#] Need to move closer to Pokestop')
            position = (lat, lng, 0.0)

            if self.config.walk > 0:
                self.stepper._walk_to(self.config.walk, *position)
            else:
                self.api.set_position(*position)
            self.api.player_update(latitude=lat, longitude=lng)
            response_dict = self.api.call()
            logger.log('[#] Arrived at Pokestop')
            sleep(2)

        self.api.fort_details(fort_id=self.fort['id'],
                              latitude=lat,
                              longitude=lng)
        response_dict = self.api.call()
        if 'responses' in response_dict \
                and'FORT_DETAILS' in response_dict['responses'] \
                and 'name' in response_dict['responses']['FORT_DETAILS']:
            fort_details = response_dict['responses']['FORT_DETAILS']
            fort_name = fort_details['name'].encode('utf8', 'replace')
        else:
            fort_name = 'Unknown'
        logger.log('[#] Now at Pokestop: ' + fort_name + ' - Spinning...',
                   'yellow')
        sleep(2)
        self.api.fort_search(fort_id=self.fort['id'],
                             fort_latitude=lat,
                             fort_longitude=lng,
                             player_latitude=f2i(self.position[0]),
                             player_longitude=f2i(self.position[1]))
        response_dict = self.api.call()
        if 'responses' in response_dict and \
                'FORT_SEARCH' in response_dict['responses']:

            spin_details = response_dict['responses']['FORT_SEARCH']
            if spin_details['result'] == 1:
                logger.log("[+] Loot: ", 'green')
                experience_awarded = spin_details.get('experience_awarded',
                                                      False)
                if experience_awarded:
                    logger.log("[+] " + str(experience_awarded) + " xp",
                               'green')

                items_awarded = spin_details.get('items_awarded', False)
                if items_awarded:
                    tmp_count_items = {}
                    for item in items_awarded:
                        item_id = item['item_id']
                        if not item_id in tmp_count_items:
                            tmp_count_items[item_id] = item['item_count']
                        else:
                            tmp_count_items[item_id] += item['item_count']

                    for item_id, item_count in tmp_count_items.iteritems():
                        item_id = str(item_id)
                        item_name = self.item_list[item_id]

                        logger.log("[+] " + str(item_count) + "x " + item_name,
                                   'green')

                else:
                    logger.log("[#] Nothing found.", 'yellow')

                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    logger.log('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))

                if not items_awarded and not experience_awarded and not pokestop_cooldown:
                    message = (
                        'Stopped at Pokestop and did not find experience, items '
                        'or information about the stop cooldown. You are '
                        'probably softbanned. Try to play on your phone, '
                        'if pokemons always ran away and you find nothing in '
                        'PokeStops you are indeed softbanned. Please try again '
                        'in a few hours.')
                    raise RuntimeError(message)
            elif spin_details['result'] == 2:
                logger.log("[#] Pokestop out of range")
            elif spin_details['result'] == 3:
                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    logger.log('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))
            elif spin_details['result'] == 4:
                print_red("[#] Inventory is full, switching to catch mode...")
                self.config.mode = 'poke'

            if 'chain_hack_sequence_number' in response_dict['responses'][
                    'FORT_SEARCH']:
                time.sleep(2)
                return response_dict['responses']['FORT_SEARCH'][
                    'chain_hack_sequence_number']
            else:
                print_yellow('[#] may search too often, lets have a rest')
                return 11
        sleep(8)
        return 0
Exemplo n.º 6
0
    def work(self):
        lat = self.fort['latitude']
        lng = self.fort['longitude']

        self.api.fort_details(fort_id=self.fort['id'],
                              latitude=lat,
                              longitude=lng)
        response_dict = self.api.call()
        if 'responses' in response_dict \
                and'FORT_DETAILS' in response_dict['responses'] \
                and 'name' in response_dict['responses']['FORT_DETAILS']:
            fort_details = response_dict['responses']['FORT_DETAILS']
            fort_name = fort_details['name'].encode('utf8', 'replace')
        else:
            fort_name = 'Unknown'
        logger.log('[#]  Sekarang berada di  Pokestop: ' + fort_name + ' - Memutar...',
                   'yellow')
        sleep(2)
        self.api.fort_search(fort_id=self.fort['id'],
                             fort_latitude=lat,
                             fort_longitude=lng,
                             player_latitude=f2i(self.position[0]),
                             player_longitude=f2i(self.position[1]))
        response_dict = self.api.call()
        if 'responses' in response_dict and \
                'FORT_SEARCH' in response_dict['responses']:

            spin_details = response_dict['responses']['FORT_SEARCH']
            if spin_details['result'] == 1:
                logger.log("[+] Loot: ", 'green')
                experience_awarded = spin_details.get('experience_awarded',
                                                      False)
                if experience_awarded:
                    logger.log("[+] " + str(experience_awarded) + " xp",
                               'green')

                items_awarded = spin_details.get('items_awarded', False)
                if items_awarded:
                    self.config.mode = 'all'
                    tmp_count_items = {}
                    for item in items_awarded:
                        item_id = item['item_id']
                        if not item_id in tmp_count_items:
                            tmp_count_items[item_id] = item['item_count']
                        else:
                            tmp_count_items[item_id] += item['item_count']

                    for item_id, item_count in tmp_count_items.iteritems():
                        item_name = self.item_list[str(item_id)]

                        logger.log("[+] " + str(item_count) +
                                    "x " + item_name +
                                    " (Total: " + str(self.bot.item_inventory_count(item_id)) + ")", 'green')
                        
                        # RECYCLING UNWANTED ITEMS
                        if str(item_id) in self.config.item_filter:
                            logger.log("[+] Recycling " + str(item_count) + "x " + item_name + "...", 'green')
                            #RECYCLE_INVENTORY_ITEM
                            response_dict_recycle = self.bot.drop_item(item_id=item_id, count=item_count)

                            if response_dict_recycle and \
                                'responses' in response_dict_recycle and \
                                'RECYCLE_INVENTORY_ITEM' in response_dict_recycle['responses'] and \
                                    'result' in response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']:
                                result = response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['result']
                            if result is 1: # Request success
                                logger.log("[+] Recycling success", 'green')
                            else:
                                logger.log("[+] Recycling gagal!", 'red')
                else:
                    logger.log("[#] Nothing found.", 'yellow')

                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    logger.log('[#] PokeStop on cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))

                if not items_awarded and not experience_awarded and not pokestop_cooldown:
                        print_red('Masih kena softbanned')
                        self.config.mode = 'farm'
            elif spin_details['result'] == 2:
                logger.log("[#] Pokestop out of range")
            elif spin_details['result'] == 3:
                pokestop_cooldown = spin_details.get(
                    'cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    logger.log('[#] PokeStop  cooldown. Time left: ' + str(
                        format_time((pokestop_cooldown / 1000) -
                                    seconds_since_epoch)))
            elif spin_details['result'] == 4:
                print_red("[#] Inventory penuh, ke mode berburu...")
                self.config.mode = 'poke'

            if 'chain_hack_sequence_number' in response_dict['responses'][
                    'FORT_SEARCH']:
                time.sleep(2)
                return response_dict['responses']['FORT_SEARCH'][
                    'chain_hack_sequence_number']
            else:
                print_yellow('[#] Leren seek...')
                return 11
        sleep(8)
        return 0