Example #1
0
    def asyncGet(self):
        try:
            # Get request ip
            ip = self.getRequestIP()

            # Argument check
            if not requestsManager.checkArguments(self.request.arguments,
                                                  ["u", "h"]):
                raise exceptions.invalidArgumentsException(self.MODULE_NAME)

            # Get user ID
            username = self.get_argument("u")
            userID = userUtils.getID(username)
            if userID is None:
                raise exceptions.loginFailedException(self.MODULE_NAME,
                                                      username)

            # Check login
            log.info("{} ({}) wants to connect".format(username, userID))
            if not userUtils.checkLogin(userID, self.get_argument("h"), ip):
                raise exceptions.loginFailedException(self.MODULE_NAME,
                                                      username)

            # Ban check
            if userUtils.isBanned(userID):
                raise exceptions.userBannedException(self.MODULE_NAME,
                                                     username)

            # Lock check
            if userUtils.isLocked(userID):
                raise exceptions.userLockedException(self.MODULE_NAME,
                                                     username)

            # 2FA check
            if userUtils.check2FA(userID, ip):
                raise exceptions.need2FAException(self.MODULE_NAME, username,
                                                  ip)

            # Update latest activity
            userUtils.updateLatestActivity(userID)

            # Get country and output it
            country = glob.db.fetch(
                "SELECT country FROM users_stats WHERE id = %s",
                [userID])["country"]
            self.write(country)
        except exceptions.invalidArgumentsException:
            pass
        except exceptions.loginFailedException:
            self.write("error: pass\n")
        except exceptions.userBannedException:
            pass
        except exceptions.userLockedException:
            pass
        except exceptions.need2FAException:
            self.write("error: verify\n")
Example #2
0
    def asyncGet(self):
        try:
            # Get request ip
            ip = self.getRequestIP()

            # Argument check
            if not requestsManager.checkArguments(self.request.arguments,
                                                  ["u", "h"]):
                raise exceptions.invalidArgumentsException(MODULE_NAME)

            # Get user ID
            username = self.get_argument("u")
            userID = userUtils.getID(username)
            if userID is None:
                self.write("error: pass\n")
                return

            # Check login
            log.info("{} ({}) wants to connect".format(username, userID))
            if not userUtils.checkLogin(userID, self.get_argument("h"), ip):
                self.write("error: pass\n")
                return

            # Ban check
            if userUtils.isBanned(userID):
                return

            # Lock check
            if userUtils.isLocked(userID):
                return
            # 2FA check
            if userUtils.check2FA(userID, ip):
                self.write("error: verify\n")

            # Update latest activity
            userUtils.updateLatestActivity(userID)

            if "x" in self.request.arguments:
                if len(self.get_argument("x")) > 4:
                    '''
					When "x" is found in the arguments, it means two things,
					1. "Monitor" has just been triggered (desktop screenshot """"""anticheat"""""")
					2. Files named "LL" (used by *a certain cheat website* for login data) have been found on the users computer.
					This should *NEVER* happen, but just incase it does, i'll send a notification to the discord.
					'''
                    webhook = Webhook(
                        glob.conf.config["discord"]
                        ["ahook"],  #send shit to discord hq
                        color=0xc32c74,
                        footer="stupid anticheat")
                    if glob.conf.config["discord"]["enable"]:
                        webhook.set_title(
                            title=f"Catched some cheater {username} ({userID})"
                        )
                        webhook.set_desc(
                            f'They just tried to send bancho_monitor and they have LL files!'
                        )
                        webhook.set_footer(text="peppycode anticheat")
                        webhook.post()

            # Get country and output it
            country = glob.db.fetch(
                "SELECT country FROM users_stats WHERE id = %s",
                [userID])["country"]
            self.write(country)
        except exceptions.invalidArgumentsException:
            pass
        except exceptions.loginFailedException:
            self.write("error: pass\n")
        except exceptions.userBannedException:
            pass
        except exceptions.userLockedException:
            pass
        except exceptions.need2FAException:
            self.write("error: verify\n")