• Ladon插件编写之简单端口扫描C#源码


    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 + "	21 Open
    ");
                    if (K8CheckPort(ip, 80))
                        Console.Write(ip + "	80 Open
    ");
                    if (K8CheckPort(ip, 1433))
                        Console.Write(ip + "	1433 Open
    ");
                    if (K8CheckPort(ip, 3306))
                        Console.Write(ip + "	3306 Open
    ");
                    if (K8CheckPort(ip, 1521))
                        Console.Write(ip + "	1521 Open
    ");
                    if (K8CheckPort(ip, 3389))
                        Console.Write(ip + "	3389 Open
    ");
                }
    
                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 + "	" + Port + "	Open");
                    return true;
                }
                catch (Exception ex)
                {
                    //Console.WriteLine(scanip + "	" + Port + "	Close");
                    return false;
                }
            }
    
        }
    }
    
  • 相关阅读:
    三、ADO.Net基础【04】简单查询
    Canvas 图片绕边旋转的小动画
    Canvas 剪切图片
    Canvas 图片平铺设置
    Canvas 给图形绘制阴影
    Canvas 图形组合方式
    [转]JS获取URL传参方法
    HTML5 FileReader接口学习笔记
    css3实现圆角边框渐变
    HTML5新增属性学习笔记
  • 原文地址:https://www.cnblogs.com/k8gege/p/12307475.html
Copyright © 2020-2023  润新知