Add support for insecure anonymous session, open bridge geo-spoofing

This commit is contained in:
Rahul Kumar Patel
2021-03-29 07:49:10 +05:30
parent d6d1bdca7d
commit ea290fedba
10 changed files with 199 additions and 11 deletions

View File

@@ -169,7 +169,7 @@ dependencies {
implementation "com.github.topjohnwu.libsu:core:${versions.libsu}" implementation "com.github.topjohnwu.libsu:core:${versions.libsu}"
//Love <3 //Love <3
api("com.gitlab.AuroraOSS:gplayapi:fe28788fa0") api("com.gitlab.AuroraOSS:gplayapi:efb14fa545")
} }
Properties props = new Properties() Properties props = new Properties()

View File

@@ -0,0 +1,25 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.data.model
data class InsecureAuth(
val email: String,
val auth: String
)

View File

@@ -48,6 +48,8 @@ object Preferences {
const val PREFERENCE_TOS_READ = "PREFERENCE_TOS_READ" const val PREFERENCE_TOS_READ = "PREFERENCE_TOS_READ"
const val PREFERENCE_INSECURE_ANONYMOUS = "PREFERENCE_INSECURE_ANONYMOUS"
private fun getPrefs(context: Context): SharedPreferences { private fun getPrefs(context: Context): SharedPreferences {
return PreferenceManager.getDefaultSharedPreferences(context) return PreferenceManager.getDefaultSharedPreferences(context)

View File

@@ -144,26 +144,32 @@ abstract class BaseActivity : AppCompatActivity(), NetworkProvider.NetworkListen
task { task {
TimeUnit.SECONDS.sleep(5) TimeUnit.SECONDS.sleep(5)
} successUi { } successUi {
val sheet = TOSSheet.newInstance() if (!supportFragmentManager.isDestroyed) {
sheet.isCancelable = false val sheet = TOSSheet.newInstance()
sheet.show(supportFragmentManager, TOSSheet.TAG) sheet.isCancelable = false
sheet.show(supportFragmentManager, TOSSheet.TAG)
}
} }
} }
fun showNetworkConnectivitySheet() { fun showNetworkConnectivitySheet() {
runOnUiThread { runOnUiThread {
supportFragmentManager.beginTransaction() if (!supportFragmentManager.isDestroyed) {
.add(NetworkDialogSheet.newInstance(), NetworkDialogSheet.TAG) supportFragmentManager.beginTransaction()
.commitAllowingStateLoss() .add(NetworkDialogSheet.newInstance(), NetworkDialogSheet.TAG)
.commitAllowingStateLoss()
}
} }
} }
fun hideNetworkConnectivitySheet() { fun hideNetworkConnectivitySheet() {
runOnUiThread { runOnUiThread {
val fragment = supportFragmentManager.findFragmentByTag(NetworkDialogSheet.TAG) if (!supportFragmentManager.isDestroyed) {
fragment?.let { val fragment = supportFragmentManager.findFragmentByTag(NetworkDialogSheet.TAG)
supportFragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss() fragment?.let {
supportFragmentManager.beginTransaction().remove(fragment)
.commitAllowingStateLoss()
}
} }
} }
} }

View File

@@ -36,6 +36,7 @@ import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_EXTERNAL import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_EXTERNAL
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
import com.aurora.store.util.Preferences.PREFERENCE_INSECURE_ANONYMOUS
import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID
import com.aurora.store.util.Preferences.PREFERENCE_INTRO import com.aurora.store.util.Preferences.PREFERENCE_INTRO
import com.aurora.store.util.Preferences.PREFERENCE_THEME_ACCENT import com.aurora.store.util.Preferences.PREFERENCE_THEME_ACCENT
@@ -155,6 +156,9 @@ class OnboardingActivity : BaseActivity() {
save(PREFERENCE_DOWNLOAD_ACTIVE, 3) save(PREFERENCE_DOWNLOAD_ACTIVE, 3)
save(PREFERENCE_DOWNLOAD_EXTERNAL, false) save(PREFERENCE_DOWNLOAD_EXTERNAL, false)
/*Network*/
save(PREFERENCE_INSECURE_ANONYMOUS, false)
/*Theme*/ /*Theme*/
save(PREFERENCE_THEME_TYPE, 0) save(PREFERENCE_THEME_TYPE, 0)
save(PREFERENCE_THEME_ACCENT, 0) save(PREFERENCE_THEME_ACCENT, 0)

View File

@@ -0,0 +1,48 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.preferences
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.aurora.extensions.runOnUiThread
import com.aurora.extensions.toast
import com.aurora.store.R
import com.aurora.store.util.CommonUtil
import com.aurora.store.util.Preferences
class NetworkPreference : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.preferences_network, rootKey)
val insecureAnonymous: Preference? =
findPreference(Preferences.PREFERENCE_INSECURE_ANONYMOUS)
insecureAnonymous?.let {
it.onPreferenceClickListener =
Preference.OnPreferenceClickListener {
runOnUiThread {
requireContext().toast(R.string.insecure_anonymous_apply)
}
false
}
}
}
}

View File

@@ -24,11 +24,13 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.aurora.Constants import com.aurora.Constants
import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.providers.DeviceInfoProvider
import com.aurora.gplayapi.helpers.AuthHelper import com.aurora.gplayapi.helpers.AuthHelper
import com.aurora.gplayapi.helpers.AuthValidator import com.aurora.gplayapi.helpers.AuthValidator
import com.aurora.store.AccountType import com.aurora.store.AccountType
import com.aurora.store.data.AuthState import com.aurora.store.data.AuthState
import com.aurora.store.data.RequestState import com.aurora.store.data.RequestState
import com.aurora.store.data.model.InsecureAuth
import com.aurora.store.data.network.HttpClient import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AccountProvider import com.aurora.store.data.providers.AccountProvider
import com.aurora.store.data.providers.NativeDeviceInfoProvider import com.aurora.store.data.providers.NativeDeviceInfoProvider
@@ -81,6 +83,19 @@ class AuthViewModel(application: Application) : BaseAndroidViewModel(application
} }
fun buildAnonymousAuthData() { fun buildAnonymousAuthData() {
val insecure = Preferences.getBoolean(
getApplication(),
Preferences.PREFERENCE_INSECURE_ANONYMOUS
)
if (insecure) {
buildInSecureAnonymousAuthData()
} else {
buildSecureAnonymousAuthData()
}
}
private fun buildSecureAnonymousAuthData() {
updateStatus("Requesting new session") updateStatus("Requesting new session")
task { task {
@@ -118,6 +133,54 @@ class AuthViewModel(application: Application) : BaseAndroidViewModel(application
} }
} }
private fun buildInSecureAnonymousAuthData() {
updateStatus("Requesting new session")
task {
var properties = NativeDeviceInfoProvider(getApplication())
.getNativeDeviceProperties()
if (spoofProvider.isDeviceSpoofEnabled())
properties = spoofProvider.getSpoofDeviceProperties()
val playResponse = HttpClient
.getPreferredClient()
.getAuth(
Constants.URL_DISPENSER
)
val insecureAuth: InsecureAuth
if (playResponse.isSuccessful) {
insecureAuth = gson.fromJson(
String(playResponse.responseBytes),
InsecureAuth::class.java
)
} else {
when (playResponse.code) {
404 -> throw Exception("Server unreachable")
429 -> throw Exception("Oops, You are rate limited")
else -> throw Exception(playResponse.errorString)
}
}
val deviceInfoProvider = DeviceInfoProvider(properties, Locale.getDefault().toString())
AuthHelper.buildInsecure(
insecureAuth.email,
insecureAuth.auth,
Locale.getDefault(),
deviceInfoProvider
)
} success {
//Set AuthData as anonymous
it.isAnonymous = true
verifyAndSaveAuth(it, AccountType.ANONYMOUS)
} fail {
updateStatus(it.message.toString())
}
}
private fun buildSavedAuthData() { private fun buildSavedAuthData() {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
supervisorScope { supervisorScope {

View File

@@ -282,6 +282,8 @@
<string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string> <string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string>
<string name="pref_filter_google_summary">"Removes all Google Apps from search results and category apps"</string> <string name="pref_filter_google_summary">"Removes all Google Apps from search results and category apps"</string>
<string name="pref_filter_google_title">"Filter Google apps"</string> <string name="pref_filter_google_title">"Filter Google apps"</string>
<string name="pref_insecure_anonymous_summary">"Generate GSF ID locally on device"</string>
<string name="pref_insecure_anonymous_title">"Insecure anonymous session"</string>
<string name="pref_install_auto_summary">"Apps are installed instantly after download completes"</string> <string name="pref_install_auto_summary">"Apps are installed instantly after download completes"</string>
<string name="pref_install_auto_title">"Auto install APKs after download"</string> <string name="pref_install_auto_title">"Auto install APKs after download"</string>
<string name="pref_install_delete_summary">"APKs will be deleted by default"</string> <string name="pref_install_delete_summary">"APKs will be deleted by default"</string>
@@ -294,6 +296,7 @@
<string name="pref_install_mode_title">"Installation method"</string> <string name="pref_install_mode_title">"Installation method"</string>
<string name="pref_install_profile_summary">"Select the target profile to install apps to. Only works with the root installation method"</string> <string name="pref_install_profile_summary">"Select the target profile to install apps to. Only works with the root installation method"</string>
<string name="pref_install_profile_title">"Installation profiles (Experimental)"</string> <string name="pref_install_profile_title">"Installation profiles (Experimental)"</string>
<string name="pref_network_title">"Networking"</string>
<string name="pref_ui_accent_title">"Accent"</string> <string name="pref_ui_accent_title">"Accent"</string>
<string name="pref_ui_theme_black">"Black"</string> <string name="pref_ui_theme_black">"Black"</string>
<string name="pref_ui_theme_dark">"Dark"</string> <string name="pref_ui_theme_dark">"Dark"</string>
@@ -312,6 +315,7 @@
<string name="purchase_session_expired">"Session expired, re-login to obtain new session."</string> <string name="purchase_session_expired">"Session expired, re-login to obtain new session."</string>
<string name="spoof_apply">"Make sure you re-login to apply the spoof"</string> <string name="spoof_apply">"Make sure you re-login to apply the spoof"</string>
<string name="insecure_anonymous_apply">"Make sure you re-login and restart app to apply changes."</string>
<string name="tab_categories">"Categories"</string> <string name="tab_categories">"Categories"</string>
<string name="tab_editor_choice">"Editor's choice"</string> <string name="tab_editor_choice">"Editor's choice"</string>

View File

@@ -49,4 +49,12 @@
app:key="pref_download" app:key="pref_download"
app:layout="@layout/item_preference" app:layout="@layout/item_preference"
app:title="@string/pref_app_download" /> app:title="@string/pref_app_download" />
<Preference
android:fragment="com.aurora.store.view.ui.preferences.NetworkPreference"
app:icon="@drawable/ic_network"
app:iconSpaceReserved="false"
app:key="pref_network"
app:layout="@layout/item_preference"
app:title="@string/pref_network_title" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -0,0 +1,28 @@
<!--
~ Aurora Store
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
~
~ Aurora Store is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 2 of the License, or
~ (at your option) any later version.
~
~ Aurora Store is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
~
-->
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreferenceCompat
app:defaultValue="false"
app:iconSpaceReserved="false"
app:key="PREFERENCE_INSECURE_ANONYMOUS"
app:summary="@string/pref_insecure_anonymous_summary"
app:title="@string/pref_insecure_anonymous_title" />
</PreferenceScreen>