如何通过netsh查找所有wlan的密码

问题描述 投票:0回答:2

我想找出我所有 wlan 的名称及其密码:

ssid : password

通过搜索,我意识到可以使用 netsh 单独提取密码 但是我需要一个批处理脚本来获取每个wlan的名称,并提取并显示每个名称的密码 例如,我希望输出是这样的:

ModemN1 :  123987654af
IsntModem : PASSw0rd!23

如果你有除netsh之外的其他解决方案,请告诉我

可以找到所有的wlan配置文件:

C:> netsh wlan show profile

Profiles on interface Wi-Fi:

Group policy profiles (read only)
---------------------------------
    <None>

User profiles
-------------
    All User Profile     : ModemN1
    All User Profile     : IsntModem

这里应该提取两个 ModemN1, IsntModem 字符串 对于这些字符串中的每一个,将字符串放入此命令中:

netsh wlan show profile <WLAN_NAME> key=clear

C:> netsh wlan show profile IsntModem key=clear

Profile IsntModem on interface Wi-Fi:
=======================================================================

Applied: All User Profile

Profile information
-------------------
    Version                : 1
    Type                   : Wireless LAN
    Name                   : IsntModem
    Control options        :
        Connection mode    : Connect automatically
        Network broadcast  : Connect even if this network is not broadcasting
        AutoSwitch         : Do not switch to other networks
        MAC Randomization  : Disabled

Connectivity settings
---------------------
    Number of SSIDs        : 1
    SSID name              : "IsntModem"
    Network type           : Infrastructure
    Radio type             : [ Any Radio Type ]
    Vendor extension          : Not present

Security settings
-----------------
    Authentication         : WPA2-Personal
    Cipher                 : CCMP
    Authentication         : WPA2-Personal
    Cipher                 : GCMP
    Security key           : Present
    Key Content            : PASSw0rd!23

Cost settings
-------------
    Cost                   : Unrestricted
    Congested              : No
    Approaching Data Limit : No
    Over Data Limit        : No
    Roaming                : No
    Cost Source            : Default

并从这里提取密码

谢谢你帮助我❤

powershell batch-file cmd wifi netsh
2个回答
2
投票

我确定这之前已经被解析过,虽然找不到 副本,你可以试一试,似乎工作得很好:

netsh wlan show profile |
    Select-String '(?<=All User Profile\s+:\s).+' |
    ForEach-Object {
        $wlan = $_.Matches.Value
        $passw = netsh wlan show profile $wlan key=clear |
            Select-String '(?<=Key Content\s+:\s).+'

        [pscustomobject]@{
            Name     = $wlan
            Password = $passw.Matches.Value
        }
    }

对于正则表达式的描述:


0
投票

您可以运行一个相当简单的脚本,方法是打开记事本并将代码键入记事本并将文档另存为 Script.ps1(实际名称无关紧要,重要的是包含 .ps1)确保将保存从 .txt 更改为“所有文件”(否则脚本将不会运行)并将其保存到桌面。将其保存到桌面后,右键单击并“使用 PowerShell 打开”以运行所述脚本。更简单的方法是简单地搜索 PowerShell ISE。启动后,右上角有一个小箭头,上面写着脚本,单击它,然后粘贴我将在最后提供的代码。然后有一个绿色的小“播放”按钮(指向右侧的箭头)单击它以运行脚本。脚本运行后,关闭 PowerShell 并继续到您的桌面,将出现一个名为“Log”的新 .txt 文件。在此日志中,一侧是每个 SSID 的副本,它们旁边的密钥位于单独的一列中。 这是执行此操作所需的脚本:

(netsh wlan 显示配置文件)|选择字符串“:(.+)$” | %{$name=$.Matches.Groups[1].Value.Trim(); $} | %{(netsh wlan show profile name=”$name” key=clear)} |选择字符串“Key Content\W+:(.+)$” | %{$pass=$.Matches.Groups[1].Value.Trim(); $} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} |格式表-AutoSize |输出文件 $env:USERPROFILE\Desktop\Log.txt

© www.soinside.com 2019 - 2024. All rights reserved.