summaryrefslogtreecommitdiffstats
path: root/samloader/fusclient.py
diff options
context:
space:
mode:
authorNayil Mukhametshin <66028747+nlscc@users.noreply.github.com>2020-05-25 17:22:43 +0200
committerNayil Mukhametshin <66028747+nlscc@users.noreply.github.com>2020-05-25 17:22:43 +0200
commit6273f3634b72c0df21c2ece52b750b8834b7fed2 (patch)
treed01f11b47087320eeabf64f20a62687ecea6ee13 /samloader/fusclient.py
downloadsamloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.tar
samloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.tar.gz
samloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.tar.bz2
samloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.tar.lz
samloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.tar.xz
samloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.tar.zst
samloader-6273f3634b72c0df21c2ece52b750b8834b7fed2.zip
Diffstat (limited to 'samloader/fusclient.py')
-rw-r--r--samloader/fusclient.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/samloader/fusclient.py b/samloader/fusclient.py
new file mode 100644
index 0000000..6836923
--- /dev/null
+++ b/samloader/fusclient.py
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2020 Nayil Mukhametshin
+
+# FUS request helper (automatically sign requests and update tokens)
+
+import requests
+
+from . import auth
+
+class FUSClient(object):
+ def __init__(self):
+ self.auth = ""
+ self.sessid = ""
+ self.makereq("NF_DownloadGenerateNonce.do")
+ def makereq(self, path, data=""):
+ authv = 'FUS nonce="", signature="' + self.auth + '", nc="", type="", realm="", newauth="1"'
+ r = requests.post("https://neofussvr.sslcs.cdngc.net/" + path, data=data,
+ headers={"Authorization": authv}, cookies={"JSESSIONID": self.sessid})
+ if "NONCE" in r.headers:
+ self.encnonce = r.headers["NONCE"]
+ self.nonce = auth.decryptnonce(self.encnonce)
+ self.auth = auth.getauth(self.nonce)
+ if "JSESSIONID" in r.cookies:
+ self.sessid = r.cookies["JSESSIONID"]
+ r.raise_for_status()
+ return r.text
+ def downloadfile(self, filename):
+ authv = 'FUS nonce="' + self.encnonce + '", signature="' + self.auth + '", nc="", type="", realm="", newauth="1"'
+ r = requests.get("https://cloud-neofussvr.sslcs.cdngc.net/NF_DownloadBinaryForMass.do",
+ params={"file": filename}, headers={"Authorization": authv}, stream=True)
+ r.raise_for_status()
+ return r