[zt]再谈QQ自动登陆器:提供C#源码下载(下)

上次提到的QQ自动登陆器C++版本,其技术太过低级,但是所用方法在其他的应用中作用强大,尤其是外挂程序。其实就QQ登录来说有其接口的,用C#代码描述就一条语句:
1Process.Start(qqPath, "/START QQUIN:" + strAcntNum + " PWDHASH:" + strAcntPsw + " /STAT:" + (blAcntSts ? "40" : "41")); 2
其中 qqPath为QQ程序路径,strAcntNum为QQ号码,strAcntPsw为QQ的Hash值,布尔类型blAcntSts为登录状态,即是否隐身。     简单吧,看来QQ自动登陆器是没有技术含量了,今天就设计过程中的其他技术作一介绍: (1)注册表中添加QQ程序路径和登陆器程序打开密码
 1        public static string SetQQRegistryValue(string key, object value)  2        {  3            RegistryKey pregkey = Registry.CurrentUser.OpenSubKey(Constants.STR_QQ_REG_PATH, true);  4            if (pregkey == null)  5            {  6                pregkey = Registry.CurrentUser.CreateSubKey(Constants.STR_QQ_REG_PATH, RegistryKeyPermissionCheck.ReadWriteSubTree);  7                pregkey.SetValue(key, string.Empty);  8                pregkey.Close();  9                return string.Empty; 10            } 11            else 12            { 13                pregkey.SetValue(key, value); 14                pregkey.Close(); 15                return value.ToString(); 16            } 1718        } 1920        public static string GetQQRegistryValue(string key) 21        { 22            RegistryKey pregkey = Registry.CurrentUser.OpenSubKey(Constants.STR_QQ_REG_PATH, true); 23            if (pregkey == null) 24            { 25                pregkey = Registry.CurrentUser.CreateSubKey(Constants.STR_QQ_REG_PATH, RegistryKeyPermissionCheck.ReadWriteSubTree); 26            } 27            object value = pregkey.GetValue(key); 28            pregkey.Close(); 29            if (value == null) 30            { 31                return string.Empty; 32            } 33            else 34            { 35                return value.ToString(); 36            } 37        } 38
(2)序列化QQ帐号信息到文件
 1public static List<QQAccount> Get(string path)  2        {  3            if (qqInfoList == null)  4            {  5                FileStream fs = null;  6                try  7                {  8                    XmlSerializer xs = new XmlSerializer(typeof(List<QQAccount>));  9                    fs = new FileStream(path, FileMode.Open, FileAccess.Read); 10                    qqInfoList = (List<QQAccount>)xs.Deserialize(fs); 11                    fs.Close(); 12                    return qqInfoList; 13                } 14                catch 15                { 16                    if (fs != null) 17                        fs.Close(); 18                    return null; 19                } 2021            } 22            else 23            { 24                return qqInfoList; 25            } 26        } 2728public static void Set(string path, List<QQAccount> qqList) 29        { 30            if (qqList == null) 31                throw new Exception("Parameter is null!"); 3233            FileStream fs = null; 34            try 35            { 36                XmlSerializer xs = new XmlSerializer(typeof(List<QQAccount>)); 37                fs = new FileStream(path, FileMode.Create, FileAccess.Write); 38                xs.Serialize(fs, qqList); 39                fs.Close(); 40            } 41            catch 42            { 43                if (fs != null) 44                    fs.Close(); 45                throw new Exception("Xml serialization failed!"); 46            } 47        }
(3)Hash处理登录密码
 1        public static string HashBase64(string str)  2        {  3            byte[] result = new byte[str.Length];  4            try  5            {  6                MD5 md = new MD5CryptoServiceProvider();  7                result = md.ComputeHash(System.Text.Encoding.UTF8.GetBytes(str));  8                return Convert.ToBase64String(result);  9            } 10            catch 11            { 12                return ""; 13            } 14        } 15
如下提供源码下载,作的粗糙,原谅!如有更好的建议请留言! 源码下载
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章