1
0
mirror of synced 2025-01-31 12:23:52 +01:00

Add brute force options for NLG hashes

This commit is contained in:
KillzXGaming 2019-11-06 19:40:19 -05:00
parent 28e0edb8ad
commit c1d25c8372
2 changed files with 327 additions and 10 deletions

View File

@ -35,11 +35,27 @@
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.chkUseHex = new Toolbox.Library.Forms.STCheckBox();
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.maxLengthUD = new Toolbox.Library.Forms.NumericUpDownUint();
this.stLabel7 = new Toolbox.Library.Forms.STLabel();
this.searchUppercase = new Toolbox.Library.Forms.STCheckBox();
this.stButton1 = new Toolbox.Library.Forms.STButton();
this.bruteForceStringTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel6 = new Toolbox.Library.Forms.STLabel();
this.bruteForceHashTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel5 = new Toolbox.Library.Forms.STLabel();
this.stLabel4 = new Toolbox.Library.Forms.STLabel();
this.characterStartTB = new Toolbox.Library.Forms.STTextBox();
this.stLabel8 = new Toolbox.Library.Forms.STLabel();
this.contentContainer.SuspendLayout();
this.stPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.maxLengthUD)).BeginInit();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stLabel4);
this.contentContainer.Controls.Add(this.stPanel1);
this.contentContainer.Controls.Add(this.chkUseHex);
this.contentContainer.Controls.Add(this.stLabel3);
this.contentContainer.Controls.Add(this.stLabel2);
@ -47,7 +63,7 @@
this.contentContainer.Controls.Add(this.hashTypeCB);
this.contentContainer.Controls.Add(this.resultTB);
this.contentContainer.Controls.Add(this.stringTB);
this.contentContainer.Size = new System.Drawing.Size(469, 120);
this.contentContainer.Size = new System.Drawing.Size(624, 359);
this.contentContainer.Controls.SetChildIndex(this.stringTB, 0);
this.contentContainer.Controls.SetChildIndex(this.resultTB, 0);
this.contentContainer.Controls.SetChildIndex(this.hashTypeCB, 0);
@ -55,11 +71,13 @@
this.contentContainer.Controls.SetChildIndex(this.stLabel2, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel3, 0);
this.contentContainer.Controls.SetChildIndex(this.chkUseHex, 0);
this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel4, 0);
//
// stringTB
//
this.stringTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.stringTB.Location = new System.Drawing.Point(88, 76);
this.stringTB.Location = new System.Drawing.Point(88, 74);
this.stringTB.Name = "stringTB";
this.stringTB.Size = new System.Drawing.Size(121, 20);
this.stringTB.TabIndex = 11;
@ -68,7 +86,7 @@
// resultTB
//
this.resultTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.resultTB.Location = new System.Drawing.Point(299, 76);
this.resultTB.Location = new System.Drawing.Point(299, 74);
this.resultTB.Name = "resultTB";
this.resultTB.Size = new System.Drawing.Size(160, 20);
this.resultTB.TabIndex = 12;
@ -80,7 +98,7 @@
this.hashTypeCB.ButtonColor = System.Drawing.Color.Empty;
this.hashTypeCB.FormattingEnabled = true;
this.hashTypeCB.IsReadOnly = false;
this.hashTypeCB.Location = new System.Drawing.Point(88, 45);
this.hashTypeCB.Location = new System.Drawing.Point(88, 43);
this.hashTypeCB.Name = "hashTypeCB";
this.hashTypeCB.Size = new System.Drawing.Size(121, 21);
this.hashTypeCB.TabIndex = 13;
@ -88,7 +106,7 @@
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(20, 48);
this.stLabel1.Location = new System.Drawing.Point(20, 46);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(62, 13);
this.stLabel1.TabIndex = 14;
@ -97,7 +115,7 @@
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(20, 78);
this.stLabel2.Location = new System.Drawing.Point(20, 76);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(37, 13);
this.stLabel2.TabIndex = 15;
@ -106,7 +124,7 @@
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(225, 78);
this.stLabel3.Location = new System.Drawing.Point(225, 76);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(68, 13);
this.stLabel3.TabIndex = 16;
@ -115,7 +133,7 @@
// chkUseHex
//
this.chkUseHex.AutoSize = true;
this.chkUseHex.Location = new System.Drawing.Point(299, 47);
this.chkUseHex.Location = new System.Drawing.Point(299, 45);
this.chkUseHex.Name = "chkUseHex";
this.chkUseHex.Size = new System.Drawing.Size(86, 17);
this.chkUseHex.TabIndex = 17;
@ -123,15 +141,139 @@
this.chkUseHex.UseVisualStyleBackColor = true;
this.chkUseHex.CheckedChanged += new System.EventHandler(this.chkUseHex_CheckedChanged);
//
// stPanel1
//
this.stPanel1.Controls.Add(this.characterStartTB);
this.stPanel1.Controls.Add(this.stLabel8);
this.stPanel1.Controls.Add(this.maxLengthUD);
this.stPanel1.Controls.Add(this.stLabel7);
this.stPanel1.Controls.Add(this.searchUppercase);
this.stPanel1.Controls.Add(this.stButton1);
this.stPanel1.Controls.Add(this.bruteForceStringTB);
this.stPanel1.Controls.Add(this.stLabel6);
this.stPanel1.Controls.Add(this.bruteForceHashTB);
this.stPanel1.Controls.Add(this.stLabel5);
this.stPanel1.Location = new System.Drawing.Point(5, 100);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(610, 250);
this.stPanel1.TabIndex = 18;
//
// maxLengthUD
//
this.maxLengthUD.Location = new System.Drawing.Point(381, 97);
this.maxLengthUD.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.maxLengthUD.Name = "maxLengthUD";
this.maxLengthUD.Size = new System.Drawing.Size(120, 20);
this.maxLengthUD.TabIndex = 27;
//
// stLabel7
//
this.stLabel7.AutoSize = true;
this.stLabel7.Location = new System.Drawing.Point(378, 81);
this.stLabel7.Name = "stLabel7";
this.stLabel7.Size = new System.Drawing.Size(116, 13);
this.stLabel7.TabIndex = 26;
this.stLabel7.Text = "Max Character Search:";
//
// searchUppercase
//
this.searchUppercase.AutoSize = true;
this.searchUppercase.Location = new System.Drawing.Point(386, 129);
this.searchUppercase.Name = "searchUppercase";
this.searchUppercase.Size = new System.Drawing.Size(115, 17);
this.searchUppercase.TabIndex = 24;
this.searchUppercase.Text = "Search Uppercase";
this.searchUppercase.UseVisualStyleBackColor = true;
//
// stButton1
//
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(22, 212);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.TabIndex = 23;
this.stButton1.Text = "Start";
this.stButton1.UseVisualStyleBackColor = false;
this.stButton1.Click += new System.EventHandler(this.stButton1_Click);
//
// bruteForceStringTB
//
this.bruteForceStringTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.bruteForceStringTB.Location = new System.Drawing.Point(205, 48);
this.bruteForceStringTB.Multiline = true;
this.bruteForceStringTB.Name = "bruteForceStringTB";
this.bruteForceStringTB.Size = new System.Drawing.Size(160, 157);
this.bruteForceStringTB.TabIndex = 21;
//
// stLabel6
//
this.stLabel6.AutoSize = true;
this.stLabel6.Location = new System.Drawing.Point(202, 32);
this.stLabel6.Name = "stLabel6";
this.stLabel6.Size = new System.Drawing.Size(70, 13);
this.stLabel6.TabIndex = 22;
this.stLabel6.Text = "String Result:";
//
// bruteForceHashTB
//
this.bruteForceHashTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.bruteForceHashTB.Location = new System.Drawing.Point(22, 48);
this.bruteForceHashTB.Multiline = true;
this.bruteForceHashTB.Name = "bruteForceHashTB";
this.bruteForceHashTB.Size = new System.Drawing.Size(161, 157);
this.bruteForceHashTB.TabIndex = 20;
//
// stLabel5
//
this.stLabel5.AutoSize = true;
this.stLabel5.Location = new System.Drawing.Point(19, 32);
this.stLabel5.Name = "stLabel5";
this.stLabel5.Size = new System.Drawing.Size(46, 13);
this.stLabel5.TabIndex = 20;
this.stLabel5.Text = "Hashes:";
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(20, 107);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(65, 13);
this.stLabel4.TabIndex = 19;
this.stLabel4.Text = "Brute Force:";
//
// characterStartTB
//
this.characterStartTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.characterStartTB.Location = new System.Drawing.Point(381, 49);
this.characterStartTB.Name = "characterStartTB";
this.characterStartTB.Size = new System.Drawing.Size(159, 20);
this.characterStartTB.TabIndex = 28;
//
// stLabel8
//
this.stLabel8.AutoSize = true;
this.stLabel8.Location = new System.Drawing.Point(378, 32);
this.stLabel8.Name = "stLabel8";
this.stLabel8.Size = new System.Drawing.Size(76, 13);
this.stLabel8.TabIndex = 29;
this.stLabel8.Text = "Starting String:";
//
// HashCalculatorForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(475, 125);
this.ClientSize = new System.Drawing.Size(630, 364);
this.Name = "HashCalculatorForm";
this.Text = "Hash Calculator";
this.contentContainer.ResumeLayout(false);
this.contentContainer.PerformLayout();
this.stPanel1.ResumeLayout(false);
this.stPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.maxLengthUD)).EndInit();
this.ResumeLayout(false);
}
@ -145,5 +287,17 @@
private Library.Forms.STLabel stLabel2;
private Library.Forms.STLabel stLabel1;
private Library.Forms.STCheckBox chkUseHex;
private Library.Forms.STLabel stLabel4;
private Library.Forms.STPanel stPanel1;
private Library.Forms.STTextBox bruteForceStringTB;
private Library.Forms.STLabel stLabel6;
private Library.Forms.STTextBox bruteForceHashTB;
private Library.Forms.STLabel stLabel5;
private Library.Forms.STButton stButton1;
private Library.Forms.STCheckBox searchUppercase;
private Library.Forms.STLabel stLabel7;
private Library.Forms.NumericUpDownUint maxLengthUD;
private Library.Forms.STTextBox characterStartTB;
private Library.Forms.STLabel stLabel8;
}
}

View File

@ -5,9 +5,10 @@ using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
using Toolbox.Library.Forms;
using Toolbox.Library;
namespace Toolbox
{
@ -21,6 +22,8 @@ namespace Toolbox
hashTypeCB.Items.Add("NLG_Hash");
hashTypeCB.SelectedIndex = 0;
maxLengthUD.Value = 3;
}
private void stTextBox1_TextChanged(object sender, EventArgs e) {
@ -62,5 +65,165 @@ namespace Toolbox
return (uint)h;
}
private bool CancelOperation = false;
private bool UseSpeialcase => true;
private bool UseLowercase => true;
private bool UseUppercase => searchUppercase.Checked;
private char[] SetupCharacters()
{
List<char> chars = new List<char>();
if (UseLowercase)
chars.AddRange(CharacterSetLower);
// if (UseUppercase)
// chars.AddRange(CharacterSetUpper);
// if (UseSpeialcase)
// chars.AddRange(Special);
return chars.ToArray();
}
private void stButton1_Click(object sender, EventArgs e)
{
STProgressBar progressBar = new STProgressBar();
progressBar.FormClosed += OnProgressBarExist;
progressBar.Show();
progressBar.Task = $"Searching characters";
Thread Thread = new Thread((ThreadStart)(() =>
{
BruteForceHashes(progressBar);
}));
Thread.Start();
}
private void BruteForceHashes(STProgressBar progressBar)
{
if (bruteForceHashTB.Text.Length == 0)
return;
var characterSet = SetupCharacters();
CancelOperation = false;
List<uint> hashes = new List<uint>();
foreach (var line in bruteForceHashTB.Lines)
{
uint hash = 0;
uint.TryParse(line, out hash);
if (hash == 0) continue;
hashes.Add(hash);
}
if (hashes.Count == 0) return;
int maxLength = (int)maxLengthUD.Value;
char lastChar = 'z';
var firstChar = characterSet.FirstOrDefault();
int charIndex = 0;
bool useSpace = true;
for (int length = 1; length <= maxLength; ++length)
{
UpdateProgressbar(progressBar, length, maxLength);
StringBuilder Sb = new StringBuilder(new String(' ', length));
while (true && CancelOperation == false && hashes.Count > 0)
{
String value = Sb.ToString();
uint calculatedHash = StringToHash($"{characterStartTB.Text}{value}");
if (hashes.Contains(calculatedHash))
{
UpdateTextbox($"[{calculatedHash}] {characterStartTB.Text}{value}");
hashes.Remove(calculatedHash);
if (hashes.Count == 0)
{
progressBar.Close();
return;
}
}
if (value.All(item => item == lastChar))
break;
// Add one: aaa -> aab -> ... aaz -> aba -> ... -> zzz
for (int i = length - 1; i >= 0; --i)
if (Sb[i] == ' ')
{
if (UseUppercase)
Sb[i] = 'A';
else
Sb[i] = 'a';
break;
}
else if (Sb[i] == 'Z')
{
Sb[i] = 'a';
break;
}
else if (Sb[i] != lastChar)
{
Sb[i] = (Char)(Sb[i] + 1);
break;
}
else
{
Sb[i] = ' ';
}
}
}
progressBar.Close();
}
private void UpdateProgressbar(STProgressBar progressBar, int length, int maxLength)
{
if (progressBar.InvokeRequired)
{
progressBar.Invoke((MethodInvoker)delegate {
progressBar.Task = $"Searching characters {length} of max {maxLength}";
progressBar.Value = ((length * 100) / maxLength);
progressBar.Refresh();
});
}
}
private void UpdateTextbox(string text)
{
if (bruteForceStringTB.InvokeRequired)
{
bruteForceStringTB.Invoke((MethodInvoker)delegate {
bruteForceStringTB.AppendText(text);
});
}
else
bruteForceStringTB.AppendText(text);
}
private char[] Special = new char[]
{ ' ', };
private char[] Digits = new char[]
{ '0','1','2','3','4','5','6','7','8','9' };
private char[] CharacterSetLower = new char[]
{ 'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s',
't','u','v','w', 'x', 'y', 'z'};
private char[] CharacterSetUpper = new char[]
{ 'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S',
'T','U','V','W', 'X', 'Y', 'Z'};
private void OnProgressBarExist(object sender, EventArgs e)
{
CancelOperation = true;
}
}
}