コード例 #1
0
    def get_any_active(self):
        tokens = self.get_all_active()
        if tokens:
            return tokens[0]

        Log.error("No valid token detected. Script will crash")
        return {}
コード例 #2
0
ファイル: getcontact.py プロジェクト: mrpelancong/getcontact
    def get_information_by_phone(self, phone):
        Log.d("Call get_information_by_phone with phone ", phone)
        result_name = self.get_name_by_phone(phone)
        result_tags = self.get_tags_by_phone(phone)

        self.update_config()

        return dict(**result_name, **result_tags)
コード例 #3
0
ファイル: getcontact.py プロジェクト: mrpelancong/getcontact
    def get_tags_by_phone(self, phoneNumber):
        Log.d("Call get_tags_by_phone with phoneNumber ", phoneNumber)
        response = self.requester.get_phone_tags(phoneNumber)
        if response:
            result = {
                "tags": [tag["tag"] for tag in response["result"]["tags"]]
            }
            return result

        return {"tags": []}
コード例 #4
0
ファイル: requester.py プロジェクト: mrpelancong/getcontact
    def repeat_last_task(self):
        function = self.current_task["function"]
        phone = self.current_task["phone"]

        if function == "get_phone_name":
            return self.get_phone_name(phone)
        if function == "get_phone_tags":
            return self.get_phone_tags(phone)

        Log.error("Incorrect task for repeat")
        return None
コード例 #5
0
ファイル: getcontact.py プロジェクト: f14a2cd/getcontact
    def get_name_by_phone(self, phoneNumber):
        Log.d("Call get_name_by_phone with phoneNumber ", phoneNumber)
        response = self.requester.get_phone_name(phoneNumber)
        if response:
            name = response["result"]["profile"]["name"]
            surname = response["result"]["profile"]["surname"]
            if not name and not surname:
                user_name = None
            else:
                user_name = f"{parse_none(name)} {parse_none(surname)}"

            country_code = response["result"]["profile"]["countryCode"]
            country = response["result"]["profile"]["country"]

            if not country:
                country_name = f"{parse_none(country_code)}"
            else:
                country_name = f"{country} {parse_none(country_code)}"

            result = {
                "name":
                user_name,
                "phoneNumber":
                response["result"]["profile"]["phoneNumber"],
                "country":
                country_name,
                "displayName":
                response["result"]["profile"]["displayName"],
                "profileImage":
                response["result"]["profile"]["profileImage"],
                "email":
                response["result"]["profile"]["email"],
                "is_spam":
                True if response["result"]["spamInfo"]["degree"] == "high" else
                False,
            }

            remain_count = response["result"]["subscriptionInfo"]["usage"][
                "search"]["remainingCount"]
            self.updater.update_remain_count_by_token(config.TOKEN,
                                                      remain_count)

            return result
        else:
            return {
                "name": None,
                "phoneNumber": phoneNumber,
                "country": config.COUNTRY,
                "displayName": "Not Found",
                "profileImage": None,
                "email": None,
                "is_spam": False,
            }
コード例 #6
0
ファイル: getcontact.py プロジェクト: mrpelancong/getcontact
 def _print_beauty_output(self, data):
     Log.d("Call _print_beauty_output with data ", data)
     print("Phone:", data["phoneNumber"])
     print("User:"******"displayName"])
     if "tags" in data.keys() and data["tags"]:
         print("Tag list: ")
         for tag in data["tags"]:
             print(
                 "\t",
                 tag.encode("utf-8",
                            errors="replace").decode("utf-8",
                                                     errors="replace"),
             )
コード例 #7
0
ファイル: getcontact.py プロジェクト: mrpelancong/getcontact
 def get_from_file(self, file):
     Log.d("Call get_from_file with file ", file)
     with open(file, "r") as f:
         phones = f.read().split("\n")
     for phone in phones:
         self.print_information_by_phone(phone)
コード例 #8
0
ファイル: getcontact.py プロジェクト: mrpelancong/getcontact
 def print_information_by_phone(self, phone):
     Log.d("Call print_information_by_phone with phone ", phone)
     data = self.get_information_by_phone(phone)
     self._print_beauty_output(data)
コード例 #9
0
ファイル: getcontact.py プロジェクト: mrpelancong/getcontact
 def get_name_by_phone_with_change_token(self, phone):
     Log.d("Call get_name_by_phone_with_change_token with phone ", phone)
     result = self.get_name_by_phone(phone)
     self.update_config()
     return result
コード例 #10
0
    def _parse_response(self, response):
        Log.d("Call _parse_response with response:", response.text)

        if response.status_code == 200:
            return True, response.json()["data"]
        if response.status_code == 201:
            return True, response.json()
        else:
            Log.d("Not correct answer from server.")
            response = response.json()
            if "data" in response.keys():
                response = response["data"]
                Log.d("Response: ", response)

                response = json.loads(self.cipher.decrypt_AES_b64(response))
                Log.d("Response decrypted: ", response)

                errorCode = response["meta"]["errorCode"]

                if errorCode == "403004":
                    print("Captcha is detected. ")
                    from getcontact.decode_captcha import CaptchaDecode

                    c = CaptchaDecode()
                    code, path = c.decode_response(response)
                    self.decode_captcha(code)

                    return False, {"repeat": True}
                if errorCode == "404001":
                    print("No information about phone in database")
                if errorCode == "403021":
                    # Token dead
                    Log.d("Token is dead.", config.TOKEN)
                    self.updater.update_remain_count_by_token(config.TOKEN, 0)
            else:
                Log.d("Unhandled error with response", response)
                Log.d("Try to use correct token")
            return False, {}
コード例 #11
0
 def _send_post(self, url, data):
     Log.d("Call _send_post with url:", url, "data:", data)
     response = requests.post(url, data=data, headers=self.headers)
     self.update_timestamp()
     return self._parse_response(response)