From a2e50a0c184c9108b6561fc21d0e7384024094ce Mon Sep 17 00:00:00 2001 From: selfisekai Date: Sun, 20 Sep 2020 18:25:04 +0200 Subject: [PATCH] netiawifi (costa coffee pl) fxcker --- librefi/fxckers/_map.py | 2 ++ librefi/fxckers/netiawifi.py | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 librefi/fxckers/netiawifi.py diff --git a/librefi/fxckers/_map.py b/librefi/fxckers/_map.py index 76cdef0..813ed78 100644 --- a/librefi/fxckers/_map.py +++ b/librefi/fxckers/_map.py @@ -4,6 +4,7 @@ from .ledatel import LedatelFxcker from .ipartners import IPartnersFxcker from .kfchotspot import KFCHotspotFxcker from .justwifi import JustWifiFxcker +from .netiawifi import NetiaWifiFxcker fxckers_map = [ ([r"re:MZK Opole \d{3}(?: (?:2.4|5)GHz)?"], DummyFxcker), @@ -15,4 +16,5 @@ fxckers_map = [ "Intercity_WiFi", "_PKP_WIFI", ], JustWifiFxcker), + (["COSTA COFFEE"], NetiaWifiFxcker), ] diff --git a/librefi/fxckers/netiawifi.py b/librefi/fxckers/netiawifi.py new file mode 100644 index 0000000..df6657f --- /dev/null +++ b/librefi/fxckers/netiawifi.py @@ -0,0 +1,67 @@ +from ._common import BaseFxcker +from ..utils import regex_search_string, dump_qs +import re +from urllib.parse import unquote + + +class NetiaWifiFxcker(BaseFxcker): + def unfxck(self, location=None): + start = self.request("GET", location) + initial_redir_url = regex_search_string( + r'
]*action="([^"]+)"', start.text) + start_form = {} + for param in ["mac", "ip", "apname", "essid", "url", "switch_url"]: + start_form[param] = regex_search_string( + r']*name="%s" value="([^"]+)"' % (re.escape(param)), + start.text) + initial_redir = self.request( + "POST", initial_redir_url, data=dump_qs(start_form), headers={ + "Content-Type": "application/x-www-form-urlencoded", + }) + splash_url = regex_search_string( + r']*action="([^"]+)"', initial_redir.text) + splash = self.request("POST", splash_url, data=dump_qs({ + "initialRedirect": True, + })) + accept_url = regex_search_string( + r"form\.setAttribute\('action', '([^']+)'\)", splash.text) + accept_page = self.request("POST", accept_url, data=dump_qs({ + "ie11postFix": "sendPost", + }), headers={ + "Content-Type": "application/x-www-form-urlencoded", + }) + + # what the fuck is that, Netia? + for match in regex_search_string( + # flake8: noqa: E501 + r"document\.cookie\s*=\s*'([^']+)'\s*\+\s*decodeURIComponent\('([^']+)'\)\s*\+\s*'([^']+)';", + accept_page.text, multiple=True, whole_match=True): + self.cookie_jar.set_cookie(match.group( + 1) + unquote(match.group(2)) + match.group(3)) + for match in regex_search_string( + # flake8: noqa: E501 + r"document\.cookie\s*=\s*'([^']+)'\s*\+\s*'([^']+)'\s*\+\s*'([^']+)';", + accept_page.text, multiple=True, whole_match=True): + self.cookie_jar.set_cookie(match.group( + 1) + match.group(2) + match.group(3)) + for match in regex_search_string( + # flake8: noqa: E501 + r"document\.cookie\s*=\s*'([^']+)';", + accept_page.text, multiple=True, whole_match=True): + self.cookie_jar.set_cookie(match.group(1)) + + login_url = regex_search_string( + r']*action="([^"]+)"', accept_page.text) + login_form = {} + for match in regex_search_string( + r']*name="([^"]+)" value="([^"]*)"', + accept_page.text, multiple=True, whole_match=True): + login_form[match.group(1)] = match.group(2) + login_page = self.request("GET", login_url + "?" + dump_qs(login_form)) + + welcome_url = unquote(regex_search_string( + r'