mirror of
https://github.com/LSPosed/MagiskOnWSALocal.git
synced 2025-09-01 18:20:14 +00:00
send request to generate wsa links via threads (#323)
This commit is contained in:
parent
c143787681
commit
ebb7a7f548
1 changed files with 37 additions and 23 deletions
|
@ -18,16 +18,18 @@
|
||||||
# Copyright (C) 2022 LSPosed Contributors
|
# Copyright (C) 2022 LSPosed Contributors
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import requests
|
|
||||||
from xml.dom import minidom
|
|
||||||
import html
|
import html
|
||||||
import warnings
|
|
||||||
import re
|
|
||||||
from pathlib import Path
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import warnings
|
||||||
|
from pathlib import Path
|
||||||
|
from threading import Thread
|
||||||
from typing import OrderedDict
|
from typing import OrderedDict
|
||||||
|
from xml.dom import minidom
|
||||||
|
|
||||||
|
from requests import Session
|
||||||
|
|
||||||
|
|
||||||
class Prop(OrderedDict):
|
class Prop(OrderedDict):
|
||||||
def __init__(self, props: str=...) -> None:
|
def __init__(self, props: str=...) -> None:
|
||||||
|
@ -55,6 +57,8 @@ ms_account_conf = download_dir/".ms_account"
|
||||||
tempScript = sys.argv[4]
|
tempScript = sys.argv[4]
|
||||||
cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
|
cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
|
||||||
user = ''
|
user = ''
|
||||||
|
session = Session()
|
||||||
|
|
||||||
if ms_account_conf.is_file():
|
if ms_account_conf.is_file():
|
||||||
with open(ms_account_conf, "r") as f:
|
with open(ms_account_conf, "r") as f:
|
||||||
conf = Prop(f.read())
|
conf = Prop(f.read())
|
||||||
|
@ -63,7 +67,7 @@ print(f"Generating WSA download link: arch={arch} release_type={release_name}",
|
||||||
with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f:
|
with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f:
|
||||||
cookie_content = f.read().format(user)
|
cookie_content = f.read().format(user)
|
||||||
|
|
||||||
out = requests.post(
|
out = session.post(
|
||||||
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
|
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
|
||||||
data=cookie_content,
|
data=cookie_content,
|
||||||
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
||||||
|
@ -75,7 +79,7 @@ cookie = doc.getElementsByTagName('EncryptedData')[0].firstChild.nodeValue
|
||||||
with open(Path.cwd().parent / "xml/WUIDRequest.xml", "r") as f:
|
with open(Path.cwd().parent / "xml/WUIDRequest.xml", "r") as f:
|
||||||
cat_id_content = f.read().format(user, cookie, cat_id, release_type)
|
cat_id_content = f.read().format(user, cookie, cat_id, release_type)
|
||||||
|
|
||||||
out = requests.post(
|
out = session.post(
|
||||||
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
|
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
|
||||||
data=cat_id_content,
|
data=cat_id_content,
|
||||||
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
||||||
|
@ -104,6 +108,24 @@ with open(Path.cwd().parent / "xml/FE3FileUrl.xml", "r") as f:
|
||||||
if not download_dir.is_dir():
|
if not download_dir.is_dir():
|
||||||
download_dir.mkdir()
|
download_dir.mkdir()
|
||||||
tmpdownlist = open(download_dir/tempScript, 'a')
|
tmpdownlist = open(download_dir/tempScript, 'a')
|
||||||
|
|
||||||
|
def send_req(i,v,out_file,out_file_name):
|
||||||
|
out = session.post(
|
||||||
|
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured',
|
||||||
|
data=FE3_file_content.format(user, i, v, release_type),
|
||||||
|
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
||||||
|
verify=False
|
||||||
|
)
|
||||||
|
doc = minidom.parseString(out.text)
|
||||||
|
for l in doc.getElementsByTagName("FileLocation"):
|
||||||
|
url = l.getElementsByTagName("Url")[0].firstChild.nodeValue
|
||||||
|
if len(url) != 99:
|
||||||
|
print(f"download link: {url} to {out_file}", flush=True)
|
||||||
|
tmpdownlist.writelines(url + '\n')
|
||||||
|
tmpdownlist.writelines(f' dir={download_dir}\n')
|
||||||
|
tmpdownlist.writelines(f' out={out_file_name}\n')
|
||||||
|
|
||||||
|
threads = []
|
||||||
for i, v, f in identities:
|
for i, v, f in identities:
|
||||||
if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f):
|
if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f):
|
||||||
out_file_name = f"Microsoft.UI.Xaml_{arch}.appx"
|
out_file_name = f"Microsoft.UI.Xaml_{arch}.appx"
|
||||||
|
@ -122,20 +144,12 @@ for i, v, f in identities:
|
||||||
out_file = download_dir / out_file_name
|
out_file = download_dir / out_file_name
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
out = requests.post(
|
th = Thread(target=send_req, args=(i,v,out_file,out_file_name))
|
||||||
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured',
|
threads.append(th)
|
||||||
data=FE3_file_content.format(user, i, v, release_type),
|
th.daemon = True
|
||||||
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
|
th.start()
|
||||||
verify=False
|
|
||||||
)
|
|
||||||
doc = minidom.parseString(out.text)
|
|
||||||
for l in doc.getElementsByTagName("FileLocation"):
|
|
||||||
url = l.getElementsByTagName("Url")[0].firstChild.nodeValue
|
|
||||||
if len(url) != 99:
|
|
||||||
print(f"download link: {url} to {out_file}", flush=True)
|
|
||||||
tmpdownlist.writelines(url + '\n')
|
|
||||||
tmpdownlist.writelines(f' dir={download_dir}\n')
|
|
||||||
tmpdownlist.writelines(f' out={out_file_name}\n')
|
|
||||||
tmpdownlist.writelines(f'https://aka.ms/Microsoft.VCLibs.{arch}.14.00.Desktop.appx\n')
|
tmpdownlist.writelines(f'https://aka.ms/Microsoft.VCLibs.{arch}.14.00.Desktop.appx\n')
|
||||||
tmpdownlist.writelines(f' dir={download_dir}\n')
|
tmpdownlist.writelines(f' dir={download_dir}\n')
|
||||||
|
for th in threads:
|
||||||
|
th.join()
|
||||||
tmpdownlist.close()
|
tmpdownlist.close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue