吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2197|回复: 17
收起左侧

[C&C++ 原创] 获取电脑已连接过的wifi密码(代码分享)

[复制链接]
YWQ8 发表于 2023-5-18 16:09
本帖最后由 YWQ8 于 2023-5-19 00:35 编辑

主要就是用了“netsh wlan show profiles”命令获取配置信息,然后“netsh wlan show profiles name="xxx" key=clear”查看,思路很简单。
[C++] 纯文本查看 复制代码
#include<bits/stdc++.h>
using namespace std;
string cmd(const string&line)
{
        FILE*f=_popen(line.c_str(),"r");          //popen开一个shell通道 
        string res;
        char b[500];
        while(fgets(b,sizeof b,f))
        {
                res+=b;
        }
        _pclose(f);
        return res;
} 
int main()
{
        string line="netsh wlan show profiles";                        //获取连接过的wifi的ssid 
        string a=cmd(line);
        int cnt=a.size();
        bool g=false;
        int con1=0,con2=0;
        vector<string>pu;
        for(int i=0;i<cnt;i++)
        {
                if(a[i]==':')
                {
                        if(!g)
                        {
                                g=true;
                                cout<<"\n\n\n";
                                continue;
                        }
                        int l=i+=2;
                        while(a[i]!=10)i++;
                        string t=a.substr(l,i-l);
                        string kt=cmd("netsh wlan show profiles name="+("\""+t+"\"")+" key=clear");
                        con1++;
                        //cout<<t<<endl;
                        //cout<<kt<<endl;
                        int cnt=kt.size(),r=0;
                        int d[]={-71,-40,-68,-4,-60,-38,-56,-35};                        //“关键内容”转成int 
                        bool h=false;
                        for(int j=0;j<cnt;j++)
                        {
                                if(kt[j]==d[r])                        //比对找到密码所在 
                                {
                                        r++;
                                        if(r==7)
                                        {
                                                while(kt[j]!=':')j++;
                                                int l=j+=2;
                                                while(kt[j]!=10)j++;
                                                cout<<"\t\t"<<t<<":"<<kt.substr(l,j-l)<<endl;
                                                con2++;
                                                h=true;
                                                break;
                                        }
                                }
                                else r=0;
                        }
                        if(!h)pu.push_back(t);        
                }         
        }
        printf("\n\t   共查询到%d条记录,已打印%d条。\n",con1,con2);
        printf("\n\t    以下wifi无密码:\n");
        for(auto i:pu)cout<<"\n\t\t\t"<<i<<endl;
        //cout<<a;
}

免费评分

参与人数 2吾爱币 +6 热心值 +2 收起 理由
turtledove + 1 + 1 实用
苏紫方璇 + 5 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

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

并非如此 发表于 2023-5-18 17:30
我很赞同,但是  第13行  return ret;  返回错了,应该是 返回 res 吧
TR小米哥 发表于 2023-5-22 17:43

学习了,举一反三上python也能跑,具体来说,执行以下两个 PowerShell命令:
netsh wlan show profiles:此命令列出了所有已连接过的 WiFi 的配置文件名称。
netsh wlan show profile name="{profile_name}" key=clear:此命令获取名为 profile_name 的 WiFi 配置文件的详细信息,包括密码。


[Python] 纯文本查看 复制代码
import subprocess

# Run the PowerShell command to get the list of all Wi-Fi profiles
command = 'netsh wlan show profiles'
profiles = subprocess.check_output(['powershell', '-Command', command]).decode('utf-8')

# Loop through all profiles and get the password for each one
for profile in profiles.split('\n'):
    if 'All User Profile' in profile:
        ssid = profile.split(':')[1].strip()
        command = f'netsh wlan show profile name="{ssid}" key=clear'
        profile_info = subprocess.check_output(['powershell', '-Command', command]).decode('utf-8')
        if 'Key Content' in profile_info:
            password = profile_info.split('Key Content')[1].split(':')[1].strip()
            print(f'SSID: {ssid}')
            print(f'Password: {password}\n')
8970665 发表于 2023-5-18 16:34
feiyuefei 发表于 2023-5-18 17:49
手机上本来也有这种软件,但是现在软件限制越来越多了。。。。
SuperF 发表于 2023-5-18 18:26
feiyuefei 发表于 2023-5-18 17:49
手机上本来也有这种软件,但是现在软件限制越来越多了。。。。

请问手机上有不需要root的这种软件吗?求PM一个。
adamfh 发表于 2023-5-18 18:31
的确可以,支持下,感谢分享。
trytostudy 发表于 2023-5-18 18:46
牛啊大佬
zaa025 发表于 2023-5-18 21:11
想问一下手机上曾经连接过的wifi详细的连接时间怎么查看?
lf8848 发表于 2023-5-19 16:18
手机上可以提取吗?
bandishui 发表于 2023-5-19 16:48
学习了, 试一下看看怎么样, 谢谢分享
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

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

GMT+8, 2024-5-5 21:43

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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