본문 바로가기
공부,일/C# 네트워크

packet 분석기 만들기 (1)

by fromnothing1 2021. 9. 10.

c 로 만들어진 packet 라이브러리 다운 

https://www.winpcap.org/install/default.htm

 

WinPcap · Download

WinPcap Has Ceased Development. We recommend Npcap. The WinPcap project has ceased development and WinPcap and WinDump are no longer maintained. WE RECOMMEND USING Npcap INSTEAD. If you do insist upon using WinPcap, be aware that its installer Uses NDIS 5.

www.winpcap.org

 

 

 

https://sourceforge.net/projects/sharppcap/

 

SharpPcap

Download SharpPcap for free. NOTE: Project has moved to github, including file downloads. SharpPcap is a cross-platform packet capture framework for the .NET environment, based on the famous pcap / WinPcap libraries.

sourceforge.net

c 용으로 만들어진 라이브러리를 c# 용으로 바꿔주는 dll 다운 

 

다운 

압축 풀어서 release 에 dll 파일 두개 c# 참조 추가하기에서 추가하자  

 

 

간단한 버전 확인 해주는 코드 

using SharpPcap;
using System;

namespace packat
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("SharpPcap : 버전 "+SharpPcap.Version.VersionString);
            Console.WriteLine("Pcap : 버전 " + Pcap.Version.Substring(0, Pcap.Version.IndexOf(',')));


        }
    }
}

내컴퓨터에서  capture 가능한 인터넷 장비에 대한 정보 출력

static void Main(string[] args)
        {
            Console.WriteLine("인터넷 장치 숫자 : "+SharpPcap.CaptureDeviceList.Instance.Count.ToString()); // NIC(랜카드) 장치 숫자 
            foreach (var item in SharpPcap.CaptureDeviceList.Instance)
            {
                
                if (item.ToString().IndexOf("FriendlyName") != -1)
                {
                    Console.WriteLine(item.ToString().Split('\n')[1]);

                }
            }
        }

댓글