Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -887,12 +887,7 @@ async def handle_encrypted_stream(encrypted_data: str, request: Request):
|
|
887 |
browser_info = request.headers.get('User-Agent', '') + request.headers.get('Accept-Language', '') + str(request.client.host)
|
888 |
key = hashlib.sha256(browser_info.encode()).hexdigest()[:32]
|
889 |
|
890 |
-
|
891 |
-
iv = encrypted_bytes[:16]
|
892 |
-
ciphertext = encrypted_bytes[16:]
|
893 |
-
|
894 |
-
cipher = Fernet(base64.urlsafe_b64encode(key.encode()))
|
895 |
-
decrypted_url = cipher.decrypt(base64.urlsafe_b64encode(iv + ciphertext)).decode()
|
896 |
|
897 |
if not decrypted_url.startswith('/rbxg/'):
|
898 |
raise ValueError("Invalid decrypted URL")
|
@@ -998,6 +993,13 @@ async def retry_upload(upload_url: str, file_content: bytes, content_type: str,
|
|
998 |
|
999 |
return False
|
1000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1001 |
if __name__ == "__main__":
|
1002 |
import uvicorn
|
1003 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
887 |
browser_info = request.headers.get('User-Agent', '') + request.headers.get('Accept-Language', '') + str(request.client.host)
|
888 |
key = hashlib.sha256(browser_info.encode()).hexdigest()[:32]
|
889 |
|
890 |
+
decrypted_url = decrypt_url(encrypted_data, key)
|
|
|
|
|
|
|
|
|
|
|
891 |
|
892 |
if not decrypted_url.startswith('/rbxg/'):
|
893 |
raise ValueError("Invalid decrypted URL")
|
|
|
993 |
|
994 |
return False
|
995 |
|
996 |
+
def decrypt_url(encrypted_data: str, key: str) -> str:
|
997 |
+
try:
|
998 |
+
decrypted = base64.b64decode(encrypted_data).decode('utf-8')
|
999 |
+
return decrypted
|
1000 |
+
except:
|
1001 |
+
raise ValueError("Invalid encrypted data")
|
1002 |
+
|
1003 |
if __name__ == "__main__":
|
1004 |
import uvicorn
|
1005 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|