コード例 #1
0
        private Unknown6 GenerateSignature(IEnumerable <IMessage> requests)
        {
            var accelNextZ = RandomDevice.NextInRange(5.8125, 10.125);        //9,80665
            var accelNextX = RandomDevice.NextInRange(-0.513123, 0.61231567); //Considering we handle phone only in 2 directions
            var accelNextY = Math.Sqrt(96.16744225D - accelNextZ * accelNextZ) * ((accelNextZ > 9.8) ? -1 : 1);

            var sig = new Signature
            {
                TimestampSinceStart = (ulong)_internalWatch.ElapsedMilliseconds,
                Timestamp           = (ulong)DateTime.UtcNow.ToUnixTime(),
                DeviceInfo          = new Signature.Types.DeviceInfo()
                {
                    DeviceId              = _settings.DeviceId,
                    AndroidBoardName      = _settings.AndroidBoardName,
                    AndroidBootloader     = _settings.AndroidBootloader,
                    DeviceBrand           = _settings.DeviceBrand,
                    DeviceModel           = _settings.DeviceModel,
                    DeviceModelIdentifier = _settings.DeviceModelIdentifier,
                    DeviceModelBoot       = _settings.DeviceModelBoot,
                    HardwareManufacturer  = _settings.HardwareManufacturer,
                    HardwareModel         = _settings.HardwareModel,
                    FirmwareBrand         = _settings.FirmwareBrand,
                    FirmwareTags          = _settings.FirmwareTags,
                    FirmwareType          = _settings.FirmwareType,
                    FirmwareFingerprint   = _settings.FirmwareFingerprint
                }
            };

            sig.SensorInfo.Add(new Signature.Types.SensorInfo
            {
                GravityZ              = accelNextZ,
                GravityX              = accelNextX,
                GravityY              = accelNextY,
                TimestampSnapshot     = (ulong)_internalWatch.ElapsedMilliseconds - 230,
                MagneticFieldX        = accelNextX * 10,
                MagneticFieldY        = -20 + -20 * accelNextY / 9.8065,
                MagneticFieldZ        = -40 * accelNextZ / 9.8065,
                AttitudePitch         = Math.Acos(accelNextX / 9.8065),
                AttitudeRoll          = Math.Acos(accelNextY / 9.8065),
                AttitudeYaw           = Math.Acos(accelNextZ / 9.8065),
                LinearAccelerationX   = RandomDevice.NextInRange(-0.005, 0.005),
                LinearAccelerationY   = RandomDevice.NextInRange(0.5, 1),
                LinearAccelerationZ   = RandomDevice.NextInRange(-0.05, 0.05),
                RotationRateX         = RandomDevice.NextInRange(-0.0001, 0.0001),
                RotationRateY         = RandomDevice.NextInRange(-0.0005, 0.0005),
                RotationRateZ         = RandomDevice.NextInRange(-0.003, 0.003),
                MagneticFieldAccuracy = RandomDevice.Next(10),
                Status = 3
            });

            sig.LocationFix.Add(new Signature.Types.LocationFix()
            {
                Provider = "fused",

                //Unk4 = 120,
                Latitude  = (float)_latitude,
                Longitude = (float)_longitude,
                Altitude  = (float)_altitude,
                Speed     = -1,
                Course    = -1,
                //TimestampSinceStart = (ulong)InternalWatch.ElapsedMilliseconds - 200,
                TimestampSnapshot  = (ulong)_internalWatch.ElapsedMilliseconds - 200,
                Floor              = 3,
                HorizontalAccuracy = (float)Math.Round(RandomDevice.NextInRange(4, 10), 6), //10
                VerticalAccuracy   = RandomDevice.Next(3, 7),
                ProviderStatus     = 3,
                LocationType       = 1
            });

            //Compute 10

            byte[] serializedTicket = _authTicket.ToByteArray();

            uint firstHash = HashBuilder.Hash32(serializedTicket);

            var locationBytes = BitConverter.GetBytes(_latitude).Reverse()
                                .Concat(BitConverter.GetBytes(_longitude).Reverse())
                                .Concat(BitConverter.GetBytes(_altitude).Reverse()).ToArray();

            sig.LocationHash1 = HashBuilder.Hash32Salt(locationBytes, firstHash);

            //Compute 20
            sig.LocationHash2 = HashBuilder.Hash32(locationBytes);

            //Compute 24
            ulong seed = HashBuilder.Hash64(_authTicket.ToByteArray());

            foreach (var req in requests)
            {
                sig.RequestHash.Add(HashBuilder.Hash64Salt64(req.ToByteArray(), seed));
            }

            //static for now
            //sig.Unk22 = ByteString.CopyFrom(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F);
            sig.SessionHash = SessionHash;
            sig.Unknown25   = 16892874496697272497; //16892874496697272497; //7363665268261373700; //-8537042734809897855;



            var val = new Unknown6
            {
                RequestType = 6,
                Unknown2    = new Unknown6.Types.Unknown2 {
                    Unknown1 = ByteString.CopyFrom(PCrypt.encrypt(sig.ToByteArray(), (uint)sig.TimestampSinceStart))
                }
            };

            return(val);
        }
コード例 #2
0
        private RequestEnvelope.Types.PlatformRequest GenerateSignature(RequestEnvelope requestEnvelope)
        {
            byte[] ticketBytes = requestEnvelope.AuthTicket != null?requestEnvelope.AuthTicket.ToByteArray() : requestEnvelope.AuthInfo.ToByteArray();

            // Common device info
            Signature.Types.DeviceInfo deviceInfo = new Signature.Types.DeviceInfo
            {
                DeviceId             = _settings.DeviceId,
                DeviceBrand          = _settings.DeviceBrand,
                DeviceModel          = _settings.DeviceModel,
                DeviceModelBoot      = _settings.DeviceModelBoot,
                HardwareManufacturer = _settings.HardwareManufacturer,
                HardwareModel        = _settings.HardwareModel,
                FirmwareBrand        = _settings.FirmwareBrand,
                FirmwareType         = _settings.FirmwareType
            };

            // Android
            if (_client.Platform == Platform.Android)
            {
                deviceInfo.AndroidBoardName      = _settings.AndroidBoardName;
                deviceInfo.AndroidBootloader     = _settings.AndroidBootloader;
                deviceInfo.DeviceModelIdentifier = _settings.DeviceModelIdentifier;
                deviceInfo.FirmwareTags          = _settings.FirmwareTags;
                deviceInfo.FirmwareFingerprint   = _settings.FirmwareFingerprint;
            }

            var sig = new Signature
            {
                SessionHash         = SessionHash,
                Unknown25           = Client_4500_Unknown25,
                Timestamp           = (ulong)Utils.GetTime(true),
                TimestampSinceStart = (ulong)(Utils.GetTime(true) - _client.StartTime),
                LocationHash1       = (int)Utils.GenerateLocation1(ticketBytes, _latitude, _longitude, _horizontalAccuracy),
                LocationHash2       = (int)Utils.GenerateLocation2(_latitude, _longitude, _horizontalAccuracy),
                DeviceInfo          = deviceInfo
            };

            sig.SensorInfo.Add(new SensorInfo()
            {
                TimestampSnapshot     = (ulong)(Utils.GetTime(true) - _client.StartTime - RandomDevice.Next(100, 500)),
                LinearAccelerationX   = TRandomDevice.Triangular(-3, 1, 0),
                LinearAccelerationY   = TRandomDevice.Triangular(-2, 3, 0),
                LinearAccelerationZ   = TRandomDevice.Triangular(-4, 2, 0),
                MagneticFieldX        = TRandomDevice.Triangular(-50, 50, 0),
                MagneticFieldY        = TRandomDevice.Triangular(-60, 50, -5),
                MagneticFieldZ        = TRandomDevice.Triangular(-60, 40, -30),
                AttitudePitch         = GenRandom(-47.149471283, 61.8397789001),
                AttitudeYaw           = GenRandom(-47.149471283, 61.8397789001),
                AttitudeRoll          = GenRandom(-47.149471283, 5),
                RotationRateX         = GenRandom(0.0729667818829, 0.0729667818829),
                RotationRateY         = GenRandom(-2.788630499244109, 3.0586791383810468),
                RotationRateZ         = GenRandom(-0.34825887123552773, 0.19347580173737935),
                GravityX              = TRandomDevice.Triangular(-1, 1, 0.15),
                GravityY              = TRandomDevice.Triangular(-1, 1, -.2),
                GravityZ              = TRandomDevice.Triangular(-1, .7, -0.8),
                MagneticFieldAccuracy = -1,
                Status = 3
            });

            Signature.Types.LocationFix locationFix = new Signature.Types.LocationFix
            {
                Provider           = TRandomDevice.Choice(new List <string>(new string[] { "network", "network", "network", "network", "fused" })),
                Latitude           = (float)_latitude,
                Longitude          = (float)_longitude,
                Altitude           = (float)_altitude,
                HorizontalAccuracy = _horizontalAccuracy,
                TimestampSnapshot  = (ulong)(Utils.GetTime(true) - _client.StartTime - RandomDevice.Next(100, 300)),
                ProviderStatus     = 3,
                LocationType       = 1
            };

            if (_horizontalAccuracy >= 65)
            {
                locationFix.HorizontalAccuracy = TRandomDevice.Choice(new List <int>(new int[] { _horizontalAccuracy, 65, 65, (int)Math.Round(GenRandom(66, 80)), 200 }));
                if (_client.Platform == Platform.Ios)
                {
                    locationFix.VerticalAccuracy = (float)TRandomDevice.Triangular(35, 100, 65);
                }
            }
            else
            {
                locationFix.HorizontalAccuracy = _horizontalAccuracy;
                if (_client.Platform == Platform.Ios)
                {
                    if (_horizontalAccuracy > 10)
                    {
                        locationFix.VerticalAccuracy = (float)TRandomDevice.Choice(new List <double>(new double[] { 24, 32, 48, 48, 64, 64, 96, 128 }));
                    }
                    else
                    {
                        locationFix.VerticalAccuracy = (float)TRandomDevice.Choice(new List <double>(new double[] { 3, 4, 6, 6, 8, 12, 24 }));
                    }
                }
            }


            if (_client.Platform == Platform.Ios)
            {
                if (RandomDevice.NextDouble() > 0.95)
                {
                    // No reading for roughly 1 in 20 updates
                    locationFix.Course = -1;
                    locationFix.Speed  = -1;
                }
                else
                {
                    _course = (float)TRandomDevice.Triangular(0, 360, _course);

                    // Course is iOS only.
                    locationFix.Course = _course;

                    // Speed is iOS only.
                    locationFix.Speed = _speed;
                }
            }

            sig.LocationFix.Add(locationFix);

            foreach (var request in requestEnvelope.Requests)
            {
                sig.RequestHash.Add(Utils.GenerateRequestHash(ticketBytes, request.ToByteArray()));
            }

            var encryptedSignature = new RequestEnvelope.Types.PlatformRequest
            {
                Type           = PlatformRequestType.SendEncryptedSignature,
                RequestMessage = new SendEncryptedSignatureRequest
                {
                    EncryptedSignature = ByteString.CopyFrom(PCrypt.Encrypt(sig.ToByteArray(), (uint)_client.StartTime))
                }.ToByteString()
            };

            return(encryptedSignature);
        }
コード例 #3
0
        private RequestEnvelope.Types.PlatformRequest GenerateSignature(IEnumerable <IMessage> requests)
        {
            byte[] ticket = _authTicket.ToByteArray();

            if (sessionhash_array == null)
            {
                byte[] rByte = new byte[16];
                Random ra    = new Random();
                ra.NextBytes(rByte);
                sessionhash_array = rByte;
            }
            // Device
            Signature.Types.DeviceInfo dInfo = new Signature.Types.DeviceInfo
            {
                DeviceId              = this.DeviceId,
                AndroidBoardName      = this.AndroidBoardName, // might al
                AndroidBootloader     = this.AndroidBootloader,
                DeviceBrand           = this.DeviceBrand,
                DeviceModel           = this.DeviceModel, // might als
                DeviceModelIdentifier = this.DeviceModelIdentifier,
                DeviceModelBoot       = this.DeviceModelBoot,
                HardwareManufacturer  = this.HardwareManufacturer,
                HardwareModel         = this.HardwareModel,
                FirmwareBrand         = this.FirmwareBrand,
                FirmwareTags          = this.FirmwareTags,
                FirmwareType          = this.FirmwareType,
                FirmwareFingerprint   = this.FirmwareFingerprint
            };

            var sig = new Signature
            {
                SessionHash         = ByteString.CopyFrom(sessionhash_array),
                Unknown25           = -8408506833887075802, // Could change every Update
                TimestampSinceStart = (ulong)(Utils.GetTime(true) - _client.StartTime),
                Timestamp           = (ulong)DateTime.UtcNow.ToUnixTime(),
                LocationHash1       = Utils.GenLocation1(ticket, _latitude, _longitude, _altitude),
                LocationHash2       = Utils.GenLocation2(_latitude, _longitude, _altitude),
                DeviceInfo          = dInfo
            };

            sig.SensorInfo.Add(new POGOProtos.Networking.Envelopes.Signature.Types.SensorInfo
            {
                GravityZ              = GenRandom(9.8),
                GravityX              = GenRandom(0.02),
                GravityY              = GenRandom(0.3),
                TimestampSnapshot     = (ulong)(Utils.GetTime(true) - _client.StartTime - RandomDevice.Next(100, 500)),
                LinearAccelerationX   = GenRandom(0.12271042913198471),
                LinearAccelerationY   = GenRandom(-0.015570580959320068),
                LinearAccelerationZ   = GenRandom(0.010850906372070313),
                MagneticFieldX        = GenRandom(17.950439453125),
                MagneticFieldY        = GenRandom(-23.36273193359375),
                MagneticFieldZ        = GenRandom(-48.8250732421875),
                RotationRateX         = GenRandom(-0.0120010357350111),
                RotationRateY         = GenRandom(-0.04214850440621376),
                RotationRateZ         = GenRandom(0.94571763277053833),
                AttitudePitch         = GenRandom(-47.149471283, 61.8397789001),
                AttitudeYaw           = GenRandom(-47.149471283, 61.8397789001),
                AttitudeRoll          = GenRandom(-47.149471283, 5),
                MagneticFieldAccuracy = -1,
                Status = 3
            });
            Random r        = new Random();
            int    accuracy = r.Next(15, 50);

            sig.LocationFix.Add(new POGOProtos.Networking.Envelopes.Signature.Types.LocationFix()
            {
                Provider           = "gps",
                TimestampSnapshot  = (ulong)(Utils.GetTime(true) - _client.StartTime - RandomDevice.Next(100, 300)),
                Latitude           = (float)_latitude,
                Longitude          = (float)_longitude,
                Altitude           = (float)_altitude,
                HorizontalAccuracy = accuracy,        // Genauigkeit von GPS undso
                ProviderStatus     = 3,
                Floor        = 3,
                LocationType = 1
            });

            foreach (var requst in requests)
            {
                sig.RequestHash.Add(Utils.GenRequestHash(ticket, requst.ToByteArray()));
            }

            var encryptedSig = new RequestEnvelope.Types.PlatformRequest
            {
                Type           = PlatformRequestType.SendEncryptedSignature,
                RequestMessage = new SendEncryptedSignatureRequest
                {
                    EncryptedSignature = ByteString.CopyFrom(PCrypt.Encrypt(sig.ToByteArray(), (uint)_client.StartTime))
                }.ToByteString()
            };

            return(encryptedSig);
        }
コード例 #4
0
ファイル: RequestBuilder.cs プロジェクト: xenderUWP/PoGo-UWP
        public RequestEnvelope SetRequestEnvelopeUnknown6(RequestEnvelope requestEnvelope)
        {
            if (_sessionHash == null)
            {
                _sessionHash = new byte[32];
                _random.NextBytes(_sessionHash);
            }

            byte[] authSeed = requestEnvelope.AuthTicket != null?
                              requestEnvelope.AuthTicket.ToByteArray() :
                                  requestEnvelope.AuthInfo.ToByteArray();


            var normAccel = new Vector(_deviceInfo.Sensors.AccelRawX, _deviceInfo.Sensors.AccelRawY, _deviceInfo.Sensors.AccelRawZ);

            normAccel.NormalizeVector(1.0f);//1.0f on iOS, 9.81 on Android?

            var sig = new Signature
            {
                LocationHash1 =
                    Utils.GenerateLocation1(authSeed, requestEnvelope.Latitude, requestEnvelope.Longitude,
                                            requestEnvelope.Accuracy, _deviceInfo.VersionData.HashSeed1),
                LocationHash2 =
                    Utils.GenerateLocation2(requestEnvelope.Latitude, requestEnvelope.Longitude,
                                            requestEnvelope.Accuracy, _deviceInfo.VersionData.HashSeed1),
                SessionHash         = ByteString.CopyFrom(_sessionHash),
                Unknown25           = _deviceInfo.VersionData.VersionHash,
                Timestamp           = (ulong)DateTime.UtcNow.ToUnixTime(),
                TimestampSinceStart = (ulong)_deviceInfo.TimeSnapshot,
                SensorInfo          = new Signature.Types.SensorInfo
                {
                    AccelNormalizedX  = normAccel.X,
                    AccelNormalizedY  = normAccel.Y,
                    AccelNormalizedZ  = normAccel.Z,
                    AccelRawX         = -_deviceInfo.Sensors.AccelRawX,
                    AccelRawY         = -_deviceInfo.Sensors.AccelRawY,
                    AccelRawZ         = -_deviceInfo.Sensors.AccelRawZ,
                    MagnetometerX     = _deviceInfo.Sensors.MagnetometerX,
                    MagnetometerY     = _deviceInfo.Sensors.MagnetometerY,
                    MagnetometerZ     = _deviceInfo.Sensors.MagnetometerZ,
                    GyroscopeRawX     = _deviceInfo.Sensors.GyroscopeRawX,
                    GyroscopeRawY     = _deviceInfo.Sensors.GyroscopeRawY,
                    GyroscopeRawZ     = _deviceInfo.Sensors.GyroscopeRawZ,
                    AngleNormalizedX  = _deviceInfo.Sensors.AngleNormalizedX,
                    AngleNormalizedY  = _deviceInfo.Sensors.AngleNormalizedY,
                    AngleNormalizedZ  = _deviceInfo.Sensors.AngleNormalizedZ,
                    AccelerometerAxes = _deviceInfo.Sensors.AccelerometerAxes,
                    TimestampSnapshot = (ulong)(_deviceInfo.Sensors.TimeSnapshot - _random.Next(150, 260))
                },
                DeviceInfo = new Signature.Types.DeviceInfo
                {
                    DeviceId              = _deviceInfo.DeviceID,
                    AndroidBoardName      = _deviceInfo.AndroidBoardName,
                    AndroidBootloader     = _deviceInfo.AndroidBootloader,
                    DeviceBrand           = _deviceInfo.DeviceBrand,
                    DeviceModel           = _deviceInfo.DeviceModel,
                    DeviceModelBoot       = _deviceInfo.DeviceModelBoot,
                    DeviceModelIdentifier = _deviceInfo.DeviceModelIdentifier,
                    FirmwareFingerprint   = _deviceInfo.FirmwareFingerprint,
                    FirmwareTags          = _deviceInfo.FirmwareTags,
                    HardwareManufacturer  = _deviceInfo.HardwareManufacturer,
                    HardwareModel         = _deviceInfo.HardwareModel,
                    FirmwareBrand         = _deviceInfo.FirmwareBrand,
                    FirmwareType          = _deviceInfo.FirmwareType
                },

                ActivityStatus = _deviceInfo.ActivityStatus != null ? new Signature.Types.ActivityStatus()
                {
                    Walking    = _deviceInfo.ActivityStatus.Walking,
                    Automotive = _deviceInfo.ActivityStatus.Automotive,
                    Cycling    = _deviceInfo.ActivityStatus.Cycling,
                    Running    = _deviceInfo.ActivityStatus.Running,
                    Stationary = _deviceInfo.ActivityStatus.Stationary,
                    Tilting    = _deviceInfo.ActivityStatus.Tilting,
                }
                : null
            };


            if (_deviceInfo.GpsSattelitesInfo.Length > 0)
            {
                sig.GpsInfo = new Signature.Types.AndroidGpsInfo();
                //sig.GpsInfo.TimeToFix //currently not filled

                _deviceInfo.GpsSattelitesInfo.ToList().ForEach(sat =>
                {
                    sig.GpsInfo.Azimuth.Add(sat.Azimuth);
                    sig.GpsInfo.Elevation.Add(sat.Elevation);
                    sig.GpsInfo.HasAlmanac.Add(sat.Almanac);
                    sig.GpsInfo.HasEphemeris.Add(sat.Emphasis);
                    sig.GpsInfo.SatellitesPrn.Add(sat.SattelitesPrn);
                    sig.GpsInfo.Snr.Add(sat.Snr);
                    sig.GpsInfo.UsedInFix.Add(sat.UsedInFix);
                });
            }

            _deviceInfo.LocationFixes.ToList().ForEach(loc => sig.LocationFix.Add(new Signature.Types.LocationFix
            {
                Floor              = loc.Floor,
                Longitude          = loc.Longitude,
                Latitude           = loc.Latitude,
                Altitude           = loc.Altitude,
                LocationType       = loc.LocationType,
                Provider           = loc.Provider,
                ProviderStatus     = loc.ProviderStatus,
                HorizontalAccuracy = loc.HorizontalAccuracy,
                VerticalAccuracy   = loc.VerticalAccuracy,
                Course             = loc.Course,
                Speed              = loc.Speed,
                TimestampSnapshot  = loc.TimeSnapshot
            }));

            foreach (var request in requestEnvelope.Requests)
            {
                sig.RequestHash.Add(
                    Utils.GenerateRequestHash(authSeed, request.ToByteArray(), _deviceInfo.VersionData.HashSeed1)
                    );
            }

            requestEnvelope.Unknown6 = new Unknown6
            {
                RequestType = 6,
                Unknown2    = new Unknown6.Types.Unknown2
                {
                    EncryptedSignature = ByteString.CopyFrom(PCrypt.encrypt(sig.ToByteArray(), (uint)_deviceInfo.TimeSnapshot))
                }
            };

            return(requestEnvelope);
        }