From 921627014e243fb2dd9b4f9a9dfade26d1e11c12 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 7 Aug 2011 15:45:17 +0200 Subject: closed #375 --- module/plugins/accounts/FileserveCom.py | 118 +++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 23 deletions(-) (limited to 'module/plugins/accounts/FileserveCom.py') diff --git a/module/plugins/accounts/FileserveCom.py b/module/plugins/accounts/FileserveCom.py index 44b3f5be5..e8b4547c5 100644 --- a/module/plugins/accounts/FileserveCom.py +++ b/module/plugins/accounts/FileserveCom.py @@ -17,9 +17,40 @@ @author: mkaay """ -from module.plugins.Account import Account import re -from time import strptime, mktime +from base64 import standard_b64decode + +from Crypto.Cipher import AES + +from module.plugins.Account import Account + +def decrypt(data): + data = standard_b64decode(data) + key = standard_b64decode("L3hpTDJGaFNPVVlnc2FUdg==") + + obj = AES.new(key, AES.MODE_ECB) + + return obj.decrypt(data) + + +def parse(data): + ret = {} + for line in data.splitlines(): + line = line.strip() + k, none, v = line.partition("=") + ret[k] = v + + return ret + +def loadSoap(req, soap): + req.putHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4952)") + req.putHeader("SOAPAction", "\"urn:FileserveAPIWebServiceAction\"") + + ret = req.load("http://api.fileserve.com/api/fileserveAPIServer.php", post=soap, cookies=False, referer=False) + + req.clearHeaders() + + return ret class FileserveCom(Account): __name__ = "FileserveCom" @@ -28,30 +59,71 @@ class FileserveCom(Account): __description__ = """fileserve.com account plugin""" __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - - def loadAccountInfo(self, user, req): - src = req.load("http://fileserve.com/dashboard.php", cookies=True) + LOGIN_RE = re.compile(r"(.*?)(.*?)(.*?)%s%s" % ( + user, data["password"]) + + rep = loadSoap(req, soap) + + match = self.LOGIN_RE.search(rep) + if not match: + return False - m = re.search(r"

Premium Until

(.*?) E(.)T
", src) - if m: - zone = -5 if m.group(2) == "S" else -4 - validuntil = int(mktime(strptime(m.group(1), "%d %B %Y"))) + 24*3600 + (zone*3600) - tmp = {"validuntil":validuntil, "trafficleft":-1} - elif 'Account Type
Free' in src: - tmp = {"premium": False, "trafficleft": None, "validuntil": None} + data = parse(decrypt(match.group(1))) + + self.logDebug("Login: %s" % data) + + return data + + + def getShorten(self, req, token, fileid): + soap = "%s%s" % ( + token, fileid) + + rep = loadSoap(req, soap) + + match = self.SHORTEN_RE.search(rep) + data = parse(decrypt(match.group(1))) + self.logDebug("Shorten: %s" % data) + + return data + + + def getDirectLink(self, req, token): + soap = "%s" % token + + rep = loadSoap(req, soap) + + match = self.DIRECT_RE.search(rep) + data = parse(decrypt(match.group(1))) + self.logDebug("getDirect: %s" % data) + + return data + + + def loadAccountInfo(self, user, req): + data = self.loginApi(user, req) + + if data["user_type"] == "PREMIUM": + validuntil = int(data["expiry_date"]) + return {"trafficleft": -1, "validuntil": validuntil} else: - tmp = {"trafficleft": None} - return tmp - - def login(self, user, data, req): - - html = req.load("http://fileserve.com/login.php", - post={"loginUserName": user, "loginUserPassword": data["password"], - "autoLogin": "on", "loginFormSubmit": "Login"}, cookies=True) + return {"premium": False, "trafficleft": None, "validuntil": None} + - if r'Please Enter a valid user name.' in html or "Username doesn't exist." in html: + def login(self, user, data, req): + ret = self.loginApi(user, req, data) + if not ret: + self.wrongPassword() + elif ret["error"] == "LOGIN_FAIL": self.wrongPassword() - req.load("http://fileserve.com/dashboard.php", cookies=True) - -- cgit v1.2.3