An Explanation of My Recent "Self Destruct" Application
November 11, 2010 4 Comments
An Explanation of My Recent “Self Destruct” Application
“Self Destruct” is simply an application I made for fun, as a proof of concept. This application demonstrates a way to create an application that is able to “destroy” itself, preventing it from running until it is uninstalled, and then reinstalled later. I’d like to personally thank HandlerExploit for giving me a hint about how to do this (he mentioned that he found the trick in the provisioning code). HandlerExploit uses a similar technique in his application, “iBrick Proof of Concept”. As soon as the user opens the application, it removes it’s main class from the Dalvik package manager, preventing itself from being able to run again. The only way to run the application again after opening it is to uninstall the application, and reinstall it. This application serves no real purpose other than to demonstrate an interesting trick, and it is not malicious in any way. Please note that after running the application, it’s icon will remain in the launcher, although you won’t be able to open it. Uninstalling the application will remove the icon. I’d release the entire source code for this application, but really, the only part that actually matters is the part that removes the class from Dalvik and prevents the application from running again. Interestingly, this application requires absolutely no permissions, at all in order to do this. In case you are interested in how I did this, here is the source code for the main class in the project:
package com.dylantaylor.selfdestruct;
import android.app.Activity;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.Bundle;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PackageManager pm = getPackageManager(); ComponentName name = new ComponentName(this, Main.class);
pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
}
}
Yes, I realize that this application serves no real purpose, but it’s just something interesting that I made for fun. If you don’t want it, don’t download it. Otherwise, have fun!
P.S. Do whatever you want with that source code, it’s virtually worthless to me anyways.


Interesting. It’s great seeing programmers like yourself going out-of-the-box to try and come up with new methods to do various things. Although I’m not an android programmer myself (I’m an iPhone programmer) I still enjoy getting ideas from other programmers.
So are android apps programmed purely in javascript?
It’s Java, with some Android APIs. JavaScript is completely different than Java.
I’v been search for a way to do something like this. Would it be possible to destroy the app intirely (including the icon and label) so that it becomes completely invisible on the device?
I tried doing
name, activity.COMPONENT_ENABLED_STATE_DISABLED
as well as changing all the packagemanager references to Activity but it won’t work. I’m might not be referencing the right thing. Can you figure this out?
Pingback: What about a self-destructing App ? | crmmobile