Exemplo n.º 1
0
        public static Int32 IsUserBanned()
        {
            try
            {
                Int32 BanStatus = TelemetryStatus.USER_OK;

                WebClient client = new WebClient();

                Byte[] userbanRAW = client.DownloadData(String.Format("https://kaleidonkep99.altervista.org/kstelemetry/{0}", "users.banlist"));
                String userban    = System.Text.Encoding.UTF8.GetString(userbanRAW);

                Byte[] pcbanRAW = client.DownloadData(String.Format("https://kaleidonkep99.altervista.org/kstelemetry/{0}", "pcs.banlist"));
                String pcban    = System.Text.Encoding.UTF8.GetString(pcbanRAW);

                Byte[] macbanRAW = client.DownloadData(String.Format("https://kaleidonkep99.altervista.org/kstelemetry/{0}", "macaddresses.banlist"));
                String macban    = System.Text.Encoding.UTF8.GetString(macbanRAW);

                Byte[] hwidRAW = client.DownloadData(String.Format("https://kaleidonkep99.altervista.org/kstelemetry/{0}", "hwid.banlist"));
                String hwid    = System.Text.Encoding.UTF8.GetString(hwidRAW);

                if (BanStatus == TelemetryStatus.USER_OK)
                {
                    BanStatus = CheckPresence(userban, Environment.UserName, true); // Check userban
                    if (BanStatus == TelemetryStatus.USER_BANNED)
                    {
                        TelemetryStatus.TypeOfBan = TelemetryStatus.USER_BAN;
                    }
                }
                if (BanStatus == TelemetryStatus.USER_OK)
                {
                    BanStatus = CheckPresence(pcban, Environment.MachineName, true); // Check PC ban
                    if (BanStatus == TelemetryStatus.USER_BANNED)
                    {
                        TelemetryStatus.TypeOfBan = TelemetryStatus.PC_BAN;
                    }
                }
                if (BanStatus == TelemetryStatus.USER_OK)
                {
                    BanStatus = CheckPresence(macban, MACAddress, true); // Check MAC address ban
                    if (BanStatus == TelemetryStatus.USER_BANNED)
                    {
                        TelemetryStatus.TypeOfBan = TelemetryStatus.MAC_BAN;
                    }
                }
                if (BanStatus == TelemetryStatus.USER_OK)
                {
                    BanStatus = CheckPresence(hwid, TelemetryExt.ParseHWID(), true); // Check HWID ban
                    if (BanStatus == TelemetryStatus.USER_BANNED)
                    {
                        TelemetryStatus.TypeOfBan = TelemetryStatus.HWID_BAN;
                    }
                }

                return(BanStatus);
            }
            catch { return(TelemetryStatus.DATA_ERROR); }
        }
Exemplo n.º 2
0
        private void OkBtn_Click(object sender, EventArgs e)
        {
            Enabled = false;

            Int32 UserStatus = TelemetryExt.IsUserBanned();

            if (UserStatus != TelemetryStatus.USER_OK)
            {
                if (UserStatus == TelemetryStatus.USER_BANNED)
                {
                    MessageBox.Show(
                        String.Format("You're not allowed to send telemetry data.{0}", TelemetryStatus.Debug ? String.Format("\n\nReason: {0}", TelemetryStatus.Reasons[TelemetryStatus.TypeOfBan]) : ""),
                        "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Enabled = true;
                    Close();
                }
                else
                {
                    MessageBox.Show("Unable to run the telemetry.\n\nPlease try again later.", "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Enabled = true;
                }

                return;
            }

            // Do a check first
            if (String.IsNullOrWhiteSpace(NicknameVal.Text))
            {
                MessageBox.Show("Please use a valid (nick)name!", "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Enabled = true;
                return;
            }

            if (string.IsNullOrWhiteSpace(EmailVal.Text))
            {
                DialogResult dialogResult = MessageBox.Show("Without specifying your e-mail, I will not be able to communicate with you if an issue arises.\n\nAre you sure you would like to continue sending telemetry data without specifying your e-mail address?", "Keppy's Synthesizer - Telemetry warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
                else
                {
                    EmailVal.Text += "No e-mail address specified";
                }
            }
            else
            {
                if (!TelemetryExt.IsValidEmail(EmailVal.Text))
                {
                    DialogResult dialogResult = MessageBox.Show("Without specifying a valid e-mail, I will not be able to communicate with you if an issue arises.\n\nAre you sure you would like to continue sending telemetry data without specifying a valid e-mail address?", "Keppy's Synthesizer - Telemetry warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogResult == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        EmailVal.Text += " (Invalid e-mail address)";
                    }
                }
            }

            if (String.IsNullOrWhiteSpace(InstCPUVal.Text) ||
                String.IsNullOrWhiteSpace(InstRAMVal.Text) ||
                String.IsNullOrWhiteSpace(OSVal.Text) ||
                String.IsNullOrWhiteSpace(InstGPUVal.Text))
            {
                MessageBox.Show("Your PC specifications are mandatory!\nYou can't remove them.", "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LetUserEditSpecs.Checked = false;
                LetUserEditSpecs_CheckedChanged(sender, e);
                Enabled = true;
                return;
            }

            if (SoundCards.SelectedIndex == 0)
            {
                DialogResult dialogResult = MessageBox.Show("Without specifying your default sound card, I will be hard for me to troubleshoot the issue.\n\nAre you sure you would like to continue sending telemetry data without specifying your default sound card?", "Keppy's Synthesizer - Telemetry warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            StringBuilder TelemetryData = new StringBuilder();

            TelemetryData.AppendLine(String.Format("Telemetry data sent by {0} in {1}, through Keppy's Synthesizer {2}.",
                                                   NicknameVal.Text, DateTime.Now.ToString(), String.Format("{0}.{1}.{2}.{3}", Driver.FileMajorPart, Driver.FileMinorPart, Driver.FileBuildPart, Driver.FilePrivatePart)));
            TelemetryData.AppendLine();
            TelemetryData.AppendLine("========= Personal information =========");
            TelemetryData.AppendLine(String.Format("Name: {0} (Windows username: {1}, Computer name: {2})", NicknameVal.Text, Environment.UserName, Environment.MachineName));
            TelemetryData.AppendLine(String.Format("E-mail: {0}", EmailVal.Text));
            TelemetryData.AppendLine(String.Format("Age: {0}", String.IsNullOrWhiteSpace(AgeVal.Text) ? "Not specified" : AgeVal.Text));
            TelemetryData.AppendLine(String.Format("Country: {0}", String.IsNullOrWhiteSpace(CountryVal.Text) ? "Not specified" : CountryVal.Text));
            TelemetryData.AppendLine();
            TelemetryData.AppendLine("========= PC specifications =========");
            TelemetryData.AppendLine(String.Format("Processor: {0}\nReal value: {1}", InstCPUVal.Text, RealCPU));
            TelemetryData.AppendLine(String.Format("Installed RAM: {0}\nReal value: {1}\n", InstRAMVal.Text, RealRAM));
            TelemetryData.AppendLine(String.Format("Operating system: {0}\nReal value: {1}\n", OSVal.Text, String.Format("{0}, {1}", RealOS, RealPatch)));
            TelemetryData.AppendLine(String.Format("Graphics card: {0}\nReal value: {1}\n", InstGPUVal.Text, RealGPU));
            TelemetryData.AppendLine(String.Format("Unique PC HWID: {0}", TelemetryExt.ParseHWID()));
            TelemetryData.AppendLine(String.Format("MAC Address: {0}", MACAddress));
            TelemetryData.AppendLine();
            TelemetryData.AppendLine("========= Sound devices list =========");
            TelemetryData.AppendLine(String.Format("Default device: {0}", SoundCards.Text.ToString()));
            foreach (ManagementObject obj in mosSound.Get())
            {
                TelemetryData.AppendLine(obj["Name"].ToString());
            }
            TelemetryData.AppendLine();
            TelemetryData.AppendLine("========= Additional feedback =========");
            TelemetryData.AppendLine(String.IsNullOrWhiteSpace(AdditionalFeed.Text) ? "No additional feedback." : AdditionalFeed.Text.ToString());

            if (TelemetryExt.SendInfoForTelemetry(Encoding.ASCII.GetBytes(TelemetryData.ToString()), TelemetryData.ToString(), BugReport.Checked))
            {
                MessageBox.Show("The data have been sent!\nThank you for collaborating!\n\nPress OK to close this dialog.", "Keppy's Synthesizer - Telemetry complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            CurrentVerKey.Close();
            Close();
        }
Exemplo n.º 3
0
        private void OkBtn_Click(object sender, EventArgs e)
        {
            Enabled = false;

            Int32 UserStatus = TelemetryExt.IsUserBanned();

            if (UserStatus != TelemetryStatus.USER_OK)
            {
                if (UserStatus == TelemetryStatus.USER_BANNED)
                {
                    MessageBox.Show(
                        String.Format("You're not allowed to send telemetry data.{0}", TelemetryStatus.Debug ? String.Format("\n\nReason: {0}", TelemetryStatus.Reasons[TelemetryStatus.TypeOfBan]) : ""),
                        "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Enabled = true;
                    Close();
                }
                else
                {
                    MessageBox.Show("Unable to run the telemetry.\n\nPlease try again later.", "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Enabled = true;
                }

                return;
            }

            // Do a check first
            if (String.IsNullOrWhiteSpace(NicknameVal.Text))
            {
                MessageBox.Show("Please use a valid (nick)name!", "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Enabled = true;
                return;
            }

            if (string.IsNullOrWhiteSpace(EmailVal.Text))
            {
                DialogResult dialogResult = MessageBox.Show("Without specifying your e-mail, I will not be able to communicate with you if an issue arises.\n\nAre you sure you would like to continue sending telemetry data without specifying your e-mail address?", "Keppy's Synthesizer - Telemetry warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
                else
                {
                    EmailVal.Text += "No e-mail address specified";
                }
            }
            else
            {
                if (!TelemetryExt.IsValidEmail(EmailVal.Text))
                {
                    DialogResult dialogResult = MessageBox.Show("Without specifying a valid e-mail, I will not be able to communicate with you if an issue arises.\n\nAre you sure you would like to continue sending telemetry data without specifying a valid e-mail address?", "Keppy's Synthesizer - Telemetry warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogResult == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        EmailVal.Text += " (Invalid e-mail address)";
                    }
                }
            }

            if (String.IsNullOrWhiteSpace(InstCPUVal.Text) ||
                String.IsNullOrWhiteSpace(InstRAMVal.Text) ||
                String.IsNullOrWhiteSpace(OSVal.Text) ||
                String.IsNullOrWhiteSpace(InstGPUVal.Text))
            {
                MessageBox.Show("Your PC specifications are mandatory!\nYou can't remove them.", "Keppy's Synthesizer - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LetUserEditSpecs.Checked = false;
                LetUserEditSpecs_CheckedChanged(sender, e);
                Enabled = true;
                return;
            }

            if (SoundCards.SelectedIndex == 0)
            {
                DialogResult dialogResult = MessageBox.Show("Without specifying your default sound card, I will be hard for me to troubleshoot the issue.\n\nAre you sure you would like to continue sending telemetry data without specifying your default sound card?", "Keppy's Synthesizer - Telemetry warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            if (TelemetryExt.SendInfoForTelemetry(
                    // User info
                    NicknameVal.Text,
                    Environment.UserName,
                    Environment.MachineName,
                    EmailVal.Text,
                    String.Format("{0}", String.IsNullOrWhiteSpace(AgeVal.Text) ? "Not specified" : AgeVal.Text),
                    String.Format("{0}", String.IsNullOrWhiteSpace(CountryVal.Text) ? "Not specified" : CountryVal.Text),

                    // Computer specifications
                    String.Format("{0} (Real value: {1})", InstCPUVal.Text, RealCPU),
                    String.Format("{0} (Real value: {1})", InstGPUVal.Text, RealGPU),
                    String.Format("{0} (Real value: {1})", InstRAMVal.Text, RealRAM),
                    String.Format("{0} (Real value: {1})", OSVal.Text, String.Format("{0}, {1}", RealOS, RealPatch)),
                    SoundCards.Text.ToString(),
                    TelemetryExt.ParseHWID(),
                    MACAddress,

                    // Other info
                    DateTime.Now.ToString("dd MMMM yyyy", TelemetryExt.cultureTelemetry),
                    TelemetryExt.RandomID.Next(0, 2147483647).ToString("0000000000"),
                    String.Format("{0}.{1}.{2}.{3}", Driver.FileMajorPart, Driver.FileMinorPart, Driver.FileBuildPart, Driver.FilePrivatePart),

                    // Feedback
                    String.IsNullOrWhiteSpace(AdditionalFeed.Text) ? "No additional feedback." : AdditionalFeed.Text.ToString().Replace(System.Environment.NewLine, " "),

                    // ?
                    BugReport.Checked))
            {
                MessageBox.Show("The data have been sent!\nThank you for collaborating!\n\nPress OK to close this dialog.", "Keppy's Synthesizer - Telemetry complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            CurrentVerKey.Close();
            Close();
        }