public void LoadGenerator(CharacterRepeater Generator) { textBoxName.Text = Generator.Name; comboBoxEncoding.SelectedIndex = GeneratorEncoding.ReturnEncodingIndex(Generator.Encoding); numericUpDownIncrement.Value = Convert.ToDecimal(Generator.Increment); numericUpDownInitialCount.Value = Convert.ToDecimal(Generator.InitialCount); numericUpDownFinalCount.Value = Convert.ToDecimal(Generator.FinalCount); textBoxCharacterString.Text = Generator.Character; }
private List <string> BuildCharacterRepeats(CharacterRepeater Generator, string Text) { List <string> fuzzed = new List <string>(); for (int i = Generator.InitialCount; i <= Generator.FinalCount; i += Generator.Increment) { string multi = Multiply(Generator.Character, i); fuzzed.Add(Text.Replace("{" + Generator.Name + "}", multi)); } return(fuzzed); }
public CharacterRepeater GetGenerator() { CharacterRepeater characterRepeaterGenerator = new CharacterRepeater(); characterRepeaterGenerator.Name = textBoxName.Text; characterRepeaterGenerator.Encoding = GeneratorEncoding.GetEncoding(comboBoxEncoding.SelectedIndex); characterRepeaterGenerator.Increment = Convert.ToInt32(numericUpDownIncrement.Value); characterRepeaterGenerator.InitialCount = Convert.ToInt32(numericUpDownInitialCount.Value); characterRepeaterGenerator.FinalCount = Convert.ToInt32(numericUpDownFinalCount.Value); characterRepeaterGenerator.Character = textBoxCharacterString.Text; return(characterRepeaterGenerator); }
private List <string> BuildList(IGenerator Generator, List <string> List) { List <string> OldList = List; List <string> NewList = new List <string>(); for (int i = 0; i < OldList.Count;) { string OldValue = List[i]; List.RemoveAt(i); if (Generator.GetType() == typeof(CharacterGenerator)) { CharacterGenerator characterGenerator = (CharacterGenerator)Generator; NewList.AddRange(BuildCharacters(characterGenerator, OldValue)); } else if (Generator.GetType() == typeof(CharacterRepeater)) { CharacterRepeater characterRepeater = (CharacterRepeater)Generator; NewList.AddRange(BuildCharacterRepeats(characterRepeater, OldValue)); } else if (Generator.GetType() == typeof(FileGenerator)) { FileGenerator fileGenerator = (FileGenerator)Generator; NewList.AddRange(BuildFileString(fileGenerator, OldValue)); } else if (Generator.GetType() == typeof(NumberGenerator)) { NumberGenerator numberGenerator = (NumberGenerator)Generator; NewList.AddRange(BuildNumbers(numberGenerator, OldValue)); } else if (Generator.GetType() == typeof(RandomStringGenerator)) { RandomStringGenerator randomStringGenerator = (RandomStringGenerator)Generator; NewList.AddRange(BuildRandomStrings(randomStringGenerator, OldValue)); } else if (Generator.GetType() == typeof(StringGenerator)) { StringGenerator stringGenerator = (StringGenerator)Generator; NewList.AddRange(BuildStrings(stringGenerator, OldValue, "")); } } return(NewList); }
private void deserializeGenerators() { if (File.Exists(Application.StartupPath + "\\Generators.dat")) { ListViewItem Item; try { using (Stream deStream = File.Open(Application.StartupPath + "\\Generators.dat", FileMode.Open)) { BinaryFormatter bin = new BinaryFormatter(); Generators = (List <IGenerator>)bin.Deserialize(deStream); foreach (IGenerator generator in Generators) { Item = new ListViewItem(); if (generator.GetType() == typeof(CharacterGenerator)) { CharacterGenerator characterGenerator = (CharacterGenerator)generator; Item.Text = characterGenerator.Name; Item.SubItems.Add("Character Generator"); Item.SubItems.Add( "Inc: " + characterGenerator.Increment.ToString() + ", Start: " + characterGenerator.StartCharacter.ToString() + ", Stop: " + characterGenerator.StopCharacter.ToString() + ", Enc: " + characterGenerator.Encoding.ToString() ); } else if (generator.GetType() == typeof(CharacterRepeater)) { CharacterRepeater characterRepeater = (CharacterRepeater)generator; Item.Text = characterRepeater.Name; Item.SubItems.Add("Character Repeater Generator"); Item.SubItems.Add( "Inc: " + characterRepeater.Increment.ToString() + ", Init: " + characterRepeater.InitialCount.ToString() + ", Final: " + characterRepeater.FinalCount.ToString() + ", Enc: " + characterRepeater.Encoding.ToString() ); } else if (generator.GetType() == typeof(FileGenerator)) { FileGenerator fileGenerator = (FileGenerator)generator; Item.Text = fileGenerator.Name; Item.SubItems.Add("File Generator"); Item.SubItems.Add( "File: " + fileGenerator.FilePath.ToString() + ", Enc: " + fileGenerator.Encoding.ToString() ); } else if (generator.GetType() == typeof(NumberGenerator)) { NumberGenerator numberGenerator = (NumberGenerator)generator; Item.Text = numberGenerator.Name; Item.SubItems.Add("Number Generator"); Item.SubItems.Add( "Inc: " + numberGenerator.Increment.ToString() + ", Start: " + numberGenerator.StartNumber.ToString() + ", Stop: " + numberGenerator.StopNumber.ToString() + ", Enc: " + numberGenerator.Encoding.ToString() ); } else if (generator.GetType() == typeof(RandomStringGenerator)) { RandomStringGenerator randomStringGenerator = (RandomStringGenerator)generator; Item.Text = randomStringGenerator.Name; Item.SubItems.Add("Random String Generator"); Item.SubItems.Add( "Rep: " + randomStringGenerator.AllowRepetitions.ToString() + ", Chars: " + randomStringGenerator.CharacterSet + ", MaxStrings: " + randomStringGenerator.MaximumStrings.ToString() + ", StrLength: " + randomStringGenerator.StringLength.ToString() + ", Enc: " + randomStringGenerator.Encoding.ToString() ); } else if (generator.GetType() == typeof(StringGenerator)) { StringGenerator stringGenerator = (StringGenerator)generator; Item.Text = stringGenerator.Name; Item.SubItems.Add("String Generator"); Item.SubItems.Add( "Rep: " + stringGenerator.AllowRepetitions.ToString() + ", Chars: " + stringGenerator.CharacterSet + ", StrLength: " + stringGenerator.StringLength.ToString() + ", Enc: " + stringGenerator.Encoding.ToString() ); } listViewGenerators.Items.Add(Item); } } } catch (Exception ex) { Console.WriteLine("Fehler beim Laden der File" + ex); } } }
private void AddGeneratorFromPanel(int GeneratorIndex) { Type panelType = splitContainer4.Panel2.Controls[0].GetType(); Control panelControl = splitContainer4.Panel2.Controls[0]; ListViewItem Item = new ListViewItem(); if (panelType == typeof(ucCharacterGenerator)) { ucCharacterGenerator ucGenerator = (ucCharacterGenerator)panelControl; if (!ucGenerator.FieldsValid()) { return; } CharacterGenerator characterGenerator = ucGenerator.GetGenerator(); foreach (ListViewItem item in listViewGenerators.Items) { if (characterGenerator.Name == item.Text) { MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK); return; } } if (GeneratorIndex == -1) { Generators.Add((IGenerator)characterGenerator); } else { Generators.Insert(GeneratorIndex, (IGenerator)characterGenerator); } Item.Text = characterGenerator.Name; Item.SubItems.Add("Character Generator"); Item.SubItems.Add( "Inc: " + characterGenerator.Increment.ToString() + ", Start: " + characterGenerator.StartCharacter.ToString() + ", Stop: " + characterGenerator.StopCharacter.ToString() + ", Enc: " + characterGenerator.Encoding.ToString() ); } else if (panelType == typeof(ucCharacterRepeater)) { ucCharacterRepeater ucGenerator = (ucCharacterRepeater)panelControl; if (!ucGenerator.FieldsValid()) { return; } CharacterRepeater characterRepeater = ucGenerator.GetGenerator(); foreach (ListViewItem item in listViewGenerators.Items) { if (characterRepeater.Name == item.Text) { MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK); return; } } if (GeneratorIndex == -1) { Generators.Add((IGenerator)characterRepeater); } else { Generators.Insert(GeneratorIndex, (IGenerator)characterRepeater); } Item.Text = characterRepeater.Name; Item.SubItems.Add("Character Repeater Generator"); Item.SubItems.Add( "Inc: " + characterRepeater.Increment.ToString() + ", Init: " + characterRepeater.InitialCount.ToString() + ", Final: " + characterRepeater.FinalCount.ToString() + ", Enc: " + characterRepeater.Encoding.ToString() ); } else if (panelType == typeof(ucFileGenerator)) { ucFileGenerator ucGenerator = (ucFileGenerator)panelControl; if (!ucGenerator.FieldsValid()) { return; } FileGenerator fileGenerator = ucGenerator.GetGenerator(); foreach (ListViewItem item in listViewGenerators.Items) { if (fileGenerator.Name == item.Text) { MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK); return; } } if (GeneratorIndex == -1) { Generators.Add((IGenerator)fileGenerator); } else { Generators.Insert(GeneratorIndex, (IGenerator)fileGenerator); } Item.Text = fileGenerator.Name; Item.SubItems.Add("File Generator"); Item.SubItems.Add( "File: " + fileGenerator.FilePath.ToString() + ", Enc: " + fileGenerator.Encoding.ToString() ); } else if (panelType == typeof(ucNumberGenerator)) { ucNumberGenerator ucGenerator = (ucNumberGenerator)panelControl; if (!ucGenerator.FieldsValid()) { return; } NumberGenerator numberGenerator = ucGenerator.GetGenerator(); foreach (ListViewItem item in listViewGenerators.Items) { if (numberGenerator.Name == item.Text) { MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK); return; } } if (GeneratorIndex == -1) { Generators.Add((IGenerator)numberGenerator); } else { Generators.Insert(GeneratorIndex, (IGenerator)numberGenerator); } Item.Text = numberGenerator.Name; Item.SubItems.Add("Number Generator"); Item.SubItems.Add( "Inc: " + numberGenerator.Increment.ToString() + ", Start: " + numberGenerator.StartNumber.ToString() + ", Stop: " + numberGenerator.StopNumber.ToString() + ", Enc: " + numberGenerator.Encoding.ToString() ); } else if (panelType == typeof(ucRandomStringGenerator)) { ucRandomStringGenerator ucGenerator = (ucRandomStringGenerator)panelControl; if (!ucGenerator.FieldsValid()) { return; } RandomStringGenerator randomStringGenerator = ucGenerator.GetGenerator(); foreach (ListViewItem item in listViewGenerators.Items) { if (randomStringGenerator.Name == item.Text) { MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK); return; } } if (GeneratorIndex == -1) { Generators.Add((IGenerator)randomStringGenerator); } else { Generators.Insert(GeneratorIndex, (IGenerator)randomStringGenerator); } Item.Text = randomStringGenerator.Name; Item.SubItems.Add("Random String Generator"); Item.SubItems.Add( "Rep: " + randomStringGenerator.AllowRepetitions.ToString() + ", Chars: " + randomStringGenerator.CharacterSet + ", MaxStrings: " + randomStringGenerator.MaximumStrings.ToString() + ", StrLength: " + randomStringGenerator.StringLength.ToString() + ", Enc: " + randomStringGenerator.Encoding.ToString() ); } else if (panelType == typeof(ucStringGenerator)) { ucStringGenerator ucGenerator = (ucStringGenerator)panelControl; if (!ucGenerator.FieldsValid()) { return; } StringGenerator stringGenerator = ucGenerator.GetGenerator(); foreach (ListViewItem item in listViewGenerators.Items) { if (stringGenerator.Name == item.Text) { MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK); return; } } if (GeneratorIndex == -1) { Generators.Add((IGenerator)stringGenerator); } else { Generators.Insert(GeneratorIndex, (IGenerator)stringGenerator); } Item.Text = stringGenerator.Name; Item.SubItems.Add("String Generator"); Item.SubItems.Add( "Rep: " + stringGenerator.AllowRepetitions.ToString() + ", Chars: " + stringGenerator.CharacterSet + ", StrLength: " + stringGenerator.StringLength.ToString() + ", Enc: " + stringGenerator.Encoding.ToString() ); } if (GeneratorIndex == -1) { listViewGenerators.Items.Add(Item); } else { listViewGenerators.Items.Insert(GeneratorIndex, Item); } }