吾爱汇编

 找回密码
 立即注册

QQ登录

绑定QQ避免忘记帐号

查看: 2080|回复: 7

[C#] C#取本机在线QQ号源码

[复制链接]
幻苍秋 发表于 2022-6-27 14:56 | 显示全部楼层 |阅读模式

本帖最后由 幻苍秋 于 2022-6-27 17:39 编辑

运行环境: WIN10
涉及工具: VS2022
编程语言: C#

以下为主题内容:
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Net;
using System.IO;

namespace GetQQNumber
{
    public class GetQQNumber
    {
        private static List<string> QQnumber = new List<string>();
        private static List<string> WinClass = new List<string>();
        private static List<string> WinTitle = new List<string>();
                //本机在线QQ
        public static List<string> GetQQnumbers()
        {
            GetWindowInformation();
            for (int i = 0; i < WinClass.Count; i++) 
            {
                if (WinClass[i] == "5B3838F5-0C81-46D9-A4C0-6EA28CA3E942")
                {
                    int index = WinTitle[i].LastIndexOf("_") + 1;
                    QQnumber.Add(WinTitle[i].Substring(index, WinTitle[i].Length - index));
                    //Console.WriteLine(QQnumber[0]);
                }
            }
            return QQnumber;
        }
                //QQ头像
                public static void DownloadQQAvatar(string qqnumber, string Filepath)
        {
            string http = "https://qlogo1.store.qq.com/qzone/" + qqnumber + "/" + qqnumber + "/100?1655721377";
            WebClient client = new WebClient();
            client.Credentials = CredentialCache.DefaultCredentials;
            client.Encoding = Encoding.UTF8;
            client.DownloadFile(http, Filepath);
        }
                //昵称
                public static string GetQQName(string qqnumber)
        {
            string html = ApiGET("https://v.api.aa1.cn/api/qqnicheng/index.php?qq=" + qqnumber);
            int index = html.IndexOf(":") + 1;
            return html.Substring(index, html.Length - index - 10);
        }
        private static bool GetWindowInformation()
        {
            return EnumWindows(new EnumWindowsProc(Enuming), IntPtr.Zero);
        }

        private static void Enuming(IntPtr hWnd, IntPtr lParam)
        {
            // Console.WriteLine("WinClass:{0} \nWinTitle::{1} ", new string[] { GetClass(hWnd), GetTitle(hWnd)} );
            WinClass.Add(GetClass(hWnd));
            WinTitle.Add(GetTitle(hWnd));
        }
        private static string GetClass(IntPtr hWnd)
        {
            StringBuilder sb = new StringBuilder(256);//类名最大长度256
            GetClassName(hWnd, sb, sb.Capacity);
            return sb.ToString();

        }
        private static string GetTitle(IntPtr hWnd)
        {
            int length = GetWindowTextLength(hWnd);
            StringBuilder sb = new StringBuilder(length + 1);
            GetWindowText(hWnd, sb, sb.Capacity);
            return sb.ToString();
        }
                private static string ApiGET(string url)
        {
            try
            {
                Encoding charset = Encoding.UTF8;
                HttpWebRequest request = null;
                request = WebRequest.Create(url.Trim()) as HttpWebRequest;
                request.ProtocolVersion = HttpVersion.Version10;
                request.Method = "Get";
                request.ContentType = "application/x-www-form-urlencoded";
                request.UserAgent = DefaultUserAgent;
                HttpWebResponse response = (request.GetResponse() as HttpWebResponse);
                Stream htmlStream = response.GetResponseStream();
                StreamReader sr = new StreamReader(htmlStream);
                return sr.ReadToEnd();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return e.Message;
            }
        }

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        private static extern int GetClassName(IntPtr hWnd,  StringBuilder lpClassName, int nMaxCount);
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        private static extern int GetWindowTextLength(IntPtr hWnd);

        private delegate void EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
    }
}

闲来无事写的

评分

参与人数 10HB +10 THX +3 收起 理由
消逝的过去 + 1
流行格调 + 1 [吾爱汇编论坛52HB.COM]-吃水不忘打井人,给个评分懂感恩!
真没劲 + 1 + 1 [吾爱汇编论坛52HB.COM]-学破解防破解,知进攻懂防守!
娄胖胖 + 1
sjtkxy + 1
风里去 + 1 [吾爱汇编论坛52HB.COM]-软件反汇编逆向分析,软件安全必不可少!
程序员大明 + 2 + 1
天涯绝恋 + 1 [吾爱汇编论坛52HB.COM]-学破解防破解,知进攻懂防守!
飞刀梦想 + 1
阿枫 + 1

查看全部评分

吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
头像被屏蔽
2276980 发表于 2022-7-6 08:18 | 显示全部楼层
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
头像被屏蔽
sjtkxy 发表于 2022-9-30 05:32 | 显示全部楼层

提示: 作者被禁止或删除 内容自动屏蔽
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
吾爱稀饭 发表于 2022-10-11 23:30 | 显示全部楼层
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
2386222844 发表于 2022-10-18 08:42 | 显示全部楼层

牛啊~~~支持
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
望峰息心 发表于 2023-1-4 14:16 | 显示全部楼层
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
流行格调 发表于 2023-3-18 06:51 | 显示全部楼层


好像是通过检索窗口然后找到的qq号.
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
天理兄 发表于 2023-3-18 10:21 | 显示全部楼层

我的qq账号被盗了,也无法找回。这些方法可以找回么?
吾爱汇编论坛-学破解,防破解!知进攻,懂防守!逆向分析,软件安全!52HB.COM
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

警告:本站严惩灌水回复,尊重自己从尊重他人开始!

1层
2层
3层
4层
5层
6层
7层
8层

免责声明

吾爱汇编(www.52hb.com)所讨论的技术及相关工具仅限用于研究学习,皆在提高软件产品的安全性,严禁用于不良动机。任何个人、团体、组织不得将其用于非法目的,否则,一切后果自行承担。吾爱汇编不承担任何因为技术滥用所产生的连带责任。吾爱汇编内容源于网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除。如有侵权请邮件或微信与我们联系处理。

站长邮箱:SharkHeng@sina.com
站长QQ:1140549900


QQ|RSS|手机版|小黑屋|帮助|吾爱汇编 ( 京公网安备11011502005403号 , 京ICP备20003498号-6 )|网站地图

Powered by Discuz!

吾爱汇编 www.52hb.com

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