[原创]K8Cscan插件之端口扫描C#源码

[原创]K8Cscan插件之端口扫描C#源码

https://www.cnblogs.com/k8gege/p/10660412.html

主程序: K8 Cscan 大型内网渗透自定义扫描器
URL:  https://www.cnblogs.com/k8gege/p/10519321.html

Cscan 主程序分为检测存活主机、非检测存活主机版本  程序采用Cping原理多线程批量扫描大型内网多个IP段C段主机,

目前插件包含: C段旁注扫描、子域名扫描、Ftp密码爆破、Mysql密码爆、系统密码爆破、存活主机扫描、Web信息探测等,

其实也支持调用任意外部程序或脚本的,当然也可以用于外网扫描不要死脑筋(如子域名、C段旁注、FTP破、MYSQL爆破等)

源码

以下代码编译成netscan.dll,和Cscan.exe放在一起即可,大家可根据需要自行定制需扫描的端口。

当然也可以直接调用s.exe,但网上部分版本的s,启动多个时,S可能会崩溃或退出无结果返回。

再说调用DLL不会像调用s.exe那样占用资源,且会产生30个S扫描器进程(它不崩溃的话)

https://github.com/k8gege/K8CScan/blob/master/K8Cscan%20Moudle%20PortScan.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.Net.Sockets;
//Cscan 3.1 PortScan Moudle
namespace CscanDLL
{
    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;
            }
        }

    }
}

 效果:

猜你喜欢

转载自www.cnblogs.com/k8gege/p/10660412.html