Upload encpass.py
Browse files- encpass.py +100 -0
encpass.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import base64
|
| 3 |
+
import os
|
| 4 |
+
import struct
|
| 5 |
+
import time
|
| 6 |
+
|
| 7 |
+
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
| 8 |
+
from cryptography.hazmat.primitives.serialization import load_pem_public_key
|
| 9 |
+
from cryptography.hazmat.primitives.asymmetric import padding
|
| 10 |
+
from cryptography.hazmat.primitives import hashes
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def pwd_key_fetch():
|
| 14 |
+
url = "https://graph.facebook.com/pwd_key_fetch"
|
| 15 |
+
params = {
|
| 16 |
+
"app_version": "412474635",
|
| 17 |
+
"fb_api_caller_class": "FBPasswordEncryptionKeyFetchRequest",
|
| 18 |
+
"fb_api_req_friendly_name": "FBPasswordEncryptionKeyFetchRequest:networkRequest",
|
| 19 |
+
"flow": "controller_initialization",
|
| 20 |
+
"format": "json",
|
| 21 |
+
"locale": "vi_VN",
|
| 22 |
+
"pretty": "0",
|
| 23 |
+
"sdk": "ios",
|
| 24 |
+
"sdk_version": "3",
|
| 25 |
+
"version": "2"
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
headers = {
|
| 29 |
+
"x-fb-privacy-context": "0xf0000000b659eb4a",
|
| 30 |
+
"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/17H35 [FBAN/FBIOS;FBAV/390.1.0.38.101]",
|
| 31 |
+
"x-fb-connection-type": "wifi.CTRadioAccessTechnologyLTE",
|
| 32 |
+
"x-fb-sim-hni": "45202",
|
| 33 |
+
"authorization": "OAuth 6628568379|c1e620fa708a1d5696fb991c1bde5662",
|
| 34 |
+
"x-tigon-is-retry": "False",
|
| 35 |
+
"x-fb-friendly-name": "FBPasswordEncryptionKeyFetchRequest:networkRequest",
|
| 36 |
+
"x-fb-http-engine": "Liger",
|
| 37 |
+
"x-fb-client-ip": "True",
|
| 38 |
+
"x-fb-server-cluster": "True"
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
r = requests.get(url, params=params, headers=headers)
|
| 42 |
+
if r.status_code == 200:
|
| 43 |
+
return r.json()
|
| 44 |
+
return None
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def encrypt(password: str, pubkey: str, key_id: int):
|
| 48 |
+
|
| 49 |
+
random_key = os.urandom(32)
|
| 50 |
+
random_iv = os.urandom(12)
|
| 51 |
+
|
| 52 |
+
# load RSA public key
|
| 53 |
+
public_key = load_pem_public_key(pubkey.encode())
|
| 54 |
+
|
| 55 |
+
encrypted_rand_key = public_key.encrypt(
|
| 56 |
+
random_key,
|
| 57 |
+
padding.PKCS1v15()
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
current_time = str(int(time.time()))
|
| 61 |
+
|
| 62 |
+
aesgcm = AESGCM(random_key)
|
| 63 |
+
|
| 64 |
+
encrypted = aesgcm.encrypt(
|
| 65 |
+
random_iv,
|
| 66 |
+
password.encode(),
|
| 67 |
+
current_time.encode()
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
auth_tag = encrypted[-16:]
|
| 71 |
+
encrypted_pass = encrypted[:-16]
|
| 72 |
+
|
| 73 |
+
payload = (
|
| 74 |
+
bytes([1, key_id]) +
|
| 75 |
+
random_iv +
|
| 76 |
+
struct.pack("<h", len(encrypted_rand_key)) +
|
| 77 |
+
encrypted_rand_key +
|
| 78 |
+
auth_tag +
|
| 79 |
+
encrypted_pass
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
encoded = base64.b64encode(payload).decode()
|
| 83 |
+
|
| 84 |
+
return f"#PWD_WILDE:2:{current_time}:{encoded}"
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def encrypt_password(password):
|
| 88 |
+
data = pwd_key_fetch()
|
| 89 |
+
if not data:
|
| 90 |
+
return None
|
| 91 |
+
|
| 92 |
+
pub = data["public_key"]
|
| 93 |
+
key_id = data["key_id"]
|
| 94 |
+
|
| 95 |
+
return encrypt(password, pub, key_id)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
pwd = encrypt_password("VLteam19092025")
|
| 100 |
+
print(pwd)
|