Skip to content

Instantly share code, notes, and snippets.

@Fuzion24
Created May 6, 2012 17:00
Show Gist options
  • Save Fuzion24/2623284 to your computer and use it in GitHub Desktop.
Save Fuzion24/2623284 to your computer and use it in GitHub Desktop.
Android Reversing - Showing an uber basic conditional patch
Running apktool d APKNAME.apk will result in output that can be modified and later repackaged and ran.
isRegistered() is hardcoded to return false.
Changing
const/4 v0, 0x0
to
const/4 v0, 0x1
will cause isRegistered to ALWAYS return true. Thus always telling the application that it is registered.
.method public isRegistered()Z
.locals 1
.prologue
.line 24
const/4 v0, 0x1
return v0
.end method
package com.reversing.demo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class ReversingDemoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView) this.findViewById(R.id.android_info_text);
if (isRegistered())
tv.setText("GOOD BOY: Application is registered");
else
tv.setText("BAD BOY: Application is not registered");
}
public boolean isRegistered()
{
//A million pointless checks here
return false;
}
}
# virtual methods
.method public isRegistered()Z
.locals 1
.prologue
.line 24
const/4 v0, 0x0
return v0
.end method
.method public onCreate(Landroid/os/Bundle;)V
.locals 2
.parameter "savedInstanceState"
.prologue
.line 11
invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V
.line 12
const/high16 v1, 0x7f03
invoke-virtual {p0, v1}, Lcom/reversing/demo/ReversingDemoActivity;->setContentView(I)V
.line 14
const/high16 v1, 0x7f05
invoke-virtual {p0, v1}, Lcom/reversing/demo/ReversingDemoActivity;->findViewById(I)Landroid/view/View;
move-result-object v0
check-cast v0, Landroid/widget/TextView;
.line 15
.local v0, tv:Landroid/widget/TextView;
invoke-virtual {p0}, Lcom/reversing/demo/ReversingDemoActivity;->isRegistered()Z
move-result v1
if-eqz v1, :cond_0
.line 16
const-string v1, "GOOD BOY: Application is registered"
invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
.line 19
:goto_0
return-void
.line 18
:cond_0
const-string v1, "BAD BOY: Application is not registered"
invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
goto :goto_0
.end method
@Debabrata-Sikder
Copy link

How to change the "toast message text" colour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment