コード例 #1
0
        public RequestEnvelope GetInitialRequestEnvelope(params Request[] customRequests)
        {
            var e = new RequestEnvelope
            {
                StatusCode = 2,                                                                                                      //1

                RequestId = (ulong)DateTime.UtcNow.ToUnixTime() * 1000000 + (ulong)(RandomDevice.NextDouble() * 1000000 - 0.000001), //1469378659230941192, //3
                Requests  = { customRequests },                                                                                      //4

                //Unknown6 = , //6
                Latitude  = _latitude,  //7
                Longitude = _longitude, //8
                Altitude  = _altitude,  //9
                AuthInfo  = new RequestEnvelope.Types.AuthInfo
                {
                    Provider = _authType == AuthType.Google ? "google" : "ptc",
                    Token    = new RequestEnvelope.Types.AuthInfo.Types.JWT
                    {
                        Contents = _authToken,
                        Unknown2 = 14
                    }
                },                                                   //10
                MsSinceLastLocationfix = RandomDevice.Next(700, 999) //12
            };

            return(e);
        }
コード例 #2
0
ファイル: RequestBuilder.cs プロジェクト: leeleonis/Cpko
        public RequestEnvelope GetRequestEnvelope(params Request[] customRequests)
        {
            if (_authTicket == null)
            {
                return(new RequestEnvelope());
            }
            var e = new RequestEnvelope
            {
                StatusCode = 2,                  //1

                RequestId = 1469378659230941192, //3
                Requests  = { customRequests },  //4

                //Unknown6 = , //6
                Latitude               = _latitude,                  //7
                Longitude              = _longitude,                 //8
                Altitude               = _altitude,                  //9
                AuthTicket             = _authTicket,                //11
                MsSinceLastLocationfix = RandomDevice.Next(700, 999) //12
            };

            e.Unknown6 = new Unknown6();
            e.Unknown6.MergeFrom(GenerateSignature(customRequests));
            return(e);
        }
コード例 #3
0
        private byte[] Encrypt(byte[] bytes)
        {
            var outputLength = 32 + bytes.Length + (256 - (bytes.Length % 256));
            var ptr          = Marshal.AllocHGlobal(outputLength);
            var ptrOutput    = Marshal.AllocHGlobal(outputLength);

            FillMemory(ptr, (uint)outputLength, 0);
            FillMemory(ptrOutput, (uint)outputLength, 0);
            Marshal.Copy(bytes, 0, ptr, bytes.Length);

            int outputSize = outputLength;

            byte[] iv = new byte[32];

            lock (RandomDevice)
            {
                RandomDevice.NextBytes(iv);
            }

            EncryptNative(ptr, bytes.Length, iv, iv.Length, ptrOutput, out outputSize);

            var output = new byte[outputLength];

            Marshal.Copy(ptrOutput, output, 0, outputLength);

            Marshal.FreeHGlobal(ptrOutput);
            Marshal.FreeHGlobal(ptr);

            return(output);
        }
コード例 #4
0
        public RequestEnvelope GetRequestEnvelope(params Request[] customRequests)
        {
            int randomUk12 = 0;

            lock (RandomDevice)
            {
                randomUk12 = RandomDevice.Next(100, 999);
            }

            var e = new RequestEnvelope
            {
                StatusCode = 2,                 //1

                RequestId = _requestId,         //3
                Requests  = { customRequests }, //4

                //Unknown6 = , //6
                Latitude   = _latitude,   //7
                Longitude  = _longitude,  //8
                Altitude   = _altitude,   //9
                AuthTicket = _authTicket, //11
                Unknown12  = randomUk12   //12
            };

            e.Unknown6.Add(GenerateSignature(customRequests));
            return(e);
        }
コード例 #5
0
        public RequestEnvelope GetInitialRequestEnvelope(params Request[] customRequests)
        {
            var e = new RequestEnvelope
            {
                StatusCode = 2, //1

                RequestId = _nextRequestId++, //3
                Requests = { customRequests }, //4
                
                //Unknown6 = , //6
                Latitude = _latitude, //7
                Longitude = _longitude, //8
                Accuracy = _accuracy, //9
                AuthInfo = new POGOProtos.Networking.Envelopes.RequestEnvelope.Types.AuthInfo
                {
                    Provider = _authType == AuthType.Google ? "google" : "ptc",
                    Token = new POGOProtos.Networking.Envelopes.RequestEnvelope.Types.AuthInfo.Types.JWT
                    {
                        Contents = _authToken,
                        Unknown2 = 59
                    }
                }, //10
                MsSinceLastLocationfix = RandomDevice.Next(1200, 1900) //12
            };
            return e;
        }
コード例 #6
0
        public RequestEnvelope GetRequestEnvelope(params Request[] customRequests)
        {
            if (_authTicket == null)
            {
                return(new RequestEnvelope());
            }
            var e = new RequestEnvelope
            {
                StatusCode = 2,                                                                                            //1

                RequestId = (ulong)DateTime.UtcNow.ToUnixTime() + (ulong)(RandomDevice.NextDouble() * 1000000 - 0.000001), //3
                Requests  = { customRequests },                                                                            //4

                //Unknown6 = , //6
                Latitude               = _latitude,                  //7
                Longitude              = _longitude,                 //8
                Altitude               = _altitude,                  //9
                AuthTicket             = _authTicket,                //11
                MsSinceLastLocationfix = RandomDevice.Next(700, 999) //12
            };

            e.Unknown6 = new Unknown6();
            e.Unknown6.MergeFrom(GenerateSignature(customRequests));
            return(e);
        }
コード例 #7
0
        public RequestBuilder(string authToken, AuthType authType, double latitude, double longitude, double altitude, ISettings settings, AuthTicket authTicket = null)
        {
            _authToken     = authToken;
            _authType      = authType;
            _latitude      = latitude;
            _longitude     = longitude;
            _altitude      = altitude;
            this.settings  = settings;
            _authTicket    = authTicket;
            _nextRequestId = Convert.ToUInt64(RandomDevice.NextDouble() * Math.Pow(10, 18));
            if (_startTime == 0)
            {
                _startTime = Utils.GetTime(true);
            }

            if (SessionHash == null)
            {
                GenerateNewHash();
            }

            if (crypt == null)
            {
                crypt = new Crypt();
            }
        }
コード例 #8
0
        public ByteString GenerateNewHash()
        {
            var hashBytes = new byte[16];

            RandomDevice.NextBytes(hashBytes);

            return(ByteString.CopyFrom(hashBytes));
        }
コード例 #9
0
        public void GenerateNewHash()
        {
            var hashBytes = new byte[16];

            RandomDevice.NextBytes(hashBytes);

            SessionHash = ByteString.CopyFrom(hashBytes);
        }
コード例 #10
0
ファイル: FunctionTestForm.cs プロジェクト: WZWGeorge/RTDB
        private void 关联设备ToolStripMenuItemClick(object sender, EventArgs e)
        {
            if (dataGridView_Avaiable.SelectedRows.Count <= 0)
            {
                MessageBox.Show("关联变量必须选中变量");
                return;
            }
            DeviceBase deviceBase = new RandomDevice();

            DeviceAdapter.AddMap(
                _iVariableDesignRepository.FindVariableByPath(
                    dataGridView_Avaiable.SelectedRows[0].Cells[1].Value.ToString()),
                deviceBase);
        }
コード例 #11
0
        public RequestBuilder(string authToken, AuthType authType, double latitude, double longitude, double altitude, ISettings settings, AuthTicket authTicket = null)
        {
            _authToken  = authToken;
            _authType   = authType;
            _latitude   = latitude;
            _longitude  = longitude;
            _altitude   = altitude;
            _settings   = settings;
            _authTicket = authTicket;
            if (!InternalWatch.IsRunning)
            {
                InternalWatch.Start();
            }

            var hashBytes = new byte[16];

            RandomDevice.NextBytes(hashBytes);

            _sessionHash = ByteString.CopyFrom(hashBytes);

            if (_encryptNative != null)
            {
                return;
            }
            if (IntPtr.Size == 4)
            {
                _encryptNativeInit = (EncryptInitDelegate)
                                     FunctionLoader.LoadFunction <EncryptInitDelegate>(
                    @"Resources\encrypt32.dll", "MobBot");

                _encryptNative = (EncryptDelegate)
                                 FunctionLoader.LoadFunction <EncryptDelegate>(
                    @"Resources\encrypt32.dll", "encryptMobBot");
            }
            else
            {
                _encryptNativeInit = (EncryptInitDelegate)
                                     FunctionLoader.LoadFunction <EncryptInitDelegate>(
                    @"Resources\encrypt64.dll", "MobBot");

                _encryptNative = (EncryptDelegate)
                                 FunctionLoader.LoadFunction <EncryptDelegate>(
                    @"Resources\encrypt64.dll", "encryptMobBot");
            }
        }
コード例 #12
0
 public RequestBuilder(string authToken, AuthType authType, double latitude, double longitude, double altitude, double horizontalAccuracy, ISettings settings, AuthTicket authTicket = null)
 {
     _authToken = authToken;
     _authType = authType;
     _currentSpeed = currentSpeed;
     _latitude = latitude;
     _longitude = longitude;
     _altitude = altitude;
     _authTicket = authTicket;
     _accuracy = horizontalAccuracy;
     this.settings = settings;
     _nextRequestId = Convert.ToUInt64(RandomDevice.NextDouble() * Math.Pow(10, 18));
     if (_startTime == 0)
         _startTime = Utils.GetTime(true);
     if (SessionHash == null)
     {
         GenerateNewHash();
     }
 }  
コード例 #13
0
        public RequestEnvelope GetRequestEnvelope(params Request[] customRequests)
        {
            var e = new RequestEnvelope
            {
                StatusCode = 2, //1

                RequestId = _nextRequestId++, //3
                Requests = { customRequests }, //4

                //Unknown6 = , //6
                Latitude = _latitude, //7
                Longitude = _longitude, //8
                Accuracy = _accuracy, //9
                AuthTicket = _authTicket, //11
                MsSinceLastLocationfix = RandomDevice.Next(800, 1900) //12
            };
            e.PlatformRequests.Add(GenerateSignature(customRequests));
            return e;
        }
コード例 #14
0
    protected override void Attack()
    {
        if (Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;

            Vector3    normalizedDirection = (target.position - transform.position).normalized;
            GameObject projectile          = GameObject.Instantiate(m_projectile, transform.position + normalizedDirection * 2f, transform.rotation) as GameObject;
            Rigidbody  rb = projectile.GetComponent <Rigidbody>();

            Vector3 ballisticVelocity = GetBallisticVelocity(target.position, RandomDevice.NextInt(15, 60));

            rb.AddForce(ballisticVelocity, ForceMode.Impulse);

            SoundOnAttack soa = GetComponent <SoundOnAttack>();

            if (soa != null)
            {
                soa.Play();
            }
        }
    }
コード例 #15
0
        public Cell GetDominantCell(Cell[] neighbors, int?probability)
        {
            Cell dominantCell = null;
            int  chance       = RandomDevice.Next(1, 100);

            if (chance > probability)
            {
                return(dominantCell);
            }

            IEnumerable <IGrouping <int, Cell> > groups = neighbors.Where(c => c is Cell && c.Id > 0)
                                                          .GroupBy(c => c.Id)
                                                          .OrderByDescending(g => g.Count());

            if (groups.Any())
            {
                IEnumerable <IGrouping <int, Cell> > max = groups.Where(x => x.Count() == groups.First().Count());
                dominantCell = max.ElementAt(RandomDevice.Next(max.Count())).First();
            }

            return(dominantCell);
        }
コード例 #16
0
        public RequestEnvelope GetInitialRequestEnvelope(params Request[] customRequests)
        {
            int randomUk12 = 0;
            int randomUk2  = 0;

            lock (RandomDevice)
            {
                randomUk12 = RandomDevice.Next(100, 1000);
                randomUk2  = RandomDevice.Next(10, 100);
            }

            var e = new RequestEnvelope
            {
                StatusCode = 2,                 //1

                RequestId = _requestId,         //3
                Requests  = { customRequests }, //4

                //Unknown6 = , //6
                Latitude  = _latitude,  //7
                Longitude = _longitude, //8
                Altitude  = _altitude,  //9
                AuthInfo  = new POGOProtos.Networking.Envelopes.RequestEnvelope.Types.AuthInfo
                {
                    Provider = _authType == AuthType.Google ? "google" : "ptc",
                    Token    = new POGOProtos.Networking.Envelopes.RequestEnvelope.Types.AuthInfo.Types.JWT
                    {
                        Contents = _authToken,
                        Unknown2 = randomUk2
                    }
                },                     //10
                Unknown12 = randomUk12 //12
            };

            return(e);
        }
コード例 #17
0
        //public uint RequestCount { get; private set; } = 1;

        //private readonly Random _random = new Random(Environment.TickCount);

        /*
         * private long PositiveRandom()
         * {
         *  long ret = _random.Next() | (_random.Next() << 32);
         *  // lrand48 ensures it's never < 0
         *  // So do the same
         *  if (ret < 0)
         *      ret = -ret;
         *  return ret;
         * }
         *
         * private void IncrementRequestCount()
         * {
         *  // Request counts on android jump more than 1 at a time according to logs
         *  // They are fully sequential on iOS though
         *  // So mimic that same behavior here.
         *  if (_client.Platform == Platform.Android)
         *      RequestCount += (uint)_random.Next(2, 15);
         *  else if (_client.Platform == Platform.Ios)
         *      RequestCount++;
         * }
         *
         * private ulong GetNextRequestId()
         * {
         *  if (RequestCount == 1)
         *  {
         *      IncrementRequestCount();
         *      if (_client.Platform == Platform.Android)
         *      {
         *          // lrand48 is "broken" in that the first run of it will return a static value.
         *          // So the first time we send a request, we need to match that initial value.
         *          // Note: On android srand(4) is called in .init_array which seeds the initial value.
         *          return 0x53B77E48000000B0;
         *      }
         *      if (_client.Platform == Platform.Ios)
         *      {
         *          // Same as lrand48, iOS uses "rand()" without a pre-seed which always gives the same first value.
         *          return 0x41A700000002;
         *      }
         *  }
         *
         *  // Note that the API expects a "positive" random value here. (At least on Android it does due to lrand48 implementation details)
         *  // So we'll just use the same for iOS since it doesn't hurt, and means less code required.
         *  ulong r = (((ulong)PositiveRandom() | ((RequestCount + 1) >> 31)) << 32) | (RequestCount + 1);
         *  IncrementRequestCount();
         *  return r;
         * }
         */

        //private RequestEnvelope.Types.PlatformRequest GenerateSignature(IEnumerable<IMessage> requests)
        /// <summary>
        /// EB Check IMessage
        /// </summary>
        /// <param name="requestEnvelope"></param>
        /// <returns></returns>
        /// Also pogolib does
        /// internal async Task<PlatformRequest> GenerateSignatureAsync(RequestEnvelope requestEnvelope)
        private RequestEnvelope.Types.PlatformRequest GenerateSignature(RequestEnvelope requestEnvelope)
        {
            var timestampSinceStart = (long)(Utils.GetTime(true) - _client.StartTime);
            var locationFixes       = BuildLocationFixes(requestEnvelope, timestampSinceStart);

            requestEnvelope.Accuracy = locationFixes[0].Altitude;
            requestEnvelope.MsSinceLastLocationfix = (long)locationFixes[0].TimestampSnapshot;

            #region GenerateSignature
            var signature = new Signature
            {
                TimestampSinceStart = (ulong)timestampSinceStart,
                Timestamp           = (ulong)Utils.GetTime(true), // true means in Ms

                SensorInfo =
                {
                    new SensorInfo
                    {
                        // Values are not the same used in PogoLib
                        TimestampSnapshot   = (ulong)(timestampSinceStart + RandomDevice.Next(100, 250)),
                        LinearAccelerationX = GenRandom(0.12271042913198471),
                        LinearAccelerationY = GenRandom(-0.015570580959320068),
                        LinearAccelerationZ = GenRandom(0.010850906372070313),
                        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),
                        GravityZ            = GenRandom(9.8),
                        GravityX            = GenRandom(0.02),
                        GravityY            = GenRandom(0.3),

/*                        MagneticFieldX = GenRandom(17.950439453125),
 *                      MagneticFieldY = GenRandom(-23.36273193359375),
 *                      MagneticFieldZ = GenRandom(-48.8250732421875),*/
                        MagneticFieldAccuracy = -1,
                        Status = 3
                    }
                },
                DeviceInfo     = _DeviceInfo,// dInfo,
                LocationFix    = { locationFixes },
                ActivityStatus = new ActivityStatus
                {
                    Stationary = true
                }
            };
            #endregion

            signature.SessionHash = _sessionHash;
            signature.Unknown25   = Resources.Unknown25;

            var serializedTicket = requestEnvelope.AuthTicket != null?requestEnvelope.AuthTicket.ToByteArray() : requestEnvelope.AuthInfo.ToByteArray();

            var locationBytes = BitConverter.GetBytes(_latitude).Reverse()
                                .Concat(BitConverter.GetBytes(_longitude).Reverse())
                                .Concat(BitConverter.GetBytes(locationFixes[0].Altitude).Reverse()).ToArray();

            var requestsBytes = requestEnvelope.Requests.Select(x => x.ToByteArray()).ToArray();

            HashRequestContent hashRequest = new HashRequestContent()
            {
                Timestamp   = signature.Timestamp,
                Latitude    = requestEnvelope.Latitude,
                Longitude   = requestEnvelope.Longitude,
                Altitude    = requestEnvelope.Accuracy,
                AuthTicket  = serializedTicket,
                SessionData = signature.SessionHash.ToByteArray(),
                Requests    = new List <byte[]>(requestsBytes)
            };

            HashResponseContent responseContent;

            responseContent = _client.Hasher.RequestHashes(hashRequest);

            signature.LocationHash1 = unchecked ((int)responseContent.LocationAuthHash);
            signature.LocationHash2 = unchecked ((int)responseContent.LocationHash);
            signature.RequestHash.AddRange(responseContent.RequestHashes.Select(x => (ulong)x).ToArray());

            var encryptedSignature = new PlatformRequest
            {
                Type           = PlatformRequestType.SendEncryptedSignature,
                RequestMessage = new SendEncryptedSignatureRequest
                {
                    EncryptedSignature = ByteString.CopyFrom(PCryptPokeHash.Encrypt(signature.ToByteArray(), (uint)timestampSinceStart))
                }.ToByteString()
            };

            return(encryptedSignature);
        }
コード例 #18
0
        private RequestEnvelope.Types.PlatformRequest GenerateSignature(IEnumerable<IMessage> requests)
        {
            var ticketBytes = _authTicket.ToByteArray();
            var sig = new SignalAgglomUpdates()
            {
                EpochTimestampMs = (ulong)Utils.GetTime(true),
                TimestampMsSinceStart = (ulong)(Utils.GetTime(true) - _startTime),
                LocationHashByTokenSeed = (uint)Utils.GenerateLocation1(ticketBytes, _latitude, _longitude, _accuracy),
                LocationHash = (uint)Utils.GenerateLocation2(_latitude, _longitude, _accuracy),
                SensorUpdates = new SignalAgglomUpdates.Types.SensorUpdate()
                {
                    GravityX = GenRandom(-0.31110161542892456, 0.1681540310382843),
                    GravityY = GenRandom(-0.6574847102165222, -0.07290205359458923),
                    GravityZ = GenRandom(-0.9943905472755432, -0.7463029026985168),
                    Timestamp = (ulong)(Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 400)),
                    AccelerationX = GenRandom(-0.139084026217, 0.138112977147),
                    AccelerationY = GenRandom(-0.2, 0.19),
                    AccelerationZ = GenRandom(-0.2, 0.4),
                    MagneticFieldX = GenRandom(-47.149471283, 61.8397789001),
                    MagneticFieldY = GenRandom(-47.149471283, 61.8397789001),
                    MagneticFieldZ = GenRandom(-47.149471283, 5),
                    AttitudePitch = GenRandom(0.0729667818829, 0.0729667818829),
                    AttitudeYaw = GenRandom(-2.788630499244109, 3.0586791383810468),
                    AttitudeRoll = GenRandom(-0.34825887123552773, 0.19347580173737935),
                    RotationRateX = GenRandom(-0.9703824520111084, 0.8556089401245117),
                    RotationRateY = GenRandom(-1.7470258474349976, 1.4218578338623047),
                    RotationRateZ = GenRandom(-0.9681901931762695, 0.8396636843681335),
                    Status = 3
                },
                DeviceInfo = new SignalAgglomUpdates.Types.DeviceInfo()
                {
                    DeviceId = settings.DeviceId,
                    AndroidBoardName = settings.AndroidBoardName,
                    AndroidBootloader = settings.AndroidBootloader,
                    DeviceBrand = settings.DeviceBrand,
                    DeviceModel = settings.DeviceModel,
                    DeviceModelIdentifier = settings.DeviceModelIdentifier,
                    DeviceCommsModel = settings.DeviceModelBoot,
                    HardwareManufacturer = settings.HardwareManufacturer,
                    HardwareModel = settings.HardwareModel,
                    FirmwareBrand = settings.FirmwareBrand,
                    FirmwareTags = settings.FirmwareTags,
                    FirmwareType = settings.FirmwareType,
                    FirmwareFingerprint = settings.FirmwareFingerprint
                }
                };
            if (settings.DeviceBrand == "APPLE")
                sig.LocationUpdates.Add(new SignalAgglomUpdates.Types.LocationUpdate()
                {
                    Name = "fused",
                    TimestampMs = (Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 300)),
                    Latitude = (float)_latitude,
                    Longitude = (float)_longitude,
                    Altitude = (-(float)_altitude) - 13,
                    DeviceSpeed = (float)_currentSpeed,
                    DeviceCourse = -1,
                    HorizontalAccuracy = (float)_accuracy,
                    VerticalAccuracy = RandomDevice.Next(2, 5),
                    ProviderStatus = 3,
                    Floor = 0,
                    LocationType = 1
                });
            else
                sig.LocationUpdates.Add(new SignalAgglomUpdates.Types.LocationUpdate()
                {
                    Name = "fused",
                    TimestampMs = (Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 300)),
                    Latitude = (float)_latitude,
                    Longitude = (float)_longitude,
                    Altitude = (-(float)_altitude) - 13,
                    HorizontalAccuracy = (float)_accuracy,
                    VerticalAccuracy = RandomDevice.Next(2, 5),
                    ProviderStatus = 3,
                    Floor = 0,
                    LocationType = 1
                });

            //Compute 10
            var x = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            var firstHash = BitConverter.ToUInt32(x.ComputeHash(_authTicket.ToByteArray()), 0);
            x = new System.Data.HashFunction.xxHash(32, firstHash);
            var locationBytes = BitConverter.GetBytes(_latitude).Reverse()
                .Concat(BitConverter.GetBytes(_longitude).Reverse())
                .Concat(BitConverter.GetBytes(_accuracy).Reverse()).ToArray();
            sig.LocationHashByTokenSeed = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 20
            x = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            sig.LocationHash = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 24
            x = new System.Data.HashFunction.xxHash(64, 0x1B845238);
            var seed = BitConverter.ToUInt64(x.ComputeHash(_authTicket.ToByteArray()), 0);
            x = new System.Data.HashFunction.xxHash(64, seed);
            foreach (var req in requests)
                sig.RequestHashes.Add(BitConverter.ToUInt64(x.ComputeHash(req.ToByteArray()), 0));

            sig.Field22 = SessionHash;
            //static for now
            sig.Field25 = 7363665268261373700;




            RequestEnvelope.Types.PlatformRequest val = new RequestEnvelope.Types.PlatformRequest();
            val.Type = PlatformRequestType.SendEncryptedSignature;
            SendEncryptedSignatureRequest sigRequest = new SendEncryptedSignatureRequest();
            sigRequest.EncryptedSignature = ByteString.CopyFrom(Encrypt(sig.ToByteArray()));
            val.RequestMessage = sigRequest.ToByteString();
            return val;
            
        }
コード例 #19
0
        private Unknown6 GenerateSignature(IEnumerable <IMessage> requests)
        {
            var sig = new Signature();

            sig.TimestampSinceStart = (ulong)(Utils.GetTime(true) - _startTime);
            sig.Timestamp           = (ulong)DateTime.UtcNow.ToUnixTime();
            sig.SensorInfo          = new Signature.Types.SensorInfo()
            {
                AccelNormalizedX  = GenRandom(-0.31110161542892456, 0.1681540310382843),
                AccelNormalizedY  = GenRandom(-0.6574847102165222, -0.07290205359458923),
                AccelNormalizedZ  = GenRandom(-0.9943905472755432, -0.7463029026985168),
                TimestampSnapshot = (ulong)(Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 400)),
                MagnetometerX     = GenRandom(-0.139084026217, 0.138112977147),
                MagnetometerY     = GenRandom(-0.2, 0.19),
                MagnetometerZ     = GenRandom(-0.2, 0.4),
                AngleNormalizedX  = GenRandom(-47.149471283, 61.8397789001),
                AngleNormalizedY  = GenRandom(-47.149471283, 61.8397789001),
                AngleNormalizedZ  = GenRandom(-47.149471283, 5),
                AccelRawX         = GenRandom(0.0729667818829, 0.0729667818829),
                AccelRawY         = GenRandom(-2.788630499244109, 3.0586791383810468),
                AccelRawZ         = GenRandom(-0.34825887123552773, 0.19347580173737935),
                GyroscopeRawX     = GenRandom(-0.9703824520111084, 0.8556089401245117),
                GyroscopeRawY     = GenRandom(-1.7470258474349976, 1.4218578338623047),
                GyroscopeRawZ     = GenRandom(-0.9681901931762695, 0.8396636843681335),
                AccelerometerAxes = 3
            };

            sig.DeviceInfo = new POGOProtos.Networking.Signature.Types.DeviceInfo();
            if (settings.DeviceId != null)
            {
                sig.DeviceInfo.DeviceId = settings.DeviceId;
            }
            if (settings.AndroidBoardName != null)
            {
                sig.DeviceInfo.AndroidBoardName = settings.AndroidBoardName;
            }
            if (settings.AndroidBootloader != null)
            {
                sig.DeviceInfo.AndroidBootloader = settings.AndroidBootloader;
            }
            if (settings.DeviceBrand != null)
            {
                sig.DeviceInfo.DeviceBrand = settings.DeviceBrand;
            }
            if (settings.DeviceModel != null)
            {
                sig.DeviceInfo.DeviceModel = settings.DeviceModel;
            }
            if (settings.DeviceModelIdentifier != null)
            {
                sig.DeviceInfo.DeviceModelIdentifier = settings.DeviceModelIdentifier;
            }
            if (settings.DeviceModelBoot != null)
            {
                sig.DeviceInfo.DeviceModelBoot = settings.DeviceModelBoot;
            }
            if (settings.HardwareManufacturer != null)
            {
                sig.DeviceInfo.HardwareManufacturer = settings.HardwareManufacturer;
            }
            if (settings.HardwareModel != null)
            {
                sig.DeviceInfo.HardwareModel = settings.HardwareModel;
            }
            if (settings.FirmwareBrand != null)
            {
                sig.DeviceInfo.FirmwareBrand = settings.FirmwareBrand;
            }
            if (settings.FirmwareTags != null)
            {
                sig.DeviceInfo.FirmwareTags = settings.FirmwareTags;
            }
            if (settings.FirmwareType != null)
            {
                sig.DeviceInfo.FirmwareType = settings.FirmwareType;
            }
            if (settings.FirmwareFingerprint != null)
            {
                sig.DeviceInfo.FirmwareFingerprint = settings.FirmwareFingerprint;
            }

            sig.LocationFix.Add(new POGOProtos.Networking.Signature.Types.LocationFix()
            {
                Provider           = "fused",
                Latitude           = (float)_latitude,
                Longitude          = (float)_longitude,
                Altitude           = (float)_altitude,
                HorizontalAccuracy = (float)Math.Round(GenRandom(50, 250), 7),
                VerticalAccuracy   = RandomDevice.Next(2, 5),
                //TimestampSnapshot = (ulong)(Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 300)),
                ProviderStatus = 3,
                LocationType   = 1
            });

            //Compute 10
            var x         = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            var firstHash = BitConverter.ToUInt32(x.ComputeHash(_authTicket.ToByteArray()), 0);

            x = new System.Data.HashFunction.xxHash(32, firstHash);
            var locationBytes = BitConverter.GetBytes(_latitude).Reverse()
                                .Concat(BitConverter.GetBytes(_longitude).Reverse())
                                .Concat(BitConverter.GetBytes(_altitude).Reverse()).ToArray();

            sig.LocationHash1 = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 20
            x = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            sig.LocationHash2 = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 24
            x = new System.Data.HashFunction.xxHash(64, 0x1B845238);
            var seed = BitConverter.ToUInt64(x.ComputeHash(_authTicket.ToByteArray()), 0);

            x = new System.Data.HashFunction.xxHash(64, seed);
            foreach (var req in requests)
            {
                sig.RequestHash.Add(BitConverter.ToUInt64(x.ComputeHash(req.ToByteArray()), 0));
            }

            //static for now
            sig.Unk22 = ByteString.CopyFrom(new byte[16] {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
            });


            Unknown6 val = new Unknown6();

            val.RequestType       = 6;
            val.Unknown2          = new Unknown6.Types.Unknown2();
            val.Unknown2.Unknown1 = ByteString.CopyFrom(Encrypt(sig.ToByteArray()));
            return(val);
        }
コード例 #20
0
        private Unknown6 GenerateSignature(IEnumerable <IMessage> requests)
        {
            var sig = new POGOProtos.Networking.Signature();

            sig.TimestampSinceStart = (ulong)_internalWatch.ElapsedMilliseconds;
            sig.Timestamp           = (ulong)DateTime.UtcNow.ToUnixTime();
            sig.SensorInfo          = new POGOProtos.Networking.Signature.Types.SensorInfo()
            {
                AccelNormalizedZ  = GenRandom(9.8),
                AccelNormalizedX  = GenRandom(0.02),
                AccelNormalizedY  = GenRandom(0.3),
                TimestampSnapshot = (ulong)_internalWatch.ElapsedMilliseconds - 230,
                MagnetometerX     = GenRandom(0.12271042913198471),
                MagnetometerY     = GenRandom(-0.015570580959320068),
                MagnetometerZ     = GenRandom(0.010850906372070313),
                AngleNormalizedX  = GenRandom(17.950439453125),
                AngleNormalizedY  = GenRandom(-23.36273193359375),
                AngleNormalizedZ  = GenRandom(-48.8250732421875),
                AccelRawX         = GenRandom(-0.0120010357350111),
                AccelRawY         = GenRandom(-0.04214850440621376),
                AccelRawZ         = GenRandom(0.94571763277053833),
                GyroscopeRawX     = GenRandom(7.62939453125e-005),
                GyroscopeRawY     = GenRandom(-0.00054931640625),
                GyroscopeRawZ     = GenRandom(0.0024566650390625),
                AccelerometerAxes = 3
            };
            sig.DeviceInfo = new POGOProtos.Networking.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
            };

            float altitude      = 0;
            long  requestLength = 200;

            lock (RandomDevice)
            {
                altitude      = (float)(RandomDevice.NextDouble() * (15 - 10) + 10);
                requestLength = (long)RandomDevice.Next(100, 300);
            }

            sig.LocationFix.Add(new POGOProtos.Networking.Signature.Types.LocationFix()
            {
                Provider = "network",

                //Unk4 = 120,
                Latitude  = (float)_latitude,
                Longitude = (float)_longitude,
                //Altitude = (float)_altitude,
                Altitude            = altitude, //Just random for now
                TimestampSinceStart = (ulong)(_internalWatch.ElapsedMilliseconds - requestLength),
                Floor        = 3,
                LocationType = 1
            });

            //Compute 10
            var x         = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            var firstHash = BitConverter.ToUInt32(x.ComputeHash(_authTicket.ToByteArray()), 0);

            x = new System.Data.HashFunction.xxHash(32, firstHash);
            var locationBytes = BitConverter.GetBytes(_latitude).Reverse()
                                .Concat(BitConverter.GetBytes(_longitude).Reverse())
                                .Concat(BitConverter.GetBytes(_altitude).Reverse()).ToArray();

            sig.LocationHash1 = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 20
            x = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            sig.LocationHash2 = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 24
            x = new System.Data.HashFunction.xxHash(64, 0x1B845238);
            var seed = BitConverter.ToUInt64(x.ComputeHash(_authTicket.ToByteArray()), 0);

            x = new System.Data.HashFunction.xxHash(64, seed);
            foreach (var req in requests)
            {
                sig.RequestHash.Add(BitConverter.ToUInt64(x.ComputeHash(req.ToByteArray()), 0));
            }

            //static for now
            //sig.Unk22 = ByteString.CopyFrom(new byte[16] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F });
            byte[] buffer = new byte[16];

            lock (RandomDevice)
            {
                RandomDevice.NextBytes(buffer);
            }

            sig.Unk22 = ByteString.CopyFrom(buffer);

            Unknown6 val = new Unknown6();

            val.RequestType       = 6;
            val.Unknown2          = new Unknown6.Types.Unknown2();
            val.Unknown2.Unknown1 = ByteString.CopyFrom(Encrypt(sig.ToByteArray()));
            return(val);
        }
コード例 #21
0
        private Unknown6 GenerateSignature(IEnumerable <IMessage> requests)
        {
            var ticketBytes = _authTicket.ToByteArray();

            Signature.Types.DeviceInfo deviceInfo;
            if (settings.HardwareManufacturer.Equals("Apple", StringComparison.Ordinal))
            {
                // iOS
                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,
                };
            }
            else
            {
                // Android
                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
                };
            }

            var sig = new Signature()
            {
                Timestamp           = (ulong)Utils.GetTime(true),
                TimestampSinceStart = (ulong)(Utils.GetTime(true) - _startTime),
                LocationHash1       = Utils.GenerateLocation1(ticketBytes, _latitude, _longitude, _altitude),
                LocationHash2       = Utils.GenerateLocation2(_latitude, _longitude, _altitude),
                SensorInfo          = new Signature.Types.SensorInfo()
                {
                    AccelNormalizedX  = GenRandom(-0.31110161542892456, 0.1681540310382843),
                    AccelNormalizedY  = GenRandom(-0.6574847102165222, -0.07290205359458923),
                    AccelNormalizedZ  = GenRandom(-0.9943905472755432, -0.7463029026985168),
                    TimestampSnapshot = (ulong)(Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 400)),
                    MagnetometerX     = GenRandom(-0.139084026217, 0.138112977147),
                    MagnetometerY     = GenRandom(-0.2, 0.19),
                    MagnetometerZ     = GenRandom(-0.2, 0.4),
                    AngleNormalizedX  = GenRandom(-47.149471283, 61.8397789001),
                    AngleNormalizedY  = GenRandom(-47.149471283, 61.8397789001),
                    AngleNormalizedZ  = GenRandom(-47.149471283, 5),
                    AccelRawX         = GenRandom(0.0729667818829, 0.0729667818829),
                    AccelRawY         = GenRandom(-2.788630499244109, 3.0586791383810468),
                    AccelRawZ         = GenRandom(-0.34825887123552773, 0.19347580173737935),
                    GyroscopeRawX     = GenRandom(-0.9703824520111084, 0.8556089401245117),
                    GyroscopeRawY     = GenRandom(-1.7470258474349976, 1.4218578338623047),
                    GyroscopeRawZ     = GenRandom(-0.9681901931762695, 0.8396636843681335),
                    AccelerometerAxes = 3
                },
                DeviceInfo = deviceInfo
            };

            sig.LocationFix.Add(new Signature.Types.LocationFix()
            {
                Provider           = "fused",
                Latitude           = (float)_latitude,
                Longitude          = (float)_longitude,
                Altitude           = (float)_altitude,
                HorizontalAccuracy = (float)Math.Round(GenRandom(50, 250), 7),
                VerticalAccuracy   = RandomDevice.Next(2, 5),
                TimestampSnapshot  = (ulong)(Utils.GetTime(true) - _startTime - RandomDevice.Next(100, 300)),
                ProviderStatus     = 3,
                LocationType       = 1
            });

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

            sig.SessionHash = SessionHash;
            //sig.Unknown25 = -8537042734809897855; // For 0.33
            sig.Unknown25 = 7363665268261373700; // For 0.35

            Unknown6 val = new Unknown6()
            {
                RequestType = 6,
                Unknown2    = new Unknown6.Types.Unknown2()
                {
                    EncryptedSignature = ByteString.CopyFrom(crypt.Encrypt(sig.ToByteArray()))
                }
            };

            return(val);
        }
コード例 #22
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);
        }
コード例 #23
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);
        }
コード例 #24
0
ファイル: RequestBuilder.cs プロジェクト: leeleonis/Cpko
        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(),
                SensorInfo          = new Signature.Types.SensorInfo()
                {
                    AccelNormalizedZ  = accelNextZ,
                    AccelNormalizedX  = accelNextX,
                    AccelNormalizedY  = accelNextY,
                    TimestampSnapshot = (ulong)InternalWatch.ElapsedMilliseconds - 230,
                    MagnetometerX     = accelNextX * 10,
                    MagnetometerY     = -20 + -20 * accelNextY / 9.8065,
                    MagnetometerZ     = -40 * accelNextZ / 9.8065,
                    AngleNormalizedX  = Math.Acos(accelNextX / 9.8065),
                    AngleNormalizedY  = Math.Acos(accelNextY / 9.8065),
                    AngleNormalizedZ  = Math.Acos(accelNextZ / 9.8065),
                    AccelRawX         = RandomDevice.NextInRange(-0.005, 0.005),
                    AccelRawY         = RandomDevice.NextInRange(0.5, 1),
                    AccelRawZ         = RandomDevice.NextInRange(-0.05, 0.05),
                    GyroscopeRawX     = RandomDevice.NextInRange(-0.0001, 0.0001),
                    GyroscopeRawY     = RandomDevice.NextInRange(-0.0005, 0.0005),
                    GyroscopeRawZ     = RandomDevice.NextInRange(-0.003, 0.003),
                    AccelerometerAxes = 3
                },
                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.LocationFix.Add(new Signature.Types.LocationFix()
            {
                Provider = "fused",

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

            //Compute 10
            var x         = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            var firstHash = BitConverter.ToUInt32(x.ComputeHash(_authTicket.ToByteArray()), 0);

            x = new System.Data.HashFunction.xxHash(32, firstHash);
            var locationBytes = BitConverter.GetBytes(_latitude).Reverse()
                                .Concat(BitConverter.GetBytes(_longitude).Reverse())
                                .Concat(BitConverter.GetBytes(_altitude).Reverse()).ToArray();

            sig.LocationHash1 = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 20
            x = new System.Data.HashFunction.xxHash(32, 0x1B845238);
            sig.LocationHash2 = BitConverter.ToUInt32(x.ComputeHash(locationBytes), 0);
            //Compute 24
            x = new System.Data.HashFunction.xxHash(64, 0x1B845238);
            var seed = BitConverter.ToUInt64(x.ComputeHash(_authTicket.ToByteArray()), 0);

            x = new System.Data.HashFunction.xxHash(64, seed);
            foreach (var req in requests)
            {
                sig.RequestHash.Add(BitConverter.ToUInt64(x.ComputeHash(req.ToByteArray()), 0));
            }

            //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   = -7363665268261373700; //-8537042734809897855;



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

            return(val);
        }