Пример #1
0
 // ****************
 public GridWindow(Option StartUpOptions)
 {
     _startUpOption = StartUpOptions;
     _exe = new NewExecution( StartUpOptions );
     _exe.TaskCompleted += ProgressChanged;
     OwnPacketReceiver.EndOfScan += ScanEnded;
     InitializeComponent();
     InitializeComboBox();
     InitializeDataGridView();
 }
Пример #2
0
 public Option_window( Option opt )
 {
     InitializeComponent();
     option_ARPing.Checked = opt.Arping;
     option_ARP.Checked = opt.Arp;
     option_DNS.Checked = opt.Dns;
     option_ping.Checked = opt.Ping;
     option_port.Checked = opt.Port;
     textBox1.Text = opt.Timeout.ToString();
     textBox2.Text = opt.MaximumTasks.ToString();
     option_nbPacketToSend.Value = opt.NbPacketToSend;
     option_waitTime.Value = opt.WaitTime;
     option_TCPPort.Value = opt.TCPPort;
     option_UDPPort.Value = opt.UDPPort;
     option_RandomTCPPort.Checked = opt.RandomTCPPort;
     option_RandomUDPPort.Checked = opt.RandomUDPPort;
     textBox3.Text = opt.PortToTestString;
 }
Пример #3
0
        static void Main()
        {
            //FAIL
            Option StartupOptions = new Option();
            List<IPAddress> list = new List<IPAddress>();
            StartupOptions.IpToTest = IPRange.AutoIpRange();

            string[] startupArgs = Environment.GetCommandLineArgs();
            if ( startupArgs.Length > 1)
            {
                IntPtr ptr = GetForegroundWindow();
                int u;
                GetWindowThreadProcessId( ptr, out u );
                Process process = Process.GetProcessById( u );
                if ( process.ProcessName == "cmd" )    //Is the uppermost window a cmd process?
                {
                    StartupOptions.CmdConsole = true;
                    AttachConsole( process.Id );
                    //we have a console to attach to ..
                }
                else
                {
                    //no console AND we're in console mode ... create a new console.
                    AllocConsole();
                }

                ConsoleProgram.ConsoleMain( startupArgs, StartupOptions );
                FreeConsole();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault( false );
                Application.Run( new GridWindow( StartupOptions ) );
            }
        }
Пример #4
0
 public PingSender( Option op )
 {
     _timeout = op.Timeout;
 }
Пример #5
0
        public static void ConsoleMain( string[] startupArgs, Option StartupOptions )
        {
            Arguments args = new Arguments( startupArgs );
            Console.Title = "GridMapper";

            if ( StartupOptions.CmdConsole )
            {
                ConsoleHelper.DeletePath();
            }

            bool console = StartupOptions.CmdConsole;
            int maxTasks;
            //help message get priority over everything
            if ( args.IsTrue( "h" ) || args.IsTrue( "?" ) || args.IsTrue( "help" ) ||
                 args.Exists( "h" ) || args.Exists( "?" ) || args.Exists( "help" ) )
            {
                ConsoleHelper.PrintHelp();
            }
            else
            {
                Repository.OnRepositoryUpdated += DoNothing;
                OwnPacketReceiver.EndOfScan += ScanEnded;
                t.Interval = 50;
                t.Elapsed += timer_Tick;
                StartupOptions.CmdConsole = true;
                if ( args.IsTrue( "auto" ) || args.Exists( "auto" ) )
                {
                    _exe = new NewExecution( StartupOptions );
                    _exe.TaskCompleted += ProgressChanged;
                    LaunchScan();
                }
                else
                {
                    if ( args.Exists( "IP" ) )
                    {
                        IPParserResult Ips = IPParser.TryParse( args.Single( "IP" ) );
                        if ( Ips.HasError == true )
                        {
                            Console.WriteLine( "Not a valid input for IP" );
                        }
                        else
                        {
                            StartupOptions.IpToTest = Ips;
                        }
                    }
                    //if ( args.Exists( "p" ) )
                    //{
                    //PortsParserResult PortsToHandle = PortsParser.MainPortsParser(args.Single("p"));
                    //IEnumerator enumerator = PortsToHandle.Result.GetEnumerator();
                    //}
                    //if ( args.Exists( "t" ) || args.Exists( "tasks" ) )
                    //{
                    //    if ( int.TryParse( args.Single( "t" ), out maxTasks ) || int.TryParse( args.Single( "tasks" ), out maxTasks ) )
                    //    {
                    //        if ( maxTasks >= 1 && maxTasks <= 2000 )
                    //        {
                    //            StartupOptions.MaximumTasks = maxTasks;
                    //        }
                    //        else
                    //        {
                    //            Console.WriteLine( "The number of tasks must be between 1 and 2000, reasonnable limit is around 4" );
                    //        }
                    //    }
                    //    else
                    //    {
                    //        Console.WriteLine( "Invalid argument for -t" );
                    //    }
                    //}
                    _exe = new NewExecution( StartupOptions );
                    _exe.TaskCompleted += ProgressChanged;
                    LaunchScan();
                }

            }

            if ( console )
            {
                ConsoleHelper.ShowPath();
            }
            else
            {
                ConsoleHelper.EndOfProgram();
            }
        }
Пример #6
0
 public OptionUpdatedEventArgs( Option option )
 {
     Option = option;
 }