如何修改Android应用默认启动Activity以绕过失效的登录页面?
Hey there, let's tackle this login bypass issue step by step. I see you've already spent 8 hours trying to modify the app and hit some roadblocks—let's break down why your initial attempts didn't work and what you can try next.
First, let's address why moving the intent-filter to other activities didn't change the launch behavior: most modern apps have runtime login checks baked into their core activities. Even if you set MainActivity as the launcher in the manifest, the code inside MainActivity is almost certainly checking for an active user session, and immediately redirecting to AuthenticationActivity if it doesn't find one. Manifest changes alone can't bypass this logic—it's handled in the app's compiled code (Java/Kotlin converted to smali), not just the manifest file.
Here are actionable steps to get past the login screen:
1. Modify the MainActivity to Skip Login Redirects
Since manifest tweaks aren't enough, you'll need to edit the app's code to disable the login check. Here's how:
- Use
apktoolto fully decompile the app:apktool d your-app.apk - Navigate to the
MainActivitysmali files (look insmali/ro/umfquiz/umfquiz/presentation/main/if the app isn't obfuscated; if it is, you'll need to identify the correct smali files by looking for references toAuthenticationActivity). - Search for code that checks login status and launches the login activity. This might look like an
ifstatement checking a shared preference, auth token, or user object. - Comment out or remove the lines that trigger the redirect to
AuthenticationActivity. For example, if you find smali code like:
You can either delete those lines or force the condition to skip the redirect entirely.if-eqz v0, :cond_0 # ... code that creates an intent for AuthenticationActivity and starts it - Recompile the app with
apktool band re-sign it properly (more on signing below).
2. Fix the Signature Issue When Modifying Login Activities
When you tried adding android:enabled="false" to login activities and couldn't sign the APK, that's likely because other parts of the app depend on those activities (e.g., references in code or manifest dependencies). Instead of disabling them, try this:
- Keep the login activities enabled, but modify their code to immediately redirect to your target activity (like
ModeSelectionActivityorMainActivity) when they launch. - Open the smali file for
AuthenticationActivity, and add this code at the start of theonCreatemethod:.method protected onCreate(Landroid/os/Bundle;)V .locals 2 invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V # Add this block to redirect to ModeSelectionActivity const-class v0, Lro/umfquiz/umfquiz/presentation/ModeSelectionActivity; new-instance v1, Landroid/content/Intent; invoke-direct {v1, p0, v0}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V invoke-virtual {p0, v1}, Landroid/app/Activity;->startActivity(Landroid/content/Intent;)V invoke-virtual {p0}, Landroid/app/Activity;->finish()V return-void .end method
This way, when the app tries to launch the login screen, it will immediately jump to the learning environment instead.
3. Ensure Your Signing Process is Correct
A common issue after modifying APKs is improper signing. Make sure you're using a valid keystore:
- Generate a keystore if you don't have one (using
keytool):keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias - Sign the recompiled APK with
apksigner:apksigner sign --ks my-release-key.jks your-app-dist.apk
Or use jarsigner if you prefer:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks your-app-dist.apk my-alias
4. Check for Obfuscation or Anti-Tampering
If the app uses ProGuard obfuscation or anti-tampering tools, you'll need extra steps:
- Use tools like
frida(requires a rooted device) to hook into login check functions at runtime and bypass them. - Use smali analysis tools to trace references to
AuthenticationActivityand identify the core login validation logic.
Reference: Your AndroidManifest.xml Snippet
<application android:allowBackup="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:icon="@mipmap/ic_app" android:label="@string/app_name" android:name="ro.umfquiz.umfquiz.presentation.UMFQuizApp" android:supportsRtl="true" android:theme="@style/AppTheme"> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="@string/admob_app_id"/> <activity android:name="ro.umfquiz.umfquiz.presentation.login.AuthenticationActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden|adjustPan"/> <activity android:name="ro.umfquiz.umfquiz.presentation.login.FirstActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name="ro.umfquiz.umfquiz.presentation.login.RegisterActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name="ro.umfquiz.umfquiz.presentation.login.LoginActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:label="@string/app_name" android:name="ro.umfquiz.umfquiz.presentation.main.MainActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name="ro.umfquiz.umfquiz.presentation.ModeSelectionActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:label="@string/app_name" android:name="com.facebook.FacebookActivity" android:theme="@style/com_facebook_activity_theme"/> <activity android:exported="true" android:name="com.facebook.CustomTabActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="@string/fb_login_protocol_scheme"/> </intent-filter> </activity> <activity android:label="@string/training_mode" android:name="ro.umfquiz.umfquiz.presentation.testselection.training.TrainingSelectActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:label="@string/exam_mode" android:name="ro.umfquiz.umfquiz.presentation.testselection.exam.ExamSelectActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:label="@string/title_activity_quiz" android:name="ro.umfquiz.umfquiz.presentation.quiz.types.exam.QuizExamActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/> </application>
内容的提问来源于stack exchange,提问作者Panda YT CANAL VECHI




