Spaces:
Paused
Paused
File size: 9,301 Bytes
7b8ef10 ae9331d | 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | from flask import Flask, request, jsonify
import asyncio
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from google.protobuf.json_format import MessageToJson
import binascii
import aiohttp
import requests
import json
import like_pb2
import like_count_pb2
import uid_generator_pb2
from google.protobuf.message import DecodeError
app = Flask(__name__)
def load_tokens(server_name):
try:
if server_name == "IND":
with open("token_ind.json", "r") as f:
tokens = json.load(f)
elif server_name in {"BR", "US", "SAC", "NA"}:
with open("token_br.json", "r") as f:
tokens = json.load(f)
else:
with open("token_bd.json", "r") as f:
tokens = json.load(f)
return tokens
except Exception as e:
app.logger.error(f"Error loading tokens for server {server_name}: {e}")
return None
def encrypt_message(plaintext):
try:
key = b'Yg&tc%DEuh6%Zc^8'
iv = b'6oyZDr22E3ychjM%'
cipher = AES.new(key, AES.MODE_CBC, iv)
padded_message = pad(plaintext, AES.block_size)
encrypted_message = cipher.encrypt(padded_message)
return binascii.hexlify(encrypted_message).decode('utf-8')
except Exception as e:
app.logger.error(f"Error encrypting message: {e}")
return None
def create_protobuf_message(user_id, region):
try:
message = like_pb2.like()
message.uid = int(user_id)
message.region = region
return message.SerializeToString()
except Exception as e:
app.logger.error(f"Error creating protobuf message: {e}")
return None
async def send_request(encrypted_uid, token, url):
try:
edata = bytes.fromhex(encrypted_uid)
headers = {
'User-Agent': "Dalvik/2.1.0 (Linux; U; Android 9; ASUS_Z01QD Build/PI)",
'Connection': "Keep-Alive",
'Accept-Encoding': "gzip",
'Authorization': f"Bearer {token}",
'Content-Type': "application/x-www-form-urlencoded",
'Expect': "100-continue",
'X-Unity-Version': "2018.4.11f1",
'X-GA': "v1 1",
'ReleaseVersion': "OB47"
}
async with aiohttp.ClientSession() as session:
async with session.post(url, data=edata, headers=headers) as response:
if response.status != 200:
app.logger.error(f"Request failed with status code: {response.status}")
return response.status
return await response.text()
except Exception as e:
app.logger.error(f"Exception in send_request: {e}")
return None
async def send_multiple_requests(uid, server_name, url):
try:
region = server_name
protobuf_message = create_protobuf_message(uid, region)
if protobuf_message is None:
app.logger.error("Failed to create protobuf message.")
return None
encrypted_uid = encrypt_message(protobuf_message)
if encrypted_uid is None:
app.logger.error("Encryption failed.")
return None
tasks = []
tokens = load_tokens(server_name)
if tokens is None:
app.logger.error("Failed to load tokens.")
return None
for i in range(100):
token = tokens[i % len(tokens)]["token"]
tasks.append(send_request(encrypted_uid, token, url))
results = await asyncio.gather(*tasks, return_exceptions=True)
return results
except Exception as e:
app.logger.error(f"Exception in send_multiple_requests: {e}")
return None
def create_protobuf(uid):
try:
message = uid_generator_pb2.uid_generator()
message.saturn_ = int(uid)
message.garena = 1
return message.SerializeToString()
except Exception as e:
app.logger.error(f"Error creating uid protobuf: {e}")
return None
def enc(uid):
protobuf_data = create_protobuf(uid)
if protobuf_data is None:
return None
encrypted_uid = encrypt_message(protobuf_data)
return encrypted_uid
def make_request(encrypt, server_name, token):
try:
if server_name == "IND":
url = "https://client.ind.freefiremobile.com/GetPlayerPersonalShow"
elif server_name in {"BR", "US", "SAC", "NA"}:
url = "https://client.us.freefiremobile.com/GetPlayerPersonalShow"
else:
url = "https://clientbp.ggblueshark.com/GetPlayerPersonalShow"
edata = bytes.fromhex(encrypt)
headers = {
'User-Agent': "Dalvik/2.1.0 (Linux; U; Android 9; ASUS_Z01QD Build/PI)",
'Connection': "Keep-Alive",
'Accept-Encoding': "gzip",
'Authorization': f"Bearer {token}",
'Content-Type': "application/x-www-form-urlencoded",
'Expect': "100-continue",
'X-Unity-Version': "2018.4.11f1",
'X-GA': "v1 1",
'ReleaseVersion': "OB47"
}
response = requests.post(url, data=edata, headers=headers, verify=False)
hex_data = response.content.hex()
binary = bytes.fromhex(hex_data)
decode = decode_protobuf(binary)
if decode is None:
app.logger.error("Protobuf decoding returned None.")
return decode
except Exception as e:
app.logger.error(f"Error in make_request: {e}")
return None
def decode_protobuf(binary):
try:
items = like_count_pb2.Info()
items.ParseFromString(binary)
return items
except DecodeError as e:
app.logger.error(f"Error decoding Protobuf data: {e}")
return None
except Exception as e:
app.logger.error(f"Unexpected error during protobuf decoding: {e}")
return None
@app.route('/like', methods=['GET'])
def handle_requests():
uid = request.args.get("uid")
server_name = request.args.get("server_name", "").upper()
if not uid or not server_name:
return jsonify({"error": "UID and server_name are required"}), 400
try:
def process_request():
tokens = load_tokens(server_name)
if tokens is None:
raise Exception("Failed to load tokens.")
token = tokens[0]['token']
encrypted_uid = enc(uid)
if encrypted_uid is None:
raise Exception("Encryption of UID failed.")
# الحصول على بيانات اللاعب قبل تنفيذ عملية الإعجاب
before = make_request(encrypted_uid, server_name, token)
if before is None:
raise Exception("Failed to retrieve initial player info.")
try:
jsone = MessageToJson(before)
except Exception as e:
raise Exception(f"Error converting 'before' protobuf to JSON: {e}")
data_before = json.loads(jsone)
before_like = data_before.get('AccountInfo', {}).get('Likes', 0)
try:
before_like = int(before_like)
except Exception:
before_like = 0
app.logger.info(f"Likes before command: {before_like}")
# تحديد رابط الإعجاب حسب اسم السيرفر
if server_name == "IND":
url = "https://client.ind.freefiremobile.com/LikeProfile"
elif server_name in {"BR", "US", "SAC", "NA"}:
url = "https://client.us.freefiremobile.com/LikeProfile"
else:
url = "https://clientbp.ggblueshark.com/LikeProfile"
# إرسال الطلبات بشكل غير متزامن
asyncio.run(send_multiple_requests(uid, server_name, url))
# الحصول على بيانات اللاعب بعد تنفيذ عملية الإعجاب
after = make_request(encrypted_uid, server_name, token)
if after is None:
raise Exception("Failed to retrieve player info after like requests.")
try:
jsone_after = MessageToJson(after)
except Exception as e:
raise Exception(f"Error converting 'after' protobuf to JSON: {e}")
data_after = json.loads(jsone_after)
after_like = int(data_after.get('AccountInfo', {}).get('Likes', 0))
player_uid = int(data_after.get('AccountInfo', {}).get('UID', 0))
player_name = str(data_after.get('AccountInfo', {}).get('PlayerNickname', ''))
like_given = after_like - before_like
status = 1 if like_given != 0 else 2
result = {
"LikesGivenByAPI": like_given,
"LikesafterCommand": after_like,
"LikesbeforeCommand": before_like,
"PlayerNickname": player_name,
"UID": player_uid,
"status": status
}
return result
result = process_request()
return jsonify(result)
except Exception as e:
app.logger.error(f"Error processing request: {e}")
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=7860, debug=True, use_reloader=False) |