More theoretical foundations

App multi-opening is often used to do some illegal things, such as high wool, black ash production, and even to destroy the function of app modification. Therefore, multi-open in the actual APP application is harmful to some extent, so the identification of multi-open environment is very important, through the identification of multi-open environment is conducive to making the APP more secure.

Multi-open implementation principle analysis

There are many kinds of implementation principles of MULTI-open app, such as using multi-user mode (multi-open implementation of MUMU simulator), and running by creating different process names (multi-open split, double-open assistant). We know that each app has its own private directory, which is generally “/data/data/ package name/” or” /data/user/ user number/package name “. The multi-open method is also based on these. Then we can read the information directory in the private directory by calling the system getFilesDir() method. In a multi-open environment, the obtained directory is changed to /data/data/ multi-open package name/XXXXXXXX or /data/user/ user NUMBER/Multi-open App package name. Based on the above principle analysis, you can realize the identification of multiple open environment through the following code.

Code implementation: more open package name

// It is used to collect the name of the app package that can realize multi-opening. Most of the multi-opening apps on the latest market have been collected
private String[] packagename = {
        "com.bly.dkplat".// open the package name of the doppelgger
        "com.by.chaos"./ / chaos engine
        "com.lbe.parallel".// Parallel space
        "com.excelliance.dualaid".// Double open assistant
        "com.lody.virtual"./ / VirtualXposed VirtualApp
        "com.qihoo.magic".//360 Master
        "com.dual.dualgenius".//DualGenius/ double open wizard
        "com.jiubang.commerce.gomultiple" / / GO GO/Multiple dual drive}; Comparison is performed by reading file packagespublic  boolean checkPrivateFilePath(Context context)
{
    String path = context.getFilesDir().getPath();
    for(String vtpkg: packagename)
    {
        if(path.contains(vtpkg))
        {
            return true; }}return false;
}

Copy the code

Code implementation: multi – user


private  String GetMulData(a)
{
    // By reading the command line.
    String filter = exec("cat /proc/self/cgroup");
    if(null == filter || (filter.length() == 0))
    {
        return null;
    }

    int uidStartIndex = filter.lastIndexOf("uid");
    int uidEndIndex = filter.lastIndexOf("/pid");
    if(0 > uidStartIndex)
    {
        return null;
    }
    if( 0 >= uidEndIndex)
    {
        uidEndIndex = filter.length();
    }

    filter = filter.substring(uidStartIndex + 4, uidEndIndex);
    try {
        String strUid = filter.replaceAll("\n"."");
        if(isNumeriToUid(strUid))
        {
            int  uid = Integer.valueOf(strUid);
            filter = String.format("u0_a%d", uid -10000);
            returnfilter; }}catch (Exception e)
    {
        return null;
    }
    return  null;
}

Copy the code