Computer Hope

Microsoft => Microsoft DOS => Topic started by: zask on December 10, 2015, 01:59:02 PM

Title: Batch wifi password recover
Post by: zask on December 10, 2015, 01:59:02 PM
i took this command to grab a profile and place its name in a variable

for /f "tokens=4 delims=: " %%A in ('netsh wlan show profiles') do set "profile=%%A"
now i added this to the next line;

netsh wlan show profiles "%profile%" key=clear
then something that says "key content" (must be administrator) should appear with a wifi password next to it, how do i get that password to also go into a variable? i tried doing something like this but it just displays the word "such" for some strange reason...

for /f "tokens=4 delims=: " %%A in ('netsh wlan show profiles') do set "profile=%%A
for /f "tokens=4 delims=: " %%A in ('netsh wlan show profiles "%profile%" key=clear') do set "profile2=%%A"

echo %profile2%
thanks... :)
Title: Re: Batch wifi password recover
Post by: Geek-9pm on December 10, 2015, 03:58:29 PM
zask, please read over the forum rules.

The forum will not help with batch files that find passwords of other people on a local network.

Also, if you are indeed the administrator of a domain server, you already have tools to implement a policy that would let you have the passwords.

NOTE: to moderator. This topic should be closed.

Title: Re: Batch wifi password recover
Post by: zask on December 10, 2015, 04:18:13 PM
I know this, look everyone keeps saying that blah blah blah rules and such but i actually need this code for my own personal use, the question doesn't even imply anything to do with stealing a password, it's obvious that i already know you can steal a password just by saying "netsh wlan show profiles <profile> key=clear. im not asking how to steal a password, im asking how do i place the that password in a text file. 
Title: Re: Batch wifi password recover
Post by: zask on December 10, 2015, 04:30:22 PM
okay lets say with was with any random command that when typed in it displayed content in a prompt, how do i put that content in a text file. does that sound less malicious? the question im asking can imply with any command, not just stealing some password, even if it did grab a password, in order for the profile that has that password to even appear you would have to type its password in anyway the first place, eliminating the possibilities for someone to hack. trust me if you just used the command you would understand that its not intended to steal random peoples passwords
Title: Re: Batch wifi password recover
Post by: foxidrive on December 10, 2015, 04:33:17 PM
I agree that's it's merely an issue of parsing the text in a for /f command.

The problem will be in the delims= and tokens= items.

To give you accurate commands I'd need to see the form that the screen output takes.
Not any passwords but the spaces and number of words and special characters etc.

I get this here as i don't have wireless so I can't test it - and the OS version can change the output.

c:\>netsh wlan show profiles
The Wireless AutoConfig Service (wlansvc) is not running.
Title: Re: Batch wifi password recover
Post by: zask on December 10, 2015, 05:00:48 PM
okay i will try to explain,  when i type "netsh wlan show profiles" i get an output stating this~

Profiles on interface Wi-Fi:

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

User profiles
-------------
    All User Profile     : Zask.router

I created a command that took the current context (which is "Zask.router"; only works in administrator mode) and puts it in a variable named %profile%. that command looks like this~

for /f "tokens=4 delims=: " %%A in ('netsh wlan show profiles') do set "profile=%%A

when you type this command you get a output thats similar to this~

Profile Zask.router on interface Wi-Fi:
=======================================================================

Applied: All User Profile   

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

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

Security settings
-----------------
    Authentication         : WPA2-Personal
    Cipher                 : CCMP
    Security key           : Present
    Key Content            : Pokemonblack

CONTENT      ^      PASSWORD ^^^^^^^^^^^^
(LOOK HERE!) |_______________||||||||||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX

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


Profile Zask.router on interface Wi-Fi:
=======================================================================

Applied: All User Profile   

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

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

Security settings
-----------------
    Authentication         : WPA2-Personal
    Cipher                 : CCMP
    Security key           : Present

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

Notice the context named Key Content? see where it shows the password in the prompt beside it? how do i grab that password and put it in a variable like when i grabbed the current Profile and put it in a variable from the last command? thank you. :P and no this isn't my real password or router profile~ lol that would be dumb



Title: Re: Batch wifi password recover
Post by: zask on December 10, 2015, 05:02:53 PM
is this what your asking for?
Title: Re: Batch wifi password recover
Post by: zask on December 10, 2015, 05:06:13 PM
I agree that's it's merely an issue of parsing the text in a for /f command.

The problem will be in the delims= and tokens= items.

To give you accurate commands I'd need to see the form that the screen output takes.
Not any passwords but the spaces and number of words and special characters etc.

I get this here as i don't have wireless so I can't test it - and the OS version can change the output.

c:\>netsh wlan show profiles

The Wireless AutoConfig Service (wlansvc) is not running.

can you be more specific of what your looking for?  do you mean the output of the command i typed in, because that's stated in the comment above.
Title: Re: Batch wifi password recover
Post by: foxidrive on December 12, 2015, 03:45:33 AM
Apologies, I didn't return until now. Thanks for the sample data,
and based on that then this should work, give it a test.

If there are TAB characters in the output then TAB will need to be added to the "delims=: " section in the 3rd line.

The equals sign needs an escape character as it is treated as whitespace in an unquoted command line, and your attempt may have been showing a word from the error message rather than from the command output.

This can be unreliable as the text you are searching for can contain % characters, which is a poison character for batch scripts.

Code: [Select]
@echo off
for /f "tokens=4 delims=: " %%A in ('netsh wlan show profiles') do (
   for /f "tokens=2,* delims=: " %%B in ('netsh wlan show profiles "%%A" key^=clear ^| find /i "Key Content" ') do set "pw=%%C"
)
echo "%pw%"
pause
Title: Re: Batch wifi password recover
Post by: foxidrive on December 12, 2015, 04:05:34 AM
please read over the forum rules.

Apologies Geek,

Looking at the forum rules, it says "No help with stealing or otherwise obtaining another user's password."

It's not up to me to interpret the aim of this thread, or how it can be misused by future readers, so I'll leave it to the mods to do as they feel is right.
Title: Re: Batch wifi password recover
Post by: BC_Programmer on December 12, 2015, 05:19:09 AM
The commands the OP is requesting assistance with do none of the things Geek erroneously described it as doing. The common request for help with a script deleting files and folders is probably worthy of more consideration when it comes to wondering how something may be misused. it provides no user passwords whatsoever.

The commands listed do not feature a security risk because they do not give the user any more information than they could easily get with the Windows UI.

Basically, what it does is let you see saved profile information. For example, when you connect to a wireless network, you can select to have Windows Remember the wifi passphrase. This is stored locally, and it is this saved passphrase that is made available via this command- if the passphrase is not saved, it cannot be retrieved in this manner even if the system is actively connected to the access point. This functionality can also be accessed via the Network and Sharing Center (click the Access point, choose Wireless properties, and check off the "Show passphrase" checkbox).
Title: Re: Batch wifi password recover
Post by: zask on December 12, 2015, 04:15:53 PM
The commands the OP is requesting assistance with do none of the things Geek erroneously described it as doing. The common request for help with a script deleting files and folders is probably worthy of more consideration when it comes to wondering how something may be misused. it provides no user passwords whatsoever.

The commands listed do not feature a security risk because they do not give the user any more information than they could easily get with the Windows UI.

Basically, what it does is let you see saved profile information. For example, when you connect to a wireless network, you can select to have Windows Remember the wifi passphrase. This is stored locally, and it is this saved passphrase that is made available via this command- if the passphrase is not saved, it cannot be retrieved in this manner even if the system is actively connected to the access point. This functionality can also be accessed via the Network and Sharing Center (click the Access point, choose Wireless properties, and check off the "Show passphrase" checkbox).

Thank you for the support :P
Title: Re: Batch wifi password recover
Post by: zask on December 12, 2015, 04:19:30 PM
Apologies, I didn't return until now. Thanks for the sample data,
and based on that then this should work, give it a test.

If there are TAB characters in the output then TAB will need to be added to the "delims=: " section in the 3rd line.

The equals sign needs an escape character as it is treated as whitespace in an unquoted command line, and your attempt may have been showing a word from the error message rather than from the command output.

This can be unreliable as the text you are searching for can contain % characters, which is a poison character for batch scripts.

Code: [Select]
@echo off
for /f "tokens=4 delims=: " %%A in ('netsh wlan show profiles') do (
   for /f "tokens=2,* delims=: " %%B in ('netsh wlan show profiles "%%A" key^=clear ^| find /i "Key Content" ') do set "pw=%%C"
)
echo "%pw%"
pause
d

do I Add TAB before the delims? Thank you.
Title: Re: Batch wifi password recover
Post by: zask on December 12, 2015, 04:28:03 PM

Never mind i figured it out. :)
Title: Re: Batch wifi password recover
Post by: patio on December 12, 2015, 05:14:17 PM
Perfect...
Title: Re: Batch wifi password recover
Post by: foxidrive on December 13, 2015, 04:50:46 AM
Never mind i figured it out. :)

Did it function by only adding the tab to the delims section?
Title: Re: Batch wifi password recover
Post by: zask on December 13, 2015, 08:45:45 AM
Yeah thanks!
Title: Re: Batch wifi password recover
Post by: foxidrive on December 13, 2015, 09:05:45 AM
Cool. :)
Title: Re: Batch wifi password recover
Post by: zask on December 14, 2015, 07:10:07 PM
Yeah i know right! :P
Title: Re: Batch wifi password recover
Post by: zask on December 14, 2015, 07:12:23 PM
Cool. :)

Wanna be my programming budy, im 17 but im really good
Title: Re: Batch wifi password recover
Post by: patio on December 14, 2015, 07:20:36 PM
Everyone thinks that at 17.... :P
Title: Re: Batch wifi password recover
Post by: foxidrive on December 15, 2015, 06:52:25 AM
Wanna be my programming buddy

I added a 'd' there coz there was a syntax error.

Does a programming buddy get first dibs on copyright, and patents?  That might work for me. ;)
I'm not sure what you need help with in coding, but the forum is here for help
 
Title: Re: Batch wifi password recover
Post by: zask on December 30, 2015, 12:05:09 AM
I added a 'd' there coz there was a syntax error.

Does a programming buddy get first dibs on copyright, and patents?  That might work for me. ;)
I'm not sure what you need help with in coding, but the forum is here for help

well i dont care bout copyright as long as i get credit but i like to program virus generators, ikr lol
im not gonna get banned or anything for posting my code so if you wanna see what ive been really working on then you could email me. I eventually want to learn enough about viruses to start creating antivirus :) I've learned a lot so far...
Title: Re: Batch wifi password recover
Post by: foxidrive on December 30, 2015, 02:35:53 AM
but i like to program virus generators
I eventually want to learn enough about viruses to start creating antivirus :)

Back a fair way in the past, AV programs were command line tools only - and I wrote a script to scan cdroms for malware (shareware cdroms were popular back to get shareware, before the Internet was in common use).

My script unzipped all the programs on the shareware cdrom, in many archive formats, and scanned it all for malware.  A report was generated with the results, and was all automated.  It was good fun.

Back then the only AV tool I know about was McAfee Scan - and BBS (Bulletin Board Systems) with a dialup modem was the way to get any AV updates.

I eventually want to learn enough about viruses to start creating antivirus :)

I learned a lot about them back then - and it began when my machine at work was infected with a boot sector virus called Pong, which was shared around on 5 1/4 inch Floppy disks.

Pong was a benign virus, but viruses grew more malicious as time passed.
I hope you succeed in your plans to learn and develop AV software - it's a much more complex field these days.

Title: Re: Batch wifi password recover
Post by: camerongray on December 30, 2015, 04:52:34 AM
Wanna be my programming budy, im 17 but im really good
Rather than having a "programming buddy" and sharing code over email I'd suggest setting up a Github account and putting any code you want to be open source on there, people than then contribute as they see fit and it makes life a lot easier than managing code changes through a forum which really isn't a great way to share code.  Sure it takes time to learn how it all works but it s a very important skill to have and gives your code decent exposure.  This can be particularly good for applying for programming related jobs as your Github account acts as a portfolio of all the work you've done.  For example, my Github account is at https://github.com/camerongray1515 (https://github.com/camerongray1515) - Most of my larger stuff is private for now as I need to clean things up in order to make them public but you get the idea.

well i dont care bout copyright as long as i get credit
I'd look into proper open source licences, they really aren't as scary as they first look - You essentially include a licence file in your project and fill out the copyright years and names.etc - This means that your work is formally licenced and restricted to what people can do with it.  You'd probably want to look at the MIT licence which is essentially "do what you want as long as you leave my name in the licence file" and GPL which is similar but states that if you change the source code, you must also share the changes that you made.

i like to program virus generators [SNIP] I eventually want to learn enough about viruses to start creating antivirus :)
Not trying to discourage you but just be very careful with this - It's all too easy to make something to see how it works and accidentally get into a massive legal mess by accidentally running the virus somewhere it shouldn't have been run.  I mentor at a programming club for under 19s and quite often there are people making harmless prank type things (randomly playing noises in the background or opening the CD tray type stuff), this is all well and good until they come up with the next idea "how do we make it so it replicates to other devices on the network?" - Now you have a pretty dangerous virus! :P  You don't necessarily need to write a tonne of viruses to be able to make antivirus as viruses are so varied it would be impractical to make enough to cover all the different ways they work, instead you would need to analyse common viruses to see what they do and how you can recognise them.  It could be quite fun to see what sort of detection rate you can get but obviously don't expect to be able to rival the large antivirus providers with their teams of security researchers, there's a reason that many smaller antivirus programs use virus scanning engines from other companies!

There are also lots of other interesting areas to get into other than antivirus.  Web applications are a huge, growing area (everything is moving onto the web/cloud nowadays) and they are quite easy to get started on and easy to put launch to the public - This could be an area to apply your skills to.
Title: Re: Batch wifi password recover
Post by: zask on December 30, 2015, 11:59:31 PM
Rather than having a "programming buddy" and sharing code over email I'd suggest setting up a Github account and putting any code you want to be open source on there, people than then contribute as they see fit and it makes life a lot easier than managing code changes through a forum which really isn't a great way to share code.  Sure it takes time to learn how it all works but it s a very important skill to have and gives your code decent exposure.  This can be particularly good for applying for programming related jobs as your Github account acts as a portfolio of all the work you've done.  For example, my Github account is at https://github.com/camerongray1515 (https://github.com/camerongray1515) - Most of my larger stuff is private for now as I need to clean things up in order to make them public but you get the idea.
I'd look into proper open source licences, they really aren't as scary as they first look - You essentially include a licence file in your project and fill out the copyright years and names.etc - This means that your work is formally licenced and restricted to what people can do with it.  You'd probably want to look at the MIT licence which is essentially "do what you want as long as you leave my name in the licence file" and GPL which is similar but states that if you change the source code, you must also share the changes that you made.
Not trying to discourage you but just be very careful with this - It's all too easy to make something to see how it works and accidentally get into a massive legal mess by accidentally running the virus somewhere it shouldn't have been run.  I mentor at a programming club for under 19s and quite often there are people making harmless prank type things (randomly playing noises in the background or opening the CD tray type stuff), this is all well and good until they come up with the next idea "how do we make it so it replicates to other devices on the network?" - Now you have a pretty dangerous virus! :P  You don't necessarily need to write a tonne of viruses to be able to make antivirus as viruses are so varied it would be impractical to make enough to cover all the different ways they work, instead you would need to analyse common viruses to see what they do and how you can recognise them.  It could be quite fun to see what sort of detection rate you can get but obviously don't expect to be able to rival the large antivirus providers with their teams of security researchers, there's a reason that many smaller antivirus programs use virus scanning engines from other companies!

There are also lots of other interesting areas to get into other than antivirus.  Web applications are a huge, growing area (everything is moving onto the web/cloud nowadays) and they are quite easy to get started on and easy to put launch to the public - This could be an area to apply your skills to.

Thank you for the information about github.com, and don't worry about the whole accidentally getting in a legal mess. I have a professional programming teacher at my school that teaches me about regular programming, and after school he teaches me how to program viruses and disable, for example, if i wanted someone's computer to pop out it's cd try i could make a simple vbscript to do that, but then all i would have to do is end it's task in taskmgr. but if i wanted to add it to for example  "%ALLUSERSPROFILE%\Start Menu\Programs\Startup" then i would simply remove it from that folder, or if it infects drives, system files, or data i could just run it on a virtual machine lol. my teacher is a old school virus writer, he told me the only way to truly understand how viruses work, (by the means of where they deploy, how they remain anonymous while they transfer throughout flash drives or worse networks) you have to know how they are designed, and now of coarse it is possible to learn how to create antivirus without actually having to create a virus. But if you truly want to create good antivirus software you have to understand multiple types of viruses, stay updated on vulnerabilities, zero days, and such. which can be a pain to some but i actually enjoy the art of creating viruses (As long as it done legally in a safe and secured environment). I treat it as if it is my hobbie, i believe all forms of code are beautiful in there own unique way. and my craving for knowledge in all subjects of programming holds a strong importance in my life.
Title: Re: Batch wifi password recover
Post by: BC_Programmer on December 31, 2015, 02:11:29 PM
Oh boy...  ::)
Title: Re: Batch wifi password recover
Post by: Geek-9pm on December 31, 2015, 04:18:17 PM
Next he will tell us how his teacher also did time in jail for fraud  ::)
Title: Re: Batch wifi password recover
Post by: zask on January 02, 2016, 08:25:15 PM
Next he will tell us how his teacher also did time in jail for fraud  ::)

good one  :-\