![]() |
|
[Shell] HOW TO DISPLAY SELECTED WIFI AP'S MAC - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Shell] HOW TO DISPLAY SELECTED WIFI AP'S MAC (/showthread.php?tid=4574907) |
HOW TO DISPLAY SELECTED WIFI AP'S MAC - /{evin Mitnic/{ - Dec 8, 2014 i use this to detect if a selected wifi is broadcasting: @echo off for /F "tokens=3 delims=: " %%a in ('netsh wlan show networks mode^=bssid ^| findstr MyWiFi') do set APname=%%a for /F "tokens=3 delims=: " %%b in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do set mac=%%b echo APname echo mac pause i want to filter "MyWiFi" 's mac address only, now i'm using this but it fails because something is wrong and missing in this code: for /F "tokens=3 delims=: " %%b in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do set mac=%%b i want to display this output: MyWifi AP name 90511CD97HDE will remove ":" in 90:51:1c:D9:7H:DE hope you can help me guyz thank you very much :D * - 'Palladium - Dec 8, 2014 Please use code tags OP as your thread looks messy. * - annikk.exe - Dec 8, 2014 Your code: Code @echo offModify it to this: Code @echo offThe bit that removes the colons is this: Code %mac::=%This is string substitution. For example: Code set var=CatsCode CatsIn the above example, we substitue all instances of "C" in %var% with "M". In the original example, we're substiting ":" with "", in other words, we're removing any colons. * - /{evin Mitnic/{ - Dec 8, 2014 hi Annik.exe your my idol man thank you very much for your response.. i'm here in the Philippines i'm trying to automate the default password of any Zyxel PLDT Brand Router. the default password of WIFI AP here is always "PLDTWIFI+"last 5 characters of MAC address" example if the MAC address of that router is A1:B2:C3:D4:E5:F6 then you can connect to it with prefix "PLDTWIFI" + suffix "4E5F6" the default password will be "PLDTWIFI4E5F6" @echo off for /F "tokens=3 delims=: " %%a in ('netsh wlan show networks mode^=bssid ^| findstr PLDTMyDSL') do set AP=%%a echo %AP% for /F "delims=: tokens=5" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do set b1=%%a for /F "delims=: tokens=6" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do set b2=%%a for /F "delims=: tokens=7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do set b3=%%a echo The Password is: PLDTWIFI%b1%%b2%%b3% this is my code so far and its not complete but i think there's shorter code than this.. this is the last 6 digit of Router's mac address: %b1%%b2%%b3% i'm so noob. can i ask how can i remove the 1st letter from left of "D4E5F6" to become "4E5F6" ? 😑 * - annikk.exe - Dec 8, 2014 Ask your questions with confidence. We're all here to learn too. :> Code for /F "delims=: tokens=5" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do set b1=%%aThis code could be shortened to just this: Code for /F "delims=: tokens=5,6,7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do (set "b=%%a%%b%%c")Then %b% = D4E5F6 We want to get rid of the first character (the "D"). We can do this with string manipulation: Code set "b=%b:~1,5%"We're modifying %b% to become %b:~1,5% The first number (1) refers to the index number of each character. D = index 0 4 = index 1 E = index 2 5 = index 3 F = index 4 6 = index 5 The second number expresses how many characters to capture. In our case we put "5" so this means "starting from index 1, capture 5 characters". That gives us this: Code 4E5F6..which is what you want. :> Here are some more examples of string manipulation using this method: Code set "cat=Cats are best"Code Cats are bestCode set "cat=Cats are best"Code ats aCode set "cat=Cats are best"Code ts are beCode set "cat=Cats are best"Code CatCode set "cat=Cats are best"Code bestCode set "cat=Cats are best"Code re bestYou can also use negative numbers to select from the end of the string: Code set "cat=Cats are best"Code best...or to remove from the end of the string: Code set "cat=Cats are best"Code Cats are beHope this helps. :> * - /{evin Mitnic/{ - Dec 8, 2014 thank you man for your guides, you helped me alot.. :D * - annikk.exe - Dec 8, 2014 No problem friend, glad I could assist you. :> Please don't hesitate to ask further questions if there's anything else you're stuck on. :> * - /{evin Mitnic/{ - Dec 8, 2014 Thanks annik... the script im trying to make still have bugs when scanning the mac address of Zyxel AP is not filtered, sometimes it can get other mac address not the target AP: for /F "delims=: tokens=5,6,7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do (set "b=%%a%%b%%c") i'll try to fix later... for now i have this code and its partially working.. credits to your help XD @echo off for /F "tokens=3 delims=: " %%a in ('netsh wlan show networks mode^=bssid ^| findstr PLDTMyDSL') do set AP=%%a echo Trying to connect to %AP% for /F "delims=: tokens=5,6,7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do (set "b=%%a%%b%%c") echo %b% set "b=%b:~1,5%" echo The Password is: PLDTWIFI%b% set passkey=PLDTWIFI%b% echo ^<?xml version="1.0"?^> > PLDTMyDSL.xml echo ^<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"^> >> PLDTMyDSL.xml echo ^<name^>%AP%^</name^> >> PLDTMyDSL.xml echo ^<SSIDConfig^> >> PLDTMyDSL.xml echo ^<SSID^> >> PLDTMyDSL.xml echo ^<name^>%AP%^</name^> >> PLDTMyDSL.xml echo ^</SSID^> >> PLDTMyDSL.xml echo ^</SSIDConfig^> >> PLDTMyDSL.xml echo ^<connectionType^>ESS^</connectionType^> >> PLDTMyDSL.xml echo ^<connectionMode^>auto^</connectionMode^> >> PLDTMyDSL.xml echo ^<MSM^> >> PLDTMyDSL.xml echo ^<security^> >> PLDTMyDSL.xml echo ^<authEncryption^> >> PLDTMyDSL.xml echo ^<authentication^>WPA2PSK^</authentication^> >> PLDTMyDSL.xml echo ^<encryption^>AES^</encryption^> >> PLDTMyDSL.xml echo ^<useOneX^>false^</useOneX^> >> PLDTMyDSL.xml echo ^</authEncryption^> >> PLDTMyDSL.xml echo ^<sharedKey^> >> PLDTMyDSL.xml echo ^<keyType^>passPhrase^</keyType^> >> PLDTMyDSL.xml echo ^<protected^>false^</protected^> >> PLDTMyDSL.xml echo ^<keyMaterial^>%passkey%^</keyMaterial^> >> PLDTMyDSL.xml echo ^</sharedKey^> >> PLDTMyDSL.xml echo ^</security^> >> PLDTMyDSL.xml echo ^</MSM^> >> PLDTMyDSL.xml echo ^</WLANProfile^> >> PLDTMyDSL.xml ::automaticaly connect if wifi ap is broadcasting netsh wlan add profile filename="PLDTMyDSL.xml" setlocal enabledelayedexpansion enableextensions netsh wlan show interfaces|find /i /c "Infrastructure" >NUL && ( color a echo * Success.. Connected to the Wifi Network XD pause ) goto eoc: echo * Conneting Failed pause * - annikk.exe - Dec 8, 2014 Well, if there's only one particular wireless network that you're trying to sign into, purrhaps try adding an extra FINDSTR to only look at lines that contain the desired MAC Address. For example, you could change this: Code for /F "delims=: tokens=5,6,7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do (set "b=%%a%%b%%c")...to this: Code for /F "delims=: tokens=5,6,7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID ^| Findstr D4:E5:F6') do (set "b=%%a%%b%%c")That way, it won't pick up a different wireless network some of the time. It would be best to put the full MAC Address in there. I only know the last 3 octets from what you've told me. Does that help? :> * - /{evin Mitnic/{ - Dec 8, 2014 is there a way to scan the target AP's mac address? i'm not just trying to connect to one particular network i also want to add new scanned AP's profile. i'm trying to make a simple automated Laptop Anti-theft tool for my friend which scans Zyxel WiFi and connect to internet and send GPS data to email... i'll prefer on Zyxel because there are many available AP anywhere in our area..i prefer to connect to it because OPEN Networks are usually slow.. :) * - annikk.exe - Dec 8, 2014 (Dec 8, 2014 07:37 AM)/{evin Mitnic/{ Wrote: is there a way to scan the target AP's mac address? i'm not just trying to connect to one particular network i also want to add new scanned AP's profile. i'm trying to make a simple automated Laptop Anti-theft tool for my friend which scans Zyxel WiFi and connect to internet and send GPS data to email... i'll prefer on Zyxel because there are many available AP anywhere in our area..i prefer to connect to it because OPEN Networks are usually slow.. :) Yeah there is. :> But you would need to be connected to the wireless network first. You must first know the IP address of the AP. Lets suppose it's 192.168.1.254 1. Ping the AP: Code ping -n 1 192.168.1.2542. Now look at the following command: Code arp -a3. We can be more specific: Code arp -a | Findstr 192.168.1.254That returns the line of text with the AP's MAC Address listed on the right hand side. Then you can use the string manipulation techniques I showed you earlier to capture the MAC. * - /{evin Mitnic/{ - Dec 9, 2014 (Dec 8, 2014 08:05 AM)annikk.exe Wrote: Yeah there is. :> But you would need to be connected to the wireless network first. yup .. i've already seen that in your NetDisplay script but its hard to capture the Mac if not connected to AP.. because this code: for /F "delims=: tokens=5,6,7" %%a in ('netsh wlan show networks mode^=bssid ^| findstr BSSID') do (set "b=%%a%%b%%c") displays only the last SSID (index) of scanned AP's it conflicts the code above maybe i should use third party software? but it seems nothing available.. * - White Light - Dec 10, 2014 (Dec 9, 2014 11:09 PM)/{evin Mitnic/{ Wrote: yup .. i've already seen that in your NetDisplay script but its hard to capture the Mac if not connected to AP.. because this code: God damn, use the code tags! Code @echo offWill display every available network and the MAC address. * - /{evin Mitnic/{ - Dec 13, 2014 (Dec 10, 2014 12:49 AM)White Light Wrote: God damn, use the code tags! Code @echo off |