Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Snapchat detect XPosed Framework?

I tried to install Snapchat on my newly rooted and Xposed smartphone. But the login is impossible as Snapchat detects Xposed Framework. I "understand" the reason of this restriction, even though I think it's a bit too much as I don't use Xposed for Snapchat.

But my question is: How do they detect the Framework ?

like image 261
Gp2mv3 Avatar asked Oct 28 '16 07:10

Gp2mv3


People also ask

How do I know if xposed is installed?

Xposed itself can be detected using several ways: Using the files it installs or modifies and second more important using the stack-trace within your app. If Xposed is installed this is visible in the stack trace as Xposed is loaded into the Dalvik VM and therefore is active in each and every app.

Does xposed framework work?

It provides seamless customization ability on compatible Android devices. The Xposed Framework is easy to install and a module-based framework. It allows users to extend the functionality of the device by letting install other apps/mods/tweak at the system level.


2 Answers

SnapChat uses Google's SafetyNet Attestation API and does not specifically check if XPosed is installed. SnapChat runs SafetyNet the first time the app is launched.

To make sure SnapChat does not specifically check for the XPosed framework, I decompiled Snapchat and ran grep -lri xposed. The search came up with no results.

Checking if XPosed is installed:

I'm sure there are plenty of ways you could check if Xposed is installed. I wrote the following method which gets the currently installed Xposed version or returns null if the XposedBridge.jar was not found on the device:

/**
 * Get the current Xposed version installed on the device.
 * 
 * @param context The application context
 * @return The Xposed version or {@code null} if Xposed isn't installed.
 */
public static Integer getXposedVersion(Context context) {
  try {
    File xposedBridge = new File("/system/framework/XposedBridge.jar");
    if (xposedBridge.exists()) {
      File optimizedDir = context.getDir("dex", Context.MODE_PRIVATE);
      DexClassLoader dexClassLoader = new DexClassLoader(xposedBridge.getPath(),
          optimizedDir.getPath(), null, ClassLoader.getSystemClassLoader());
      Class<?> XposedBridge = dexClassLoader.loadClass("de.robv.android.xposed.XposedBridge");
      Method getXposedVersion = XposedBridge.getDeclaredMethod("getXposedVersion");
      if (!getXposedVersion.isAccessible()) getXposedVersion.setAccessible(true);
      return (Integer) getXposedVersion.invoke(null);
    }
  } catch (Exception ignored) {
  }
  return null;
}

As far as I can tell, Xposed has always had XposedBridge.jar in /system/framework so this should work for the official releases of Xposed but could break in future releases.

like image 56
Jared Rummler Avatar answered Sep 20 '22 17:09

Jared Rummler


I believe Snapchat uses SafetyNet, the API which also protects Android Pay and Pokemon GO.

like image 23
Maxr1998 Avatar answered Sep 20 '22 17:09

Maxr1998