How to grab Wifi passwords with only 2 commands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BillyCarpenter
    Field Supervisor

    Site Contributor
    VIP Subscriber
    10,000+ Posts
    • Aug 2020
    • 14421

    How to grab Wifi passwords with only 2 commands

    I thought this was pretty cool.

    This first command can show us all the wifi profiles stored on a windows pc.

    netsh wlan show profile


    This second command can show us all the wifi passwords

    netsh wlan show profile name="name of wifi" key=clear


    Give it a try.
    Adversity temporarily visits a strong man but stays with the weak for a lifetime.
  • slimslob
    Retired

    Site Contributor
    25,000+ Posts
    • May 2013
    • 34944

    #2
    Re: How to grab Wifi passwords with only 2 commands

    I use a freeware WiFi password revealer from magic jelly bean. It allows one to export the results to a text of CSV file. As with all freeware use caution and have a good virus protection software.

    Comment

    • tsbservice
      Field tech

      Site Contributor
      5,000+ Posts
      • May 2007
      • 7571

      #3
      Re: How to grab Wifi passwords with only 2 commands

      Originally posted by BillyCarpenter
      I thought this was pretty cool.

      This first command can show us all the wifi profiles stored on a windows pc.

      netsh wlan show profile


      This second command can show us all the wifi passwords

      netsh wlan show profile name="name of wifi" key=clear


      Give it a try.
      Sometimes users don't have any clue what the wifi password is. It will help, Thanks Billy.
      A tree is known by its fruit, a man by his deeds. A good deed is never lost, he who sows courtesy, reaps friendship, and he who plants kindness gathers love.
      Blessed are they who can laugh at themselves, for they shall never cease to be amused.

      Comment

      • techsxge
        Senior Tech

        Site Contributor
        500+ Posts
        • Jan 2022
        • 661

        #4
        Re: How to grab Wifi passwords with only 2 commands

        I mean yeah its a fancy command but not realy practical as you can just click your way through to see the password.

        Anyways, want to do it without user input?
        Code:
        (netsh wlan show profile name="$(netsh wlan show interfaces | Select-String 'SSID' | ForEach-Object { $_ -replace '^\s+SSID\s+: ','' })" key=clear) | Select-String 'Key content'
        Might work, have no wlan to test it out rn. Should grab the currently connected Wlan connection and output the password though.
        Powershell command, wont work in cmd.

        Comment

        • dalewb74
          Service Manager

          Site Contributor
          1,000+ Posts
          • Feb 2018
          • 1057

          #5
          Re: How to grab Wifi passwords with only 2 commands

          yeah that works well, have used it before. only works though if the person has connected once to the network. then they forgot the password. and for whatever reason was disconnected. run both of those commands and you have the info you need. you can blow someone's mind with that trick. lol

          Comment

          • techsxge
            Senior Tech

            Site Contributor
            500+ Posts
            • Jan 2022
            • 661

            #6
            Re: How to grab Wifi passwords with only 2 commands

            I made a script that will let you extract the passwords from any recently connected wifi to just simplify this.

            Script:
            Collection of batch and powershell scripts for free use. Credits to a book i got gifted from a book shop 3 years ago that got me interested in batch scripts - vlc3n/FuckUrBatch


            Compiled to exe:
            Release wifiPassword.ps1 compiled to .exe * vlc3n/FuckUrBatch * GitHub

            Its open source, so you dont have to worry about any bloatware being installed or the script doing shady things.
            Last edited by techsxge; 10-06-2023, 01:04 PM.

            Comment

            • Tricky
              Field Supervisor

              Site Contributor
              2,500+ Posts
              • Apr 2009
              • 2621

              #7
              Re: How to grab Wifi passwords with only 2 commands

              Originally posted by techsxge
              I made a script that will let you extract the passwords from any recently connected wifi to just simplify this.

              Script:
              https://github.com/vlc3n/FuckUrBatch...fipassword.ps1


              Compiled to exe:
              Release wifiPassword.ps1 compiled to .exe * vlc3n/FuckUrBatch * GitHub
              Can I add #!/bin/sh to the beginning of that script for Linux?
              Copytechnet search tool v0.8 Final

              Comment

              • rthonpm
                Field Supervisor

                2,500+ Posts
                • Aug 2007
                • 2835

                #8
                Re: How to grab Wifi passwords with only 2 commands

                Originally posted by skynet
                Can I add #!/bin/sh to the beginning of that script for Linux?
                No.

                Sent from my Pixel 6 Pro using Tapatalk

                Comment

                • techsxge
                  Senior Tech

                  Site Contributor
                  500+ Posts
                  • Jan 2022
                  • 661

                  #9
                  Re: How to grab Wifi passwords with only 2 commands

                  Originally posted by skynet
                  Can I add #!/bin/sh to the beginning of that script for Linux?
                  not too sure if powershell is 1:1 supported by linux.

                  In any case bin/sh would be for shell scripts, not powershell scripts.
                  You would need to add:

                  #!/usr/bin/pwsh -Command
                  Last edited by techsxge; 10-06-2023, 01:03 PM. Reason: replaced powershell with pwsh

                  Comment

                  • techsxge
                    Senior Tech

                    Site Contributor
                    500+ Posts
                    • Jan 2022
                    • 661

                    #10
                    Re: How to grab Wifi passwords with only 2 commands

                    On linux it would be smarter to just do it with a python script. I quickly translated this code so forgive any mistakes:

                    Code:
                    import subprocess
                    
                    
                    wifi_profiles_info = subprocess.check_output(['nmcli', '-t', '-f', 'SSID', 'connection', 'show', '--active']).decode('utf-8')
                    wifi_profiles = [line.strip() for line in wifi_profiles_info.split('\n')]
                    
                    
                    print("Available Wi-Fi networks:")
                    for index, profile in enumerate(wifi_profiles):
                        print(f"{index + 1}. {profile}")
                    
                    
                    selection = input("Select a Wi-Fi network (enter the number): ")
                    try:
                        selected_profile = wifi_profiles[int(selection) - 1]
                    except (ValueError, IndexError):
                        selected_profile = None
                    
                    
                    if selected_profile:
                        wifi_password_info = subprocess.check_output(['nmcli', '-s', '-g', '802-11-wireless-security.psk', 'connection', 'show', selected_profile]).decode('utf-8')
                        wifi_password = wifi_password_info.strip()
                    
                    
                        print(f"Wi-Fi network: {selected_profile}")
                        print(f"Password: {wifi_password}")
                    else:
                        print("No Wi-Fi network selected.")
                    Last edited by techsxge; 10-06-2023, 01:13 PM. Reason: Updated script as netsh does not exists on linux

                    Comment

                    • rthonpm
                      Field Supervisor

                      2,500+ Posts
                      • Aug 2007
                      • 2835

                      #11
                      Re: How to grab Wifi passwords with only 2 commands

                      Originally posted by techsxge
                      not too sure if powershell is 1:1 supported by linux.

                      In any case bin/sh would be for shell scripts, not powershell scripts.
                      You would need to add:

                      #!/usr/bin/pwsh -Command
                      It's more than just changing the string. You're using native Windows commands like netsh which aren't understood by Linux. It would be like trying to get a script calling chkdsk to work in RHEL: it's not going to know what you're trying to do.

                      Sent from my Pixel 6 Pro using Tapatalk

                      Comment

                      • techsxge
                        Senior Tech

                        Site Contributor
                        500+ Posts
                        • Jan 2022
                        • 661

                        #12
                        Re: How to grab Wifi passwords with only 2 commands

                        Originally posted by techsxge
                        On linux it would be smarter to just do it with a python script. I quickly translated this code so forgive any mistakes:

                        Code:
                        import subprocess
                        
                        
                        wifi_profiles_info = subprocess.check_output(['nmcli', '-t', '-f', 'SSID', 'connection', 'show', '--active']).decode('utf-8')
                        wifi_profiles = [line.strip() for line in wifi_profiles_info.split('\n')]
                        
                        
                        print("Available Wi-Fi networks:")
                        for index, profile in enumerate(wifi_profiles):
                            print(f"{index + 1}. {profile}")
                        
                        
                        selection = input("Select a Wi-Fi network (enter the number): ")
                        try:
                            selected_profile = wifi_profiles[int(selection) - 1]
                        except (ValueError, IndexError):
                            selected_profile = None
                        
                        
                        if selected_profile:
                            wifi_password_info = subprocess.check_output(['nmcli', '-s', '-g', '802-11-wireless-security.psk', 'connection', 'show', selected_profile]).decode('utf-8')
                            wifi_password = wifi_password_info.strip()
                        
                        
                            print(f"Wi-Fi network: {selected_profile}")
                            print(f"Password: {wifi_password}")
                        else:
                            print("No Wi-Fi network selected.")
                        Updated this code as netsh is not available on linux, my bad

                        Comment

                        • techsxge
                          Senior Tech

                          Site Contributor
                          500+ Posts
                          • Jan 2022
                          • 661

                          #13
                          Re: How to grab Wifi passwords with only 2 commands

                          Originally posted by rthonpm
                          It's more than just changing the string. You're using native Windows commands like netsh which aren't understood by Linux. It would be like trying to get a script calling chkdsk to work in RHEL: it's not going to know what you're trying to do.

                          Sent from my Pixel 6 Pro using Tapatalk
                          yep, i updated my script to not use netsh. Saw this myself after uploading it... Now it uses nmcli

                          Comment

                          • rthonpm
                            Field Supervisor

                            2,500+ Posts
                            • Aug 2007
                            • 2835

                            #14
                            Re: How to grab Wifi passwords with only 2 commands

                            So glad the Linux world made nmcli all but a standard. It's a pain having to remember what tools work on what distribution.

                            Sent from my Pixel 6 Pro using Tapatalk

                            Comment

                            • techsxge
                              Senior Tech

                              Site Contributor
                              500+ Posts
                              • Jan 2022
                              • 661

                              #15
                              Re: How to grab Wifi passwords with only 2 commands

                              Originally posted by rthonpm
                              So glad the Linux world made nmcli all but a standard. It's a pain having to remember what tools work on what distribution.

                              Sent from my Pixel 6 Pro using Tapatalk
                              standardisation is like the biggest thing holding people back on using linux i feel like.
                              nmcli should be supported by most ubuntu and redhat versions. Debian i am not too sure about

                              Comment

                              Working...