def _get_latest_version(package): latest_version = None code, body, _ = network.get(f"https://pypi.python.org/pypi/{package}/json") if code == HTTP_OK and body is not None: json_package = json.loads(body) latest_version = json_package['info']['version'] return latest_version
def verify_instagram_version(installed_ig_version): code, body, _ = network.get( f"https://insomniac-bot.com/get_latest_supported_ig_version/") if code == HTTP_OK and body is not None: json_config = json.loads(body) latest_supported_ig_version = json_config['message'] else: return try: is_ok = versiontuple(installed_ig_version) <= versiontuple( latest_supported_ig_version) except ValueError: print_debug(COLOR_FAIL + "Cannot compare IG versions" + COLOR_ENDC) return if not is_ok: print_timeless("") print_timeless( COLOR_FAIL + f"IG version ({installed_ig_version}) is newer than " f"latest supported ({latest_supported_ig_version})." + COLOR_ENDC) if insomniac_globals.is_insomniac(): print_timeless( COLOR_FAIL + "Please uninstall IG and download recommended apk from here:" + COLOR_ENDC) print_timeless( COLOR_FAIL + COLOR_BOLD + "https://insomniac-bot.com/get_latest_supported_ig_apk/" + COLOR_ENDC) print_timeless("")
def _get_confirmation_code_smspva(response_id) -> Optional[str]: url = f"http://smspva.com/priemnik.php?metod=get_sms&service=opt16" \ f"&country={SMSPVA_COUNTRY_CODE}" \ f"&id={response_id}" \ f"&apikey={SMSPVA_API_KEY}" attempts_count = 0 while True: sleeper.random_sleep(multiplier=8.0) code, body, fail_reason = network.get(url, 'Mozilla/5.0') attempts_count += 1 if code == HTTP_OK and body is not None: json_data = json.loads(body) else: print( COLOR_FAIL + f"Cannot get confirmation code via smspva.com API: {code} ({fail_reason})" + COLOR_ENDC) return None confirmation_code = json_data["sms"] if confirmation_code is None: if attempts_count >= CONFIRMATION_CODE_MAX_ATTEMPTS_COUNT: print( "Well, looks like Instagram isn't going to send SMS to this phone number" ) return None print( "Let's wait a bit more: confirmation code isn't received yet") else: break return confirmation_code
def _get_confirmation_code_sms_activate(response_id) -> Optional[str]: url = f"https://sms-activate.ru/stubs/handler_api.php" \ f"?api_key={SMS_ACTIVATE_API_KEY}" \ f"&id={response_id}" \ f"&country={SMSPVA_COUNTRY_CODE}" \ f"&action=getStatus" attempts_count = 0 while True: sleeper.random_sleep(multiplier=8.0) code, body, fail_reason = network.get(url, 'Mozilla/5.0') attempts_count += 1 if code != HTTP_OK or body is None: print( COLOR_FAIL + f"Cannot get confirmation code via sms-activate.ru API: {code} ({fail_reason})" + COLOR_ENDC) return None response_regex = re.compile(r'STATUS_OK:(\d+)') match = response_regex.match(body.decode('utf-8')) if match: confirmation_code = match.group(1) return confirmation_code else: if attempts_count >= CONFIRMATION_CODE_MAX_ATTEMPTS_COUNT: print( "Well, looks like Instagram isn't going to send SMS to this phone number" ) return None print( "Let's wait a bit more: confirmation code isn't received yet")
def _validate(activation_code, ui): code, _, fail_reason = network.get(f"{HOST}{PATH_VALIDATE}?activation_code={activation_code}{'&ui=true' if ui else ''}") if code == HTTP_OK: print(COLOR_OKGREEN + "Your activation code is confirmed, welcome!" + COLOR_ENDC) return True print(COLOR_FAIL + f"Activation code is not confirmed: {code} ({fail_reason})" + COLOR_ENDC) return False
def get_extra_feature(self, module, ui=False): print_debug_ui(f"Getting extra-feature, module: {module}, is ui: {ui} ") extra_feature_path = PATH_UI_EXTRA_FEATURE if ui else PATH_EXTRA_FEATURE code, body, fail_reason = network.get(f"{HOST}{extra_feature_path}{module}" f"?activation_code={self.activation_code}" f"&version={__version__}") if code == HTTP_OK and body is not None: extra_feature = base64.b64decode(zlib.decompress(body)) return self.load_extra_feature(extra_feature, module) print(COLOR_FAIL + f"Cannot get {'ui-' if ui else ''}module {module} from v{__version__}: " f"{code} ({fail_reason})" + COLOR_ENDC) return None
def _get_phone_number_smspva() -> Optional[PhoneNumberData]: url = f"http://smspva.com/priemnik.php?metod=get_number&service=opt16" \ f"&country={SMSPVA_COUNTRY_CODE}" \ f"&apikey={SMSPVA_API_KEY}" code, body, fail_reason = network.get(url, 'Mozilla/5.0') if code == HTTP_OK and body is not None: json_data = json.loads(body) else: print( COLOR_FAIL + f"Cannot get phone number via smspva.com API: {code} ({fail_reason})" + COLOR_ENDC) return None response_id = json_data["id"] country_code = json_data["CountryCode"] phone_number = json_data["number"] phone_number_data = PhoneNumberData(response_id, country_code, phone_number) return phone_number_data
def validate_ig_profile_existence(profile_name): if not should_validate_profile_existence: return True print(f"Validating profile {profile_name} existence") try: code, body, fail_reason = network.get(PROFILE_VALIDATION_SERVICE_URL.format(profile_name), random.choice(network.PUBLIC_USER_AGENTS)) if code == HTTP_OK and body is not None: response = body.decode('utf-8') print_debug(f"Received IG-profile-name query response for {profile_name}: {response}") profile_name_info = json.loads(response) return profile_name_info[PROFILE_STATUS_FIELD] == PROFILE_TAKEN else: print_debug(COLOR_FAIL + f"IG-profile-name {profile_name} query failed. code: {code}, error: {fail_reason}" + COLOR_ENDC) except Exception as ex: print_debug(COLOR_FAIL + f"IG-profile-name {profile_name} query failed." + COLOR_ENDC) print_debug(COLOR_FAIL + describe_exception(ex) + COLOR_ENDC) return False
def _get_phone_number_sms_activate() -> Optional[PhoneNumberData]: try: import phonenumbers except ImportError: print(COLOR_FAIL + f"Using sms-activate.ru API requires phonenumbers library." + COLOR_ENDC) print(COLOR_FAIL + COLOR_BOLD + f"python3 -m pip install phonenumbers" + COLOR_ENDC) return None url = f"https://sms-activate.ru/stubs/handler_api.php" \ f"?api_key={SMS_ACTIVATE_API_KEY}" \ f"&country={SMS_ACTIVATE_COUNTRY_CODE}" \ f"&action=getNumber" \ f"&service=ig" code, body, fail_reason = network.get(url, 'Mozilla/5.0') if code != HTTP_OK or body is None: print( COLOR_FAIL + f"Cannot get phone number via sms-activate.ru API: {code} ({fail_reason})" + COLOR_ENDC) return None response_regex = re.compile(r'ACCESS_NUMBER:(\d+):(\d+)') match = response_regex.match(body.decode('utf-8')) if match: response_id = match.group(1) full_phone_number = match.group(2) else: print(COLOR_FAIL + f"Cannot parse sms-activate.ru response: {str(body)})" + COLOR_ENDC) return None phone_number_object = phonenumbers.parse(f'+{full_phone_number}', None) country_code = str(phone_number_object.country_code) phone_number = str(phone_number_object.national_number) phone_number_data = PhoneNumberData(response_id, country_code, phone_number) return phone_number_data