public static BruteForceStep FromChar(string[] input, bool lowerAndUpper, bool mix) { string sinput = string.Join("", input); BruteForceStep c = new BruteForceStep(); c.ret = new BruteForceAllowedChars[] { new BruteForceAllowedChars(lowerAndUpper, mix, sinput) }; return(c); }
public static BruteForceStep[] FromWord(bool appendEmpty, string[] input, bool lowerAndUpper, bool upperOnlyFirst, bool mix) { List <BruteForceStep> ls = new List <BruteForceStep>(); if (appendEmpty) { ls.Add(new BruteForceStep()); } foreach (string sinput in input) { BruteForceStep c = new BruteForceStep(); c.ret = BruteForceAllowedChars.SplitWordMixed(sinput, lowerAndUpper, upperOnlyFirst, mix); ls.Add(c); } return(ls.ToArray()); }
bool ParseSection(string input, Dictionary <string, string[]> set, List <BruteForceStep[]> checks) { if (string.IsNullOrEmpty(input)) { return(true); } string iz, dr; StringHelper.Split(input, '=', out iz, out dr); string[] toca = null; if (!set.TryGetValue(iz, out toca)) { if (toca == null) { // Default values switch (iz) { case "0-F": toca = new string[] { "0123456789ABCDEF" }; break; case "0-f": toca = new string[] { "0123456789abcdef" }; break; case "0-9": toca = new string[] { "0123456789" }; break; case "¡!": toca = new string[] { " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" }; break; case "¡m!": toca = new string[] { "!#$%&()*+,-./:;<=>?@_|~" }; break; case "a-z": toca = new string[] { "abcdefghijklmnopqrstuvwxyz" }; break; case "A-Z": toca = new string[] { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" }; break; case "a-Z": toca = new string[] { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" }; break; default: toca = new string[] { iz }; dr = "w"; break; } } if (toca == null) { throw (new Exception("Cant find section '" + iz + "'")); } } //checks.Add(new check[] { new check(""), new check("#*") }); //checks.Add(new check[] { new check("word1", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word2", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word3", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word4", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word5", BruteForceAllowedChars.EMixCase.OnlyFirst) }); //checks.Add(new check[] { new check(""), new check("#*") }); //checks.Add(new check[] { new check("word1", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word2", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word3", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word4", BruteForceAllowedChars.EMixCase.OnlyFirst), new check("word5", BruteForceAllowedChars.EMixCase.OnlyFirst) }); //checks.Add(new check[] { new check(""), new check("#*") }); bool allowVacia = false; if (dr.StartsWith("!")) { dr = dr.TrimStart('!'); allowVacia = true; } dr = dr.TrimEnd('s', 'S'); // words / chars if (dr == "" || dr == "c" || dr == "C" || dr.ToUpperInvariant() == "CHAR" || dr.ToUpperInvariant() == "CH4R") { bool mix = dr.Contains("4"); bool lowerAndUpper = dr == "C" || dr == "CHAR" || dr == "CH4R"; if (allowVacia) { checks.Add(new BruteForceStep[] { new BruteForceStep(), BruteForceStep.FromChar(toca, lowerAndUpper, mix) }); } else { checks.Add(new BruteForceStep[] { BruteForceStep.FromChar(toca, lowerAndUpper, mix) }); } } else { if (dr == "w" || dr == "W" || dr.ToUpperInvariant() == "WORD" || dr.ToUpperInvariant() == "W0RD") { bool upperOnlyFirst = false; bool mix = dr.Contains("0"); if (dr == "W0rd" || dr == "Word") { upperOnlyFirst = true; } bool lowerAndUpper = dr == "W" || dr == "WORD" || dr == "W0RD"; checks.Add(BruteForceStep.FromWord(allowVacia, toca, lowerAndUpper, upperOnlyFirst, mix)); } } return(true); }