Exemplo n.º 1
0
        public void Check_For_Bot_Test()
        {
            var botScoutCheck      = new BotScout().IsBot("84.16.230.111", "*****@*****.**", "someone", out _);
            var stopForumSpamCheck = new StopForumSpam().IsBot(
                "84.16.230.111",
                "*****@*****.**",
                "someone",
                out _);

            Assert.IsTrue(botScoutCheck | stopForumSpamCheck, "This should be a Bot");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check a User (Bot) against the StopForumSpam, BotScout Service or both
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="ipAddress">The ip address.</param>
        /// <param name="result">The result.</param>
        /// <returns>
        /// Returns if Post is SPAM or not
        /// </returns>
        public bool CheckUserForSpamBot([NotNull] string userName, [CanBeNull] string emailAddress, [NotNull] string ipAddress, out string result)
        {
            result = string.Empty;

            if (YafContext.Current.Get <YafBoardSettings>().BotSpamServiceType.Equals(0))
            {
                return(false);
            }

            switch (YafContext.Current.Get <YafBoardSettings>().BotSpamServiceType)
            {
            case 1:
            {
                var stopForumSpam = new StopForumSpam();

                return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }

            case 2:
            {
                if (YafContext.Current.Get <YafBoardSettings>().BotScoutApiKey.IsSet())
                {
                    var botScout = new BotScout();

                    return(botScout.IsBot(ipAddress, emailAddress, userName, out result));
                }

                // use StopForumSpam instead
                var stopForumSpam = new StopForumSpam();

                return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }

            case 3:
            {
                // use StopForumSpam instead
                var stopForumSpam = new StopForumSpam();

                if (!YafContext.Current.Get <YafBoardSettings>().BotScoutApiKey.IsSet())
                {
                    return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
                }

                var botScout = new BotScout();

                return(botScout.IsBot(ipAddress, emailAddress, userName) &&
                       stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reports the User
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Report_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.Get <YafBoardSettings>().StopForumSpamApiKey.IsNotSet())
            {
                return;
            }

            var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);

            try
            {
                var stopForumSpam = new StopForumSpam();

                if (!stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName))
                {
                    return;
                }

                this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITUSER", "BOT_REPORTED"), MessageTypes.Success);

                this.Logger.Log(
                    this.PageContext.PageUserID,
                    "User Reported to StopForumSpam.com",
                    "User (Name:{0}/ID:{1}/IP:{2}/Email:{3}) Reported to StopForumSpam.com by {4}".FormatWith(
                        user.UserName,
                        this.CurrentUserID,
                        this.IPAddresses.FirstOrDefault(),
                        user.Email,
                        this.Get <YafBoardSettings>().EnableDisplayName
                            ? this.PageContext.CurrentUserData.DisplayName
                            : this.PageContext.CurrentUserData.UserName),
                    EventLogTypes.SpamBotReported);
            }
            catch (Exception exception)
            {
                this.PageContext.AddLoadMessage(
                    this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"),
                    MessageTypes.Error);

                this.Logger.Log(
                    this.PageContext.PageUserID,
                    "User (Name{0}/ID:{1}) Report to StopForumSpam.com Failed".FormatWith(
                        user.UserName,
                        this.CurrentUserID),
                    exception);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Check a User (Bot) against the StopForumSpam, BotScout Service or both
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="ipAddress">The IP address.</param>
        /// <param name="result">The result.</param>
        /// <returns>
        /// Returns if Post is SPAM or not
        /// </returns>
        public bool CheckUserForSpamBot([NotNull] string userName, [CanBeNull] string emailAddress, [NotNull] string ipAddress, out string result)
        {
            // Check internal
            var internalCheck = new InternalCheck();

            var isInternalFoundBot = internalCheck.IsBot(ipAddress, emailAddress, userName, out result);

            if (isInternalFoundBot)
            {
                return(true);
            }

            if (BoardContext.Current.Get <BoardSettings>().BotSpamServiceType.Equals(0))
            {
                return(false);
            }

            switch (BoardContext.Current.Get <BoardSettings>().BotSpamServiceType)
            {
            case 1:
            {
                var stopForumSpam = new StopForumSpam();

                return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }

            case 2:
            {
                if (BoardContext.Current.Get <BoardSettings>().BotScoutApiKey.IsSet())
                {
                    var botScout = new BotScout();

                    return(botScout.IsBot(ipAddress, emailAddress, userName, out result));
                }

                // use StopForumSpam instead
                var stopForumSpam = new StopForumSpam();

                return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }

            case 3:
            {
                // use StopForumSpam instead
                var stopForumSpam = new StopForumSpam();

                if (!BoardContext.Current.Get <BoardSettings>().BotScoutApiKey.IsSet())
                {
                    return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
                }

                var botScout = new BotScout();

                return(botScout.IsBot(ipAddress, emailAddress, userName) &&
                       stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }

            case 4:
            {
                // use StopForumSpam instead
                var stopForumSpam = new StopForumSpam();

                if (!BoardContext.Current.Get <BoardSettings>().BotScoutApiKey.IsSet())
                {
                    return(stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
                }

                var botScout = new BotScout();

                return(botScout.IsBot(ipAddress, emailAddress, userName)
                       | stopForumSpam.IsBot(ipAddress, emailAddress, userName, out result));
            }
            }

            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Kills the User
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Kill_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserId);

            // Ban User Email?
            if (this.BanEmail.Checked)
            {
                this.GetRepository <BannedEmail>().Save(
                    null,
                    user.Email,
                    $"Email was reported by: {(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)}");
            }

            // Ban User IP?
            if (this.BanIps.Checked && this.IPAddresses.Any())
            {
                this.BanUserIps();
            }

            // Ban User IP?
            if (this.BanName.Checked)
            {
                this.GetRepository <BannedName>().Save(
                    null,
                    user.UserName,
                    $"Name was reported by: {(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)}");
            }

            this.DeleteAllUserMessages();

            if (this.ReportUser.Checked && this.Get <YafBoardSettings>().StopForumSpamApiKey.IsSet() &&
                this.IPAddresses.Any())
            {
                try
                {
                    var stopForumSpam = new StopForumSpam();

                    if (stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), user.Email, user.UserName))
                    {
                        this.GetRepository <Registry>().IncrementReportedSpammers();

                        this.Logger.Log(
                            this.PageContext.PageUserID,
                            "User Reported to StopForumSpam.com",
                            $"User (Name:{user.UserName}/ID:{this.CurrentUserId}/IP:{this.IPAddresses.FirstOrDefault()}/Email:{user.Email}) Reported to StopForumSpam.com by {(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName)}",
                            EventLogTypes.SpamBotReported);
                    }
                }
                catch (Exception exception)
                {
                    this.PageContext.AddLoadMessage(
                        this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"),
                        MessageTypes.danger);

                    this.Logger.Log(
                        this.PageContext.PageUserID,
                        $"User (Name{user.UserName}/ID:{this.CurrentUserId}) Report to StopForumSpam.com Failed",
                        exception);
                }
            }

            switch (this.SuspendOrDelete.SelectedValue)
            {
            case "delete":
                if (this.CurrentUserId > 0)
                {
                    // we are deleting user
                    if (this.PageContext.PageUserID == this.CurrentUserId)
                    {
                        // deleting yourself isn't an option
                        this.PageContext.AddLoadMessage(
                            this.GetText("ADMIN_USERS", "MSG_SELF_DELETE"),
                            MessageTypes.danger);
                        return;
                    }

                    // get user(s) we are about to delete
                    using (var dt = this.GetRepository <User>().ListAsDataTable(
                               this.PageContext.PageBoardID,
                               this.CurrentUserId,
                               DBNull.Value))
                    {
                        // examine each if he's possible to delete
                        foreach (DataRow row in dt.Rows)
                        {
                            if (row["IsGuest"].ToType <int>() > 0)
                            {
                                // we cannot delete guest
                                this.PageContext.AddLoadMessage(
                                    this.GetText("ADMIN_USERS", "MSG_DELETE_GUEST"),
                                    MessageTypes.danger);
                                return;
                            }

                            if ((row["IsAdmin"] == DBNull.Value || row["IsAdmin"].ToType <int>() <= 0) &&
                                (row["IsHostAdmin"] == DBNull.Value || row["IsHostAdmin"].ToType <int>() <= 0))
                            {
                                continue;
                            }

                            // admin are not deletable either
                            this.PageContext.AddLoadMessage(
                                this.GetText("ADMIN_USERS", "MSG_DELETE_ADMIN"),
                                MessageTypes.danger);
                            return;
                        }
                    }

                    // all is good, user can be deleted
                    UserMembershipHelper.DeleteUser(this.CurrentUserId.ToType <int>());

                    YafBuildLink.Redirect(ForumPages.admin_users);
                }

                break;

            case "suspend":
                if (this.CurrentUserId > 0)
                {
                    this.GetRepository <User>().Suspend(
                        this.CurrentUserId.ToType <int>(),
                        DateTime.UtcNow.AddYears(5));
                }

                break;
            }

            this.PageContext.AddLoadMessage(
                this.GetTextFormatted("MSG_USER_KILLED", user.UserName),
                MessageTypes.success);

            // update the displayed data...
            this.BindData();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Kills the User
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Kill_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            // Ban User Email?
            if (this.BanEmail.Checked)
            {
                this.GetRepository <BannedEmail>().Save(
                    null,
                    this.User.Item1.Email,
                    $"Email was reported by: {this.Get<IUserDisplayName>().GetName(this.PageContext.User)}");
            }

            // Ban User IP?
            if (this.BanIps.Checked && this.IPAddresses.Any())
            {
                this.BanUserIps();
            }

            // Ban User IP?
            if (this.BanName.Checked)
            {
                this.GetRepository <BannedName>().Save(
                    null,
                    this.User.Item1.Name,
                    $"Name was reported by: {this.Get<IUserDisplayName>().GetName(this.PageContext.User)}");
            }

            this.DeleteAllUserMessages();

            if (this.ReportUser.Checked && this.Get <BoardSettings>().StopForumSpamApiKey.IsSet() &&
                this.IPAddresses.Any())
            {
                try
                {
                    var stopForumSpam = new StopForumSpam();

                    if (stopForumSpam.ReportUserAsBot(this.IPAddresses.FirstOrDefault(), this.User.Item1.Email, this.User.Item1.Name))
                    {
                        this.GetRepository <Registry>().IncrementReportedSpammers();

                        this.Logger.Log(
                            this.PageContext.PageUserID,
                            "User Reported to StopForumSpam.com",
                            $"User (Name:{this.User.Item1.Name}/ID:{this.CurrentUserId}/IP:{this.IPAddresses.FirstOrDefault()}/Email:{this.User.Item1.Email}) Reported to StopForumSpam.com by {this.Get<IUserDisplayName>().GetName(this.PageContext.User)}",
                            EventLogTypes.SpamBotReported);
                    }
                }
                catch (Exception exception)
                {
                    this.PageContext.AddLoadMessage(
                        this.GetText("ADMIN_EDITUSER", "BOT_REPORTED_FAILED"),
                        MessageTypes.danger);

                    this.Logger.Log(
                        this.PageContext.PageUserID,
                        $"User (Name{this.User.Item1.Name}/ID:{this.CurrentUserId}) Report to StopForumSpam.com Failed",
                        exception);
                }
            }

            switch (this.SuspendOrDelete.SelectedValue)
            {
            case "delete":
                if (this.CurrentUserId > 0)
                {
                    // we are deleting user
                    if (this.PageContext.PageUserID == this.CurrentUserId)
                    {
                        // deleting yourself isn't an option
                        this.PageContext.AddLoadMessage(
                            this.GetText("ADMIN_USERS", "MSG_SELF_DELETE"),
                            MessageTypes.danger);
                        return;
                    }

                    // get user(s) we are about to delete
                    if (this.User.Item1.IsGuest.Value)
                    {
                        // we cannot delete guest
                        this.PageContext.AddLoadMessage(
                            this.GetText("ADMIN_USERS", "MSG_DELETE_GUEST"),
                            MessageTypes.danger);
                        return;
                    }

                    if (!this.User.Item4.IsAdmin &&
                        !this.User.Item1.UserFlags.IsHostAdmin)
                    {
                        return;
                    }

                    // admin are not deletable either
                    this.PageContext.AddLoadMessage(
                        this.GetText("ADMIN_USERS", "MSG_DELETE_ADMIN"),
                        MessageTypes.danger);


                    // all is good, user can be deleted
                    this.Get <IAspNetUsersHelper>().DeleteUser(this.CurrentUserId);

                    BuildLink.Redirect(ForumPages.Admin_Users);
                }

                break;

            case "suspend":
                if (this.CurrentUserId > 0)
                {
                    this.GetRepository <User>().Suspend(
                        this.CurrentUserId,
                        DateTime.UtcNow.AddYears(5));
                }

                break;
            }

            this.PageContext.AddLoadMessage(
                this.GetTextFormatted("MSG_USER_KILLED", this.User.Item1.Name),
                MessageTypes.success);

            // update the displayed data...
            this.BindData();
        }