Ladon插件实例简单端口扫描C#源码 - K8哥哥
2020-02-14 15:58:00 Author: www.cnblogs.com(查看原文) 阅读量:382 收藏

PortScan

源码为单纯检测端口是否开放,有需要大家可自行定制功能。
当然可以使用PortScan模块扫描开放端口带服务和Web识别。

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.Net.Sockets;
//Ladon PortScan Moudle
namespace LadonDLL
{
    public class scan
    {
        public static string run(string ip)
        {
            if (string.IsNullOrEmpty(ip))
                return "";
            else
            {
                if (K8CheckPort(ip, 21))
                    Console.Write(ip + "\t21 Open\r\n");
                if (K8CheckPort(ip, 80))
                    Console.Write(ip + "\t80 Open\r\n");
                if (K8CheckPort(ip, 1433))
                    Console.Write(ip + "\t1433 Open\r\n");
                if (K8CheckPort(ip, 3306))
                    Console.Write(ip + "\t3306 Open\r\n");
                if (K8CheckPort(ip, 1521))
                    Console.Write(ip + "\t1521 Open\r\n");
                if (K8CheckPort(ip, 3389))
                    Console.Write(ip + "\t3389 Open\r\n");
            }

            return "";
        }

        private static bool K8CheckPort(string ip, int Port)
        {
            //int Port = 21;
            IPAddress scanip = IPAddress.Parse(ip);
            IPEndPoint point = new IPEndPoint(scanip, Port);
            try
            {
                TcpClient tcp = new TcpClient();
                tcp.Connect(point);
                //Console.WriteLine(scanip + "\t" + Port + "\tOpen");
                return true;
            }
            catch (Exception ex)
            {
                //Console.WriteLine(scanip + "\t" + Port + "\tClose");
                return false;
            }
        }

    }
}

文章来源: http://www.cnblogs.com/k8gege/p/12307475.html
如有侵权请联系:admin#unsafe.sh