A
A
Alex2017-07-19 17:00:03
.NET
Alex, 2017-07-19 17:00:03

How to implement multithreaded brute in c#?

I have a database of logins, passwords, ports and ip addresses. The bottom line is that you need to implement a separate enumeration for each ip address in the streams. The code that is now works, but it displays the same thing several times.

public static string IpsFile = "data/IPs.txt";
        public static string LoginFile = "data/logins.txt";
        public static string PasswordFile = "data/passwords.txt";
        public static string PortsFile = "data/ports.txt";
        
        static void Main(string[] args)
        {
            CHCNetSDK.NET_DVR_Init();
            int threads = 10;
            for (int i = 0; i <= threads; i++)
            {
                string[] ips = File.ReadAllLines(IpsFile);
                string[] ports = File.ReadAllLines(PortsFile);
                string[] logins = File.ReadAllLines(LoginFile);
                string[] passwords = File.ReadAllLines(PasswordFile);

                foreach (string ip in ips)
                {
                    foreach (string port in ports)
                    {
                        foreach (string login in logins)
                        {
                            foreach (string password in passwords)
                            {
                                Brute brute = new Brute(ip, int.Parse(port), login, password);
                                Thread myThread = new Thread(brute.BruteCam)
                                {
                                    Name = "Thread #" + i
                                };
                                myThread.Start();
                            }
                        }
                    }
                }
            }
            Console.ReadLine();
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question