Hello Reader!
Right now I’m sitting in a Cafe near my place, where I spend most of my weekends and was going through few of my old Powershell scripts, I saw the one which I’m sharing right now because it works well in public places, with lots of people 😀
So today we’re looking it a quick script to Identify Unsecure WiFi Connection nearby you.
Yes unsecure! that means without a password in an automated fashion 😉
HOW IT WORKS :
To make it work is a 4 step Process –
- Find all Nearby Wifi connections and their properties using Netsh command.
- Convert the results from step one to Powershell objects, and filter out Open WiFi’s (Without Password)
- Log results to a File with Timestamps
- Display a Balloon notification in system tray
HOW TO RUN :
There two ways to run the script –
- Run it On demand, whenever required by executing it in any Powershell host.
- Schedule the script execution in Task Scheduler to run it every 5 mins (Preferred approach
PURPOSE :
Purpose is NOT stealing your neighbor’s WiFi data 🙂 !! But, I wrote this script just for fun 😉 and to educate people to at-least keep a password on their WiFi.
Infact I just called out a name of Guy who was flaunting his open Wifi on his Iphone 😀 later got weird looks from him across the cafe.
SCRIPT :
Function Show-NotifyBalloon($Title, $Message) | |
{ | |
[system.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null | |
$Global:Balloon = New-Object System.Windows.Forms.NotifyIcon | |
$Balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -id $pid | Select-Object -ExpandProperty Path)) | |
$Balloon.BalloonTipIcon = 'Info' | |
$Balloon.BalloonTipText = $Message | |
$Balloon.BalloonTipTitle = $Title | |
$Balloon.Visible = $true | |
$Balloon.ShowBalloonTip(10000) | |
Start-Sleep -Seconds 20 | |
$Balloon.Visible =$false; $Balloon.Dispose() | |
} | |
Function Find-UnsecureWIFIConnection | |
{ | |
Param( | |
[Switch] $LogWithTimestamp | |
) | |
$data = (netsh wlan show networks mode=Bssid | ?{$_ -like "SSID*" -or $_ -like "*Authentication*" -or $_ -like "*Encryption*"}).trim() | |
$result = For($i = 0;$i -lt $data.count;) | |
{ | |
''|Select @{n='Connection';e={($data[$i].split(':')[1]).trim()}}, @{n='Authentication';e={($data[$i+1].split(':')[1]).trim()}}, @{n='Encryption';e={($data[$i+2].split(':')[1]).trim()}} | |
$i=$i+3 | |
} | |
If($LogWithTimestamp) | |
{ | |
$result | ?{$_.connection -ne '' -and $_.encryption -like "*none*"}|select *, @{n="TimeStamp";e={(Get-Date).ToString("HH:mm:ss dd-MMM-yyyy")}} | tee -Variable Result | |
} | |
else | |
{ | |
$result | ?{$_.connection -ne '' -and $_.encryption -like "*none*"}| Tee -Variable Result | |
} | |
$result | Export-Csv -Path "$env:TEMP\UnsecureWiFi_Logs.csv" -NoTypeInformation -Append | |
} | |
$UnsecureConnections = Find-UnsecureWIFIConnection -LogWithTimestamp | |
$Message = $UnsecureConnections.connection | %{$_+[System.Environment]::NewLine} | |
$Title = "$($UnsecureConnections.connection.count) Unsecure Connections Found nearby" | |
Show-NotifyBalloon $Title $Message |
Hoping you’ll find it fun!! 🙂 Happy weekends!
Prateek Singh
Follow @SinghPrateik
[…] on September 16, 2016 submitted by /u/Prateeksingh1590 [link] [comments] Leave a […]
LikeLike