gpsoauth-rb 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/gpsoauth.rb +62 -0
- data/lib/gpsoauth/google.rb +47 -0
- data/lib/gpsoauth/utilities.rb +30 -0
- data/lib/gpsoauth/version.rb +3 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9de53d5bf8e18fe471a98f7fa3169b35377bb720
|
4
|
+
data.tar.gz: 82d5416f6fe365b53f4b2c73116f46de3f225478
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b159bdffcba0ac4a50d677debe3a06df37cbcfafaf9df9a511d4835f3ba99c7c03309724b103afb3a1f1d6c43681e533cdf78937e004d5f5d9f3a5611fcfd1be
|
7
|
+
data.tar.gz: d3adb8502a542d224466d3efb29cac48c2d79dc19528da994310971abd5e7ad5fb06d2402411ec42e252baa44b4c0d920908b0c1784b644a7b3ab62912e8650c
|
data/lib/gpsoauth.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "gpsoauth/version"
|
2
|
+
require "gpsoauth/google"
|
3
|
+
require "gpsoauth/utilities"
|
4
|
+
require "base64"
|
5
|
+
require "openssl"
|
6
|
+
require "httparty"
|
7
|
+
|
8
|
+
module Gpsoauth
|
9
|
+
class Auth
|
10
|
+
class << self
|
11
|
+
B64_KEY = ("AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6prwgi3iJIZdodyhKZQrNWp5nKJ3srRXcUW+F1BD3baEVGcmEgqaLZUNBjm057pKRI16kB0YppeGx5qIQ5QjKzsR8ETQbKLNWgRY0QRNVz34kMJR3P/LgHax/6rmf5AAAAAwEAAQ==")
|
12
|
+
ANDROID_KEY = Google.keyFromb64(B64_KEY)
|
13
|
+
AUTH_URL = 'https://android.clients.google.com/auth'
|
14
|
+
USER_AGENT = "gpsoauth/1.0.0"
|
15
|
+
|
16
|
+
@@cookie = ""
|
17
|
+
|
18
|
+
def performAuthRequest(data, cookie = @@cookie)
|
19
|
+
response = HTTParty.post(AUTH_URL, body: data, headers: {'User-Agent': USER_AGENT, 'Cookie': cookie})
|
20
|
+
@@cookies = response.headers['Set-Cookie'] if response.headers['Set-Cookie']
|
21
|
+
return Google.parseAuthResponse(response.body)
|
22
|
+
end
|
23
|
+
|
24
|
+
def performMasterLogin(email, password, android_id, service = 'ac2dm', device_country = 'us', operatorCountry = 'us', lang = 'en', sdk_version = 17)
|
25
|
+
data = {
|
26
|
+
'accountType': 'HOSTED_OR_GOOGLE',
|
27
|
+
'Email': email,
|
28
|
+
'has_permission': 1,
|
29
|
+
'add_account': 1,
|
30
|
+
'EncryptedPasswd': Google.signature(email, password, ANDROID_KEY),
|
31
|
+
'service': service,
|
32
|
+
'source': 'android',
|
33
|
+
'androidId': android_id,
|
34
|
+
'device_country': device_country,
|
35
|
+
'operatorCountry': device_country,
|
36
|
+
'lang': lang,
|
37
|
+
'sdk_version': sdk_version
|
38
|
+
}
|
39
|
+
return performAuthRequest(data, "")
|
40
|
+
end
|
41
|
+
|
42
|
+
def performOAuth(email, master_token, android_id, service, app, client_sig, device_country = 'us', operatorCountry = 'us', lang = 'en', sdk_version = 17)
|
43
|
+
data = {
|
44
|
+
'accountType': 'HOSTED_OR_GOOGLE',
|
45
|
+
'Email': email,
|
46
|
+
'has_permission': 1,
|
47
|
+
'EncryptedPasswd': master_token,
|
48
|
+
'service': service,
|
49
|
+
'source': 'android',
|
50
|
+
'androidId': android_id,
|
51
|
+
'app': app,
|
52
|
+
'client_sig': client_sig,
|
53
|
+
'device_country': device_country,
|
54
|
+
'operatorCountry': device_country,
|
55
|
+
'lang': lang,
|
56
|
+
'sdk_version': sdk_version
|
57
|
+
}
|
58
|
+
return performAuthRequest(data)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Gpsoauth
|
2
|
+
class Google
|
3
|
+
class << self
|
4
|
+
def keyFromb64(key)
|
5
|
+
binaryKey = Base64.decode64(key)
|
6
|
+
i = Utils.bytesToLong(binaryKey[0..3])
|
7
|
+
mod = Utils.bytesToLong(binaryKey[4..3+i])
|
8
|
+
|
9
|
+
j = Utils.bytesToLong(binaryKey[i+4..i+7])
|
10
|
+
exponent = Utils.bytesToLong(binaryKey[i+8..i+7+j])
|
11
|
+
|
12
|
+
key = OpenSSL::PKey::RSA.new
|
13
|
+
key.e = OpenSSL::BN.new(exponent)
|
14
|
+
key.n = OpenSSL::BN.new(mod)
|
15
|
+
|
16
|
+
return key
|
17
|
+
end
|
18
|
+
|
19
|
+
def keyToStuct(key)
|
20
|
+
modulus = key.n
|
21
|
+
exponent = key.e
|
22
|
+
return Utils.serialize_number(modulus.num_bytes, 4) + Utils.serialize_number(modulus) + Utils.serialize_number(exponent.num_bytes, 4) + Utils.serialize_number(exponent)
|
23
|
+
end
|
24
|
+
|
25
|
+
def parseAuthResponse(text)
|
26
|
+
responseData = Hash.new
|
27
|
+
text.split("\n").each do |line|
|
28
|
+
if line == nil
|
29
|
+
next
|
30
|
+
end
|
31
|
+
key, _, val = line.partition('=')
|
32
|
+
responseData[key] = val
|
33
|
+
end
|
34
|
+
return responseData
|
35
|
+
end
|
36
|
+
|
37
|
+
def signature(email, password, key)
|
38
|
+
signature = "\x00"
|
39
|
+
struct = keyToStuct(key).pack('c*')
|
40
|
+
signature = signature + OpenSSL::Digest::SHA1.digest(struct)[0...4]
|
41
|
+
encryptedLogin = key.public_encrypt(email + "\x00" + password, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
|
42
|
+
signature = signature + encryptedLogin
|
43
|
+
return Base64.urlsafe_encode64(signature)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Gpsoauth
|
2
|
+
class Utils
|
3
|
+
class << self
|
4
|
+
def bytesToLong(s)
|
5
|
+
return s.bytes.inject {|a, b| (a << 8) + b }
|
6
|
+
end
|
7
|
+
|
8
|
+
def divmod(bn, v)
|
9
|
+
bn = bn.to_s.to_i if bn.is_a?(OpenSSL::BN)
|
10
|
+
return bn.divmod(v)
|
11
|
+
end
|
12
|
+
|
13
|
+
def serialize_number(n, min_size=nil)
|
14
|
+
res = []
|
15
|
+
n, mod = divmod(n, 256)
|
16
|
+
while mod > 0 || n > 0
|
17
|
+
res << mod
|
18
|
+
n, mod = divmod(n, 256)
|
19
|
+
end
|
20
|
+
res = res.reverse
|
21
|
+
if min_size
|
22
|
+
if res.size < min_size
|
23
|
+
res = Array.new(min_size - res.size, 0) + res
|
24
|
+
end
|
25
|
+
end
|
26
|
+
return res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gpsoauth-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sawyer Charles
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.14'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.14'
|
55
|
+
description: Direct ruby port of the gpsoauth python library. (https://github.com/simon-weber/gpsoauth)
|
56
|
+
email:
|
57
|
+
- xssc@users.noreply.github.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/gpsoauth.rb
|
63
|
+
- lib/gpsoauth/google.rb
|
64
|
+
- lib/gpsoauth/utilities.rb
|
65
|
+
- lib/gpsoauth/version.rb
|
66
|
+
homepage: https://github.com/xssc/gpsoauth
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: gpsoauth for ruby
|
90
|
+
test_files: []
|