Skip to content

Commit

Permalink
Added data breach checking (Working but needs a lot of cleanup to do)
Browse files Browse the repository at this point in the history
  • Loading branch information
-- committed Jan 21, 2021
1 parent 9f9ccda commit 365e57a
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 54 deletions.
10 changes: 9 additions & 1 deletion vIDsafe/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
15 changes: 15 additions & 0 deletions vIDsafe/Credential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ public Credential(string username)

public CredentialStatus Status => _status;

public string GetDomain()
{
//TODO: Cleanup
if (_url != null)
{
if (_url.Length > 0)
{
string host = new Uri(_url).Host;
return host.Substring(host.LastIndexOf('.', host.LastIndexOf('.') - 1) + 1);
}
}

return "";
}

public void SetDetails(string username, string password, string url, string notes)
{
this._userName = username;
Expand Down
1 change: 0 additions & 1 deletion vIDsafe/Encryption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public static string AesEncrypt(string plainText, byte[] key)
{
byte[] textBytes = Encoding.ASCII.GetBytes(plainText);


//https://stackoverflow.com/q/8041451

using (AesCryptoServiceProvider AES = GetAES(key))
Expand Down
57 changes: 57 additions & 0 deletions vIDsafe/EnzoicAPI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using EnzoicClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace vIDsafe
{
class EnzoicAPI
{
//https://www.enzoic.com/docs-dotnet-quick-start/

private static Enzoic _enzoic = new Enzoic("API", "Secret");

public static bool CheckPassword(string password)
{
// Check whether a password has been compromised
if (_enzoic.CheckPassword(password))
{
return true;
}
else
{
return false;
}
}

public static bool CheckCredential(string email, string password)
{
// Check whether a specific set of credentials are compromised
if (_enzoic.CheckCredentials(email, password))
{
return true;
}
else
{
return false;
}
}

public static List<ExposureDetails> GetExposureDetails (string email)
{
// get all exposures for a given user
ExposuresResponse exposures = _enzoic.GetExposuresForUser(email);

List<ExposureDetails> exposureDetails = new List<ExposureDetails>();

foreach (string exposure in exposures.Exposures)
{
exposureDetails.Add(_enzoic.GetExposureDetails(exposure));
}

return exposureDetails;
}
}
}
70 changes: 35 additions & 35 deletions vIDsafe/FormIdentities.Designer.cs

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

3 changes: 0 additions & 3 deletions vIDsafe/FormLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public partial class FormLogin : Form
public FormLogin()
{
InitializeComponent();

txtName.Text = "testacc123";
txtPassword.Text = "123";
}

private void btnLogin_Click(object sender, EventArgs e)
Expand Down
27 changes: 23 additions & 4 deletions vIDsafe/FormOverview.Designer.cs

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

41 changes: 33 additions & 8 deletions vIDsafe/FormOverview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,28 @@ public FormOverview()

private void LoadFormComponents()
{
AddIdentityColumns();
DisplayHealthScores();
DisplayCredentialInformation();
}

private void DisplayHealthScores()
private void AddIdentityColumns()
{
FormvIDsafe.Main.User.Vault.CalculateHealthScore();

//TODO: Cleanup
tlpIdentities.ColumnStyles.Clear();

foreach (Identity identity in FormvIDsafe.Main.User.Vault.Identities)
{
tlpIdentities.ColumnCount += 1;
tlpIdentities.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
}
}

private void DisplayHealthScores()
{
//TODO: Cleanup
for (int i = 0; i < FormvIDsafe.Main.User.Vault.Identities.Count; i++)
{
Identity identity = FormvIDsafe.Main.User.Vault.GetIdentity(i);

ContentAlignment textAlign = ContentAlignment.MiddleCenter;
Font labelFont = new Font("Segoe UI", 9.75f);
Expand Down Expand Up @@ -67,10 +75,12 @@ private void DisplayHealthScores()
BackColor = CalculateHealthColor(identity.HealthScore)
};

tlpIdentities.Controls.Remove(tlpIdentities.GetControlFromPosition(i, 0));

identityPanel.Controls.Add(identityName);
identityPanel.Controls.Add(identityScore);

tlpIdentities.Controls.Add(identityPanel, tlpIdentities.ColumnCount-2, 0);
tlpIdentities.Controls.Add(identityPanel, i, 0);
}

foreach (ColumnStyle style in tlpIdentities.ColumnStyles)
Expand All @@ -86,17 +96,21 @@ private Color CalculateHealthColor(int healthScore)

double colorMultiplier = (double)healthScore / 100;

//Todo: fix colours
if (healthScore >= 75)
{
color = Color.FromArgb(Color.MediumSeaGreen.ToArgb() * ((int) (colorMultiplier)));
Color good = Color.MediumSeaGreen;
color = Color.FromArgb(good.A, good.R, good.G * ((int)(colorMultiplier)), good.B);
}
else if (healthScore >= 50)
{
color = Color.FromArgb(Color.Khaki.ToArgb() * ((int)(colorMultiplier)));
Color medium = Color.Khaki;
color = Color.FromArgb(medium.A, medium.R * ((int)(colorMultiplier)), medium.G * ((int)(colorMultiplier)), medium.B);
}
else if (healthScore >= 0)
{
color = Color.FromArgb(Color.DarkSalmon.ToArgb() * ((int)(colorMultiplier)));
Color bad = Color.DarkSalmon;
color = Color.FromArgb(bad.A, bad.R * ((int)(colorMultiplier)), bad.G, bad.B);
}

Console.WriteLine(color);
Expand Down Expand Up @@ -152,5 +166,16 @@ private void btnManageIdentities_Click(object sender, EventArgs e)
FormHome.ChangeSelectedButton(btnIdentities);
FormHome.OpenChildForm(new FormIdentities());
}
private void btnRefresh_Click(object sender, EventArgs e)
{
Refresh();
}

private void Refresh()
{
FormvIDsafe.Main.User.Vault.CalculateHealthScore();
DisplayHealthScores();
DisplayCredentialInformation();
}
}
}
Loading

0 comments on commit 365e57a

Please sign in to comment.