diff --git a/SHA1Hash.sln b/SHA1Hash.sln new file mode 100644 index 0000000..aed5804 --- /dev/null +++ b/SHA1Hash.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36930.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PasswordChecker", "SHA1Hash\PasswordChecker.csproj", "{2C345A81-5098-47CA-B971-83FECBF88718}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2C345A81-5098-47CA-B971-83FECBF88718}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C345A81-5098-47CA-B971-83FECBF88718}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C345A81-5098-47CA-B971-83FECBF88718}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C345A81-5098-47CA-B971-83FECBF88718}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4A1632D2-41EC-46E8-9DFD-E5F9357ABBE9} + EndGlobalSection +EndGlobal diff --git a/SHA1Hash/Form1.Designer.cs b/SHA1Hash/Form1.Designer.cs new file mode 100644 index 0000000..d631984 --- /dev/null +++ b/SHA1Hash/Form1.Designer.cs @@ -0,0 +1,158 @@ +namespace SHA1Hash +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + txtInput = new TextBox(); + label1 = new Label(); + btnHash = new Button(); + txtOutput = new TextBox(); + txtResult = new TextBox(); + lblStatus = new Label(); + txtDesc = new TextBox(); + btnCreateReport = new Button(); + btnZeroTrust = new Button(); + SuspendLayout(); + // + // txtInput + // + txtInput.Font = new Font("Consolas", 9F); + txtInput.Location = new Point(12, 27); + txtInput.Name = "txtInput"; + txtInput.Size = new Size(303, 22); + txtInput.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 9); + label1.Name = "label1"; + label1.Size = new Size(68, 15); + label1.TabIndex = 1; + label1.Text = "Enter String"; + // + // btnHash + // + btnHash.Location = new Point(321, 26); + btnHash.Name = "btnHash"; + btnHash.Size = new Size(75, 23); + btnHash.TabIndex = 2; + btnHash.Text = "Hash"; + btnHash.UseVisualStyleBackColor = true; + btnHash.Click += btnHash_Click; + // + // txtOutput + // + txtOutput.Font = new Font("Consolas", 9F); + txtOutput.Location = new Point(12, 56); + txtOutput.Name = "txtOutput"; + txtOutput.Size = new Size(303, 22); + txtOutput.TabIndex = 3; + // + // txtResult + // + txtResult.Font = new Font("Consolas", 9F); + txtResult.Location = new Point(12, 99); + txtResult.Name = "txtResult"; + txtResult.Size = new Size(384, 22); + txtResult.TabIndex = 4; + // + // lblStatus + // + lblStatus.AutoSize = true; + lblStatus.Location = new Point(12, 81); + lblStatus.Name = "lblStatus"; + lblStatus.Size = new Size(16, 15); + lblStatus.TabIndex = 5; + lblStatus.Text = "..."; + // + // txtDesc + // + txtDesc.Font = new Font("Consolas", 9F); + txtDesc.HideSelection = false; + txtDesc.Location = new Point(12, 127); + txtDesc.Multiline = true; + txtDesc.Name = "txtDesc"; + txtDesc.ScrollBars = ScrollBars.Vertical; + txtDesc.Size = new Size(384, 268); + txtDesc.TabIndex = 6; + // + // btnCreateReport + // + btnCreateReport.Location = new Point(12, 401); + btnCreateReport.Name = "btnCreateReport"; + btnCreateReport.Size = new Size(384, 23); + btnCreateReport.TabIndex = 7; + btnCreateReport.Text = "Create Report"; + btnCreateReport.UseVisualStyleBackColor = true; + btnCreateReport.Click += btnCreateReport_Click; + // + // btnZeroTrust + // + btnZeroTrust.Location = new Point(321, 56); + btnZeroTrust.Name = "btnZeroTrust"; + btnZeroTrust.Size = new Size(75, 23); + btnZeroTrust.TabIndex = 8; + btnZeroTrust.Text = "ZeroTrust"; + btnZeroTrust.UseVisualStyleBackColor = true; + btnZeroTrust.Click += btnZeroTrust_Click; + // + // Form1 + // + AcceptButton = btnHash; + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(409, 436); + Controls.Add(btnZeroTrust); + Controls.Add(btnCreateReport); + Controls.Add(txtDesc); + Controls.Add(lblStatus); + Controls.Add(txtResult); + Controls.Add(txtOutput); + Controls.Add(btnHash); + Controls.Add(label1); + Controls.Add(txtInput); + Name = "Form1"; + Text = "Password Checker"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox txtInput; + private Label label1; + private Button btnHash; + private TextBox txtOutput; + private TextBox txtResult; + private Label lblStatus; + private TextBox txtDesc; + private Button btnCreateReport; + private Button btnZeroTrust; + } +} diff --git a/SHA1Hash/Form1.cs b/SHA1Hash/Form1.cs new file mode 100644 index 0000000..e28dc08 --- /dev/null +++ b/SHA1Hash/Form1.cs @@ -0,0 +1,180 @@ +using System.Security.Cryptography; +using System.Text; + +namespace SHA1Hash +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void btnZeroTrust_Click(object sender, EventArgs e) + { + txtDesc.Text = ""; + txtOutput.Text = ""; + txtResult.Text = ""; + Application.DoEvents(); + string input = txtInput.Text; + string hash = ComputeSHA1Hash(input); + txtOutput.Text = hash; + string iSha5 = hash.Substring(0, 5); + Random random = new Random((int)DateTime.Now.Ticks); + string iSha6 = hash.Substring(random.Next(6, 36), 3); + string rHash = hash.Substring(5); + txtOutput.Text = rHash; + lblStatus.Text = "web request..."; + Application.DoEvents(); + string returnString = Task.Run(async () => await SendGetRequestWithShaAsyncZeroTrust("https://www.home.daprogs.net/pwn/zerotrust.php", iSha5, iSha6)).GetAwaiter().GetResult(); + //string returnString = Task.Run(async () => await SendGetRequestWithShaAsyncZeroTrust("https://www.daprogs.com/pwn/zerotrust.php", iSha5, iSha6)).GetAwaiter().GetResult(); + lblStatus.Text = "response..."; + Application.DoEvents(); + lblStatus.Text = $"request sent: {iSha5}-{iSha6}"; + Application.DoEvents(); + if (returnString.Contains("BAD")) + { + if(returnString.ToLower().Contains(rHash.ToLower())) + { + txtResult.Text = "BAD - Your password is listed"; + txtDesc.Text = $"{returnString.Replace("BAD:\r\n", "")}"; + int selectStart = txtDesc.Text.IndexOf(rHash.ToUpper()); + txtDesc.Select(selectStart, 35); + } + else + txtResult.Text = "OK - Not in list"; + } + else + txtResult.Text = returnString; + + txtInput.Focus(); + txtInput.SelectAll(); + } + + private void btnHash_Click(object sender, EventArgs e) + { + txtDesc.Text = ""; + txtOutput.Text = ""; + txtResult.Text = ""; + Application.DoEvents(); + string input = txtInput.Text; + string hash = ComputeSHA1Hash(input); + txtOutput.Text = hash; + lblStatus.Text = "web request..."; + Application.DoEvents(); + string returnString = Task.Run(async () => await SendGetRequestWithShaAsync("https://www.home.daprogs.net/pwn/indexapi.php", hash)).GetAwaiter().GetResult(); + //string returnString = Task.Run(async () => await SendGetRequestWithShaAsync("https://www.daprogs.com/pwn/indexapi.php", hash)).GetAwaiter().GetResult(); + lblStatus.Text = "response..."; + Application.DoEvents(); + txtResult.Text = returnString; + lblStatus.Text = "..."; + Application.DoEvents(); + if (returnString.Contains("BAD")) + { + txtDesc.Text = "This password is in the master list.\r\n"; + txtDesc.Text += $"It has been seen {txtResult.Text.Split(":")[1].Replace("\r\n", "")} times\r\n"; + txtDesc.Text += "Even a value of 1 is bad.\r\n"; + txtDesc.Text += "You need to change this password ASAP!\r\n"; + } + txtInput.Focus(); + txtInput.SelectAll(); + } + + public static string ComputeSHA1Hash(string input) + { + using (SHA1 sha1 = SHA1.Create()) + { + byte[] inputBytes = Encoding.UTF8.GetBytes(input); + byte[] hashBytes = sha1.ComputeHash(inputBytes); + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < hashBytes.Length; i++) + { + sb.Append(hashBytes[i].ToString("x2")); + } + + return sb.ToString(); + } + } + + async Task SendGetRequestWithShaAsync(string url, string sha) + { + using (HttpClient client = new HttpClient()) + { + try + { + string fullUrl = $"{url}?sha1={Uri.EscapeDataString(sha)}"; + + HttpResponseMessage response = await client.GetAsync(fullUrl); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + return responseBody; + } + catch (HttpRequestException e) + { + return $"Request exception: {e.Message}"; + } + } + } + + async Task SendGetRequestWithShaAsyncZeroTrust(string url, string sha5, string sha6) + { + using (HttpClient client = new HttpClient()) + { + try + { + string fullUrl = $"{url}?sha5={Uri.EscapeDataString(sha5)}&sha6={Uri.EscapeDataString(sha6)}"; + HttpResponseMessage response = await client.GetAsync(fullUrl); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + return responseBody; + } + catch (HttpRequestException e) + { + return $"Request exception: {e.Message}"; + } + } + } + + private void btnCreateReport_Click(object sender, EventArgs e) + { + using (StreamWriter SW = new StreamWriter("userReport.txt", false)) + { + using (StreamReader SR = new StreamReader("passList.csv")) + { + string passThing = SR.ReadToEnd(); + string[] passList = passThing.Split("\r\n"); + int cCount = 0; + int tCount = passList.Count(); + foreach (string item in passList) + { + if (item.Contains(",")) + { + string[] items = item.Split(","); + string email = items[0].Split(";")[0] + "@" + items[2]; + string password = items[1]; + if (password.Length > 0) + { + string hash = ComputeSHA1Hash(password); + txtOutput.Text = hash; + txtResult.Text = $"{cCount}/{tCount}"; + lblStatus.Text = "web request..."; + Application.DoEvents(); + string returnString = Task.Run(async () => await SendGetRequestWithShaAsync("https://www.daprogs.com/pwn/indexapi.php", hash)).GetAwaiter().GetResult(); + lblStatus.Text = "response..."; + Application.DoEvents(); + if (returnString.Contains("BAD")) + SW.WriteLine($"{email},Password is hacked!({returnString.Split(":")[1].Replace("\r\n", "")})"); + } + } + cCount++; + } + } + } + txtOutput.Text = "Complete."; + lblStatus.Text = "Complete."; + Application.DoEvents(); + } + } +} diff --git a/SHA1Hash/Form1.resx b/SHA1Hash/Form1.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/SHA1Hash/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SHA1Hash/PasswordChecker.csproj b/SHA1Hash/PasswordChecker.csproj new file mode 100644 index 0000000..663fdb8 --- /dev/null +++ b/SHA1Hash/PasswordChecker.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/SHA1Hash/Program.cs b/SHA1Hash/Program.cs new file mode 100644 index 0000000..3170f49 --- /dev/null +++ b/SHA1Hash/Program.cs @@ -0,0 +1,17 @@ +namespace SHA1Hash +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file