From 7964c61699cc1e581f21d30a050354bbc85a326b Mon Sep 17 00:00:00 2001 From: klockky Date: Sat, 6 Jun 2026 19:36:24 +0300 Subject: [PATCH] fix(spoof): persist and apply all spoofing fields --- lib/backend/api.dart | 21 ++++++-- lib/core/storage/spoofing_service.dart | 8 ++- .../screens/profile/spoof_screen.dart | 49 +++++++++++++++++++ 3 files changed, 73 insertions(+), 5 deletions(-) diff --git a/lib/backend/api.dart b/lib/backend/api.dart index 4221c4f..a3fb613 100644 --- a/lib/backend/api.dart +++ b/lib/backend/api.dart @@ -179,6 +179,9 @@ class Api { String locale = 'ru'; String deviceLocale = Platform.localeName.substring(0, 2); String deviceId = await DeviceIdentity.deviceId(); + String pushDeviceType = 'GCM'; + String instanceId = await DeviceIdentity.instanceId(); + int clientSessionId = DeviceIdentity.clientSessionId; if (Platform.isLinux) { final linuxInfo = await deviceInfo.linuxInfo; @@ -223,6 +226,10 @@ class Api { locale = sLocale; deviceLocale = sLocale.split(RegExp(r'[-_]')).first; } + final sDeviceLocale = spoofed['device_locale'] as String?; + if (sDeviceLocale != null && sDeviceLocale.isNotEmpty) { + deviceLocale = sDeviceLocale; + } final sDeviceId = spoofed['device_id'] as String?; if (sDeviceId != null && sDeviceId.isNotEmpty) deviceId = sDeviceId; appVersion = (spoofed['app_version'] as String?) ?? appVersion; @@ -233,6 +240,14 @@ class Api { } else if (sBuild is String) { buildNumber = int.tryParse(sBuild) ?? buildNumber; } + final sPushType = spoofed['push_device_type'] as String?; + if (sPushType != null && sPushType.isNotEmpty) pushDeviceType = sPushType; + final sInstanceId = spoofed['instance_id'] as String?; + if (sInstanceId != null && sInstanceId.isNotEmpty) { + instanceId = sInstanceId; + } + final sClientSession = spoofed['client_session_id']; + if (sClientSession is int) clientSessionId = sClientSession; } _userAgent = { @@ -241,7 +256,7 @@ class Api { 'osVersion': osVersion, 'timezone': timezone, 'screen': screen, - 'pushDeviceType': 'GCM', + 'pushDeviceType': pushDeviceType, 'arch': architecture, 'locale': locale, 'buildNumber': buildNumber, @@ -252,9 +267,9 @@ class Api { _deviceId = deviceId; final payload = { - 'mt_instanceid': await DeviceIdentity.instanceId(), + 'mt_instanceid': instanceId, 'userAgent': _userAgent, - 'clientSessionId': DeviceIdentity.clientSessionId, + 'clientSessionId': clientSessionId, 'deviceId': deviceId, }; diff --git a/lib/core/storage/spoofing_service.dart b/lib/core/storage/spoofing_service.dart index b5e8c57..a51890b 100644 --- a/lib/core/storage/spoofing_service.dart +++ b/lib/core/storage/spoofing_service.dart @@ -16,11 +16,15 @@ class SpoofingService { 'screen': prefs.getString('spoof_screen'), 'timezone': prefs.getString('spoof_timezone'), 'locale': prefs.getString('spoof_locale'), + 'device_locale': prefs.getString('spoof_devicelocale'), 'device_id': prefs.getString('spoof_deviceid'), 'device_type': prefs.getString('spoof_devicetype'), - 'app_version': hardcodedAppVersion, + 'app_version': prefs.getString('spoof_appversion') ?? hardcodedAppVersion, 'arch': prefs.getString('spoof_arch') ?? 'arm64-v8a', - 'build_number': hardcodedBuildNumber, + 'build_number': prefs.getInt('spoof_buildnumber') ?? hardcodedBuildNumber, + 'instance_id': prefs.getString('spoof_instanceid'), + 'client_session_id': prefs.getInt('spoof_clientsessionid'), + 'push_device_type': prefs.getString('spoof_pushdevicetype'), }; } } diff --git a/lib/frontend/screens/profile/spoof_screen.dart b/lib/frontend/screens/profile/spoof_screen.dart index 9eef76d..48434c0 100644 --- a/lib/frontend/screens/profile/spoof_screen.dart +++ b/lib/frontend/screens/profile/spoof_screen.dart @@ -103,6 +103,21 @@ class _SpoofScreenState extends State { _buildNumberController.text = prefs.getInt('spoof_buildnumber')?.toString() ?? '$_hardcodedBuildNumber'; + _pushDeviceTypeController.text = + prefs.getString('spoof_pushdevicetype') ?? 'GCM'; + + final savedDeviceLocale = prefs.getString('spoof_devicelocale'); + if (savedDeviceLocale != null && savedDeviceLocale.isNotEmpty) { + _deviceLocaleController.text = savedDeviceLocale; + } + final savedInstanceId = prefs.getString('spoof_instanceid'); + if (savedInstanceId != null && savedInstanceId.isNotEmpty) { + _instanceIdController.text = savedInstanceId; + } + final savedClientSessionId = prefs.getInt('spoof_clientsessionid'); + if (savedClientSessionId != null) { + _clientSessionIdController.text = '$savedClientSessionId'; + } String savedType = prefs.getString('spoof_devicetype') ?? 'ANDROID'; if (savedType == 'WEB') savedType = 'ANDROID'; @@ -235,6 +250,13 @@ class _SpoofScreenState extends State { 'device_id': prefs.getString('spoof_deviceid') ?? '', 'device_type': prefs.getString('spoof_devicetype') ?? 'ANDROID', 'arch': prefs.getString('spoof_arch') ?? '', + 'device_locale': prefs.getString('spoof_devicelocale') ?? '', + 'app_version': prefs.getString('spoof_appversion') ?? '', + 'build_number': prefs.getInt('spoof_buildnumber')?.toString() ?? '', + 'push_device_type': prefs.getString('spoof_pushdevicetype') ?? '', + 'instance_id': prefs.getString('spoof_instanceid') ?? '', + 'client_session_id': + prefs.getInt('spoof_clientsessionid')?.toString() ?? '', }; final newValues = { @@ -246,6 +268,12 @@ class _SpoofScreenState extends State { 'device_id': _deviceIdController.text, 'device_type': _selectedDeviceType, 'arch': _selectedArch, + 'device_locale': _deviceLocaleController.text, + 'app_version': _appVersionController.text, + 'build_number': _buildNumberController.text, + 'push_device_type': _pushDeviceTypeController.text, + 'instance_id': _instanceIdController.text, + 'client_session_id': _clientSessionIdController.text, }; bool otherDataChanged = false; @@ -358,6 +386,27 @@ class _SpoofScreenState extends State { await prefs.setString('spoof_deviceid', _deviceIdController.text); await prefs.setString('spoof_devicetype', _selectedDeviceType); await prefs.setString('spoof_arch', _selectedArch); + await prefs.setString('spoof_devicelocale', _deviceLocaleController.text); + await prefs.setString('spoof_appversion', _appVersionController.text); + await prefs.setString( + 'spoof_pushdevicetype', + _pushDeviceTypeController.text, + ); + await prefs.setString('spoof_instanceid', _instanceIdController.text); + + final buildNumber = int.tryParse(_buildNumberController.text); + if (buildNumber != null) { + await prefs.setInt('spoof_buildnumber', buildNumber); + } else { + await prefs.remove('spoof_buildnumber'); + } + + final clientSessionId = int.tryParse(_clientSessionIdController.text); + if (clientSessionId != null) { + await prefs.setInt('spoof_clientsessionid', clientSessionId); + } else { + await prefs.remove('spoof_clientsessionid'); + } } void _generateNewDeviceId() {