C#一行代码登陆QQ居然碰到这么多麻烦(有意思)

Process.Start("C:\\Program Files\\Tencent\\QQ\\QQ.exe", "/START QQUIN:QQ号码 PWDHASH:密码的哈希 /STAT:40");

/STAT:40表示隐身,41表示在线.

一开始我在网上找了下PWDHASH的算法是Base64(md5(QQ密码,16));当然,因为网上的大都是去年的所以我也考虑了其他算法,不过最终都登陆失败.困了我一天,还好bbs.pfan.cn有个家伙叫我自己写算法,跟踪后发现正确的算法应该是Base64String(md5(QQ密码,32)).其实这个算法我也试过,不过不是自己写的,失败原因鉴定为我把QQ密码拿到在线加密服务器去转化.//最终认定QQ2008的PWDHASH计算方法是先把QQ密码(eg:124dfs5216)加密成32位的MD5比特流:9AE46DFB2512CA1191A51F66C8A9A35B再两个一组9A E4 6D FB 25 12 CA 11 91 A5 1F 66 C8 A9 A3 5B变回16个ASCII码字符串,再对其Base64加密(难怪很多人误以为是拿16位的MD5去Base64变换).而我当时拿小写的9AE46DFB2512CA1191A51F66C8A9A35B去Base64加密,所以错误了,问题还是在自己.

后来我就写了个Form形式的迷你QQ登陆器.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Diagnostics;

namespace 密你QQ登陆器
{
    public partial class Form1 : Form
    {

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btn_Login = new System.Windows.Forms.Button();
            this.txB_Account = new System.Windows.Forms.TextBox();
            this.chkB_Hide = new System.Windows.Forms.CheckBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.txB_Psw = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            //
            // btn_Login
            //
            this.btn_Login.BackColor = System.Drawing.Color.Red;
            this.btn_Login.Location = new System.Drawing.Point(188, 4);
            this.btn_Login.Name = "btn_Login";
            this.btn_Login.Size = new System.Drawing.Size(41, 23);
            this.btn_Login.TabIndex = 0;
            this.btn_Login.Text = "登陆";
            this.btn_Login.UseVisualStyleBackColor = false;
            this.btn_Login.Click += new System.EventHandler(this.btn_Login_Click);
            //
            // txB_Account
            //
            this.txB_Account.Location = new System.Drawing.Point(65, 6);
            this.txB_Account.Name = "txB_Account";
            this.txB_Account.Size = new System.Drawing.Size(117, 21);
            this.txB_Account.TabIndex = 1;
            //
            // chkB_Hide
            //
            this.chkB_Hide.AutoSize = true;
            this.chkB_Hide.Location = new System.Drawing.Point(188, 38);
            this.chkB_Hide.Name = "chkB_Hide";
            this.chkB_Hide.Size = new System.Drawing.Size(48, 16);
            this.chkB_Hide.TabIndex = 2;
            this.chkB_Hide.Text = "隐身";
            this.chkB_Hide.UseVisualStyleBackColor = true;
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 9);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(47, 12);
            this.label1.TabIndex = 3;
            this.label1.Text = "QQ帐号:";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(24, 36);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(35, 12);
            this.label2.TabIndex = 4;
            this.label2.Text = "密码:";
            //
            // txB_Psw
            //
            this.txB_Psw.Location = new System.Drawing.Point(65, 33);
            this.txB_Psw.Name = "txB_Psw";
            this.txB_Psw.PasswordChar = '*';
            this.txB_Psw.Size = new System.Drawing.Size(117, 21);
            this.txB_Psw.TabIndex = 5;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.PaleGreen;
            this.ClientSize = new System.Drawing.Size(241, 61);
            this.Controls.Add(this.txB_Psw);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.chkB_Hide);
            this.Controls.Add(this.txB_Account);
            this.Controls.Add(this.btn_Login);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "迷你QQ登陆器";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btn_Login;
        private System.Windows.Forms.TextBox txB_Account;
        private System.Windows.Forms.CheckBox chkB_Hide;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox txB_Psw;
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_Login_Click(object sender, EventArgs e)
        {
            try
            {
                string QQNum = txB_Account.Text.ToString().Trim();
                string pswStr = txB_Psw.Text.ToString().Trim();
                byte[] pwbyte = new byte[pswStr.Length];
                MD5 myMd5 = new MD5CryptoServiceProvider();
                pwbyte = myMd5.ComputeHash(Encoding.UTF8.GetBytes(pswStr));
                string Is_Hide = (chkB_Hide.Checked) ? "40" : "41";
                Process.Start("C:\\Program Files\\Tencent\\QQ\\QQ.exe", "/START QQUIN:" + QQNum + " PWDHASH:" +
                    Convert.ToBase64String(pwbyte) + " /STAT:" + Is_Hide);
            
}
            catch
            {
                MessageBox.Show("自己找错误!");
            }
        }
    }
}    

   

有了这个,就可以自己先用算法酸楚PSWDHASH,后建个控制台程序.用

Process.Start("C:\\Program Files\\Tencent\\QQ\\QQ.exe", "/START QQUIN:QQ号码 PWDHASH:密码的哈希 /STAT:40");

实现快速登陆了.

原文地址:https://www.cnblogs.com/chenbg2001/p/1492636.html