728x90
반응형
using System; using SharpPcap; namespace Net_Packet001 { class Program { static void Main(string[] args) { string NIC_Name = "Wi-Fi"; ICaptureDevice PcapDevice = null; if (1 > CaptureDeviceList.Instance.Count) { Console.WriteLine("패킷을 캡쳐할 수 있는 장치 존재하지 않아 종료합니다..."); return; } foreach (ICaptureDevice NIC in CaptureDeviceList.Instance) { string FriendName = NIC.ToString().Split('\n')[1]; FriendName = FriendName.Substring(FriendName.IndexOf(' ') + 1); if(FriendName == NIC_Name) { PcapDevice = NIC; break; } } if (null == PcapDevice) { Console.WriteLine("캡쳐에 적합한 장치 이름을 검색할 수 없어 종료합니다..."); return; } else { Console.WriteLine("==========================================================================="); Console.WriteLine("캡쳐에 사용할 적합한 NIC의 검색을 완료하였습니다..."); Console.WriteLine("==========================================================================="); Console.WriteLine(PcapDevice); Console.WriteLine("==========================================================================="); Console.WriteLine("패킷을 캡쳐하기 위해 위 장치를 사용합니다..."); Console.WriteLine("==========================================================================="); } } } }
icapturedevice.cs.html
0.02MB
728x90
'기술자료 > C#' 카테고리의 다른 글
C# 소켓 억셉트 Socket Asynchronous Accept 초간단 소스 (0) | 2021.09.15 |
---|---|
C# Console 비동기 입력 ReadLine ReadKey Asynchronous input 초간단 소스 (0) | 2021.09.15 |
C# Packet Capture Programming #4 - 패킷 출력 HexaView (0) | 2021.09.07 |
C# Packet Capture Programming #3 - 패킷 캡쳐 GetNextPacket (0) | 2021.09.07 |
static HexaViewer Class 구현 - ArraySegment 응용 (0) | 2021.09.07 |
C# Packet Capture Programming #1 (0) | 2021.09.01 |
예외처리 1 : try catch 문법 (0) | 2021.06.10 |
포인터 사용 C# Pointer unsafe (0) | 2021.04.29 |