How does some apps(wechat) ignore fake location and then detect the real one?

blackkara picture blackkara · May 12, 2016 · Viewed 55k times · Source

I have installed a fake location app and set my location different. Then opened Google Maps and Wechat app,

  • Google Maps shows my location as what i set(fake)
  • Wechat app ignores fake location and detects real location (how?)

Then i wanted to prevent wechat analyze my previously received real locations and new fake location.

  • Uninstalled Wechat
  • Restarted my device
  • Set my location as fake
  • Installed Wechat again

But same result, it detects my real location.

I really want to understand how they do this. Any ideas?


What i have tried

  • Gps provider spoof
  • Network provider spoof
  • Fused location provider spoof
  • IP geolocation spoof
  • Gps provider spoof + IP geolocation spoof

UPDATE

Uses GPS even when disabled.

enter image description here

07-02 11:46:15.504 2346-2356/? D/LocationManagerService: request 434a7e28 gps Request[ACCURACY_FINE gps requested=+1s0ms fastest=+1s0ms] from com.tencent.mm(10173)


CONCLUSION

  • You can fake location on older versions of wechat(lower than 6.0)
  • Uses something like BaiduLocationSDK. It's not affected from any mock attempt through LocationManager and Fused provider.
  • I'm not sure but, seems like BaiduLocationSDK uses GPS through hardware level.

Answer

Sakchham picture Sakchham · Jun 30, 2016

To check for fake location most applications look for GGA and GSV sentences in the NMEA (National Marine Electronics Association) data received by them. The fake location providers do not send NMEA sentences along with location, so this parameter can be used to
If they haven't received and GGA and GSV sentences in a threshold amount of time, say 100 seconds they red flag the current location provider.
This process is repeated till a valid set of NMEA sentences has been received and then the corresponding location is selected.

To retreive NMEA data LocationManager#addNmeaListener(GpsStatus.NmeaListener listener) is called and then in the listener

void onNmeaReceived(long timestamp, String nmea) {
    Log.d("Nmea Data",nmea);
}

for more info see adding a NmeaListener
the NMEA sentences, GGA and GSV look as follows

GGA - essential fix data which provide 3D location and accuracy data.

Sample : "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"

Where:
 GGA          Global Positioning System Fix Data
 123519       Fix taken at 12:35:19 UTC
 4807.038,N   Latitude 48 deg 07.038' N
 01131.000,E  Longitude 11 deg 31.000' E
 1            Fix quality: 0 = invalid
                           1 = GPS fix (SPS)
                           2 = DGPS fix
                           3 = PPS fix
                           4 = Real Time Kinematic
                           5 = Float RTK<br/>
                           6 = estimated (dead reckoning) (2.3 feature)
                           7 = Manual input mode>
                           8 = Simulation mode
 08           Number of satellites being tracked
 0.9          Horizontal dilution of position
 545.4,M      Altitude, Meters, above mean sea level
 46.9,M       Height of geoid (mean sea level) above WGS84 ellipsoid
 (empty field) time in seconds since last DGPS update
 (empty field) DGPS station ID number
 *47          the checksum data, always begins with *


GSV - Satellites in View shows data about the satellites that the unit might be able to find based on its viewing mask and almanac data. It also shows current ability to track this data. Note that one GSV sentence only can provide data for up to 4 satellites and thus there may need to be 3 sentences for the full information. It is reasonable for the GSV sentence to contain more satellites than GGA might indicate since GSV may include satellites that are not used as part of the solution. It is not a requirement that the GSV sentences all appear in sequence. To avoid overloading the data bandwidth some receivers may place the various sentences in totally different samples since each sentence identifies which one it is.

Sample:"$GPGSV,2,1,08,01,40,083,46,02,17,308,41,12,07,344,39,14,22,228,45*75"

Where:
  GSV          Satellites in view
  2            Number of sentences for full data
  1            sentence 1 of 2
  08           Number of satellites in view

  01           Satellite PRN number
  40           Elevation, degrees
  083          Azimuth, degrees
  46           SNR - higher is better
               for up to 4 satellites per sentence
  *75          the checksum data, always begins with *

Source : NMEAData