Skip to content

Commit

Permalink
Merge pull request strazzere#2 from jacobsoo/master
Browse files Browse the repository at this point in the history
minor changes - thanks jacob!
  • Loading branch information
strazzere committed Mar 25, 2014
2 parents a256239 + 41811fc commit d2a1cba
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 13 deletions.
29 changes: 17 additions & 12 deletions AntiEmulator/src/diff/strazzere/anti/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,26 @@ public boolean isQEmuEnvDetected() {
log("hasKnownDeviceId : " + FindEmulator.hasKnownDeviceId(getApplicationContext()));
log("hasKnownImei : " + FindEmulator.hasKnownImei(getApplicationContext()));
log("hasKnownPhoneNumber : " + FindEmulator.hasKnownPhoneNumber(getApplicationContext()));
log("isOperatorNameAndroid : " + FindEmulator.isOperatorNameAndroid(getApplicationContext()));
log("hasKnownImsi : " + FindEmulator.hasKnownImsi(getApplicationContext()));
log("hasEmulatorBuild:" + FindEmulator.hasEmulatorBuild(getApplicationContext()));
log("hasPipes : " + FindEmulator.hasPipes());
log("hasQEmuDriver : " + FindEmulator.hasQEmuDriver());
log("hasQEmuFiles : " + FindEmulator.hasQEmuFiles());
if(FindEmulator.hasKnownDeviceId(getApplicationContext()) ||
FindEmulator.hasKnownImei(getApplicationContext()) ||
FindEmulator.hasKnownPhoneNumber(getApplicationContext()) ||
FindEmulator.hasPipes() ||
FindEmulator.hasQEmuDriver() ||
FindEmulator.hasQEmuFiles()) {
log("QEmu environment detected.");
return true;
} else {
log("QEmu environment not detected.");
return false;
}
if(FindEmulator.hasKnownDeviceId(getApplicationContext()) ||
FindEmulator.hasKnownImei(getApplicationContext()) ||
FindEmulator.hasKnownImsi(getApplicationContext()) ||
FindEmulator.hasEmulatorBuild(getApplicationContext()) ||
FindEmulator.hasKnownPhoneNumber(getApplicationContext())) ||
FindEmulator.hasPipes() ||
FindEmulator.hasQEmuDriver() ||
FindEmulator.hasQEmuFiles()){
log("QEmu environment detected.");
return true;
}else{
log("QEmu environment not detected.");
return false;
}
}

public boolean isTaintTrackingDetected() {
Expand Down
59 changes: 58 additions & 1 deletion AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,27 @@
public class FindEmulator {

// Need to check the format of these
// Android emulator support up to 16 concurrent emulator
// The console of the first emulator instance running on a given
// machine uses console port 5554
// Subsequent instances use port numbers increasing by two
private static String[] known_numbers = {
"15555215554" // Default emulator phone number
"15555215554", // Default emulator phone numbers
"15555215556",
"15555215558",
"15555215560",
"15555215562",
"15555215564",
"15555215566",
"15555215568",
"15555215570",
"15555215572",
"15555215574",
"15555215576",
"15555215578",
"15555215580",
"15555215582",
"15555215584",
};

private static String[] known_imeis = {
Expand All @@ -31,6 +50,10 @@ public class FindEmulator {
"000000000000000" // Default emulator id
};

private static String[] known_imsi_ids = {
"310260000000000" // Default imsi id
};

private static String[] known_pipes = {
"/dev/socket/qemud",
"/dev/qemu_pipe"
Expand Down Expand Up @@ -199,7 +222,41 @@ public static boolean hasKnownDeviceId(Context context) {
return false;
}

public static boolean hasKnownImsi(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String imsi = telephonyManager.getSubscriberId();

for(String known_imsi : known_imsi_ids) {
if(known_imsi.equalsIgnoreCase(imsi)) {
return true;
}
}
return false;
}

public static boolean hasEmulatorBuild(Context context) {
String BOARD = android.os.Build.BOARD; //The name of the underlying board, like "unknown".
String BOOTLOADER = android.os.Build.BOOTLOADER; // The system bootloader version number.
String BRAND = android.os.Build.BRAND; //The brand (e.g., carrier) the software is customized for, if any. "generic"
String DEVICE = android.os.Build.DEVICE; // The name of the industrial design. "generic"
String HARDWARE = android.os.Build.HARDWARE; //The name of the hardware (from the kernel command line or /proc). "goldfish"
String MODEL = android.os.Build.MODEL; //The end-user-visible name for the end product. "sdk"
String PRODUCT = android.os.Build.PRODUCT; //The name of the overall product.
if (BOARD == "unknown" || BOOTLOADER == "unknown" || BRAND == "generic" || DEVICE == "generic" || MODEL == "sdk" || PRODUCT == "sdk" || HARDWARE == "goldfish") {
return true;
}
return false;
}

public static boolean isOperatorNameAndroid(Context paramContext) {
String szOperatorName = ((TelephonyManager)paramContext.getSystemService("phone")).getNetworkOperatorName();
boolean isAndroid = szOperatorName.toLowerCase().equals("android");
return isAndroid;
}
/*
Can remove this as it's covered under hasKnownDeviceId
public static boolean hasKnownImei(Context context) {
return false;
}
*/
}

0 comments on commit d2a1cba

Please sign in to comment.