文章出處

  static void Main(string[] args)
        {
            Console.WriteLine("請輸入ip");
            string ip = Console.ReadLine();
            Parallel.For(1, 65535, i => scan(ip, i, 200));
            Console.WriteLine("掃描完成");


        }

        public static void scan(string ip, int port, int timeout)
        {
            TcpClient tc = new TcpClient();
            tc.ReceiveTimeout = timeout;
            try
            {
                tc.Connect(ip, port);
                if (tc.Connected)
                {
                    Console.WriteLine("Port {0} is Open", port.ToString().PadRight(6));
                    Console.WriteLine("連接成功!!!");
                }
            }
            catch
            {
                //Console.WriteLine("Port {0} is Closed", port.ToString().PadRight(6));
            }
            finally
            {
                tc.Close();
                tc = null;

            }
        }

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()