吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 758|回复: 24
收起左侧

[求助] 我有一个程序,一个mssql数据库!

[复制链接]
a7741200 发表于 2023-10-24 22:08
本帖最后由 a7741200 于 2023-10-24 22:10 编辑

我有一个账号注册的EXE程序。还有数据库。我是编程小白,不知道大佬们能不能知道这个程序如何将账号和密码写入数据库的。主要问题是不知道密码是如何加密的。
但是我还有一条修改账号密码的SQL语句。是将密码修改为123456的语句。
大佬们有空帮忙看一下吧!万分感谢。
程序和数据库的地址:链接:https://pan.baidu.com/s/1NJpxCPtDS6JR9yI0Ib0aPQ?pwd=q6ma
提取码:q6ma
--来自百度网盘超级会员V4的分享
SQL修改密码为123456的SQL语句:
修改用户密码123456
[SQL] 纯文本查看 复制代码
UPDATE "AionAccounts"."dbo"."user_auth" SET "password"=0xB53AA2DEE7078F3F0A93B5B578E2C4C4 where "account"='a7741200';


有个网友拿到这个程序以后不知道怎么搞出来的一段代码。我用AI转换为账号注册程序,账号和密码写到数据库中了,但是登录的时候提示密码错误,然后我用SQL修改密码为123456的SQL语句将密码修改为123456,就能登录了。
以下是朋友给的代码:
[C#] 纯文本查看 复制代码
namespace RegisterAccount
{                
                private static readonly Regex PwdRegex = new Regex("^[\\x20-\\xFF]{4,16}$");

                private const long Magic_0 = 256L;

                private const long Magic_1 = 65536L;

                private const long Magic_2 = 16777216L;

                private const long Magic_3 = 4294967296L;
                //密码加密逻辑
                public static byte[] GetAccountPasswordHash(string input)
                {
                        bool flag = !AionCrypto.PwdRegex.IsMatch(input);
                        if (flag)
                        {
                                throw new ArgumentException("Input string was not math requiremens (from 4 to 16 ascii symbols)", "input");
                        }
                        byte[] array = new byte[17];
                        byte[] array2 = new byte[17];
                        byte[] bytes = Encoding.ASCII.GetBytes(input);
                        for (int i = 0; i < input.Length; i++)
                        {
                                array[i + 1] = bytes[i];
                                array2[i + 1] = array[i + 1];
                        }
                        long num = (long)((ulong)array[1] + (ulong)array[2] * 256UL + (ulong)array[3] * 65536UL + (ulong)array[4] * 16777216UL);
                        long num2 = num * 213119L + 2529077L;
                        num2 -= num2 / 4294967296L * 4294967296L;
                        num = (long)((ulong)array[5] + (ulong)array[6] * 256UL + (ulong)array[7] * 65536UL + (ulong)array[8] * 16777216UL);
                        long num3 = num * 213247L + 2529089L;
                        num3 -= num3 / 4294967296L * 4294967296L;
                        num = (long)((ulong)array[9] + (ulong)array[10] * 256UL + (ulong)array[11] * 65536UL + (ulong)array[12] * 16777216UL);
                        long num4 = num * 213203L + 2529589L;
                        num4 -= num4 / 4294967296L * 4294967296L;
                        num = (long)((ulong)array[13] + (ulong)array[14] * 256UL + (ulong)array[15] * 65536UL + (ulong)array[16] * 16777216UL);
                        long num5 = num * 213821L + 2529997L;
                        num5 -= num5 / 4294967296L * 4294967296L;
                        array[4] = (byte)(num2 / 16777216L);
                        array[3] = (byte)((num2 - (long)((int)array[4] * 16777216)) / 65536L);
                        array[2] = (byte)((num2 - (long)((int)array[4] * 16777216) - (long)((int)array[3] * 65536)) / 256L);
                        array[1] = (byte)(num2 - (long)((int)array[4] * 16777216) - (long)((int)array[3] * 65536) - (long)((int)array[2] * 256));
                        array[8] = (byte)(num3 / 16777216L);
                        array[7] = (byte)((num3 - (long)((ulong)array[8] * 16777216UL)) / 65536L);
                        array[6] = (byte)((num3 - (long)((ulong)array[8] * 16777216UL) - (long)((int)array[7] * 65536)) / 256L);
                        array[5] = (byte)(num3 - (long)((ulong)array[8] * 16777216UL) - (long)((int)array[7] * 65536) - (long)((int)array[6] * 256));
                        array[12] = (byte)(num4 / 16777216L);
                        array[11] = (byte)((num4 - (long)((ulong)array[12] * 16777216UL)) / 65536L);
                        array[10] = (byte)((num4 - (long)((ulong)array[12] * 16777216UL) - (long)((int)array[11] * 65536)) / 256L);
                        array[9] = (byte)(num4 - (long)((ulong)array[12] * 16777216UL) - (long)((int)array[11] * 65536) - (long)((int)array[10] * 256));
                        array[16] = (byte)(num5 / 16777216L);
                        array[15] = (byte)((num5 - (long)((ulong)array[16] * 16777216UL)) / 65536L);
                        array[14] = (byte)((num5 - (long)((ulong)array[16] * 16777216UL) - (long)((int)array[15] * 65536)) / 256L);
                        array[13] = (byte)(num5 - (long)((ulong)array[16] * 16777216UL) - (long)((int)array[15] * 65536) - (long)((int)array[14] * 256));
                        array2[1] = (array2[1] ^ array[1]);
                        int j = 1;
                        while (j < 16)
                        {
                                j++;
                                array2[j] = (array2[j] ^ array2[j - 1] ^ array[j]);
                        }
                        j = 0;
                        while (j < 16)
                        {
                                j++;
                                bool flag2 = array2[j] == 0;
                                if (flag2)
                                {
                                        array2[j] = 102;
                                }
                        }
                        byte[] array3 = new byte[16];
                        Buffer.BlockCopy(array2, 1, array3, 0, 16);
                        return array3;
                }

        public class MainWindow : Window, IComponentConnector
        {
                public MainWindow()
                {
                        AppDomain.CurrentDomain.UnhandledException += this.CurrentDomainOnUnhandledException;
                        this.InitializeComponent();
                }

                private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
                {
                        MessageBox.Show(e.ExceptionObject.ToString(), "FATAL!", MessageBoxButton.OK, MessageBoxImage.Hand);
                }
                //账号注册逻辑
                private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
                {
                        bool flag = this.PbConfirm.Password != this.PbPwd.Password;
                        if (flag)
                        {
                                MessageBox.Show("Password not equal confirmation!", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        }
                        else
                        {
                                byte[] value = null;
                                try
                                {
                                        value = AionCrypto.GetAccountPasswordHash(this.PbConfirm.Password);
                                }
                                catch (ArgumentException ex)
                                {
                                        MessageBox.Show("Password must be from 4 to 16 latin letters or numbers!", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                        return;
                                }
                                using (SqlConnection sqlConnection = new SqlConnection("Server=np:.;Database=AionAccounts;Connection Timeout=200"))
                                {
                                        sqlConnection.Open();
                                        using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
                                        {
                                                sqlCommand.CommandText = "agent_CreateAccount";
                                                sqlCommand.CommandType = CommandType.StoredProcedure;
                                                sqlCommand.Parameters.AddWithValue("@ggid", Guid.NewGuid());
                                                sqlCommand.Parameters.AddWithValue("@account", this.TbLogin.Text);
                                                sqlCommand.Parameters.AddWithValue("@password", value);
                                                sqlCommand.Parameters.AddWithValue("@email", "m@" + this.TbLogin.Text);
                                                sqlCommand.Parameters.AddWithValue("@mobile", "phone");
                                                sqlCommand.Parameters.AddWithValue("@question1", string.Empty);
                                                sqlCommand.Parameters.AddWithValue("@question2", string.Empty);
                                                sqlCommand.Parameters.AddWithValue("@answer1", new byte[1]);
                                                sqlCommand.Parameters.AddWithValue("@answer2", new byte[1]);
                                                SqlParameter sqlParameter = sqlCommand.Parameters.Add("@ReturnVal", SqlDbType.Int);
                                                sqlParameter.Direction = ParameterDirection.ReturnValue;
                                                sqlCommand.ExecuteNonQuery();
                                                int num = (int)sqlParameter.Value;
                                                bool flag2 = num == 0;
                                                if (flag2)
                                                {
                                                        MessageBox.Show("Account not created! Invalid login or login already exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                                }
                                                else
                                                {
                                                        MessageBox.Show(string.Format("Account was created! Account id = {0}!", num), "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                                                }
                                        }
                                }
                        }
                }
        }
}



发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| a7741200 发表于 2023-10-24 22:14
本帖最后由 a7741200 于 2023-10-24 22:32 编辑

然后我将我用AI转换的账号注册程序代码也发出来大佬们看看吧!
[C#] 纯文本查看 复制代码
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace RegisterAccount
{
    public class MainForm : Form
    {
        private TextBox tbLogin;
        private TextBox tbPwd;
        private TextBox tbConfirm;
        private TextBox tbEmail; // 新增的邮箱文本框
        private TextBox tbPhone; // 新增的电话号码文本框
        private Button btnRegister;
        private Label lblLogin;
        private Label lblPwd;
        private Label lblConfirm;
        private Label lblEmail;
        private Label lblPhone;
        private static readonly Regex PwdRegex = new Regex("^[\\x20-\\xFF]{4,16}$");

        public MainForm()
        {
            InitializeComponent();
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (tbConfirm.Text != tbPwd.Text)
            {
                MessageBox.Show("Password does not match confirmation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                byte[] value = null;
                try
                {
                    value = GetAccountPasswordHash(tbConfirm.Text);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show("Password must be 4 to 16 Latin letters or numbers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                using (SqlConnection sqlConnection = new SqlConnection("Server=127.0.0.1;Database=AionAccounts;User Id=sa;Password=123456;Connection Timeout=200"))
                {
                    sqlConnection.Open();
                    using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
                    {
                        sqlCommand.CommandText = "agent_CreateAccount";
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.Parameters.AddWithValue("@ggid", Guid.NewGuid());
                        sqlCommand.Parameters.AddWithValue("@account", tbLogin.Text);
                        sqlCommand.Parameters.AddWithValue("@password", value);
                        sqlCommand.Parameters.AddWithValue("@email", tbEmail.Text); // 使用用户输入的邮箱
                        sqlCommand.Parameters.AddWithValue("@mobile", tbPhone.Text); // 使用用户输入的电话号码
                        sqlCommand.Parameters.AddWithValue("@question1", string.Empty);
                        sqlCommand.Parameters.AddWithValue("@question2", string.Empty);
                        sqlCommand.Parameters.AddWithValue("@answer1", new byte[1]);
                        sqlCommand.Parameters.AddWithValue("@answer2", new byte[1]);
                        SqlParameter sqlParameter = sqlCommand.Parameters.Add("@ReturnVal", SqlDbType.Int);
                        sqlParameter.Direction = ParameterDirection.ReturnValue;
                        sqlCommand.ExecuteNonQuery();
                        int num = (int)sqlParameter.Value;
                        if (num == 0)
                        {
                            MessageBox.Show("Account not created! Invalid login or login already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            MessageBox.Show(string.Format("Account created successfully! Account ID = {0}!", num), "Info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                }
            }
        }

        private void InitializeComponent()
        {
            this.tbLogin = new System.Windows.Forms.TextBox();
            this.tbPwd = new System.Windows.Forms.TextBox();
            this.tbConfirm = new System.Windows.Forms.TextBox();
            this.tbEmail = new System.Windows.Forms.TextBox();
            this.tbPhone = new System.Windows.Forms.TextBox();
            this.btnRegister = new System.Windows.Forms.Button();
            this.lblLogin = new System.Windows.Forms.Label();
            this.lblPwd = new System.Windows.Forms.Label();
            this.lblConfirm = new System.Windows.Forms.Label();
            this.lblEmail = new System.Windows.Forms.Label();
            this.lblPhone = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // tbLogin
            // 
            this.tbLogin.Location = new System.Drawing.Point(100, 20);
            this.tbLogin.Name = "tbLogin";
            this.tbLogin.Size = new System.Drawing.Size(150, 21);
            this.tbLogin.TabIndex = 1;
            // 
            // tbPwd
            // 
            this.tbPwd.Location = new System.Drawing.Point(100, 50);
            this.tbPwd.Name = "tbPwd";
            this.tbPwd.PasswordChar = '*';
            this.tbPwd.Size = new System.Drawing.Size(150, 21);
            this.tbPwd.TabIndex = 3;
            // 
            // tbConfirm
            // 
            this.tbConfirm.Location = new System.Drawing.Point(140, 80);
            this.tbConfirm.Name = "tbConfirm";
            this.tbConfirm.PasswordChar = '*';
            this.tbConfirm.Size = new System.Drawing.Size(150, 21);
            this.tbConfirm.TabIndex = 5;
            // 
            // tbEmail
            // 
            this.tbEmail.Location = new System.Drawing.Point(100, 110);
            this.tbEmail.Name = "tbEmail";
            this.tbEmail.Size = new System.Drawing.Size(150, 21);
            this.tbEmail.TabIndex = 7;
            // 
            // tbPhone
            // 
            this.tbPhone.Location = new System.Drawing.Point(100, 140);
            this.tbPhone.Name = "tbPhone";
            this.tbPhone.Size = new System.Drawing.Size(150, 21);
            this.tbPhone.TabIndex = 9;
            // 
            // btnRegister
            // 
            this.btnRegister.Location = new System.Drawing.Point(100, 180);
            this.btnRegister.Name = "btnRegister";
            this.btnRegister.Size = new System.Drawing.Size(100, 30);
            this.btnRegister.TabIndex = 10;
            this.btnRegister.Text = "Register";
            this.btnRegister.Click += new System.EventHandler(this.btnRegister_Click);
            // 
            // lblLogin
            // 
            this.lblLogin.AutoSize = true;
            this.lblLogin.Location = new System.Drawing.Point(20, 20);
            this.lblLogin.Name = "lblLogin";
            this.lblLogin.Size = new System.Drawing.Size(41, 12);
            this.lblLogin.TabIndex = 0;
            this.lblLogin.Text = "Login:";
            // 
            // lblPwd
            // 
            this.lblPwd.AutoSize = true;
            this.lblPwd.Location = new System.Drawing.Point(20, 50);
            this.lblPwd.Name = "lblPwd";
            this.lblPwd.Size = new System.Drawing.Size(59, 12);
            this.lblPwd.TabIndex = 2;
            this.lblPwd.Text = "Password:";
            // 
            // lblConfirm
            // 
            this.lblConfirm.AutoSize = true;
            this.lblConfirm.Location = new System.Drawing.Point(20, 80);
            this.lblConfirm.Name = "lblConfirm";
            this.lblConfirm.Size = new System.Drawing.Size(107, 12);
            this.lblConfirm.TabIndex = 4;
            this.lblConfirm.Text = "Confirm Password:";
            // 
            // lblEmail
            // 
            this.lblEmail.AutoSize = true;
            this.lblEmail.Location = new System.Drawing.Point(20, 110);
            this.lblEmail.Name = "lblEmail";
            this.lblEmail.Size = new System.Drawing.Size(41, 12);
            this.lblEmail.TabIndex = 6;
            this.lblEmail.Text = "Email:";
            // 
            // lblPhone
            // 
            this.lblPhone.AutoSize = true;
            this.lblPhone.Location = new System.Drawing.Point(20, 140);
            this.lblPhone.Name = "lblPhone";
            this.lblPhone.Size = new System.Drawing.Size(41, 12);
            this.lblPhone.TabIndex = 8;
            this.lblPhone.Text = "Phone:";
            // 
            // MainForm
            // 
            this.ClientSize = new System.Drawing.Size(350, 288);
            this.Controls.Add(this.lblLogin);
            this.Controls.Add(this.tbLogin);
            this.Controls.Add(this.lblPwd);
            this.Controls.Add(this.tbPwd);
            this.Controls.Add(this.lblConfirm);
            this.Controls.Add(this.tbConfirm);
            this.Controls.Add(this.lblEmail);
            this.Controls.Add(this.tbEmail);
            this.Controls.Add(this.lblPhone);
            this.Controls.Add(this.tbPhone);
            this.Controls.Add(this.btnRegister);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.Name = "MainForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Account Registration";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private static byte[] GetAccountPasswordHash(string input)
        {
            if (!PwdRegex.IsMatch(input))
            {
                throw new ArgumentException("Input string does not meet the requirements (4 to 16 ASCII symbols)", "input");
            }

            byte[] array = new byte[17];
            byte[] array2 = new byte[17];
            byte[] bytes = Encoding.ASCII.GetBytes(input);

            for (int i = 0; i < input.Length; i++)
            {
                array[i + 1] = bytes[i];
                array2[i + 1] = array[i + 1];
            }

            long num = (long)((ulong)array[1] + (ulong)array[2] * 256UL + (ulong)array[3] * 65536UL + (ulong)array[4] * 16777216UL);
            long num2 = num * 213119L + 2529077L;
            num2 -= num2 / 4294967296L * 4294967296L;

            // Perform similar calculations for num3, num4, and num5

            array[4] = (byte)(num2 / 16777216L);
            array[3] = (byte)((num2 - (long)((int)array[4] * 16777216)) / 65536L);
            array[2] = (byte)((num2 - (long)((int)array[4] * 16777216) - (long)((int)array[3] * 65536)) / 256L);
            array[1] = (byte)(num2 - (long)((int)array[4] * 16777216) - (long)((int)array[3] * 65536) - (long)((int)array[2] * 256));

            // Perform similar assignments for array[5] to array[16]

            array2[1] = (byte)(array2[1] ^ array[1]);

            for (int j = 1; j < 16; j++)
            {
                array2[j] = (byte)(array2[j] ^ array2[j - 1] ^ array[j]);
            }

            for (int j = 0; j < 16; j++)
            {
                if (array2[j] == 0)
                {
                    array2[j] = 102;
                }
            }

            byte[] array3 = new byte[16];
            Buffer.BlockCopy(array2, 1, array3, 0, 16);
            return array3;
        }
    }

    public static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
    }
}
头像被屏蔽
yyb1813 发表于 2023-10-24 23:10
gebiafu 发表于 2023-10-24 23:26
交大研究 发表于 2023-10-25 08:15
加密过程如下:

将输入字符串转换为ASCII码的字节数组。
根据一系列的计算和位操作,对字节数组中的元素进行加密处理。
最后,将加密后的字节数组复制到另一个数组中,并返回该数组。
具体问题,需要花时间。
sai609 发表于 2023-10-25 08:50
ai终究解决不了底层东西,&#127568;自己学
jyjjf 发表于 2023-10-25 09:30
自己看看GetAccountPasswordHash("123456")这个函数的返回值是不是一样,就知道函数对不对了
 楼主| a7741200 发表于 2023-10-25 09:31
jyjjf 发表于 2023-10-25 09:30
自己看看GetAccountPasswordHash("123456")这个函数的返回值是不是一样,就知道函数对不对了

不一样。不知道怎么回事。另外我是小白,确实不懂这些东西。
 楼主| a7741200 发表于 2023-10-25 09:33
数据库也提供了。不知道大佬们能不能看看数据库中储存密码是怎么储存的。通过数据库,看不出来密码的加密方式吗?
jyjjf 发表于 2023-10-25 09:35
a7741200 发表于 2023-10-25 09:31
不一样。不知道怎么回事。另外我是小白,确实不懂这些东西。

我用转换的vb代码也是不一样,估计还有十六进制转字符串问题
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-24 18:33

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表