前几天看到一篇文章说通过DOS命令就可以登陆QQ,在运行里试了一下,真的可以。

代码如下:QQ路径 /start QQUIN:QQ号 PWDHASH:经过MD5和BASE64双充加密的QQ密码  /stat:登陆类型

今天就想做个QQ登录器试一下,信息保存尝试使用了序列化,发现功能真的太强大了,刚才整理了一下,现在完工,里面做了大量的注释,放出代码,文章最下面有打包的下载:

QQLoginForm.cs窗体

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 QQLogin
{
    
    public partial class QQLoginForm : Form
    {
        public QQLoginForm()
        {
            InitializeComponent();
        }
        
        UserInfo ui;
        private void button1_Click(object sender, EventArgs e)
        {
             //单用户登陆
            if (ui == null)
            {
                ui = new UserInfo();//如果没有提取出来对象,就创建一个
            }
            if (ui != null)
            {
                ui.Username = this.txtUser.Text.Trim();
                ui.Password = this.txtPwd.Text;
                ui.Type = this.cboType.Text == "正常" ? "41" : "40";
                if (this.ValidateInput())
                {//验证是否输入完全
                    if (string.IsNullOrEmpty(ui.Path))
                    {//判断是否有QQ路径,如果没有就打开对话框来选择一下
                        DialogResult dr = this.opfQQ.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            ui.Path = opfQQ.FileName;//将选择的路径赋值给对象
                            this.LoginQQ(ui.Username, ui.Password, ui.Type, ui.Path);//登陆QQ
                        }

}
                    else
                    {
                        this.LoginQQ(ui.Username, ui.Password, ui.Type, ui.Path);

}
                }

SerializeHelper.SerializeUserInfo(ui);//每次登陆都序列化保存一次
              
            }

}
        private bool ValidateInput()
        {//验证是否输入完整
            if (this.txtUser.Text == "")
            {
                this.txtUser.Focus();
                return false;
            }
            else if(this.txtPwd.Text=="")
            {
                this.txtPwd.Focus();
                return false;
            }
            return true;
        
        }

private void LoginQQ(string user,string pwd,string type,string path)
        {//登陆QQ的命令,通过CMD命令来执行
            Process MyProcess = new Process();
            //设定程序名
            MyProcess.StartInfo.FileName = "cmd.exe";
            //关闭Shell的使用
            MyProcess.StartInfo.UseShellExecute = false;
            //重定向标准输入
            MyProcess.StartInfo.RedirectStandardInput = true;
            //重定向标准输出
            MyProcess.StartInfo.RedirectStandardOutput = true;
            //重定向错误输出
            MyProcess.StartInfo.RedirectStandardError = true;
            //设置不显示窗口
            MyProcess.StartInfo.CreateNoWindow = true;
            //执行强制结束命令
            MyProcess.Start();
            MyProcess.StandardInput.WriteLine(path+" /start QQUIN:"+user+" PWDHASH:" + EncodeHash.pwdHash(pwd) + "  /stat:"+type);//直接结束进程ID
            MyProcess.StandardInput.WriteLine("Exit");

}

private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

private void txtUser_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < '0' || e.KeyChar > '9')&&e.KeyChar!=8)
            {//只能输入数字和退格键
                e.Handled = true;
            }
        }

private void QQLoginForm_Load(object sender, EventArgs e)
        {
            LoadInfo();//单用户获取

}
        private void LoadInfo()
        {//单用户获取
            ui = SerializeHelper.DeserializeUserInfo();//返回获取后对象
            if (ui != null)
            {
                this.txtUser.Text = ui.Username;//填充文本框
                this.txtPwd.Text = ui.Password;//填充密码框
                this.cboType.SelectedIndex = ui.Type == "41" ? 0 : 1;//选择登陆方式
            }
            else
            {
                this.cboType.SelectedIndex = 0;
            }
        }
        private void btnConfig_Click(object sender, EventArgs e)
        {
            ConfigForm cf = new ConfigForm();
            cf.ShowDialog();
            LoadInfo();
        }

}
}

/

ConfigForm.cs 配置窗体

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace QQLogin
{
    public partial class ConfigForm : Form
    {

UserInfo ui;
        public ConfigForm()
        {
            InitializeComponent();
        }

private void txtPath_Click(object sender, EventArgs e)
        {//点击一次文本框,弹出一次对话框来选择QQ路径
            DialogResult dr = this.opfQQ.ShowDialog();
            if (dr == DialogResult.OK)
            {
                this.txtPath.Text = opfQQ.FileName;
               
            }
        }
       
        private bool ValidateInput()
        {//验证是否输入完整
            if (this.txtUser.Text == "")
            {
                this.txtUser.Focus();
                return false;
            }
            else if (this.txtPwd.Text == "")
            {
                this.txtPwd.Focus();
                return false;
            }
            else if (this.txtPath.Text == "")
            {
                return false;
            }
            return true;

}
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

private void ConfigForm_Load(object sender, EventArgs e)
        {
            LoadInfo();
        }
        
        private void btnSave_Click(object sender, EventArgs e)
        {
            ui = new UserInfo();
            ui.Username = this.txtUser.Text.Trim();
            ui.Password = this.txtPwd.Text;
            ui.Type = this.cboType.Text == "正常" ? "41" : "40";
            ui.Path = this.txtPath.Text;
            if (this.ValidateInput())
            {
                SerializeHelper.SerializeUserInfo(ui);                
                this.Close();
            }

}
        private void LoadInfo()
        {
            ui = SerializeHelper.DeserializeUserInfo();
            if (ui != null)
            {
                this.txtUser.Text = ui.Username;
                this.txtPwd.Text = ui.Password;
                this.cboType.SelectedIndex = ui.Type == "41" ? 0 : 1;
                this.txtPath.Text = ui.Path;
            }
            else
            {
                this.cboType.SelectedIndex = 0;
            }
        }
    }
}

EncodeHash.cs 加密类

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace QQLogin
{
    /** <summary>
    /// 编码加密类
    /// </summary>
    class EncodeHash
    {
        /** <summary>
        /// 通过MD5加密后返回加密后的BASE64密码
        /// </summary>
        /// <param name="pwd">要加密的内容</param>
        /// <returns>通过MD5加密后返回加密后的BASE64密码</returns>
        
        public static string pwdHash(string pwd)
        {//使用MD5的16位加密后再转换成BASE64
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();//实例化一个md5对像 
            // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择  
            byte[] s = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pwd));
            return Convert.ToBase64String(s);
        }

/** <summary>
        /// 返回MD5的32位加密后的密码
        /// </summary>
        /// <param name="inputString">要加密的内容</param>
        /// <returns>加密后的结果</returns>
        public static string StringToMD5Hash(string inputString)
        {
            
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(inputString));
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < encryptedBytes.Length; i++)
            {
                sb.AppendFormat("{0:x2}", encryptedBytes);
            }
            return sb.ToString();
        }
        
        /** <summary>
        /// Base64编码
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string EncodeBase64(string code)
        {
            string encode = "";
            byte[] bytes = System.Text.Encoding.Default.GetBytes(code);

try
            {
                encode = Convert.ToBase64String(bytes);
            }
            catch
            {
                encode = code;
            }
            return encode;
        }
        
        /** <summary>
        /// Base64解码
        /// </summary>
        /// <param name="code_type"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string DecodeBase64(string code_type, string code)
        {
            string decode = "";
            byte[] bytes = Convert.FromBase64String(code);
            try
            {
                decode = Encoding.GetEncoding(code_type).GetString(bytes);
            }
            catch
            {
                decode = code;
            }
            return decode;
        }
    }
}

///

SerializeHelper.cs 序列化类,打算做多用户登录器呢,就预留了两个用来序列化集合的方法

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;//序列化
using System.IO;

namespace QQLogin
{
    /** <summary>
    /// 序列化帮助类
    /// </summary>
    class SerializeHelper
    {
        /** <summary>
        /// 使用反序列化方式读取信息
        /// </summary>
        /// <returns></returns>
        public static  UserInfo DeserializeUserInfo()
        {//将用户信息使用反序列化方式提取
            UserInfo ui = null;
            try
            {
                FileStream fileStream = null;
                fileStream = new FileStream(Application.StartupPath + "\\UserInfo.bin", FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                ui = (UserInfo)bf.Deserialize(fileStream);
                fileStream.Close();
            }
            catch (Exception ex)
            {
            }
            return ui;
        }
        /** <summary>
        /// 序列化UserInfo对象
        /// </summary>
        /// <param name="ui">传入要序列化的UserInfo对象</param>
        public static void SerializeUserInfo(UserInfo ui)
        {//将用户信息使用序列化方式保存
            try
            {
                FileStream fileStream = null;
                fileStream = new FileStream(Application.StartupPath + "\\UserInfo.bin", FileMode.Create);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fileStream, ui);
                fileStream.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /** <summary>
        /// 反序列化UserInfo泛型集合对象
        /// </summary>
        /// <returns></returns>
        public static List<UserInfo> DeserializeList()
        {//将用户信息使用反序列化方式提取
            List<UserInfo> lst = null;
            FileStream fileStream = null;
            try
            {

fileStream = new FileStream(Application.StartupPath + "\\UserInfo.bin", FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                lst = (List<UserInfo>)bf.Deserialize(fileStream);
                fileStream.Close();
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
                
           
            return lst;
        }
        /** <summary>
        /// 序列化UserInfo泛型集合对象
        /// </summary>
        /// <param name="ui">传入要序列化的List<UserInfo>对象</param>
        public static void SerializeList(List<UserInfo> lst)
        {//将用户信息使用序列化方式保存
            FileStream fileStream = null;
            try
            {

fileStream = new FileStream(Application.StartupPath + "\\UserInfo.bin", FileMode.Create);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fileStream, lst);
                fileStream.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

UserInfo.cs用户信息类

using System;
using System.Collections.Generic;
using System.Text;

namespace QQLogin
{
    /** <summary>
    /// 用户信息类
    /// </summary>
    [Serializable]
    class UserInfo
    {
        private string username;

public string Username
        {
            get { return username; }
            set { username = value; }
        }
        private string password;

public string Password
        {
            get { return password; }
            set { password = value; }
        }
        private string type;

public string Type
        {
            get { return type; }
            set { type = value; }
        }
        private string path;

public string Path
        {
            get { return path; }
            set { path = value; }
        }

}
}

/

下载Demo地址:http://u.115.com/file/bha14f52#
QQLogin.rar

C#实现的QQ登录器相关推荐

  1. 基于clswindow for vb开发的qq登录器源码

    clswindow是vb下控制外部程序的一个框架,封装了很多简单使用的操作函数. clswindow的详细介绍:https://blog.csdn.net/sysdzw/article/details ...

  2. QQ自动登录/QQ登录器/程序源代码/VS2010/VS2012/VC/MFC

    学习豪迪,研究了一下QQ自动登录怎么写. 以前QQ登录的介面先用SPY++来找到QQ登陆框,然后再把密码copy进去,就可以了. 现在的QQ登录介面这招不行,用SPY++是找不到任何ID的. 怎办呢? ...

  3. 用duilib制作仿QQ2013动态背景登录器

    转载请说明原出处,谢谢~~ 在上一篇博客里,我修复了CActiveXUI控件的bug,从而可以使用flash动画来制作程序的背景,这篇博客说明一下应该怎么使用CActiveXUI控件创建透明无窗体的背 ...

  4. 美多商城之用户登录(QQ登录)

    二.QQ登录 2.1 QQ登录开发文档 QQ登录:即我们所说的第三方登录,是指用户可以不在本项目中输入密码,而直接通过第三方的验证,成功登录本项目. 1. QQ互联开发者申请步骤 若想实现QQ登录,需 ...

  5. java qq登录界面_用java实现QQ登录界面怎么写

    展开全部 用32313133353236313431303231363533e78988e69d8331333365646263java做QQ登录界面的写法如下: package ch10; impo ...

  6. 按键精灵上传账号到服务器_百度网盘超级会员账号登录器

    百度网盘超级会员账号登录器 该软件较为简洁,双击运行,自动进行网页登录,程序已内置一个网盘超级会员账号供大家使用,可以正常下载,请大家不要上传任何违法违规内容,该程序仅供大家临时下载使用,同时下载人数 ...

  7. Qt模仿QQ登录界面(一)

    这两天研究qt,练习时做了个仿QQ登录界面,我这次实现的比较简单,先在这里记录一下,以后有空了会继续完善的. (一)效果图 这里使用我的qq号测试的如图: (二)工程文件 (三)代码实现 mainwi ...

  8. read.html5.qq.com,如何通过第三方QQ登录网站首页

    QQ登录,就是我们所说的第三方登录,是指用户可以不在本项目中输入密码,而直接通过第三方的验证,成功登录本项目 若想实现QQ登录,需要成为QQ互联的开发者,审核通过才可实现.注册方法参考链接http:/ ...

  9. Unity Shader(一) Lowpoly动态低多边形 (QQ登录界面低边动画)

    前言 在逛论坛的时候偶然发现有人在问动态低多边形(Lowpoly)是如何实现的,因为经常编写UGUI拓展对顶点操作较为熟悉的我立马就想到利用继承UnityEngine.Graphic,重写OnPopu ...

最新文章

  1. python quit函数作用_Python常用函数学习笔记
  2. codeblocks常用配置
  3. hdoj1176【DP】
  4. No PIL installation found INFO:superset.utils.screenshots:No PIL installation found
  5. java实现多对多关系的方法_java – 如何在JPA中实现复杂的多对多关系?
  6. Scala 多继承问题
  7. jQuery animate()动画效果
  8. atom 基础使用教程
  9. 从进化的角度看为啥要均贫富
  10. 微信小程序 图片处理:压缩、上传、审核
  11. vb.net视频总结
  12. 「总结」最全2万字长文解读7大方向人脸数据集v2.0版
  13. python selenium 跳转网页_selenium关于页面跳转
  14. CMD查看Win10注册码
  15. Selenium-针对alert弹窗无法获取,弹出no such alert的解决方法
  16. 工具-在WIN10上搭建Ftp服务器(转)
  17. keras实战项目:CIFAR-10 图像分类
  18. 送你一份2019年最新最全的技能图谱(附思维导图)!
  19. Canal adapter1.1.5安装部署配置(3)
  20. atmel c keil 包_Atmel SAM D21开发板试用心得 ——利用Keil5,全速运行

热门文章

  1. 字幕下载下来是php文件,剪映字幕导出为SRT文件网页版
  2. 而立,不惑和知天命—程序员的三个层次
  3. 浏览器页面性能分析指南(chrome)
  4. Windows10 pc使用Apple Studio Display显示器设置
  5. 自动驾驶 9-1: (线性)卡尔曼滤波器The (Linear) Kalman Filter
  6. 很棒的 Django 应用程序、项目和资源的精选表单
  7. 超市会员管理系统,数据库课程设计
  8. python 3.8安装pillow包报错
  9. 2022最新软件测试面试八股文,全网最全最新,堪称地表最强
  10. 携手长亮数据打造数据底座 GBase 8a MPP助力承德银行数字化转型