Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[C#] The real Brute Force by Mathian

Hi! When I first heard about BruteForce, I imagined going over all the options from "a" to "z". I have created such code long ago, but it would be worth thinking about exceptions:
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace Cycle
{
    class Program
    {
        static void Main(string[] args)
        {
            string Chars = "Alphabet";
            for (int i = 0; i <= 3; i++)
            {
                foreach (var Password in GetCombinations(Chars.ToArray(), i))
                    Console.WriteLine(Password);
            }
            Console.ReadLine();
        }
        private static IEnumerable<string> GetCombinations(char[] Chars, int MaximumLength)
        {
            if (MaximumLength < 1) yield break;
            foreach (var a in Chars)
            {
                yield return a.ToString();
                foreach (var b in GetCombinations(Chars, MaximumLength - 1)) yield return a + b;
            }
        }
    }
}
With this code you can get absolutely all combinations of passwords, but it will take an incredible amount of time. I'm not saying that this is the best way (rather the opposite), but this is the real Brute Force.

Spoiler (Click to View)

Author: Mathian Developer
better use Parallel.ForEach
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
By outputting every password to console, you're massively reducing the speed of the program
(Dec 26, 2018 08:48 PM).TheMarv Wrote:  By outputting every password to console, you're massively reducing the speed of the program
Oh my God! Friend, you can not output to the console. I provided the generation algorithm
Code
foreach (var Password in GetCombinations(Chars.ToArray(), i))
                    Console.WriteLine(Password);

This will output every possibility to the console, that's what I was referring to
@OP thank you for sharing this!

(Dec 27, 2018 01:31 AM).TheMarv Wrote:  
Code
               foreach (var Password in GetCombinations(Chars.ToArray(), i))
                   Console.WriteLine(Password);

This will output every possibility to the console, that's what I was referring to

He has provided the algorithm to generate passwords, where you want them outputted is your choice 🤝

Regards,
Paskowsky
(Dec 27, 2018 03:36 AM)Paskowsky Wrote:  @OP thank you for sharing this!


He has provided the algorithm to generate passwords, where you want them outputted is your choice  🤝

Regards,
Paskowsky

Ofc, I just wanted to point out, that putting it out in the console would decrease the performance.
(Dec 27, 2018 01:31 AM).TheMarv Wrote:  
Code
               foreach (var Password in GetCombinations(Chars.ToArray(), i))
                   Console.WriteLine(Password);

This will output every possibility to the console, that's what I was referring to
You can save to file, add to database or apply. Conclusion in the console - a demonstration of work


(Dec 27, 2018 03:36 AM)Paskowsky Wrote:  @OP thank you for sharing this!


He has provided the algorithm to generate passwords, where you want them outputted is your choice  🤝

Regards,
Paskowsky
Enjoy :)
Enumerators and IEnumerable = very slow. An iterative approach would be much faster. This code snippet is really not useful in the real world for relatively good bruteforcing.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Dec 27, 2018 03:20 PM)0xDEAD10CC Wrote:  Enumerators and IEnumerable = very slow. An iterative approach would be much faster. This code snippet is really not useful in the real world for relatively good bruteforcing.
I by no means suggest to produce brutus by this method


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by airpline1Mar 18, 2020 01:20 PM 8 1,156 Mar 18, 2020 01:20 PM
Last Post: JKHA
[Shell] by HackooOct 19, 2018 02:06 PM 6 750 Oct 19, 2018 02:06 PM
Last Post: Irritiable
[Python] by @DexterSep 30, 2018 06:51 AM 4 290 Sep 30, 2018 06:51 AM
Last Post: kookur