Skip to content

Commit

Permalink
fix: new TLS/JA3 blacklist patch
Browse files Browse the repository at this point in the history
  • Loading branch information
xerusmsp committed Aug 19, 2024
1 parent 96440f1 commit 986a01a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
26 changes: 14 additions & 12 deletions msp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import http.client
import random
import base64
import msp_tls_client
from typing import List, Union
from datetime import date, datetime
from urllib.parse import urlparse
Expand Down Expand Up @@ -107,7 +108,6 @@ def from_object_inner(obj):
return hashlib.sha1(result_str.encode()).hexdigest()



def invoke_method(server: str, method: str, params: list, session_id: str) -> tuple[int, any]:
"""
Invoke a method on the MSP API
Expand All @@ -129,7 +129,11 @@ def invoke_method(server: str, method: str, params: list, session_id: str) -> tu
encoded_req = remoting.encode(event).getvalue()

full_endpoint = f"https://ws-{server}.mspapis.com/Gateway.aspx?method={method}"
conn = http.client.HTTPSConnection(urlparse(full_endpoint).hostname)

session = msp_tls_client.Session(
client_identifier="xerus_ja3_spoof",
force_http1=True,
)

headers = {
"Referer": "app:/cache/t1.bin/[[DYNAMIC]]/2",
Expand All @@ -140,22 +144,20 @@ def invoke_method(server: str, method: str, params: list, session_id: str) -> tu
"video/x-flv;q=0.7, audio/mp4, application/futuresplash, "
"/;q=0.5, application/x-mpegURL"),
"x-flash-version": "32,0,0,100",
"Content-Length": str(len(encoded_req)),
"Content-Type": "application/x-amf",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows; U; en) AppleWebKit/533.19.4 "
"(KHTML, like Gecko) AdobeAIR/32.0",
"Connection": "Keep-Alive",
}
path = urlparse(full_endpoint).path
query = urlparse(full_endpoint).query
conn.request("POST", path + "?" + query, encoded_req, headers=headers)

with conn.getresponse() as resp:
resp_data = resp.read() if resp.status == 200 else None
if resp.status != 200:
return (resp.status, resp_data)
return (resp.status, remoting.decode(resp_data)["/1"].body)

response = session.post(full_endpoint, data=encoded_req, headers=headers)

resp_data = response.content if response.status_code == 200 else None

if response.status_code != 200:
return (response.status_code, resp_data)
return (response.status_code, remoting.decode(resp_data)["/1"].body)


def get_session_id() -> str:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Py3AMF==0.8.10
Py3AMF==0.8.10
git+https://github.com/xerusmsp/msp-tls-client.git

0 comments on commit 986a01a

Please sign in to comment.