SoFunction
Updated on 2025-04-09

Several ways to distinguish between real machines and emulators on Android

The current emulators are so powerful, from Bluetooth, sensors and other accessories to IMEI, Mac, and mobile phone hardware information, you can simulate everything from it

In order to prevent users from using the emulator to simulate the machine to perform malicious operations such as order brushing and traffic brushing.

Some information returned by the device needs to be obtained to identify the authenticity of the device.

Below is the difference between the sorted simulator and the real machine

Although most of them can be imitated and forged, if all dimensions are combined to monitor, there should be no big problems.

1. Native way.

Read configuration and hardware-related information in the device through c-code.

1,diskstats

Gets the partition status information of the flash memory.

int fd = open(“/proc/diskstats”, O_RDONLY);

bytes = read(fd, buf, bytes);

Difference: There are mmcblk0 partitions in real machines, but the simulator does not have partition information.

2. Mac address.

Read the Mac address through socket and ioctl.

sockfd = socket(AF_INET, SOCK_DGRAM, 0);

ioctl(sockfd, SIOCGIFCONF, (char*)&ifc);

ioctl(sockfd, SIOCGIFADDR, &ifr[i])

ioctl(sockfd, SIOCGIFHWADDR, (char*)&ifr[i])

Difference: The real machine can get the IP and Mac addresses of wlan0, while the emulator can only get the IP and Mac addresses of eth0;

3. Useful prop information.

__system_property_get(key, buf);

Difference: The simulator has no attributes, and the machine serial number is the real machine.

The simulator attribute is goldfish, and the real machine is the respective model.

4. CPU information.

int fd = open(“/proc/cpuinfo”, O_RDONLY);

bytes = read(fd, buf, bytes);

Difference: The hardware of cpuinfo in the simulator is Goldfish.

5,drivers

int fd = open(“/proc/tty/drivers”, O_RDONLY);

Difference: The driver that contains goldfish in the emulator

6. Emulator-specific files.

int fd = open(“/dev/socket/qemud”, O_RDONLY);

int fd = open(“/dev/qemu_pipe”, O_RDONLY);

Difference: The simulator's proprietary file is not available in the real machine.

2. Traditional way:

Through the Java layer code acquisition, there can be the following methods:

1. IMEI and IMSI

IMEI International ID code for mobile devices.

IMSI IMSI International Mobile User Identification Code, stored in SIM card

final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

String imei = ();

String imsi = ();

Device 1: 354273055927169 / null (no card)

Equipment 2: 862966024243759 / 460011040618938

Simulator: 0000000000000000/3102600000000000

2. Serial serial number

String serial = ;

Device 1: 4df78680771b117b

Device 2: OBAI5HDQZPDIRCQG

Emulator: unknown

3,android_id

String android_id = (getContentResolver(), Secure.ANDROID_ID);

There are both devices and emulators, 16-bit.

4. Mac address

WifiManager wifimanage=(WifiManager)getSystemService(Context.WIFI_SERVICE); WifiInfo wifiinfo= ();

Equipment 1:88:32:9b:1e:49:20

Device 2:f8:a4:5f:fd:56:17

Emulator: null

The above is a compilation and comparison of the methods of distinguishing real machines and emulators on Android. Friends who need it can refer to it.