Skip to content

Instantly share code, notes, and snippets.

@PintsizedSix40
Created October 11, 2019 19:09
Show Gist options
  • Save PintsizedSix40/beaa01d68369f9797c0723aac842fff8 to your computer and use it in GitHub Desktop.
Save PintsizedSix40/beaa01d68369f9797c0723aac842fff8 to your computer and use it in GitHub Desktop.
A small C# program to grab wifi passwords (as well as the names) and output it to the console.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WifiPassGrabber
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c netsh wlan show profile");
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"All User Profile : (.*)\n");
System.Collections.IEnumerator e = r.Matches(result).GetEnumerator();
while(e.MoveNext() != false)
{
Console.WriteLine("-----");
System.Collections.IEnumerator en = ((System.Text.RegularExpressions.Match)e.Current).Groups.GetEnumerator();
en.MoveNext();
en.MoveNext();
string name = en.Current.ToString();
Console.WriteLine(name);
Console.WriteLine(":::::");
//
System.Diagnostics.ProcessStartInfo procStartInfo2 =
new System.Diagnostics.ProcessStartInfo("cmd", "/c netsh wlan show profile \""+name+"\" key=clear");
procStartInfo2.RedirectStandardOutput = true;
procStartInfo2.UseShellExecute = false;
procStartInfo2.CreateNoWindow = true;
System.Diagnostics.Process proc2 = new System.Diagnostics.Process();
proc2.StartInfo = procStartInfo2;
proc2.Start();
string result2 = proc2.StandardOutput.ReadToEnd();
System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@" Key Content : (.*)\n");
System.Collections.IEnumerator en2 = (r2.Match(result2).Groups.GetEnumerator());
en2.MoveNext();
en2.MoveNext();
try
{
Console.WriteLine(en2.Current.ToString());
}catch(Exception exc)
{
Console.WriteLine("NETWORK");
Console.WriteLine("OPEN");
}
Console.WriteLine("-----");
Console.WriteLine("");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment