Skip to content

Commit

Permalink
Merge pull request #16 from 0x78654C/v1.1.7-share-vault-lock
Browse files Browse the repository at this point in the history
V1.1.7 share vault lock
  • Loading branch information
0x78654C authored Jul 22, 2024
2 parents ab1b666 + 327a185 commit bc07880
Show file tree
Hide file tree
Showing 41 changed files with 756 additions and 237 deletions.
13 changes: 13 additions & 0 deletions PwM.Tests/Encryption/Sha1Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace PwM.Tests.Encryption
{
public class Sha1Test
{
[Theory]
[InlineData("pawn", "1245E238CD5CD7E0D3E5CF5233265A6F2095E5B0")]
public void Ensure_we_can_(string inParam, string expected)
{
var hashSha1 = PwMLib.Sha1Converter.Hash(inParam);
Assert.Equal(expected, hashSha1);
}
}
}
19 changes: 19 additions & 0 deletions PwM.Tests/HIPB/HIBPTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using PwMLib;

namespace PwM.Tests.HIPB
{
public class HIBPTest
{
[Theory]
[InlineData("pawn")]
public void Check_API_HIBP(string password)
{
var hibp = new HIBP(GlobalVariables.apiHIBP);
var totalBreaches = hibp.CheckIfPwnd(password).Result;
bool isbreached = false;
if (totalBreaches != "0")
isbreached = true;
Assert.True(isbreached);
}
}
}
26 changes: 26 additions & 0 deletions PwM.Tests/Util/NetworkTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using PwMLib;

namespace PwM.Tests.Util
{
public class NetworkTest
{
[Theory]
[InlineData("https://google.com")]
public void Check_Web_Response(string address)
{
var network = new Network(address);
var isGooglUp = network.IsWebResponding();
Assert.True(isGooglUp);
}

[Theory]
[InlineData("google.com")]
[InlineData("api.pwnedpasswords.com")]
public void Check_Ping_Response(string address)
{
var network = new Network(address);
var isGooglUp = network.PingHost();
Assert.True(isGooglUp);
}
}
}
23 changes: 12 additions & 11 deletions PwM/Model/AddApplications.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:adorners="http://gu.se/Adorners"
mc:Ignorable="d"
Title="PwM - Password Manager" Name="AddApplicationWPF" Icon="pack://application:,,,/Resources/Logo.ico" AllowsTransparency="True" Height="214.998" Width="235" ResizeMode="NoResize" WindowStyle="None" MouseDown="Window_MouseDown" WindowStartupLocation="CenterScreen" >
Title="PwM - Password Manager" Name="AddApplicationWPF" Icon="pack://application:,,,/Resources/Logo.ico" AllowsTransparency="True" Height="276" Width="280" ResizeMode="NoResize" WindowStyle="None" MouseDown="Window_MouseDown" WindowStartupLocation="CenterScreen" >
<Border BorderBrush="#690fc2" BorderThickness="1">
<Grid Background="#f3f5f2" >
<Grid Background="#f3f5f2" Margin="0,0,0,3" >
<Grid VerticalAlignment="Top" Height="39" Background="#551cc7" >
<TextBlock Text="Add Applications" Name="titleTxt" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#f3f5f2" FontSize="18" Margin="30,6,22,4" Width="181" RenderTransformOrigin="0.5,0.5"/>
<materialDesign:PackIcon Name="vaultIcon" Foreground="#f3f5f2" PreviewMouseDown="closeLBL_PreviewMouseDown" Kind="Close" Margin="205,7,0,9" Width="28" Height="23" VerticalAlignment="Center"/>
<Label Content=" " ToolTip="Close" HorizontalAlignment="Left" Margin="207,8,0,0" VerticalAlignment="Top" Foreground="#0d0300" FontSize="14" FontWeight="Bold" Height="21" PreviewMouseDown="closeLBL_PreviewMouseDown" Width="22" />
<materialDesign:PackIcon Name="vaultIcon" Foreground="#f3f5f2" PreviewMouseDown="closeLBL_PreviewMouseDown" Kind="Close" Margin="248,0,0,0" Width="28" Height="23" VerticalAlignment="Center"/>
<Label Content=" " ToolTip="Close" HorizontalAlignment="Left" Margin="250,0,0,0" VerticalAlignment="Center" Foreground="#0d0300" FontSize="14" FontWeight="Bold" Height="21" PreviewMouseDown="closeLBL_PreviewMouseDown" Width="22" />
</Grid>
<TextBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="14" VerticalContentAlignment="Center" adorners:Watermark.Text="Application Name" TextAlignment="Center" x:Name="appNameTXT" HorizontalAlignment="Left" Height="30" Margin="28,57,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="176" TextChanged="appNameTXT_TextChanged">
<TextBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="16" VerticalContentAlignment="Center" adorners:Watermark.Text="Application Name" TextAlignment="Center" x:Name="appNameTXT" HorizontalAlignment="Center" Height="30" Margin="0,50,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="176" TextChanged="appNameTXT_TextChanged" TextBlock.FontSize="18">
<adorners:Watermark.TextStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Opacity" Value="0.5" />
Expand All @@ -24,7 +24,7 @@
</Style>
</adorners:Watermark.TextStyle>
</TextBox>
<TextBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="14" VerticalContentAlignment="Center" adorners:Watermark.Text="Account Name" TextAlignment="Center" x:Name="accountNameTXT" HorizontalAlignment="Left" Height="30" Margin="28,92,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="176" TextChanged="accountNameTXT_TextChanged">
<TextBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="16" VerticalContentAlignment="Center" adorners:Watermark.Text="Account Name" TextAlignment="Center" x:Name="accountNameTXT" HorizontalAlignment="Center" Height="30" Margin="0,94,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="176" TextChanged="accountNameTXT_TextChanged" TextBlock.FontSize="18">
<adorners:Watermark.TextStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Opacity" Value="0.5" />
Expand All @@ -33,7 +33,7 @@
</Style>
</adorners:Watermark.TextStyle>
</TextBox>
<TextBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="12" Visibility="Hidden" adorners:Watermark.Text ="Account Password" VerticalContentAlignment="Center" TextAlignment="Center" x:Name="PasswordShow" HorizontalAlignment="Left" Height="30" Margin="28,126,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="176" TextChanged="accountNameTXT_TextChanged">
<TextBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="18" Visibility="Hidden" adorners:Watermark.Text ="Account Password" VerticalContentAlignment="Center" TextAlignment="Center" x:Name="PasswordShow" HorizontalAlignment="Center" Height="30" Margin="0,139,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="176" TextChanged="accountNameTXT_TextChanged">
<adorners:Watermark.TextStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Opacity" Value="0.5" />
Expand All @@ -42,9 +42,9 @@
</Style>
</adorners:Watermark.TextStyle>
</TextBox>
<materialDesign:PackIcon Name="GeneratePassAcc" ToolTip="Generate Password" Foreground="Gray" Kind="LockAdd" Margin="4,131,0,0" Width="18" Height="23" VerticalAlignment="Top" RenderTransformOrigin="0.556,-0.722" PreviewMouseDown="GeneratePassAcc_PreviewMouseDown"/>
<materialDesign:PackIcon Name="ShowPassword" ToolTip="Show Password (Right Click)" Foreground="Gray" Kind="Eye" Margin="210,133,0,0" Width="18" Height="18" VerticalAlignment="Top" RenderTransformOrigin="0.556,-0.722" PreviewMouseRightButtonDown="ShowHidePassword" PreviewMouseRightButtonUp="ShowHidePassword" PreviewMouseMove="ShowPassword_PreviewMouseMove"/>
<PasswordBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="14" adorners:Watermark.Text ="Account Password" Name="accPasswordBox" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Height="30" Margin="28,126,0,0" VerticalAlignment="Top" Width="176" PasswordChanged="accPasswordBox_PasswordChanged" >
<materialDesign:PackIcon Name="GeneratePassAcc" ToolTip="Generate Password" Foreground="Gray" Kind="LockAdd" Margin="27,146,0,0" Width="18" Height="23" RenderTransformOrigin="0.556,-0.722" PreviewMouseDown="GeneratePassAcc_PreviewMouseDown"/>
<materialDesign:PackIcon Name="ShowPassword" ToolTip="Show Password (Right Click)" Foreground="Gray" Kind="Eye" Margin="233,151,0,0" Width="18" Height="18" RenderTransformOrigin="0.556,-0.722" PreviewMouseRightButtonDown="ShowHidePassword" PreviewMouseRightButtonUp="ShowHidePassword" PreviewMouseMove="ShowPassword_PreviewMouseMove"/>
<PasswordBox Background="#f3f5f2" BorderThickness="0,0,0,1" BorderBrush="#8D0FC3" Foreground="Black" FontSize="16" adorners:Watermark.Text ="Account Password" Name="accPasswordBox" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Height="30" Margin="0,139,0,0" VerticalAlignment="Top" Width="176" PasswordChanged="accPasswordBox_PasswordChanged" TextBlock.FontSize="18" >
<adorners:Watermark.TextStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Opacity" Value="0.5" />
Expand All @@ -53,7 +53,8 @@
</Style>
</adorners:Watermark.TextStyle>
</PasswordBox>
<Button Name="addAppBTN" Style="{DynamicResource RoundCorner2}" Content="Add" Margin="72,165,0,0" Width="94" Height="37" Foreground="#FFE1DDEE" Click="addAppBTN_Click" IsEnabled="False" HorizontalAlignment="Left" VerticalAlignment="Top" IsDefault="True"/>
<Button Name="addAppBTN" Style="{DynamicResource RoundCorner2}" Content="Add" Margin="0,224,0,0" Width="94" Height="37" Foreground="#FFE1DDEE" Click="addAppBTN_Click" IsEnabled="False" HorizontalAlignment="Center" VerticalAlignment="Top" IsDefault="True"/>
<TextBlock Name="breachLbl" Visibility="Hidden" Text="The password is part of an exposed data breach." HorizontalAlignment="Center" Margin="0,177,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.217,0.197" Height="40" Foreground="#FFD24E1C" TextWrapping="Wrap" Width="224" FontSize="14"/>
</Grid>
</Border>
</Window>
56 changes: 49 additions & 7 deletions PwM/Model/AddApplications.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
using Microsoft.Win32;
using PwMLib;
using System.ComponentModel;
using System.Runtime.Versioning;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace PwM
{
[SupportedOSPlatform("Windows")]
/// <summary>
/// Interaction logic for AddApplications.xaml
/// </summary>
public partial class AddApplications : Window
{
private BackgroundWorker _worker;
private string _breaches = "";
Network network = new Network(PwMLib.GlobalVariables.apiHIBPMain);
public AddApplications()
{
InitializeComponent();
Expand All @@ -28,7 +34,7 @@ private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventA
switch (e.Mode)
{
case PowerModes.Suspend:
Utils.GlobalVariables.closeAppConfirmation = true;
PwMLib.GlobalVariables.closeAppConfirmation = true;
this.Close();
break;
}
Expand All @@ -44,7 +50,7 @@ private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
if (e.Reason == SessionSwitchReason.SessionLock)
{
Utils.GlobalVariables.closeAppConfirmation = true;
PwMLib.GlobalVariables.closeAppConfirmation = true;
this.Close();
}
}
Expand All @@ -56,10 +62,10 @@ private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
/// <param name="e"></param>
private void addAppBTN_Click(object sender, RoutedEventArgs e)
{
Utils.GlobalVariables.applicationName = appNameTXT.Text;
Utils.GlobalVariables.accountName = accountNameTXT.Text;
Utils.GlobalVariables.accountPassword = accPasswordBox.Password;
Utils.GlobalVariables.closeAppConfirmation = false;
PwMLib.GlobalVariables.applicationName = appNameTXT.Text;
PwMLib.GlobalVariables.accountName = accountNameTXT.Text;
PwMLib.GlobalVariables.accountPassword = accPasswordBox.Password;
PwMLib.GlobalVariables.closeAppConfirmation = false;
Utils.TextPassBoxChanges.ClearTextPassBox(appNameTXT, accountNameTXT, accPasswordBox);
this.Close();
}
Expand All @@ -82,7 +88,7 @@ private void Window_MouseDown(object sender, MouseButtonEventArgs e)
/// <param name="e"></param>
private void closeLBL_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
Utils.GlobalVariables.closeAppConfirmation = true;
PwMLib.GlobalVariables.closeAppConfirmation = true;
this.Close();
}

Expand Down Expand Up @@ -137,6 +143,42 @@ private void accountNameTXT_TextChanged(object sender, TextChangedEventArgs e)
private void accPasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
Utils.TextPassBoxChanges.TextPassBoxChanged(appNameTXT, accountNameTXT, accPasswordBox, addAppBTN);
if (network.PingHost())
{
_worker = new BackgroundWorker();
_worker.DoWork += BreackCheck_BW;
_worker.RunWorkerCompleted += BreackCheck_RunWorkerCompleted;
_worker.RunWorkerAsync();
}
}

/// <summary>
/// Set visibility if password breaches are found.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BreackCheck_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (_breaches == "0")
breachLbl.Visibility = Visibility.Hidden;
else
breachLbl.Visibility = Visibility.Visible;
}

/// <summary>
/// Get password breaches.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BreackCheck_BW(object sender, DoWorkEventArgs e)
{
var hibp = new HIBP(PwMLib.GlobalVariables.apiHIBP);
if (!string.IsNullOrEmpty(accPasswordBox.Password))
{
_breaches = hibp.CheckIfPwnd(accPasswordBox.Password).Result;
}
else
_breaches = "0";
}

/// <summary>
Expand Down
Loading

0 comments on commit bc07880

Please sign in to comment.