[C#] King Spam 0.2

Iniciado por BigBear, Octubre 17, 2014, 11:09:05 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Un simple programa estilo consola en C# para hacer spam en un canal IRC desde un archivo de texto con el spam a enviar.

El codigo :

Código: csharp

// King Spam 0.2
// (C) Doddy Hackman 2014

using System;
using System.Collections.Generic;
using System.Text;

using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text.RegularExpressions;

namespace kingspam
{
    class Program
    {

        static string[] usuarios;

        static StreamReader leer_datos;
        static StreamWriter mandar_datos;

        static void printear_logo(string texto)
        {

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(texto);
            Console.ResetColor();

        }

        static void printear(string texto)
        {

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(texto);
            Console.ResetColor();

        }

        static void printear_especial(string texto)
        {

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(texto);
            Console.ResetColor();

        }

        static string print_form(string texto)
        {

            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(texto);
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Cyan;
            string resultado = Console.ReadLine();
            Console.ResetColor();

            return resultado;

        }

        static void Main(string[] args)
        {

            printear_logo("\n-- == KingSpam 0.2 == --\n\n");

            string host_irc = print_form("[+] Host : ");
            string port_irc = print_form("\n[+] Port : ");
            string canal_irc = print_form("\n[+] Channel : ");
            string nick_irc = print_form("\n[+] Nickname : ");
            string file_spam = print_form("\n[+] Filename with spam : ");
            string timeout = print_form("\n[+] Timeout : ");

            if (File.Exists(file_spam))
            {
                string[] spam_lista_now = System.IO.File.ReadAllLines(file_spam);
                List<string> spam_lista = new List<string> {""};
                foreach (string agregar in spam_lista_now)
                {
                    spam_lista.Add(agregar);
                }

                NetworkStream conexion;
                TcpClient irc;

                string host = host_irc;
                string nickname = nick_irc;
                string canal = canal_irc;
                string code = "";

                printear_especial("\n[+] Connecting ...\n");

                try
                {

                    irc = new TcpClient(host, Convert.ToInt32(port_irc));
                    conexion = irc.GetStream();
                    leer_datos = new StreamReader(conexion);
                    mandar_datos = new StreamWriter(conexion);

                    mandar_datos.WriteLine("NICK " + nickname);
                    mandar_datos.Flush();

                    mandar_datos.WriteLine("USER " + nickname + " 1 1 1 1");
                    mandar_datos.Flush();

                    mandar_datos.WriteLine("JOIN " + canal);
                    mandar_datos.Flush();

                    printear("[+] Online ...");
                   

                }

                catch
                {
                    printear("\n[-] Error\n");
                }

                while (true)
                {
                    while ((code = leer_datos.ReadLine()) != null)
                    {

                        Match regex = Regex.Match(code, "PING(.*)", RegexOptions.IgnoreCase);
                        if (regex.Success)
                        {
                            string te_doy_pong = "PONG " + regex.Groups[1].Value;
                            mandar_datos.WriteLine(te_doy_pong);
                            mandar_datos.Flush();
                        }

                        regex = Regex.Match(code, ":(.*) 353 (.*) = (.*) :(.*)", RegexOptions.IgnoreCase);
                        if (regex.Success)
                        {
                            string usuarios_lista = regex.Groups[4].Value;
                            usuarios = usuarios_lista.Split(' ');
                            printear("\n[+] Users Found : " + usuarios.Length + "\n");
                            foreach (string usuario in usuarios)
                            {
                                printear("[+] User : " + usuario);
                            }
                            printear_especial("\n[+] Spammer Online\n");

                            while (true)
                            {

                                System.Threading.Thread.Sleep(Convert.ToInt32(timeout) * 1000);

                                var azar = new Random();
                                int pos = azar.Next(spam_lista.Count);
                                string mensaje = spam_lista[pos];

                                if (mensaje != "")
                                {
                                    mandar_datos.WriteLine("PRIVMSG" + " " + canal + " " + mensaje);
                                    mandar_datos.Flush();
                                }

                                foreach (string usuario in usuarios)
                                {
                                    if (usuario != nick_irc)
                                    {
                                        if (spam_lista[pos] != "")
                                        {
                                            mandar_datos.WriteLine("PRIVMSG" + " " + usuario + " " + mensaje);
                                            mandar_datos.Flush();
                                        }
                                    }
                                }
                            }

                        }
                   
                       
                    }

                }

            }
            else
            {
                printear_especial("[-] Error loading file");
            }

            Console.ReadLine();
           
        }
    }
}

// The End ?


Imagenes :





Si lo quieren bajar lo pueden hacer de No tienes permitido ver los links. Registrarse o Entrar a mi cuenta.

Excelente aporte se te agradece ;)!
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta