Skip to content

Commit

Permalink
New option for dealing with empty passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaifm committed Jan 4, 2025
1 parent d3e19a9 commit 4064e65
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 31 deletions.
4 changes: 3 additions & 1 deletion HIBPOfflineCheck/HIBPOfflineCheckExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ public Options LoadOptions()
WarningDialog = config.GetBool(Options.Names.WARNING_DIALOG, false),
AutoCheck = config.GetBool(Options.Names.AUTO_CHECK, true),
WarningDialogText = XmlUnescape(config.GetString(Options.Names.WARNING_DIALOG_TEXT) ?? "WARNING - INSECURE PASSWORD\r\n\r\nThis password is insecure and publicly known"),
BloomFilter = config.GetString(Options.Names.BLOOM_FILTER) ?? ""
BloomFilter = config.GetString(Options.Names.BLOOM_FILTER) ?? "",
MarkEmptyPasswords = (Options.EmptyPwdDefault) config.GetLong(Options.Names.MARK_EMPTY_PASSWORDS, (long) Options.EmptyPwdDefault.Secure)
};

this.options = options;
Expand All @@ -212,6 +213,7 @@ public void SaveOptions(Options options)
config.SetBool(Options.Names.AUTO_CHECK, options.AutoCheck);
config.SetString(Options.Names.WARNING_DIALOG_TEXT, XmlEscape(options.WarningDialogText));
config.SetString(Options.Names.BLOOM_FILTER, options.BloomFilter);
config.SetLong(Options.Names.MARK_EMPTY_PASSWORDS, (long) options.MarkEmptyPasswords);

this.options = options;
prov.PluginOptions = options;
Expand Down
79 changes: 53 additions & 26 deletions HIBPOfflineCheck/HIBPOfflineCheckOptions.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions HIBPOfflineCheck/HIBPOfflineCheckOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private bool CommitOptions()
options.WarningDialog = checkBoxWarningDialog.Checked;
options.AutoCheck = checkBoxAutoCheck.Checked;
options.WarningDialogText = textBoxWarningDialog.Text;
options.MarkEmptyPasswords = (Options.EmptyPwdDefault) comboBoxEmptyPw.SelectedIndex;

bool bloomFilterChanged = (options.BloomFilter != textBoxBloomFilter.Text);
options.BloomFilter = textBoxBloomFilter.Text;
Expand Down Expand Up @@ -89,6 +90,7 @@ private void HIBPOfflineCheckOptions_Load(object sender, EventArgs e)
textBoxBloomFilter.Enabled = radioButtonBloom.Checked;
buttonCreateBloom.Enabled = radioButtonBloom.Checked;
buttonBrowseBloom.Enabled = radioButtonBloom.Checked;
comboBoxEmptyPw.SelectedIndex = (int) options.MarkEmptyPasswords;

textBoxFileName.Select();
textBoxFileName.Select(0, 0);
Expand Down
20 changes: 19 additions & 1 deletion HIBPOfflineCheck/HIBPOfflineColumnProv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ private void GetPasswordStatus()
return;
}

if (IsEmptyPassword())
{
if (PluginOptions.MarkEmptyPasswords == Options.EmptyPwdDefault.Secure)
Status = PluginOptions.SecureText;
else if (PluginOptions.MarkEmptyPasswords == Options.EmptyPwdDefault.Pwned)
Status = PluginOptions.InsecureText;
else if (PluginOptions.MarkEmptyPasswords == Options.EmptyPwdDefault.Excluded)
Status = PluginOptions.ExcludedText;

receivedStatus = true;
return;
}

if (PluginOptions.CheckMode == Options.CheckModeType.Offline)
{
GetOfflineStatus();
Expand All @@ -72,7 +85,7 @@ private string GetPasswordSHA()
{
var context = new SprContext(PasswordEntry, Host.Database, SprCompileFlags.All);
var password = SprEngine.Compile(PasswordEntry.Strings.GetSafe(PwDefs.PasswordField).ReadString(), context);

var pwdShaBytes = sha1.ComputeHash(Encoding.UTF8.GetBytes(password));
var sb = new StringBuilder(2 * pwdShaBytes.Length);

Expand All @@ -85,6 +98,11 @@ private string GetPasswordSHA()
}
}

private bool IsEmptyPassword()
{
return PasswordEntry.Strings.GetSafe(PwDefs.PasswordField).IsEmpty;
}

private void GetOnlineStatus()
{
var pwdSha = GetPasswordSHA();
Expand Down
9 changes: 9 additions & 0 deletions HIBPOfflineCheck/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ public enum CheckModeType
BloomFilter = 2
}

public enum EmptyPwdDefault
{
Secure = 0,
Pwned = 1,
Excluded = 2
}

public static class Names
{
private const string PLUGIN_NAMESPACE = "HIBPOfflineCheck";
Expand All @@ -26,6 +33,7 @@ public static class Names
public const string CHECK_MODE = PLUGIN_NAMESPACE + ".CheckMode";
public const string BLOOM_FILTER = PLUGIN_NAMESPACE + ".BloomFilter";
public const string AUTO_CHECK = PLUGIN_NAMESPACE + ".AutoCheck";
public const string MARK_EMPTY_PASSWORDS = PLUGIN_NAMESPACE + ".MarkEmptyPasswords";
}

public string HIBPFileName { get; set; }
Expand All @@ -41,5 +49,6 @@ public static class Names
public CheckModeType CheckMode { get; set; }
public string BloomFilter { get; set; }
public bool AutoCheck { get; set; }
public EmptyPwdDefault MarkEmptyPasswords { get; set; }
}
}
4 changes: 2 additions & 2 deletions HIBPOfflineCheck/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.10.0")]
[assembly: AssemblyFileVersion("1.7.10.0")]
[assembly: AssemblyVersion("1.7.11.0")]
[assembly: AssemblyFileVersion("1.7.11.0")]
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:
HIBPOfflineCheck:1.7.10.0
HIBPOfflineCheck:1.7.11.0
:

0 comments on commit 4064e65

Please sign in to comment.