mirror of
https://github.com/carlospolop/PEASS-ng
synced 2024-11-20 12:39:21 +01:00
Add WiFi credential functionality
This commit is contained in:
parent
157e22ce0e
commit
822e149c72
@ -1649,21 +1649,25 @@ namespace winPEAS
|
||||
{
|
||||
try
|
||||
{
|
||||
Beaprint.MainPrint("Looking saved Wifis");
|
||||
Beaprint.MainPrint("Looking for saved Wifi credentials");
|
||||
if (exec_cmd)
|
||||
{
|
||||
Dictionary<string, string> colorsC = new Dictionary<string, string>()
|
||||
Dictionary<string, string> networkConnections = Wifi.Retrieve();
|
||||
Dictionary<string, string> ansi_colors_regexp = new Dictionary<string, string>();
|
||||
|
||||
//Make sure the passwords are all flagged as ansi_color_bad.
|
||||
foreach (var connection in networkConnections)
|
||||
{
|
||||
{ ": .*", Beaprint.ansi_color_bad },
|
||||
};
|
||||
Beaprint.AnsiPrint(" " + MyUtils.ExecCMD("wlan show profile", "netsh.exe"), colorsC);
|
||||
ansi_colors_regexp.Add(connection.Value, Beaprint.ansi_color_bad);
|
||||
}
|
||||
Beaprint.DictPrint(networkConnections, ansi_colors_regexp, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Beaprint.GrayPrint(" This function is not yet implemented.");
|
||||
Beaprint.InfoPrint("If you want to list saved Wifis connections you can list the using 'netsh wlan show profile'");
|
||||
Beaprint.InfoPrint("If you want to get the clear-text password use 'netsh wlan show profile <SSID> key=clear'");
|
||||
}
|
||||
Beaprint.InfoPrint("If you want to get the clear-text password use 'netsh wlan show profile <SSID> key=clear'");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -2434,7 +2438,6 @@ namespace winPEAS
|
||||
|
||||
|
||||
/*
|
||||
* Wifi (passwords?)
|
||||
* Keylogger?
|
||||
* Input prompt ==> Better in PS
|
||||
* Cretae list of malicious drives that could allow to privesc?
|
||||
|
55
winPEAS/winPEASexe/winPEAS/Wifi.cs
Normal file
55
winPEAS/winPEASexe/winPEAS/Wifi.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace winPEAS
|
||||
{
|
||||
class Wifi
|
||||
{
|
||||
public static Dictionary<string, string> Retrieve()
|
||||
{
|
||||
Dictionary<string, string> connections = new Dictionary<string, string>();
|
||||
foreach (string ssid in GetSSIDs())
|
||||
{
|
||||
string password = GetPassword(ssid);
|
||||
connections.Add(ssid, password);
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetSSIDs()
|
||||
{
|
||||
string args = "wlan show profiles";
|
||||
string result = MyUtils.ExecCMD(args, "netsh");
|
||||
Regex regex = new Regex(@"\s+:\s+([^\r\n]+)", RegexOptions.Multiline);
|
||||
MatchCollection matches = regex.Matches(result);
|
||||
List<string> ssids = new List<string>();
|
||||
|
||||
for (int i = 0; i < matches.Count; i++)
|
||||
{
|
||||
if (matches[i].Groups.Count > 0 && !string.IsNullOrWhiteSpace(matches[i].Groups[1].Value))
|
||||
{
|
||||
ssids.Add(matches[i].Groups[1].Value);
|
||||
}
|
||||
}
|
||||
|
||||
return ssids;
|
||||
}
|
||||
|
||||
private static string GetPassword(string ssid)
|
||||
{
|
||||
string args = $@" wlan show profile name=""{ssid}"" key=""clear""";
|
||||
string result = MyUtils.ExecCMD(args, "netsh");
|
||||
Regex regex = new Regex(@"Key Content\s+:\s+([^\r\n]+)", RegexOptions.Multiline);
|
||||
MatchCollection matches = regex.Matches(result);
|
||||
string password = string.Empty;
|
||||
|
||||
if (matches.Count > 0 && matches[0].Groups.Count > 1)
|
||||
{
|
||||
password = matches[0].Groups[1].Value;
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -155,6 +155,7 @@
|
||||
<Compile Include="TaskScheduler\XmlSerializationHelper.cs" />
|
||||
<Compile Include="UserInfo.cs" />
|
||||
<Compile Include="Watson.cs" />
|
||||
<Compile Include="Wifi.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
Loading…
Reference in New Issue
Block a user