├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── Common ├── Packet32.h ├── WpcapNames.h └── dagc.h ├── Examples-pcap ├── GNUmakefile ├── MakeaAll.dsw ├── MakeaAll.sln ├── UDPdump │ ├── GNUmakefile │ ├── UDPdump.dsp │ ├── UDPdump.dsw │ ├── UDPdump.vcproj │ └── udpdump.c ├── basic_dump │ ├── GNUmakefile │ ├── basic_dump.c │ ├── basic_dump.dsp │ ├── basic_dump.dsw │ └── basic_dump.vcproj ├── basic_dump_ex │ ├── GNUmakefile │ ├── basic_dump_ex.c │ ├── basic_dump_ex.dsp │ ├── basic_dump_ex.dsw │ └── basic_dump_ex.vcproj ├── iflist │ ├── GNUmakefile │ ├── iflist.c │ ├── iflist.dsp │ ├── iflist.dsw │ └── iflist.vcproj ├── pcap_filter │ ├── GNUmakefile │ ├── Makefile.unix │ ├── pcap_filter.c │ ├── pcap_filter.dsp │ ├── pcap_filter.dsw │ └── pcap_filter.vcproj ├── pktdump_ex │ ├── GNUmakefile │ ├── pktdump_ex.c │ ├── pktdump_ex.dsp │ ├── pktdump_ex.dsw │ └── pktdump_ex.vcproj ├── readfile │ ├── GNUmakefile │ ├── readfile.c │ ├── readfile.dsp │ ├── readfile.dsw │ └── readfile.vcproj ├── readfile_ex │ ├── GNUmakefile │ ├── readfile_ex.c │ ├── readfile_ex.dsp │ ├── readfile_ex.dsw │ └── readfile_ex.vcproj ├── savedump │ ├── GNUmakefile │ ├── savedump.c │ ├── savedump.dsp │ ├── savedump.dsw │ └── savedump.vcproj ├── sendpack │ ├── GNUmakefile │ ├── sendpack.c │ ├── sendpack.dsp │ ├── sendpack.dsw │ └── sendpack.vcproj ├── stats │ ├── stats.c │ ├── stats.dsp │ └── stats.dsw └── winpcap_stress │ ├── winpcap_stress.c │ ├── winpcap_stress.dsp │ └── winpcap_stress.dsw ├── Examples ├── MakeAll.sln ├── MakeaAll.dsw ├── NETMETER │ ├── CapDll.h │ ├── CaptureThread.cpp │ ├── Console.h │ ├── LineColl.cpp │ ├── LineColl.h │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── NETMETER.CPP │ ├── NETMETER.H │ ├── ProgCaptDlg.h │ ├── SelectAdapter.cpp │ ├── SelectAdapter.h │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── netmeter.dsp │ ├── netmeter.dsw │ ├── netmeter.rc │ ├── netmeterDoc.cpp │ ├── netmeterDoc.h │ ├── netmeterView.cpp │ ├── netmeterView.h │ ├── res │ │ ├── BMP00001.BMP │ │ ├── bitmap1.bmp │ │ ├── bitmap2.bmp │ │ ├── cap_wizi.bmp │ │ ├── listbmp.bmp │ │ ├── netmeter.ico │ │ ├── netmeter.rc2 │ │ └── netmeterDoc.ico │ └── resource.h ├── PacketDriver │ ├── GetMacAddress │ │ ├── GetMacAddress.c │ │ ├── GetMacAddress.dsp │ │ └── GetMacAddress.vcproj │ ├── TestPacketCapture │ │ ├── TestPacketCapture.c │ │ ├── TestPacketCapture.dsp │ │ └── TestPacketCapture.vcproj │ ├── TestPacketSend │ │ ├── TestPacketSend.c │ │ ├── TestPacketSend.dsp │ │ └── TestPacketSend.vcproj │ └── readme.txt ├── UDPdump │ ├── UDPdump.dsp │ ├── UDPdump.dsw │ ├── UDPdump.vcproj │ └── udpdump.c ├── UserLevelBridge │ ├── UserBridge.c │ ├── UserBridge.dsp │ ├── UserBridge.dsw │ └── UserBridge.vcproj ├── iflist │ ├── iflist.c │ ├── iflist.dsp │ ├── iflist.dsw │ └── iflist.vcproj ├── kdump │ ├── kdump.c │ ├── kdump.dsp │ ├── kdump.dsw │ └── kdump.exe ├── misc │ ├── MakeAll.sln │ ├── MakeaAll.dsw │ ├── basic_dump.c │ ├── basic_dump.dsp │ ├── basic_dump.vcproj │ ├── basic_dump_ex.c │ ├── basic_dump_ex.dsp │ ├── basic_dump_ex.vcproj │ ├── readfile.c │ ├── readfile.dsp │ ├── readfile.vcproj │ ├── readfile_ex.c │ ├── readfile_ex.dsp │ ├── readfile_ex.vcproj │ ├── savedump.c │ ├── savedump.dsp │ ├── savedump.vcproj │ ├── sendpack.c │ ├── sendpack.dsp │ └── sendpack.vcproj ├── pcap_filter │ ├── pcap_filter.c │ ├── pcap_filter.dsp │ ├── pcap_filter.dsw │ └── pcap_filter.vcproj ├── pcap_fopen │ ├── pcap_fopen.cpp │ └── pcap_fopen.vcproj ├── pktdump_ex │ ├── pktdump_ex.c │ ├── pktdump_ex.dsp │ ├── pktdump_ex.dsw │ └── pktdump_ex.vcproj ├── sendcap │ ├── sencap.dsw │ ├── sendcap.c │ ├── sendcap.dsp │ └── sendcap.vcproj ├── smp_1 │ ├── smp_1.c │ ├── smp_1.dsp │ ├── smp_1.dsw │ └── smp_1.vcproj └── tcptop │ ├── tcptop.c │ ├── tcptop.dsp │ ├── tcptop.dsw │ └── tcptop.vcproj ├── LICENSE ├── Libpcap-License.txt ├── README.md ├── WinPcap-License-And-Acknowledgements.txt ├── appveyor.yml ├── build_sdk.bat ├── build_sdk.txt ├── create_docs.bat ├── create_examples.bat ├── create_include.bat ├── create_lib.bat ├── docs ├── Makefile ├── npcap-guide-wrapper.html ├── npcap-guide-wrapper.xml └── npcap-guide.xml ├── dox ├── WinPcap_docs.html ├── compile.htm ├── doxygen_groups.txt ├── doxygen_groups_packetdll.txt ├── footer.htm ├── internals-arch.gif ├── internals.htm ├── intro.htm ├── language.htm ├── libpcap │ ├── funcs │ │ └── pcap.h │ └── incs │ │ └── pcap.h ├── main.txt ├── main_packetdll.txt ├── note.txt ├── npf-dump.gif ├── npf-ndis.gif ├── npf-npf.gif ├── npf.htm ├── packet.htm ├── packet_samp.htm ├── pics │ ├── dump.gif │ ├── encoding.gif │ ├── stats.gif │ ├── stats_wpcap.gif │ ├── winpcap.gif │ └── winpcap_small.gif ├── prj │ ├── winpcap_c.dox │ ├── winpcap_c_packetdll.dox │ └── winpcap_noc.dox ├── slides.ppt ├── style.css ├── wpcap.htm ├── wpcap_remote.htm ├── wpcap_samp.htm ├── wpcap_samp1.htm ├── wpcap_samp2.htm ├── wpcap_tut.txt ├── wpcap_tut1.txt ├── wpcap_tut2.txt ├── wpcap_tut3.txt ├── wpcap_tut4.txt ├── wpcap_tut5.txt ├── wpcap_tut6.txt ├── wpcap_tut7.txt ├── wpcap_tut8.txt └── wpcap_tut9.txt ├── integrate_libpcap.bat ├── packetWin7 ├── Dll │ ├── AdInfo.cpp │ ├── Extra_lib_x64 │ │ └── npptools.lib │ ├── NpfImExt.cpp │ ├── NpfImExt.h │ ├── Packet.def │ ├── Packet32-Int.h │ ├── Packet32.cpp │ ├── Project │ │ ├── GNUmakefile │ │ ├── Packet.sln │ │ ├── Packet.vcxproj │ │ └── Packet.vcxproj.filters │ ├── ProtInstall.cpp │ ├── ProtInstall.h │ ├── WanPacket │ │ ├── WanPacket.cpp │ │ ├── WanPacket.def │ │ ├── WanPacket.dsp │ │ ├── WanPacket.dsw │ │ ├── WanPacket.h │ │ ├── version.rc │ │ └── version.rc2 │ ├── debug.h │ ├── netcfgapi.cpp │ ├── netcfgapi.h │ ├── strsafe.h │ ├── version.aps │ ├── version.rc │ └── version.rc2 ├── Helper │ ├── NpcapHelper.sln │ ├── NpcapHelper │ │ ├── NpcapHelper.cpp │ │ ├── NpcapHelper.vcxproj │ │ ├── NpcapHelper.vcxproj.filters │ │ ├── resource.h │ │ ├── version.rc │ │ └── version.rc2 │ ├── NpcapHelperTest │ │ ├── NpcapHelperTest.c │ │ ├── NpcapHelperTest.vcxproj │ │ └── NpcapHelperTest.vcxproj.filters │ └── debug.h ├── NPFInstall │ ├── NPFInstall.sln │ └── NPFInstall │ │ ├── CalloutInstall.cpp │ │ ├── CalloutInstall.h │ │ ├── DriverStoreClear.cpp │ │ ├── DriverStoreClear.h │ │ ├── LoopbackInstall.cpp │ │ ├── LoopbackInstall.h │ │ ├── LoopbackRecord.cpp │ │ ├── LoopbackRecord.h │ │ ├── LoopbackRename.cpp │ │ ├── LoopbackRename.h │ │ ├── LoopbackRename2.cpp │ │ ├── LoopbackRename2.h │ │ ├── NPFInstall.cpp │ │ ├── NPFInstall.exe.manifest.in │ │ ├── NPFInstall.vcxproj │ │ ├── NPFInstall.vcxproj.filters │ │ ├── ProcessUtil.cpp │ │ ├── ProcessUtil.h │ │ ├── RegKey.cpp │ │ ├── RegKey.h │ │ ├── RegUtil.cpp │ │ ├── RegUtil.h │ │ ├── WlanRecord.cpp │ │ ├── WlanRecord.h │ │ ├── msg.h │ │ ├── rc_ids.h │ │ ├── version.rc │ │ └── version.rc2 ├── WlanHelper │ ├── WlanHelper.sln │ └── WlanHelper │ │ ├── Tool.cpp │ │ ├── Tool.h │ │ ├── WlanHelper.cpp │ │ ├── WlanHelper.vcxproj │ │ ├── WlanHelper.vcxproj.filters │ │ ├── version.rc │ │ └── version.rc2 └── npf │ ├── npf Package │ └── npf Package.vcxproj │ ├── npf.sln │ └── npf │ ├── DEBUG.H │ ├── Lo_send.c │ ├── Lo_send.h │ ├── Loopback.c │ ├── Loopback.h │ ├── Openclos.c │ ├── Packet.c │ ├── Packet.h │ ├── Read.c │ ├── Write.c │ ├── bucket_lookup.c │ ├── bucket_lookup.h │ ├── count_packets.c │ ├── count_packets.h │ ├── dump.c │ ├── functions.c │ ├── functions.h │ ├── ieee80211_radiotap.h │ ├── ioctls.h │ ├── jitter.c │ ├── jitter.h │ ├── macros.h │ ├── memory_t.h │ ├── normal_lookup.c │ ├── normal_lookup.h │ ├── npcap.inf │ ├── npcap.rc │ ├── npcap_wfp.inf │ ├── npf.inf │ ├── npf.rc │ ├── npf.vcxproj │ ├── npf.vcxproj.filters │ ├── npf_wfp.inf │ ├── stdafx.h │ ├── tcp_session.c │ ├── tcp_session.h │ ├── time_calls.h │ ├── tme.c │ ├── tme.h │ ├── valid_insns.h │ ├── win_bpf.h │ ├── win_bpf_filter.c │ ├── win_bpf_filter_init.c │ └── win_bpf_filter_init.h ├── todo.txt ├── version.h └── wpcap └── Win32-Extensions ├── Win32-Extensions.c ├── Win32-Extensions.h ├── version.aps ├── version.rc └── version.rc2 /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.ncb 3 | *.suo 4 | *.sdf 5 | *.opensdf 6 | *.aps 7 | *.pdb 8 | *.exe 9 | *.msi 10 | *.zip 11 | *.ilk 12 | *.obj 13 | *.user 14 | *.cat 15 | *.sys 16 | *.dll 17 | *.ipch 18 | *.VC.db 19 | Debug/ 20 | Release/ 21 | Debug(*)/ 22 | Release(*)/ 23 | Vista Debug/ 24 | Vista Release/ 25 | Vista Debug(*)/ 26 | Vista Release(*)/ 27 | Win7 Debug/ 28 | Win7 Release/ 29 | Win7 Debug(*)/ 30 | Win7 Release(*)/ 31 | Win7 Release SDV/ 32 | Win7DebugAdmin-onlyMode/ 33 | Win7ReleaseAdmin-onlyMode/ 34 | sdv/ 35 | build.err 36 | build.log 37 | msbuild.log 38 | runsdvui.cmd 39 | SDV-default.xml 40 | sdv-user.sdv 41 | sdv-map.h 42 | staticdv.job 43 | StaticDVTrace.log 44 | npcap.res 45 | /installer/win10/ 46 | /installer/win10_winpcap/ 47 | /installer/win8_below/ 48 | /installer/win8_below_winpcap/ 49 | /installer/disk1/ 50 | /installer/setup.inf 51 | /installer/setup.rpt 52 | /npcap-sdk/ 53 | /dox/prj/ 54 | /packetWin7/Dll/Project/Debug*/ 55 | /packetWin7/Dll/Project/Release*/ 56 | /packetWin7/Dll/Project/x64/Debug*/ 57 | /packetWin7/Dll/Project/x64/Release*/ 58 | /wpcap/libpcap/Win32/Prj/Debug*/ 59 | /wpcap/libpcap/Win32/Prj/Release*/ 60 | *.VC.opendb 61 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "wpcap/libpcap"] 2 | path = wpcap/libpcap 3 | url = ../libpcap 4 | -------------------------------------------------------------------------------- /Examples-pcap/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | SUBDIRS = basic_dump basic_dump_ex iflist pcap_filter pktdump_ex readfile readfile_ex savedump sendpack UDPdump 5 | 6 | all clean install uninstall: ${SUBDIRS} 7 | for subdir in ${SUBDIRS}; do \ 8 | echo "Entering $$subdir"; \ 9 | (cd $$subdir && ${MAKE} $@) \ 10 | done; 11 | -------------------------------------------------------------------------------- /Examples-pcap/MakeaAll.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "UDPdump"=.\UDPdump\UDPdump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "basic_dump"=.\basic_dump\basic_dump.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "basic_dump_ex"=.\basic_dump_ex\basic_dump_ex.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "iflist"=.\iflist\iflist.dsp - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | Project: "pcap_filter"=.\pcap_filter\pcap_filter.dsp - Package Owner=<4> 55 | 56 | Package=<5> 57 | {{{ 58 | }}} 59 | 60 | Package=<4> 61 | {{{ 62 | }}} 63 | 64 | ############################################################################### 65 | 66 | Project: "pktdump_ex"=.\pktdump_ex\pktdump_ex.dsp - Package Owner=<4> 67 | 68 | Package=<5> 69 | {{{ 70 | }}} 71 | 72 | Package=<4> 73 | {{{ 74 | }}} 75 | 76 | ############################################################################### 77 | 78 | Project: "readfile"=.\readfile\readfile.dsp - Package Owner=<4> 79 | 80 | Package=<5> 81 | {{{ 82 | }}} 83 | 84 | Package=<4> 85 | {{{ 86 | }}} 87 | 88 | ############################################################################### 89 | 90 | Project: "readfile_ex"=.\readfile_ex\readfile_ex.dsp - Package Owner=<4> 91 | 92 | Package=<5> 93 | {{{ 94 | }}} 95 | 96 | Package=<4> 97 | {{{ 98 | }}} 99 | 100 | ############################################################################### 101 | 102 | Project: "savedump"=.\savedump\savedump.dsp - Package Owner=<4> 103 | 104 | Package=<5> 105 | {{{ 106 | }}} 107 | 108 | Package=<4> 109 | {{{ 110 | }}} 111 | 112 | ############################################################################### 113 | 114 | Project: "sendpack"=.\sendpack\sendpack.dsp - Package Owner=<4> 115 | 116 | Package=<5> 117 | {{{ 118 | }}} 119 | 120 | Package=<4> 121 | {{{ 122 | }}} 123 | 124 | ############################################################################### 125 | 126 | Global: 127 | 128 | Package=<5> 129 | {{{ 130 | }}} 131 | 132 | Package=<3> 133 | {{{ 134 | }}} 135 | 136 | ############################################################################### 137 | 138 | -------------------------------------------------------------------------------- /Examples-pcap/UDPdump/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Loris Degioanni 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = udpdump.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap -lwsock32 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o udpdump.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} udpdump.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/UDPdump/UDPdump.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "UDPdump"=.\UDPdump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = basic_dump.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o basic_dump.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} basic_dump.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump/basic_dump.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | /* 3 | * we do not want the warnings about the old deprecated and unsecure CRT functions 4 | * since these examples can be compiled under *nix as well 5 | */ 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #endif 8 | 9 | #include "pcap.h" 10 | 11 | /* prototype of the packet handler */ 12 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 13 | 14 | int main() 15 | { 16 | pcap_if_t *alldevs; 17 | pcap_if_t *d; 18 | int inum; 19 | int i=0; 20 | pcap_t *adhandle; 21 | char errbuf[PCAP_ERRBUF_SIZE]; 22 | 23 | /* Retrieve the device list */ 24 | if(pcap_findalldevs(&alldevs, errbuf) == -1) 25 | { 26 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 27 | exit(1); 28 | } 29 | 30 | /* Print the list */ 31 | for(d=alldevs; d; d=d->next) 32 | { 33 | printf("%d. %s", ++i, d->name); 34 | if (d->description) 35 | printf(" (%s)\n", d->description); 36 | else 37 | printf(" (No description available)\n"); 38 | } 39 | 40 | if(i==0) 41 | { 42 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 43 | return -1; 44 | } 45 | 46 | printf("Enter the interface number (1-%d):",i); 47 | scanf("%d", &inum); 48 | 49 | if(inum < 1 || inum > i) 50 | { 51 | printf("\nInterface number out of range.\n"); 52 | /* Free the device list */ 53 | pcap_freealldevs(alldevs); 54 | return -1; 55 | } 56 | 57 | /* Jump to the selected adapter */ 58 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 59 | 60 | /* Open the device */ 61 | /* Open the adapter */ 62 | if ((adhandle= pcap_open_live(d->name, // name of the device 63 | 65536, // portion of the packet to capture. 64 | // 65536 grants that the whole packet will be captured on all the MACs. 65 | 1, // promiscuous mode (nonzero means promiscuous) 66 | 1000, // read timeout 67 | errbuf // error buffer 68 | )) == NULL) 69 | { 70 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name); 71 | /* Free the device list */ 72 | pcap_freealldevs(alldevs); 73 | return -1; 74 | } 75 | 76 | printf("\nlistening on %s...\n", d->description); 77 | 78 | /* At this point, we don't need any more the device list. Free it */ 79 | pcap_freealldevs(alldevs); 80 | 81 | /* start the capture */ 82 | pcap_loop(adhandle, 0, packet_handler, NULL); 83 | 84 | pcap_close(adhandle); 85 | return 0; 86 | } 87 | 88 | 89 | /* Callback function invoked by libpcap for every incoming packet */ 90 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data) 91 | { 92 | struct tm *ltime; 93 | char timestr[16]; 94 | time_t local_tv_sec; 95 | 96 | /* 97 | * unused parameters 98 | */ 99 | (VOID)(param); 100 | (VOID)(pkt_data); 101 | 102 | /* convert the timestamp to readable format */ 103 | local_tv_sec = header->ts.tv_sec; 104 | ltime=localtime(&local_tv_sec); 105 | strftime( timestr, sizeof timestr, "%H:%M:%S", ltime); 106 | 107 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 108 | 109 | } 110 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump/basic_dump.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "basic_dump"=.\basic_dump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump_ex/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = basic_dump_ex.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o basic_dump_ex.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} basic_dump_ex.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump_ex/basic_dump_ex.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | /* 3 | * we do not want the warnings about the old deprecated and unsecure CRT functions 4 | * since these examples can be compiled under *nix as well 5 | */ 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #endif 8 | 9 | #include "pcap.h" 10 | 11 | int main() 12 | { 13 | pcap_if_t *alldevs; 14 | pcap_if_t *d; 15 | int inum; 16 | int i=0; 17 | pcap_t *adhandle; 18 | int res; 19 | char errbuf[PCAP_ERRBUF_SIZE]; 20 | struct tm *ltime; 21 | char timestr[16]; 22 | struct pcap_pkthdr *header; 23 | const u_char *pkt_data; 24 | time_t local_tv_sec; 25 | 26 | 27 | /* Retrieve the device list */ 28 | if(pcap_findalldevs(&alldevs, errbuf) == -1) 29 | { 30 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 31 | return -1; 32 | } 33 | 34 | /* Print the list */ 35 | for(d=alldevs; d; d=d->next) 36 | { 37 | printf("%d. %s", ++i, d->name); 38 | if (d->description) 39 | printf(" (%s)\n", d->description); 40 | else 41 | printf(" (No description available)\n"); 42 | } 43 | 44 | if(i==0) 45 | { 46 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 47 | return -1; 48 | } 49 | 50 | printf("Enter the interface number (1-%d):",i); 51 | scanf("%d", &inum); 52 | 53 | if(inum < 1 || inum > i) 54 | { 55 | printf("\nInterface number out of range.\n"); 56 | /* Free the device list */ 57 | pcap_freealldevs(alldevs); 58 | return -1; 59 | } 60 | 61 | /* Jump to the selected adapter */ 62 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 63 | 64 | /* Open the adapter */ 65 | if ((adhandle= pcap_open_live(d->name, // name of the device 66 | 65536, // portion of the packet to capture. 67 | // 65536 grants that the whole packet will be captured on all the MACs. 68 | 1, // promiscuous mode (nonzero means promiscuous) 69 | 1000, // read timeout 70 | errbuf // error buffer 71 | )) == NULL) 72 | { 73 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name); 74 | /* Free the device list */ 75 | pcap_freealldevs(alldevs); 76 | return -1; 77 | } 78 | 79 | printf("\nlistening on %s...\n", d->description); 80 | 81 | /* At this point, we don't need any more the device list. Free it */ 82 | pcap_freealldevs(alldevs); 83 | 84 | /* Retrieve the packets */ 85 | while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){ 86 | 87 | if(res == 0) 88 | /* Timeout elapsed */ 89 | continue; 90 | 91 | /* convert the timestamp to readable format */ 92 | local_tv_sec = header->ts.tv_sec; 93 | ltime=localtime(&local_tv_sec); 94 | strftime( timestr, sizeof timestr, "%H:%M:%S", ltime); 95 | 96 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 97 | } 98 | 99 | if(res == -1){ 100 | printf("Error reading the packets: %s\n", pcap_geterr(adhandle)); 101 | return -1; 102 | } 103 | 104 | pcap_close(adhandle); 105 | return 0; 106 | } 107 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump_ex/basic_dump_ex.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "basic_dump_ex"=.\basic_dump_ex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/iflist/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = iflist.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o iflist.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} iflist.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/iflist/iflist.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "iflist"=.\iflist.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/pcap_filter/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = pcap_filter.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o pf.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} pf.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/pcap_filter/Makefile.unix: -------------------------------------------------------------------------------- 1 | 2 | CC = gcc 3 | INCLDIR = -I /usr/src/sys 4 | LIBS = -lpcap 5 | 6 | pktdump: pcap_filter.o 7 | $(CC) $(INCLDIR) pcap_filter.o $(LIBS) -o pf 8 | rm *.o 9 | 10 | -------------------------------------------------------------------------------- /Examples-pcap/pcap_filter/pcap_filter.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "pcap_filter"=.\pcap_filter.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/pktdump_ex/GNUmakefile: -------------------------------------------------------------------------------- 1 | PCAP_PATH = ../../lib 2 | CFLAGS = -g -O -mno-cygwin -I ../../include 3 | 4 | OBJS = pktdump_ex.o 5 | LIBS = -L ${PCAP_PATH} -lwpcap 6 | 7 | all: ${OBJS} 8 | ${CC} ${CFLAGS} -o pktdump_ex.exe ${OBJS} ${LIBS} 9 | 10 | clean: 11 | rm -f ${OBJS} pktdump_ex.exe 12 | 13 | .c.o: 14 | ${CC} ${CFLAGS} -c -o $*.o $< 15 | -------------------------------------------------------------------------------- /Examples-pcap/pktdump_ex/pktdump_ex.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "pktdump_ex"=.\pktdump_ex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/readfile/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = readfile.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o readfile.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} readfile.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/readfile/readfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define LINE_LEN 16 5 | 6 | void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *); 7 | 8 | int main(int argc, char **argv) 9 | { 10 | pcap_t *fp; 11 | char errbuf[PCAP_ERRBUF_SIZE]; 12 | 13 | if(argc != 2) 14 | { 15 | printf("usage: %s filename", argv[0]); 16 | return -1; 17 | 18 | } 19 | 20 | /* Open the capture file */ 21 | if ((fp = pcap_open_offline(argv[1], // name of the device 22 | errbuf // error buffer 23 | )) == NULL) 24 | { 25 | fprintf(stderr,"\nUnable to open the file %s.\n", argv[1]); 26 | return -1; 27 | } 28 | 29 | /* read and dispatch packets until EOF is reached */ 30 | pcap_loop(fp, 0, dispatcher_handler, NULL); 31 | 32 | pcap_close(fp); 33 | return 0; 34 | } 35 | 36 | 37 | 38 | void dispatcher_handler(u_char *temp1, 39 | const struct pcap_pkthdr *header, 40 | const u_char *pkt_data) 41 | { 42 | u_int i=0; 43 | 44 | /* 45 | * unused variable 46 | */ 47 | (VOID*)temp1; 48 | 49 | /* print pkt timestamp and pkt len */ 50 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 51 | 52 | /* Print the packet */ 53 | for (i=1; (i < header->caplen + 1 ) ; i++) 54 | { 55 | printf("%.2x ", pkt_data[i-1]); 56 | if ( (i % LINE_LEN) == 0) printf("\n"); 57 | } 58 | 59 | printf("\n\n"); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Examples-pcap/readfile/readfile.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "readfile"=.\readfile.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/readfile_ex/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = readfile_ex.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o readfile_ex.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} readfile_ex.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/readfile_ex/readfile_ex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define LINE_LEN 16 5 | 6 | int main(int argc, char **argv) 7 | { 8 | pcap_t *fp; 9 | char errbuf[PCAP_ERRBUF_SIZE]; 10 | struct pcap_pkthdr *header; 11 | const u_char *pkt_data; 12 | u_int i=0; 13 | int res; 14 | 15 | if(argc != 2) 16 | { 17 | printf("usage: %s filename", argv[0]); 18 | return -1; 19 | 20 | } 21 | 22 | /* Open the capture file */ 23 | if ((fp = pcap_open_offline(argv[1], // name of the device 24 | errbuf // error buffer 25 | )) == NULL) 26 | { 27 | fprintf(stderr,"\nUnable to open the file %s.\n", argv[1]); 28 | return -1; 29 | } 30 | 31 | /* Retrieve the packets from the file */ 32 | while((res = pcap_next_ex(fp, &header, &pkt_data)) >= 0) 33 | { 34 | /* print pkt timestamp and pkt len */ 35 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 36 | 37 | /* Print the packet */ 38 | for (i=1; (i < header->caplen + 1 ) ; i++) 39 | { 40 | printf("%.2x ", pkt_data[i-1]); 41 | if ( (i % LINE_LEN) == 0) printf("\n"); 42 | } 43 | 44 | printf("\n\n"); 45 | } 46 | 47 | 48 | if (res == -1) 49 | { 50 | printf("Error reading the packets: %s\n", pcap_geterr(fp)); 51 | } 52 | 53 | pcap_close(fp); 54 | return 0; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Examples-pcap/readfile_ex/readfile_ex.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "readfile_ex"=.\readfile_ex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/savedump/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = savedump.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o savedump.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} savedump.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/savedump/savedump.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | /* 3 | * we do not want the warnings about the old deprecated and unsecure CRT functions 4 | * since these examples can be compiled under *nix as well 5 | */ 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #endif 8 | 9 | #include "pcap.h" 10 | 11 | /* prototype of the packet handler */ 12 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 13 | 14 | int main(int argc, char **argv) 15 | { 16 | pcap_if_t *alldevs; 17 | pcap_if_t *d; 18 | int inum; 19 | int i=0; 20 | pcap_t *adhandle; 21 | char errbuf[PCAP_ERRBUF_SIZE]; 22 | pcap_dumper_t *dumpfile; 23 | 24 | 25 | /* Check command line */ 26 | if(argc != 2) 27 | { 28 | printf("usage: %s filename", argv[0]); 29 | return -1; 30 | } 31 | 32 | /* Retrieve the device list on the local machine */ 33 | if (pcap_findalldevs(&alldevs, errbuf) == -1) 34 | { 35 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 36 | exit(1); 37 | } 38 | 39 | /* Print the list */ 40 | for(d=alldevs; d; d=d->next) 41 | { 42 | printf("%d. %s", ++i, d->name); 43 | if (d->description) 44 | printf(" (%s)\n", d->description); 45 | else 46 | printf(" (No description available)\n"); 47 | } 48 | 49 | if(i==0) 50 | { 51 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 52 | return -1; 53 | } 54 | 55 | printf("Enter the interface number (1-%d):",i); 56 | scanf("%d", &inum); 57 | 58 | if(inum < 1 || inum > i) 59 | { 60 | printf("\nInterface number out of range.\n"); 61 | /* Free the device list */ 62 | pcap_freealldevs(alldevs); 63 | return -1; 64 | } 65 | 66 | /* Jump to the selected adapter */ 67 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 68 | 69 | 70 | /* Open the adapter */ 71 | if ((adhandle= pcap_open_live(d->name, // name of the device 72 | 65536, // portion of the packet to capture. 73 | // 65536 grants that the whole packet will be captured on all the MACs. 74 | 1, // promiscuous mode (nonzero means promiscuous) 75 | 1000, // read timeout 76 | errbuf // error buffer 77 | )) == NULL) 78 | { 79 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name); 80 | /* Free the device list */ 81 | pcap_freealldevs(alldevs); 82 | return -1; 83 | } 84 | 85 | /* Open the dump file */ 86 | dumpfile = pcap_dump_open(adhandle, argv[1]); 87 | 88 | if(dumpfile==NULL) 89 | { 90 | fprintf(stderr,"\nError opening output file\n"); 91 | return -1; 92 | } 93 | 94 | printf("\nlistening on %s... Press Ctrl+C to stop...\n", d->description); 95 | 96 | /* At this point, we no longer need the device list. Free it */ 97 | pcap_freealldevs(alldevs); 98 | 99 | /* start the capture */ 100 | pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile); 101 | 102 | pcap_close(adhandle); 103 | return 0; 104 | } 105 | 106 | /* Callback function invoked by libpcap for every incoming packet */ 107 | void packet_handler(u_char *dumpfile, const struct pcap_pkthdr *header, const u_char *pkt_data) 108 | { 109 | /* save the packet on the dump file */ 110 | pcap_dump(dumpfile, header, pkt_data); 111 | } 112 | -------------------------------------------------------------------------------- /Examples-pcap/savedump/savedump.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "savedump"=.\savedump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/sendpack/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = sendpack.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o sendpack.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} sendpack.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/sendpack/sendpack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | int main(int argc, char **argv) 8 | { 9 | pcap_t *fp; 10 | char errbuf[PCAP_ERRBUF_SIZE]; 11 | u_char packet[100]; 12 | int i; 13 | 14 | /* Check the validity of the command line */ 15 | if (argc != 2) 16 | { 17 | printf("usage: %s interface", argv[0]); 18 | return 1; 19 | } 20 | 21 | /* Open the adapter */ 22 | if ((fp = pcap_open_live(argv[1], // name of the device 23 | 65536, // portion of the packet to capture. It doesn't matter in this case 24 | 1, // promiscuous mode (nonzero means promiscuous) 25 | 1000, // read timeout 26 | errbuf // error buffer 27 | )) == NULL) 28 | { 29 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[1]); 30 | return 2; 31 | } 32 | 33 | /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */ 34 | packet[0]=1; 35 | packet[1]=1; 36 | packet[2]=1; 37 | packet[3]=1; 38 | packet[4]=1; 39 | packet[5]=1; 40 | 41 | /* set mac source to 2:2:2:2:2:2 */ 42 | packet[6]=2; 43 | packet[7]=2; 44 | packet[8]=2; 45 | packet[9]=2; 46 | packet[10]=2; 47 | packet[11]=2; 48 | 49 | /* Fill the rest of the packet */ 50 | for(i=12;i<100;i++) 51 | { 52 | packet[i]= (u_char)i; 53 | } 54 | 55 | /* Send down the packet */ 56 | if (pcap_sendpacket(fp, // Adapter 57 | packet, // buffer with the packet 58 | 100 // size 59 | ) != 0) 60 | { 61 | fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp)); 62 | return 3; 63 | } 64 | 65 | pcap_close(fp); 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Examples-pcap/sendpack/sendpack.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "sendpack"=.\sendpack.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/stats/stats.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "stats"=.\stats.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples-pcap/winpcap_stress/winpcap_stress.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "winpcap_stress"=.\winpcap_stress.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/NETMETER/CapDll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | 35 | #if !defined(AFX_CapDll_H__03FA9206_C8EA_11D2_B729_0048540133F7__INCLUDED_) 36 | #define AFX_CapDll_H__03FA9206_C8EA_11D2_B729_0048540133F7__INCLUDED_ 37 | 38 | #if _MSC_VER >= 1000 39 | #pragma once 40 | #endif // _MSC_VER >= 1000 41 | 42 | #ifndef __AFXWIN_H__ 43 | #error include 'stdafx.h' before including this file for PCH 44 | #endif 45 | 46 | #include "resource.h" // main symbols 47 | #define MaxCapPars 10 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // CCapDll: 51 | // See CapDll.cpp for the implementation of this class 52 | // 53 | #ifdef _EXPORTING 54 | #define CLASS_DECLSPEC __declspec(dllexport) 55 | #else 56 | #define CLASS_DECLSPEC __declspec(dllimport) 57 | #endif 58 | 59 | void CLASS_DECLSPEC InitCapDll(const char* INI); 60 | 61 | class CLASS_DECLSPEC CCapDll 62 | { 63 | public: 64 | CCapDll(); 65 | const char* GetFileName(); 66 | char* SetFileName(const char* fn); 67 | const char* GetAdapter(); 68 | const char* GetPath(); 69 | const char* GetFilter(); 70 | char* SetPath(const char * p); 71 | char* SetAdapter(const char* ad); 72 | char* SetFilter(const char* ad); 73 | int CaptureDialog(const char* Adapter,const char* P, CWnd* mw); 74 | int ChooseAdapter(const char* Adapter, CWnd* mw); 75 | const char* Capture(const char* file, CWnd* mw); 76 | ~CCapDll(); 77 | private: 78 | char* Path; 79 | char* Adapter; 80 | char* FileName; 81 | char* Filter; 82 | int bufdim; 83 | int ncapture; 84 | int snaplen; 85 | int promisquous; 86 | void LoadCmds(); 87 | CString RetrieveValue(CString keyval); 88 | }; 89 | 90 | 91 | ///////////////////////////////////////////////////////////////////////////// 92 | 93 | //{{AFX_INSERT_LOCATION}} 94 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 95 | 96 | #endif // !defined(AFX_CapDll_H__03FA9206_C8EA_11D2_B729_0048540133F7__INCLUDED_) 97 | -------------------------------------------------------------------------------- /Examples/NETMETER/CaptureThread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "stdafx.h" 35 | #include "resource.h" 36 | #include "capdll.h" 37 | #include "console.h" 38 | 39 | HANDLE in,out,err; 40 | 41 | DWORD d; 42 | CCapPars* pObject; 43 | CRITICAL_SECTION Crit; 44 | 45 | // callback routine called by libpcap for every incoming packet 46 | void dispatcher_handler(u_char *pParam,const struct pcap_pkthdr *header, const u_char *pkt_data) 47 | { 48 | UINT delay; 49 | LARGE_INTEGER Bps,Pps; 50 | CCapPars* pObject; 51 | 52 | pObject=(CCapPars*)pParam; 53 | //Calculate the delay in microseconds from the last sample. 54 | //This value is obtained from the timestamp that the capture driver 55 | //associates to the sample. 56 | delay=(header->ts.tv_sec-pObject->lasttime.tv_sec)*1000000-pObject->lasttime.tv_usec+header->ts.tv_usec; 57 | //get the number of Bits per second 58 | Bps.QuadPart=(((LONGLONG)(*(LONGLONG*)(pkt_data+8))*80)/(delay)); 59 | //get the number of Packets per second 60 | Pps.QuadPart=(((LONGLONG)(*(LONGLONG*)(pkt_data))*100000000)/((LONGLONG)delay*14880)); 61 | 62 | //store current timestamp 63 | pObject->lasttime.tv_sec=header->ts.tv_sec; 64 | pObject->lasttime.tv_usec=header->ts.tv_usec; 65 | 66 | pObject->prg->DrawBoard(&(pObject->prg->DrawBuffer),pObject->prg->wrett,Bps.LowPart,Pps.LowPart); 67 | } 68 | 69 | //main thread procedure: launches the capture and wait 70 | UINT MyThreadProc( LPVOID pParam ) 71 | { 72 | int i; 73 | 74 | if (pParam == NULL) 75 | return -1; // illegal parameter 76 | pObject=(CCapPars*)pParam; 77 | 78 | //reset the timer 79 | pObject->lasttime.tv_sec=0; 80 | pObject->lasttime.tv_usec=0; 81 | 82 | //start the capture loop 83 | i = pcap_loop(pObject->fp, 0, dispatcher_handler, (PUCHAR)pParam); 84 | 85 | Sleep(INFINITE); 86 | 87 | return 0; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /Examples/NETMETER/Console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "..\..\include\pcap.h" 35 | #include "netmeterDoc.h" 36 | #include "netmeterView.h" 37 | 38 | UINT MyThreadProc( LPVOID pParam ); 39 | 40 | typedef struct CCapPars 41 | { 42 | CNetmeterView* prg; //CNetmeterView class that launched the capture thread 43 | pcap_t *fp; //libpcap adapter 44 | struct timeval lasttime; //last capture time (internal) 45 | }CCapPars; 46 | -------------------------------------------------------------------------------- /Examples/NETMETER/LineColl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "LineColl.h" 35 | 36 | #ifdef _DEBUG 37 | #undef THIS_FILE 38 | static char THIS_FILE[]=__FILE__; 39 | #define new DEBUG_NEW 40 | #endif 41 | 42 | ////////////////////////////////////////////////////////////////////// 43 | // Construction/Destruction 44 | ////////////////////////////////////////////////////////////////////// 45 | 46 | LineCollection::LineCollection(CString *s,int skip) 47 | { 48 | m_Skip=skip; 49 | if(s==NULL) return; 50 | *this=*s; 51 | } 52 | 53 | LineCollection::LineCollection(CArchive &ar,int skip) 54 | { 55 | if (ar.IsStoring()) 56 | { 57 | return; 58 | } 59 | else 60 | { 61 | m_Skip=skip; 62 | CString s; 63 | int i,j; 64 | vect.SetSize(0); 65 | for(i=0,j=0;ar.ReadString(s);i++) 66 | { 67 | if(m_Skip && s=="") continue; 68 | vect.SetSize(j+1); 69 | vect[j]=s; 70 | j++; 71 | } 72 | } 73 | } 74 | 75 | LineCollection::~LineCollection() 76 | { 77 | } 78 | 79 | int LineCollection::GetSize() 80 | { 81 | return vect.GetSize(); 82 | } 83 | 84 | CString & LineCollection::operator =(CString &s) 85 | { 86 | int i,l,n,t=0; 87 | l=s.GetLength(); 88 | vect.SetSize(0); 89 | for(i=0,n=0;i0 && (s)[i-1]=='\n') continue; 94 | vect.SetSize(t+1); 95 | vect[t]=(s).Mid(n,i-n-1); 96 | t++; 97 | n=i+1; 98 | } 99 | } 100 | return s; 101 | } 102 | 103 | void LineCollection::clear() 104 | { 105 | vect.SetSize(0); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Examples/NETMETER/LineColl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #if !defined(AFX_LINECOLL_H__EE11D4A3_ED58_11D1_939A_000000000000__INCLUDED_) 35 | #define AFX_LINECOLL_H__EE11D4A3_ED58_11D1_939A_000000000000__INCLUDED_ 36 | 37 | #if _MSC_VER >= 1000 38 | #pragma once 39 | #endif // _MSC_VER >= 1000 40 | 41 | #include 42 | #include 43 | 44 | class LineCollection 45 | { 46 | public: 47 | void clear(); 48 | CString & operator =(CString &); 49 | int GetSize(); 50 | int getLineCount(){return GetSize();}; 51 | const char* line(int i){if (i vect; 59 | }; 60 | 61 | #endif // !defined(AFX_LINECOLL_H__EE11D4A3_ED58_11D1_939A_000000000000__INCLUDED_) 62 | -------------------------------------------------------------------------------- /Examples/NETMETER/MainFrm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "stdafx.h" 35 | #include "netmeter.h" 36 | 37 | #include "MainFrm.h" 38 | 39 | #ifdef _DEBUG 40 | #define new DEBUG_NEW 41 | #undef THIS_FILE 42 | static char THIS_FILE[] = __FILE__; 43 | #endif 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | // CMainFrame 47 | 48 | IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 49 | 50 | BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 51 | //{{AFX_MSG_MAP(CMainFrame) 52 | //}}AFX_MSG_MAP 53 | END_MESSAGE_MAP() 54 | 55 | ///////////////////////////////////////////////////////////////////////////// 56 | // CMainFrame construction/destruction 57 | 58 | CMainFrame::CMainFrame() 59 | { 60 | } 61 | 62 | CMainFrame::~CMainFrame() 63 | { 64 | } 65 | 66 | BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 67 | { 68 | if( !CFrameWnd::PreCreateWindow(cs) ) 69 | return FALSE; 70 | 71 | cs.style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; 72 | cs.cx=260; 73 | cs.cy=180; 74 | 75 | return TRUE; 76 | } 77 | 78 | ///////////////////////////////////////////////////////////////////////////// 79 | // CMainFrame diagnostics 80 | 81 | #ifdef _DEBUG 82 | void CMainFrame::AssertValid() const 83 | { 84 | CFrameWnd::AssertValid(); 85 | } 86 | 87 | void CMainFrame::Dump(CDumpContext& dc) const 88 | { 89 | CFrameWnd::Dump(dc); 90 | } 91 | 92 | #endif //_DEBUG 93 | -------------------------------------------------------------------------------- /Examples/NETMETER/MainFrm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // MainFrm.h : interface of the CMainFrame class 35 | // 36 | ///////////////////////////////////////////////////////////////////////////// 37 | 38 | #if !defined(AFX_MAINFRM_H__3BF6CD27_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 39 | #define AFX_MAINFRM_H__3BF6CD27_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 40 | 41 | #if _MSC_VER > 1000 42 | #pragma once 43 | #endif // _MSC_VER > 1000 44 | 45 | class CMainFrame : public CFrameWnd 46 | { 47 | 48 | protected: // create from serialization only 49 | CMainFrame(); 50 | DECLARE_DYNCREATE(CMainFrame) 51 | 52 | // Attributes 53 | public: 54 | 55 | // Operations 56 | public: 57 | 58 | // Overrides 59 | // ClassWizard generated virtual function overrides 60 | //{{AFX_VIRTUAL(CMainFrame) 61 | public: 62 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 63 | //}}AFX_VIRTUAL 64 | 65 | // Implementation 66 | public: 67 | virtual ~CMainFrame(); 68 | #ifdef _DEBUG 69 | virtual void AssertValid() const; 70 | virtual void Dump(CDumpContext& dc) const; 71 | #endif 72 | 73 | // Generated message map functions 74 | protected: 75 | //{{AFX_MSG(CMainFrame) 76 | //}}AFX_MSG 77 | DECLARE_MESSAGE_MAP() 78 | }; 79 | 80 | ///////////////////////////////////////////////////////////////////////////// 81 | 82 | //{{AFX_INSERT_LOCATION}} 83 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 84 | 85 | #endif // !defined(AFX_MAINFRM_H__3BF6CD27_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 86 | -------------------------------------------------------------------------------- /Examples/NETMETER/NETMETER.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // netmeter.h : main header file for the NETMETER application 35 | // 36 | 37 | #if !defined(AFX_NETMETER_H__3BF6CD23_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 38 | #define AFX_NETMETER_H__3BF6CD23_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 39 | 40 | #if _MSC_VER > 1000 41 | #pragma once 42 | #endif // _MSC_VER > 1000 43 | 44 | #ifndef __AFXWIN_H__ 45 | #error include 'stdafx.h' before including this file for PCH 46 | #endif 47 | 48 | #include "resource.h" // main symbols 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // CNetmeterApp: 52 | // See netmeter.cpp for the implementation of this class 53 | // 54 | 55 | class CNetmeterApp : public CWinApp 56 | { 57 | public: 58 | CNetmeterApp(); 59 | 60 | // Overrides 61 | // ClassWizard generated virtual function overrides 62 | //{{AFX_VIRTUAL(CNetmeterApp) 63 | public: 64 | virtual BOOL InitInstance(); 65 | //}}AFX_VIRTUAL 66 | 67 | // Implementation 68 | //{{AFX_MSG(CNetmeterApp) 69 | afx_msg void OnAppAbout(); 70 | //}}AFX_MSG 71 | DECLARE_MESSAGE_MAP() 72 | }; 73 | 74 | 75 | ///////////////////////////////////////////////////////////////////////////// 76 | 77 | //{{AFX_INSERT_LOCATION}} 78 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 79 | 80 | #endif // !defined(AFX_NETMETER_H__3BF6CD23_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 81 | -------------------------------------------------------------------------------- /Examples/NETMETER/ProgCaptDlg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | 35 | #if !defined(AFX_PROGCAPTDLG_H__D79DA3C4_3B52_11D2_9482_0020AF2A4474__INCLUDED_) 36 | #define AFX_PROGCAPTDLG_H__D79DA3C4_3B52_11D2_9482_0020AF2A4474__INCLUDED_ 37 | 38 | #if _MSC_VER >= 1000 39 | #pragma once 40 | #endif // _MSC_VER >= 1000 41 | // ProgCaptDlg.h : header file 42 | // 43 | #include "..\..\include\pcap-c.h" 44 | 45 | class CCapPars; 46 | 47 | ///////////////////////////////////////////////////////////////////////////// 48 | // CProgCaptDlg dialog 49 | 50 | class CProgCaptDlg : public CDialog 51 | { 52 | // Construction 53 | public: 54 | CProgCaptDlg(CWnd* pParent = NULL); // standard constructor 55 | CCapPars* m_Main; 56 | int npc; 57 | int init; 58 | pcap_t *fp; 59 | pcap_dumper_t *dumpfile; 60 | 61 | 62 | // Dialog Data 63 | //{{AFX_DATA(CProgCaptDlg) 64 | enum { IDD = IDD_CAP_BUSY }; 65 | CStatic m_Static; 66 | CProgressCtrl m_Progress; 67 | //}}AFX_DATA 68 | 69 | 70 | // Overrides 71 | // ClassWizard generated virtual function overrides 72 | //{{AFX_VIRTUAL(CProgCaptDlg) 73 | public: 74 | virtual BOOL PreTranslateMessage(MSG* pMsg); 75 | protected: 76 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 77 | //}}AFX_VIRTUAL 78 | 79 | // Implementation 80 | protected: 81 | int p; 82 | int v; 83 | 84 | // Generated message map functions 85 | //{{AFX_MSG(CProgCaptDlg) 86 | virtual BOOL OnInitDialog(); 87 | virtual void OnCancel(); 88 | //}}AFX_MSG 89 | DECLARE_MESSAGE_MAP() 90 | }; 91 | 92 | //{{AFX_INSERT_LOCATION}} 93 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 94 | 95 | #endif // !defined(AFX_PROGCAPTDLG_H__D79DA3C4_3B52_11D2_9482_0020AF2A4474__INCLUDED_) 96 | -------------------------------------------------------------------------------- /Examples/NETMETER/SelectAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #if !defined(AFX_SELECTADAPTER_H__D41A3004_2B3D_11D0_9528_0020AF2A4474__INCLUDED_) 35 | #define AFX_SELECTADAPTER_H__D41A3004_2B3D_11D0_9528_0020AF2A4474__INCLUDED_ 36 | 37 | #if _MSC_VER >= 1000 38 | #pragma once 39 | #endif // _MSC_VER >= 1000 40 | // SelectAdapter.h : header file 41 | // 42 | 43 | #include "linecoll.h" 44 | #include "resource.h" 45 | 46 | ///////////////////////////////////////////////////////////////////////////// 47 | // CSelectAdapter dialog 48 | 49 | int ExecuteApp(CString & s); 50 | 51 | class CSelectAdapter : public CDialog 52 | { 53 | // Construction 54 | public: 55 | CSelectAdapter(CWnd* pParent = NULL); // standard constructor 56 | 57 | // Dialog Data 58 | //{{AFX_DATA(CSelectAdapter) 59 | enum { IDD = IDD_ADAPTER }; 60 | CStatic m_CAdapter; 61 | CListCtrl m_ListCtrl; 62 | //}}AFX_DATA 63 | CString m_Adapter; 64 | CString m_Cmd; 65 | CImageList m_ctlImage; 66 | 67 | // Overrides 68 | // ClassWizard generated virtual function overrides 69 | //{{AFX_VIRTUAL(CSelectAdapter) 70 | protected: 71 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 72 | //}}AFX_VIRTUAL 73 | 74 | // Implementation 75 | protected: 76 | void Update(LineCollection &lc); 77 | void AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex=-1); 78 | void SelectItem(int i); 79 | 80 | // Generated message map functions 81 | //{{AFX_MSG(CSelectAdapter) 82 | virtual BOOL OnInitDialog(); 83 | virtual void OnOK(); 84 | afx_msg void OnSelectItem(NMHDR* pNMHDR, LRESULT* pResult); 85 | afx_msg void Ondblclickitem(NMHDR* pNMHDR, LRESULT* pResult); 86 | //}}AFX_MSG 87 | DECLARE_MESSAGE_MAP() 88 | }; 89 | 90 | //{{AFX_INSERT_LOCATION}} 91 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 92 | 93 | #endif // !defined(AFX_SELECTADAPTER_H__D41A3004_2B3D_11D0_9528_0020AF2A4474__INCLUDED_) 94 | -------------------------------------------------------------------------------- /Examples/NETMETER/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // stdafx.cpp : source file that includes just the standard includes 35 | // netmeter.pch will be the pre-compiled header 36 | // stdafx.obj will contain the pre-compiled type information 37 | 38 | #include "stdafx.h" 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Examples/NETMETER/StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__3BF6CD25_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 7 | #define AFX_STDAFX_H__3BF6CD25_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | #include // MFC core and standard components 16 | #include // MFC extensions 17 | #include // MFC support for Internet Explorer 4 Common Controls 18 | #ifndef _AFX_NO_AFXCMN_SUPPORT 19 | #include // MFC support for Windows Common Controls 20 | #endif // _AFX_NO_AFXCMN_SUPPORT 21 | 22 | 23 | //{{AFX_INSERT_LOCATION}} 24 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 25 | 26 | #endif // !defined(AFX_STDAFX_H__3BF6CD25_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 27 | -------------------------------------------------------------------------------- /Examples/NETMETER/netmeter.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "netmeter"=.\netmeter.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/NETMETER/netmeterDoc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "stdafx.h" 35 | #include "netmeter.h" 36 | 37 | #include "netmeterDoc.h" 38 | 39 | #ifdef _DEBUG 40 | #define new DEBUG_NEW 41 | #undef THIS_FILE 42 | static char THIS_FILE[] = __FILE__; 43 | #endif 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | // CNetmeterDoc 47 | 48 | IMPLEMENT_DYNCREATE(CNetmeterDoc, CDocument) 49 | 50 | BEGIN_MESSAGE_MAP(CNetmeterDoc, CDocument) 51 | //{{AFX_MSG_MAP(CNetmeterDoc) 52 | //}}AFX_MSG_MAP 53 | END_MESSAGE_MAP() 54 | 55 | ///////////////////////////////////////////////////////////////////////////// 56 | // CNetmeterDoc construction/destruction 57 | 58 | CNetmeterDoc::CNetmeterDoc() 59 | { 60 | } 61 | 62 | CNetmeterDoc::~CNetmeterDoc() 63 | { 64 | } 65 | 66 | BOOL CNetmeterDoc::OnNewDocument() 67 | { 68 | if (!CDocument::OnNewDocument()) 69 | return FALSE; 70 | 71 | return TRUE; 72 | } 73 | 74 | 75 | 76 | ///////////////////////////////////////////////////////////////////////////// 77 | // CNetmeterDoc serialization 78 | 79 | void CNetmeterDoc::Serialize(CArchive& ar) 80 | { 81 | if (ar.IsStoring()) 82 | { 83 | } 84 | else 85 | { 86 | } 87 | } 88 | 89 | ///////////////////////////////////////////////////////////////////////////// 90 | // CNetmeterDoc diagnostics 91 | 92 | #ifdef _DEBUG 93 | void CNetmeterDoc::AssertValid() const 94 | { 95 | CDocument::AssertValid(); 96 | } 97 | 98 | void CNetmeterDoc::Dump(CDumpContext& dc) const 99 | { 100 | CDocument::Dump(dc); 101 | } 102 | #endif //_DEBUG 103 | 104 | ///////////////////////////////////////////////////////////////////////////// 105 | // CNetmeterDoc commands 106 | -------------------------------------------------------------------------------- /Examples/NETMETER/netmeterDoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // netmeterDoc.h : interface of the CNetmeterDoc class 35 | // 36 | ///////////////////////////////////////////////////////////////////////////// 37 | 38 | #if !defined(AFX_NETMETERDOC_H__3BF6CD29_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 39 | #define AFX_NETMETERDOC_H__3BF6CD29_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 40 | 41 | #if _MSC_VER > 1000 42 | #pragma once 43 | #endif // _MSC_VER > 1000 44 | 45 | 46 | class CNetmeterDoc : public CDocument 47 | { 48 | protected: // create from serialization only 49 | CNetmeterDoc(); 50 | DECLARE_DYNCREATE(CNetmeterDoc) 51 | 52 | // Attributes 53 | public: 54 | 55 | // Operations 56 | public: 57 | 58 | // Overrides 59 | // ClassWizard generated virtual function overrides 60 | //{{AFX_VIRTUAL(CNetmeterDoc) 61 | public: 62 | virtual BOOL OnNewDocument(); 63 | virtual void Serialize(CArchive& ar); 64 | //}}AFX_VIRTUAL 65 | 66 | // Implementation 67 | public: 68 | virtual ~CNetmeterDoc(); 69 | #ifdef _DEBUG 70 | virtual void AssertValid() const; 71 | virtual void Dump(CDumpContext& dc) const; 72 | #endif 73 | 74 | protected: 75 | 76 | // Generated message map functions 77 | protected: 78 | //{{AFX_MSG(CNetmeterDoc) 79 | //}}AFX_MSG 80 | DECLARE_MESSAGE_MAP() 81 | }; 82 | 83 | ///////////////////////////////////////////////////////////////////////////// 84 | 85 | //{{AFX_INSERT_LOCATION}} 86 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 87 | 88 | #endif // !defined(AFX_NETMETERDOC_H__3BF6CD29_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 89 | -------------------------------------------------------------------------------- /Examples/NETMETER/res/BMP00001.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/BMP00001.BMP -------------------------------------------------------------------------------- /Examples/NETMETER/res/bitmap1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/bitmap1.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/bitmap2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/bitmap2.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/cap_wizi.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/cap_wizi.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/listbmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/listbmp.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/netmeter.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/netmeter.ico -------------------------------------------------------------------------------- /Examples/NETMETER/res/netmeter.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // NETMETER.RC2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /Examples/NETMETER/res/netmeterDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/NETMETER/res/netmeterDoc.ico -------------------------------------------------------------------------------- /Examples/NETMETER/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by netmeter.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDR_MAINFRAME 128 7 | #define IDR_NETMETTYPE 129 8 | #define IDB_YELLOW 133 9 | #define IDB_BLUE 134 10 | #define IDB_YELL 135 11 | #define IDB_CAP_WIZ 175 12 | #define IDD_ADAPTER 180 13 | #define IDC_ADAPTER 1000 14 | #define IDC_LIST1 3109 15 | #define seladapter 32771 16 | 17 | // Next default values for new objects 18 | // 19 | #ifdef APSTUDIO_INVOKED 20 | #ifndef APSTUDIO_READONLY_SYMBOLS 21 | #define _APS_NEXT_RESOURCE_VALUE 137 22 | #define _APS_NEXT_COMMAND_VALUE 32772 23 | #define _APS_NEXT_CONTROL_VALUE 1000 24 | #define _APS_NEXT_SYMED_VALUE 101 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /Examples/PacketDriver/readme.txt: -------------------------------------------------------------------------------- 1 | These files use the packet.dll API instead of wpcap.dll. 2 | The use of packet.dll API is strongly discouraged. 3 | -------------------------------------------------------------------------------- /Examples/UDPdump/UDPdump.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "UDPdump"=.\UDPdump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/UserLevelBridge/UserBridge.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "UserBridge"=.\UserBridge.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/iflist/iflist.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "iflist"=.\iflist.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/kdump/kdump.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "kdump"=.\kdump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/kdump/kdump.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/Examples/kdump/kdump.exe -------------------------------------------------------------------------------- /Examples/misc/MakeaAll.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "basic_dump"=.\basic_dump.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "basic_dump_ex"=.\basic_dump_ex.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "readfile"=.\readfile.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "readfile_ex"=.\readfile_ex.dsp - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | Project: "savedump"=.\savedump.dsp - Package Owner=<4> 55 | 56 | Package=<5> 57 | {{{ 58 | }}} 59 | 60 | Package=<4> 61 | {{{ 62 | }}} 63 | 64 | ############################################################################### 65 | 66 | Project: "sendpack"=.\sendpack.dsp - Package Owner=<4> 67 | 68 | Package=<5> 69 | {{{ 70 | }}} 71 | 72 | Package=<4> 73 | {{{ 74 | }}} 75 | 76 | ############################################################################### 77 | 78 | Global: 79 | 80 | Package=<5> 81 | {{{ 82 | }}} 83 | 84 | Package=<3> 85 | {{{ 86 | }}} 87 | 88 | ############################################################################### 89 | 90 | -------------------------------------------------------------------------------- /Examples/misc/basic_dump.c: -------------------------------------------------------------------------------- 1 | #include "pcap.h" 2 | 3 | /* prototype of the packet handler */ 4 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 5 | 6 | int main() 7 | { 8 | pcap_if_t *alldevs; 9 | pcap_if_t *d; 10 | int inum; 11 | int i=0; 12 | pcap_t *adhandle; 13 | char errbuf[PCAP_ERRBUF_SIZE]; 14 | 15 | /* Retrieve the device list on the local machine */ 16 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) 17 | { 18 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 19 | exit(1); 20 | } 21 | 22 | /* Print the list */ 23 | for(d=alldevs; d; d=d->next) 24 | { 25 | printf("%d. %s", ++i, d->name); 26 | if (d->description) 27 | printf(" (%s)\n", d->description); 28 | else 29 | printf(" (No description available)\n"); 30 | } 31 | 32 | if(i==0) 33 | { 34 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 35 | return -1; 36 | } 37 | 38 | printf("Enter the interface number (1-%d):",i); 39 | scanf_s("%d", &inum); 40 | 41 | if(inum < 1 || inum > i) 42 | { 43 | printf("\nInterface number out of range.\n"); 44 | /* Free the device list */ 45 | pcap_freealldevs(alldevs); 46 | return -1; 47 | } 48 | 49 | /* Jump to the selected adapter */ 50 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 51 | 52 | /* Open the device */ 53 | if ( (adhandle= pcap_open(d->name, // name of the device 54 | 65536, // portion of the packet to capture 55 | // 65536 guarantees that the whole packet will be captured on all the link layers 56 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 57 | 1000, // read timeout 58 | NULL, // authentication on the remote machine 59 | errbuf // error buffer 60 | ) ) == NULL) 61 | { 62 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name); 63 | /* Free the device list */ 64 | pcap_freealldevs(alldevs); 65 | return -1; 66 | } 67 | 68 | printf("\nlistening on %s...\n", d->description); 69 | 70 | /* At this point, we don't need any more the device list. Free it */ 71 | pcap_freealldevs(alldevs); 72 | 73 | /* start the capture */ 74 | pcap_loop(adhandle, 0, packet_handler, NULL); 75 | 76 | return 0; 77 | } 78 | 79 | 80 | /* Callback function invoked by libpcap for every incoming packet */ 81 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data) 82 | { 83 | struct tm ltime; 84 | char timestr[16]; 85 | time_t local_tv_sec; 86 | 87 | /* 88 | * unused variables 89 | */ 90 | (VOID)(param); 91 | (VOID)(pkt_data); 92 | 93 | /* convert the timestamp to readable format */ 94 | local_tv_sec = header->ts.tv_sec; 95 | localtime_s(<ime, &local_tv_sec); 96 | strftime( timestr, sizeof timestr, "%H:%M:%S", <ime); 97 | 98 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 99 | 100 | } 101 | -------------------------------------------------------------------------------- /Examples/misc/basic_dump_ex.c: -------------------------------------------------------------------------------- 1 | #include "pcap.h" 2 | 3 | 4 | int main() 5 | { 6 | pcap_if_t *alldevs; 7 | pcap_if_t *d; 8 | int inum; 9 | int i=0; 10 | pcap_t *adhandle; 11 | int res; 12 | char errbuf[PCAP_ERRBUF_SIZE]; 13 | struct tm ltime; 14 | char timestr[16]; 15 | struct pcap_pkthdr *header; 16 | const u_char *pkt_data; 17 | time_t local_tv_sec; 18 | 19 | 20 | /* Retrieve the device list on the local machine */ 21 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) 22 | { 23 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 24 | exit(1); 25 | } 26 | 27 | /* Print the list */ 28 | for(d=alldevs; d; d=d->next) 29 | { 30 | printf("%d. %s", ++i, d->name); 31 | if (d->description) 32 | printf(" (%s)\n", d->description); 33 | else 34 | printf(" (No description available)\n"); 35 | } 36 | 37 | if(i==0) 38 | { 39 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 40 | return -1; 41 | } 42 | 43 | printf("Enter the interface number (1-%d):",i); 44 | scanf_s("%d", &inum); 45 | 46 | if(inum < 1 || inum > i) 47 | { 48 | printf("\nInterface number out of range.\n"); 49 | /* Free the device list */ 50 | pcap_freealldevs(alldevs); 51 | return -1; 52 | } 53 | 54 | /* Jump to the selected adapter */ 55 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 56 | 57 | /* Open the device */ 58 | if ( (adhandle= pcap_open(d->name, // name of the device 59 | 65536, // portion of the packet to capture. 60 | // 65536 guarantees that the whole packet will be captured on all the link layers 61 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 62 | 1000, // read timeout 63 | NULL, // authentication on the remote machine 64 | errbuf // error buffer 65 | ) ) == NULL) 66 | { 67 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name); 68 | /* Free the device list */ 69 | pcap_freealldevs(alldevs); 70 | return -1; 71 | } 72 | 73 | printf("\nlistening on %s...\n", d->description); 74 | 75 | /* At this point, we don't need any more the device list. Free it */ 76 | pcap_freealldevs(alldevs); 77 | 78 | /* Retrieve the packets */ 79 | while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){ 80 | 81 | if(res == 0) 82 | /* Timeout elapsed */ 83 | continue; 84 | 85 | /* convert the timestamp to readable format */ 86 | local_tv_sec = header->ts.tv_sec; 87 | localtime_s(<ime, &local_tv_sec); 88 | strftime( timestr, sizeof timestr, "%H:%M:%S", <ime); 89 | 90 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 91 | } 92 | 93 | if(res == -1){ 94 | printf("Error reading the packets: %s\n", pcap_geterr(adhandle)); 95 | return -1; 96 | } 97 | 98 | return 0; 99 | } -------------------------------------------------------------------------------- /Examples/misc/readfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define LINE_LEN 16 5 | 6 | void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *); 7 | 8 | int main(int argc, char **argv) 9 | { 10 | pcap_t *fp; 11 | char errbuf[PCAP_ERRBUF_SIZE]; 12 | char source[PCAP_BUF_SIZE]; 13 | 14 | if(argc != 2){ 15 | 16 | printf("usage: %s filename", argv[0]); 17 | return -1; 18 | 19 | } 20 | 21 | /* Create the source string according to the new WinPcap syntax */ 22 | if ( pcap_createsrcstr( source, // variable that will keep the source string 23 | PCAP_SRC_FILE, // we want to open a file 24 | NULL, // remote host 25 | NULL, // port on the remote host 26 | argv[1], // name of the file we want to open 27 | errbuf // error buffer 28 | ) != 0) 29 | { 30 | fprintf(stderr,"\nError creating a source string\n"); 31 | return -1; 32 | } 33 | 34 | /* Open the capture file */ 35 | if ( (fp= pcap_open(source, // name of the device 36 | 65536, // portion of the packet to capture 37 | // 65536 guarantees that the whole packet will be captured on all the link layers 38 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 39 | 1000, // read timeout 40 | NULL, // authentication on the remote machine 41 | errbuf // error buffer 42 | ) ) == NULL) 43 | { 44 | fprintf(stderr,"\nUnable to open the file %s.\n", source); 45 | return -1; 46 | } 47 | 48 | // read and dispatch packets until EOF is reached 49 | pcap_loop(fp, 0, dispatcher_handler, NULL); 50 | 51 | return 0; 52 | } 53 | 54 | 55 | 56 | void dispatcher_handler(u_char *temp1, 57 | const struct pcap_pkthdr *header, const u_char *pkt_data) 58 | { 59 | u_int i=0; 60 | 61 | /* 62 | * Unused variable 63 | */ 64 | (VOID)temp1; 65 | 66 | /* print pkt timestamp and pkt len */ 67 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 68 | 69 | /* Print the packet */ 70 | for (i=1; (i < header->caplen + 1 ) ; i++) 71 | { 72 | printf("%.2x ", pkt_data[i-1]); 73 | if ( (i % LINE_LEN) == 0) printf("\n"); 74 | } 75 | 76 | printf("\n\n"); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Examples/misc/readfile_ex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define LINE_LEN 16 5 | 6 | int main(int argc, char **argv) 7 | { 8 | pcap_t *fp; 9 | char errbuf[PCAP_ERRBUF_SIZE]; 10 | char source[PCAP_BUF_SIZE]; 11 | struct pcap_pkthdr *header; 12 | const u_char *pkt_data; 13 | u_int i=0; 14 | int res; 15 | 16 | if(argc != 2) 17 | { 18 | printf("usage: %s filename", argv[0]); 19 | return -1; 20 | } 21 | 22 | /* Create the source string according to the new WinPcap syntax */ 23 | if ( pcap_createsrcstr( source, // variable that will keep the source string 24 | PCAP_SRC_FILE, // we want to open a file 25 | NULL, // remote host 26 | NULL, // port on the remote host 27 | argv[1], // name of the file we want to open 28 | errbuf // error buffer 29 | ) != 0) 30 | { 31 | fprintf(stderr,"\nError creating a source string\n"); 32 | return -1; 33 | } 34 | 35 | /* Open the capture file */ 36 | if ( (fp= pcap_open(source, // name of the device 37 | 65536, // portion of the packet to capture 38 | // 65536 guarantees that the whole packet will be captured on all the link layers 39 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 40 | 1000, // read timeout 41 | NULL, // authentication on the remote machine 42 | errbuf // error buffer 43 | ) ) == NULL) 44 | { 45 | fprintf(stderr,"\nUnable to open the file %s.\n", source); 46 | return -1; 47 | } 48 | 49 | /* Retrieve the packets from the file */ 50 | while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0) 51 | { 52 | /* print pkt timestamp and pkt len */ 53 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 54 | 55 | /* Print the packet */ 56 | for (i=1; (i < header->caplen + 1 ) ; i++) 57 | { 58 | printf("%.2x ", pkt_data[i-1]); 59 | if ( (i % LINE_LEN) == 0) printf("\n"); 60 | } 61 | 62 | printf("\n\n"); 63 | } 64 | 65 | 66 | if (res == -1) 67 | { 68 | printf("Error reading the packets: %s\n", pcap_geterr(fp)); 69 | } 70 | 71 | return 0; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /Examples/misc/savedump.c: -------------------------------------------------------------------------------- 1 | #include "pcap.h" 2 | 3 | /* prototype of the packet handler */ 4 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 5 | 6 | int main(int argc, char **argv) 7 | { 8 | pcap_if_t *alldevs; 9 | pcap_if_t *d; 10 | int inum; 11 | int i=0; 12 | pcap_t *adhandle; 13 | char errbuf[PCAP_ERRBUF_SIZE]; 14 | pcap_dumper_t *dumpfile; 15 | 16 | 17 | 18 | /* Check command line */ 19 | if(argc != 2) 20 | { 21 | printf("usage: %s filename", argv[0]); 22 | return -1; 23 | } 24 | 25 | /* Retrieve the device list on the local machine */ 26 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) 27 | { 28 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 29 | exit(1); 30 | } 31 | 32 | /* Print the list */ 33 | for(d=alldevs; d; d=d->next) 34 | { 35 | printf("%d. %s", ++i, d->name); 36 | if (d->description) 37 | printf(" (%s)\n", d->description); 38 | else 39 | printf(" (No description available)\n"); 40 | } 41 | 42 | if(i==0) 43 | { 44 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 45 | return -1; 46 | } 47 | 48 | printf("Enter the interface number (1-%d):",i); 49 | scanf_s("%d", &inum); 50 | 51 | if(inum < 1 || inum > i) 52 | { 53 | printf("\nInterface number out of range.\n"); 54 | /* Free the device list */ 55 | pcap_freealldevs(alldevs); 56 | return -1; 57 | } 58 | 59 | /* Jump to the selected adapter */ 60 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 61 | 62 | 63 | /* Open the device */ 64 | if ( (adhandle= pcap_open(d->name, // name of the device 65 | 65536, // portion of the packet to capture 66 | // 65536 guarantees that the whole packet will be captured on all the link layers 67 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 68 | 1000, // read timeout 69 | NULL, // authentication on the remote machine 70 | errbuf // error buffer 71 | ) ) == NULL) 72 | { 73 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name); 74 | /* Free the device list */ 75 | pcap_freealldevs(alldevs); 76 | return -1; 77 | } 78 | 79 | /* Open the dump file */ 80 | dumpfile = pcap_dump_open(adhandle, argv[1]); 81 | 82 | if(dumpfile==NULL) 83 | { 84 | fprintf(stderr,"\nError opening output file\n"); 85 | return -1; 86 | } 87 | 88 | printf("\nlistening on %s... Press Ctrl+C to stop...\n", d->description); 89 | 90 | /* At this point, we no longer need the device list. Free it */ 91 | pcap_freealldevs(alldevs); 92 | 93 | /* start the capture */ 94 | pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile); 95 | 96 | return 0; 97 | } 98 | 99 | /* Callback function invoked by libpcap for every incoming packet */ 100 | void packet_handler(u_char *dumpfile, const struct pcap_pkthdr *header, const u_char *pkt_data) 101 | { 102 | /* save the packet on the dump file */ 103 | pcap_dump(dumpfile, header, pkt_data); 104 | } 105 | -------------------------------------------------------------------------------- /Examples/misc/sendpack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | void main(int argc, char **argv) 8 | { 9 | pcap_t *fp; 10 | char errbuf[PCAP_ERRBUF_SIZE]; 11 | u_char packet[100]; 12 | int i; 13 | 14 | /* Check the validity of the command line */ 15 | if (argc != 2) 16 | { 17 | printf("usage: %s interface (e.g. 'rpcap://eth0')", argv[0]); 18 | return; 19 | } 20 | 21 | /* Open the output device */ 22 | if ( (fp= pcap_open(argv[1], // name of the device 23 | 100, // portion of the packet to capture (only the first 100 bytes) 24 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 25 | 1000, // read timeout 26 | NULL, // authentication on the remote machine 27 | errbuf // error buffer 28 | ) ) == NULL) 29 | { 30 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[1]); 31 | return; 32 | } 33 | 34 | /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */ 35 | packet[0]=1; 36 | packet[1]=1; 37 | packet[2]=1; 38 | packet[3]=1; 39 | packet[4]=1; 40 | packet[5]=1; 41 | 42 | /* set mac source to 2:2:2:2:2:2 */ 43 | packet[6]=2; 44 | packet[7]=2; 45 | packet[8]=2; 46 | packet[9]=2; 47 | packet[10]=2; 48 | packet[11]=2; 49 | 50 | /* Fill the rest of the packet */ 51 | for(i=12;i<100;i++) 52 | { 53 | packet[i]=(u_char)i; 54 | } 55 | 56 | /* Send down the packet */ 57 | if (pcap_sendpacket(fp, packet, 100 /* size */) != 0) 58 | { 59 | fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp)); 60 | return; 61 | } 62 | 63 | return; 64 | } 65 | -------------------------------------------------------------------------------- /Examples/pcap_filter/pcap_filter.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "pcap_filter"=.\pcap_filter.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/pcap_fopen/pcap_fopen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 CACE Technologies, Davis (California) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of CACE Technologies nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This sample was contributed by 31 | * Marcin Okraszewski (Marcin.OkraszewskiATpl.compuware.com) 32 | * 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | /** Prints packet timestaps regardless of format*/ 40 | int _tmain(int argc, _TCHAR* argv[]) 41 | { 42 | char errbuf[PCAP_ERRBUF_SIZE]; 43 | wchar_t cmd[1024]; 44 | wchar_t tshark_path[MAX_PATH]; 45 | wchar_t file_path[MAX_PATH]; 46 | 47 | if ( argc != 3 ) { 48 | wprintf(L"Prints packet timestaps regardless of format.\n"); 49 | wprintf(L"Usage:\n\t%ls \n", argv[0]); 50 | return 1; 51 | } 52 | 53 | // conversion to short path name in case there are spaces 54 | if ( ! GetShortPathNameW(argv[1], tshark_path, MAX_PATH) || 55 | ! GetShortPathNameW(argv[2], file_path, MAX_PATH) ) 56 | { 57 | printf("Failed to convert paths to short form."); 58 | return 1; 59 | } 60 | 61 | // create tshark command, which will make the trace conversion and print in libpcap format to stdout 62 | if ( swprintf_s(cmd, 1024, L"%ls -r %ls -w - -F libpcap", tshark_path, file_path) < 0 ) { 63 | wprintf(L"Failed to create command\n"); 64 | return 1; 65 | } 66 | 67 | // start tshark 68 | FILE *tshark_out = _wpopen(cmd, L"rb"); 69 | if ( tshark_out == NULL ) { 70 | strerror_s(errbuf, PCAP_ERRBUF_SIZE, errno); 71 | printf("Failed run tshark: %s\n", errbuf); 72 | wprintf(L"Command: %ls", cmd); 73 | return 1; 74 | } 75 | 76 | // open stdout from tshark 77 | pcap_t *pcap = pcap_fopen_offline(tshark_out, errbuf); 78 | if ( pcap == NULL ) { 79 | printf("Error opening stream from tshark: %s\n", errbuf); 80 | return 1; 81 | } 82 | 83 | // print information about every packet int trace 84 | struct pcap_pkthdr hdr; 85 | while ( pcap_next(pcap, &hdr) ) { 86 | printf("packet: ts: %u.%06u, len: %4u, caplen: %4u\n", hdr.ts.tv_sec, hdr.ts.tv_usec, hdr.len, hdr.caplen); 87 | } 88 | 89 | // clean up 90 | pcap_close(pcap); 91 | _pclose(tshark_out); 92 | return 0; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /Examples/pktdump_ex/pktdump_ex.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "pktdump_ex"=.\pktdump_ex.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/sendcap/sencap.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "sendcap"=.\sendcap.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/smp_1/smp_1.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "smp_1"=.\smp_1.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Examples/tcptop/tcptop.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "tcptop"=.\tcptop.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /Libpcap-License.txt: -------------------------------------------------------------------------------- 1 | Npcap incorporates the multi-platform Libpcap packet capturing 2 | software (http://www.tcpdump.org/). Libpcap is under the 3-clause 3 | BSD-style open source license reproduced below. This allows for free 4 | redistribution and use in other softare. Npcap itself is NOT under 5 | this license. 6 | 7 | License: BSD 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions 11 | are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 2. Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in 17 | the documentation and/or other materials provided with the 18 | distribution. 19 | 3. The names of the authors may not be used to endorse or promote 20 | products derived from this software without specific prior 21 | written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 24 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Notes: 2 | # - Minimal appveyor.yml file is an empty file. All sections are optional. 3 | # - Indent each level of configuration with 2 spaces. Do not use tabs! 4 | # - All section names are case-sensitive. 5 | # - Section names should be unique on each level. 6 | 7 | #---------------------------------# 8 | # general configuration # 9 | #---------------------------------# 10 | 11 | # version format 12 | version: 0.10.{build} 13 | 14 | # branches to build 15 | branches: 16 | # blacklist 17 | except: 18 | - gh-pages 19 | 20 | # Do not build on tags (GitHub only) 21 | skip_tags: true 22 | 23 | #---------------------------------# 24 | # environment configuration # 25 | #---------------------------------# 26 | 27 | os: Windows Server 2012 28 | 29 | # clone directory 30 | clone_folder: C:\Npcap 31 | 32 | # environment variables 33 | environment: 34 | SignTool: C:\Program Files (x86)\Windows Kits\10\bin\x64 35 | 36 | # scripts that run after cloning repository 37 | install: 38 | # clone the submodules 39 | - cmd: git submodule update --init --recursive 40 | # install Win-Flex-Bison 41 | - cmd: cinst winflexbison -y 42 | 43 | #---------------------------------# 44 | # build configuration # 45 | #---------------------------------# 46 | 47 | # scripts to run before build 48 | # before_build: 49 | 50 | # scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services) 51 | # before_package: 52 | 53 | # scripts to run after build 54 | # after_build: 55 | 56 | # to run your custom scripts instead of automatic MSBuild 57 | build_script: 58 | - cmd: cd installer 59 | - cmd: echo .| Build.bat 60 | - cmd: echo .| Deploy.bat 61 | 62 | # to disable automatic builds 63 | # build: off 64 | -------------------------------------------------------------------------------- /build_sdk.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%2"== "" ( rd /s/q ./npcap-sdk 2>nul >nul) else ( rd /s /q "%2" 2>nul >nul) 4 | 5 | call create_include.bat %1 %2 6 | 7 | call create_lib.bat %1 %2 8 | 9 | call create_examples.bat %1 %2 10 | 11 | call create_docs.bat %1 %2 12 | 13 | "C:\Program Files\7-Zip\7z.exe" a installer\npcap-sdk-0.07.zip .\npcap-sdk 14 | PAUSE 15 | 16 | -------------------------------------------------------------------------------- /build_sdk.txt: -------------------------------------------------------------------------------- 1 | In order to build the developers' pack, you need to compile the various DLLs and then call build_sdk.bat 2 | This batch file, in turn, calls the four batches 3 | - create_includes.bat creates the include folder 4 | - create_lib.bat creates the lib folder 5 | - create_examples.bat copies the examples folder to the developers' pack. The examples can be compiled only under the developers' pack folder. 6 | - create_docs.bat creates the documentation (via doxygen), and then copies the generated files under the developers' pack folder. 7 | 8 | The syntax for the various scripts is 9 | 10 | winpcap_folder developer_folder 11 | 12 | winpcap_folder The winpcap sources folder. It is defaulted to .\ 13 | developer_folder The developers' pack folder. It is defaulted to .\npcap-sdk. 14 | 15 | HINT: just call build_sdk.bat without any parameter! 16 | 17 | -------------------------------------------------------------------------------- /create_docs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Creating \docs folder 8 | mkdir %WPDPACKDESTDIR% >nul 2>nul 9 | mkdir %WPDPACKDESTDIR%\docs >nul 2>nul 10 | mkdir %WPDPACKDESTDIR%\docs\html >nul 2>nul 11 | 12 | pushd %WINPCAPSOURCEDIR%\dox\prj 13 | 14 | echo - Deleting existing WinPcap documentation 15 | del /q docs\*.* 2> nul > nul 16 | echo - Creating new documentation 17 | doxygen winpcap_noc.dox >nul 18 | echo - Copying all gif files 19 | xcopy ..\pics\*.gif docs\. /v /y /q >nul 20 | xcopy ..\*.gif docs\. /v /y /q >nul 21 | 22 | popd 23 | 24 | xcopy /v /Y %WINPCAPSOURCEDIR%\dox\WinPcap_docs.html %WPDPACKDESTDIR%\docs\ >nul 25 | xcopy /v /Y %WINPCAPSOURCEDIR%\dox\prj\docs\*.* %WPDPACKDESTDIR%\docs\html\ >nul 26 | xcopy /v /Y %WINPCAPSOURCEDIR%\dox\*.gif %WPDPACKDESTDIR%\docs\html\ >nul 27 | xcopy /v /Y %WINPCAPSOURCEDIR%\dox\pics\*.gif %WPDPACKDESTDIR%\docs\html\ >nul 28 | xcopy /v /Y %WINPCAPSOURCEDIR%\docs\npcap-guide-wrapper.html %WPDPACKDESTDIR%\docs\ >nul 29 | echo Folder \docs created successfully 30 | set WPDPACKDESTDIR= 31 | set WINPCAPSOURCEDIR= 32 | -------------------------------------------------------------------------------- /create_examples.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Creating \Examples folder 8 | mkdir %WPDPACKDESTDIR% >nul 2>nul 9 | mkdir %WPDPACKDESTDIR%\Examples-pcap >nul 2>nul 10 | mkdir %WPDPACKDESTDIR%\Examples-remote >nul 2>nul 11 | 12 | xcopy /s/e/v /Y %WINPCAPSOURCEDIR%\Examples %WPDPACKDESTDIR%\Examples-remote >nul 13 | 14 | rem *** Delete Netmeter since it's no more part of the Developer's pack *** 15 | rd /S /Q %WPDPACKDESTDIR%\Examples-remote\NetMeter\ 16 | 17 | rem *** Delete kdump since the feature is not available at the moment *** 18 | rd /S /Q %WPDPACKDESTDIR%\Examples-remote\kdump\ 19 | 20 | xcopy /s/e/v /Y %WINPCAPSOURCEDIR%\Examples-pcap %WPDPACKDESTDIR%\Examples-pcap >nul 21 | 22 | rem *** Delete WinPcapStress, since it's not a real example *** 23 | rd /S /Q %WPDPACKDESTDIR%\Examples-pcap\winpcap_stress 24 | 25 | rem *** Delete stats, since it's not a real example *** 26 | rd /S /Q %WPDPACKDESTDIR%\Examples-pcap\stats 27 | 28 | 29 | echo Folder \Examples created successfully 30 | set WPDPACKDESTDIR= 31 | set WINPCAPSOURCEDIR= 32 | 33 | echo ******************************************************************** 34 | echo * * 35 | echo * Now you can build the examples from the developers' pack folder! * 36 | echo * * 37 | echo ******************************************************************** 38 | -------------------------------------------------------------------------------- /create_include.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Creating \Include folder 8 | mkdir %WPDPACKDESTDIR% 2>nul >nul 9 | mkdir %WPDPACKDESTDIR%\Include 2>nul >nul 10 | mkdir %WPDPACKDESTDIR%\Include\pcap 2>nul >nul 11 | 12 | 13 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap\*.h %WPDPACKDESTDIR%\Include\pcap\ >nul 14 | 15 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap.h %WPDPACKDESTDIR%\Include\ >nul 16 | rem xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap-int.h %WPDPACKDESTDIR%\Include\ >nul 17 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap-bpf.h %WPDPACKDESTDIR%\Include\ >nul 18 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap-namedb.h %WPDPACKDESTDIR%\Include\ >nul 19 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\remote-ext.h %WPDPACKDESTDIR%\Include\ >nul 20 | 21 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap-stdinc.h %WPDPACKDESTDIR%\Include\ >nul 22 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\Win32-Extensions\Win32-Extensions.h %WPDPACKDESTDIR%\Include\ >nul 23 | 24 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\Win32\Include\bittypes.h %WPDPACKDESTDIR%\Include\ >nul 25 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\Win32\Include\ip6_misc.h %WPDPACKDESTDIR%\Include\ >nul 26 | 27 | rem xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\Win32\Include\Gnuc.h %WPDPACKDESTDIR%\Include\ >nul 28 | 29 | 30 | xcopy /v /Y %WINPCAPSOURCEDIR%\Common\Packet32.h %WPDPACKDESTDIR%\Include\ >nul 31 | 32 | echo Folder \Include created successfully 33 | set WPDPACKDESTDIR= 34 | set WINPCAPSOURCEDIR= 35 | -------------------------------------------------------------------------------- /create_lib.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Creating \Lib folder 8 | mkdir %WPDPACKDESTDIR% >nul 2>nul 9 | mkdir %WPDPACKDESTDIR%\Lib >nul 2>nul 10 | mkdir %WPDPACKDESTDIR%\Lib\x64 >nul 2>nul 11 | 12 | xcopy /v /Y "%WINPCAPSOURCEDIR%\wpcap\libpcap\Win32\Prj\Release\wpcap.lib" %WPDPACKDESTDIR%\Lib\ >nul 13 | xcopy /v /Y "%WINPCAPSOURCEDIR%\wpcap\libpcap\Win32\Prj\x64\Release\wpcap.lib" %WPDPACKDESTDIR%\Lib\x64 >nul 14 | xcopy /v /Y "%WINPCAPSOURCEDIR%\packetWin7\Dll\Project\Release No NetMon and AirPcap\packet.lib" %WPDPACKDESTDIR%\Lib\ >nul 15 | xcopy /v /Y "%WINPCAPSOURCEDIR%\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\packet.lib" %WPDPACKDESTDIR%\Lib\x64 >nul 16 | 17 | echo Folder \Lib created successfully 18 | 19 | set WPDPACKDESTDIR= 20 | set WINPCAPSOURCEDIR= 21 | 22 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: $ 2 | 3 | # A simple Makefile for building npcap-guide-wrapper.html from the XML source 4 | # This is where docbook.xsl is on my machine, but maybe we should find a better way to generalize this. 5 | DOCBOOKXSL=/usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl 6 | XSLTPROC = xsltproc 7 | 8 | npcap-guide: dummy 9 | $(XSLTPROC) -o npcap-guide-wrapper.html $(DOCBOOKXSL) npcap-guide-wrapper.xml 10 | 11 | 12 | dummy: 13 | -------------------------------------------------------------------------------- /docs/npcap-guide-wrapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | ]> 6 | 7 |
8 | 9 | Npcap Users' Guide 10 | 11 | &npcap; 12 |
13 | -------------------------------------------------------------------------------- /dox/WinPcap_docs.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dox/doxygen_groups.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | \defgroup internals WinPcap internals 3 | \htmlinclude internals.htm 4 | */ 5 | 6 | /*! 7 | \ingroup internals 8 | \defgroup NPF NPF driver internals manual 9 | \htmlinclude npf.htm 10 | */ 11 | 12 | 13 | 14 | /*! 15 | \ingroup internals 16 | \defgroup compilation How to compile WinPcap 17 | \htmlinclude compile.htm 18 | */ 19 | 20 | 21 | 22 | /*! 23 | \ingroup internals 24 | \defgroup packetapi Packet.dll -- Packet Driver API 25 | \htmlinclude packet.htm 26 | */ 27 | 28 | /*! 29 | \defgroup wpcap WinPcap user's manual 30 | \htmlinclude wpcap.htm 31 | */ 32 | 33 | /*! 34 | \ingroup wpcap 35 | \defgroup language Filtering expression syntax 36 | \htmlinclude language.htm 37 | */ 38 | 39 | 40 | /*! 41 | \ingroup wpcap 42 | \defgroup wpcapsamps Using WinPcap in your programs 43 | \htmlinclude wpcap_samp.htm 44 | 45 | \htmlinclude wpcap_samp1.htm 46 | \include pktdump_ex\pktdump_ex.c 47 | 48 | \htmlinclude wpcap_samp2.htm 49 | \include pcap_filter/pcap_filter.c 50 | */ 51 | 52 | 53 | 54 | 55 | 56 | /*! 57 | \defgroup remote Remote Capture 58 | \htmlinclude wpcap_remote.htm 59 | */ 60 | 61 | /*! 62 | \ingroup remote 63 | \defgroup remote_struct Exported Structures and Definitions 64 | */ 65 | 66 | /*! 67 | \ingroup remote 68 | \defgroup remotefunc Exported Functions 69 | */ 70 | 71 | /*! 72 | \ingroup remote 73 | \defgroup remote_pri_func Internal Functions 74 | */ 75 | 76 | /*! 77 | \ingroup remote 78 | \defgroup remote_pri_struct Internal Structures and Definitions 79 | */ 80 | 81 | 82 | /*! 83 | \ingroup remote_struct 84 | \defgroup remote_source_string Strings related to the new source syntax 85 | */ 86 | 87 | /*! 88 | \ingroup remote_struct 89 | \defgroup remote_source_ID Identifiers related to the new source syntax 90 | */ 91 | 92 | /*! 93 | \ingroup remote_struct 94 | \defgroup remote_open_flags Flags defined in the pcap_open() function 95 | */ 96 | 97 | /*! 98 | \ingroup remote_struct 99 | \defgroup remote_samp_methods Sampling methods defined in the pcap_setsampling() function 100 | */ 101 | 102 | /*! 103 | \ingroup remote_struct 104 | \defgroup remote_auth_methods Authentication methods supported by the RPCAP protocol 105 | */ 106 | -------------------------------------------------------------------------------- /dox/doxygen_groups_packetdll.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | \defgroup internals WinPcap internals 3 | \htmlinclude internals.htm 4 | */ 5 | 6 | /*! 7 | \ingroup internals 8 | \defgroup NPF NPF driver internals manual 9 | \htmlinclude npf.htm 10 | */ 11 | 12 | 13 | 14 | /*! 15 | \ingroup internals 16 | \defgroup compilation How to compile WinPcap 17 | \htmlinclude compile.htm 18 | */ 19 | 20 | 21 | 22 | /*! 23 | \ingroup internals 24 | \defgroup packetapi Packet Driver API developer's manual 25 | \htmlinclude packet.htm 26 | */ 27 | 28 | 29 | /*! 30 | \ingroup packetapi 31 | \defgroup packetsamps Packet.dll samples 32 | \htmlinclude packet_samp.htm 33 | */ 34 | 35 | 36 | 37 | /*! 38 | \defgroup wpcap WinPcap user's manual 39 | \htmlinclude wpcap.htm 40 | */ 41 | 42 | /*! 43 | \ingroup wpcap 44 | \defgroup language Filtering expression syntax 45 | \htmlinclude language.htm 46 | */ 47 | 48 | 49 | /*! 50 | \ingroup wpcap 51 | \defgroup wpcapsamps Using WinPcap in your programs 52 | \htmlinclude wpcap_samp.htm 53 | 54 | \htmlinclude wpcap_samp1.htm 55 | \include pktdump_ex\pktdump_ex.c 56 | 57 | \htmlinclude wpcap_samp2.htm 58 | \include pcap_filter/pcap_filter.c 59 | */ 60 | 61 | 62 | 63 | 64 | 65 | /*! 66 | \defgroup remote Remote Capture 67 | \htmlinclude wpcap_remote.htm 68 | */ 69 | 70 | /*! 71 | \ingroup remote 72 | \defgroup remote_struct Exported Structures and Definitions 73 | */ 74 | 75 | /*! 76 | \ingroup remote 77 | \defgroup remotefunc Exported Functions 78 | */ 79 | 80 | /*! 81 | \ingroup remote 82 | \defgroup remote_pri_func Internal Functions 83 | */ 84 | 85 | /*! 86 | \ingroup remote 87 | \defgroup remote_pri_struct Internal Structures and Definitions 88 | */ 89 | 90 | 91 | /*! 92 | \ingroup remote_struct 93 | \defgroup remote_source_string Strings related to the new source syntax 94 | */ 95 | 96 | /*! 97 | \ingroup remote_struct 98 | \defgroup remote_source_ID Identifiers related to the new source syntax 99 | */ 100 | 101 | /*! 102 | \ingroup remote_struct 103 | \defgroup remote_open_flags Flags defined in the pcap_open() function 104 | */ 105 | 106 | /*! 107 | \ingroup remote_struct 108 | \defgroup remote_samp_methods Sampling methods defined in the pcap_setsampling() function 109 | */ 110 | 111 | /*! 112 | \ingroup remote_struct 113 | \defgroup remote_auth_methods Authentication methods supported by the RPCAP protocol 114 | */ 115 | -------------------------------------------------------------------------------- /dox/footer.htm: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | documentation. Copyright (c) 2002-2005 Politecnico di Torino. Copyright (c) 2005-2010 5 | CACE Technologies. Copyright (c) 2010-2013 6 | Riverbed Technology. All rights reserved.

7 | -------------------------------------------------------------------------------- /dox/internals-arch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/internals-arch.gif -------------------------------------------------------------------------------- /dox/internals.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | This portion of the manual describes the internal structure and interfaces of WinPcap, 12 | starting from the lowest-level module. It is targeted at people that must extend 13 | or modify this software, or to the ones interested in how it works. Therefore, 14 | developers who just want to use WinPcap in their software don't need to read it. 15 | 16 |

WinPcap structure

17 |

Quoted from the home page of winpcap:

18 |

WinPcap is an architecture for packet capture and network analysis for the 19 | Win32 platforms. It includes a kernel-level packet filter, a 20 | low-level dynamic link library (packet.dll), and a high-level and 21 | system-independent library (wpcap.dll).

22 |

Why we use the term "architecture" rather than "library"? Because packet capture is a low level mechanism 23 | that requires a strict interaction with the network adapter and with the 24 | operating system, in particular with its networking implementation, so a simple 25 | library is not sufficient.

26 |

The following figure shows the various components of WinPcap:

27 |

28 | 29 |

30 | Main components of WinPcap. 31 |

First, a capture system needs to bypass the operating systems's protocol stack in order to access 32 | the raw data transiting on the network. This requires a portion 33 | running inside the kernel of OS, interacting directly with the network interface 34 | drivers. This portion is very system dependent, and in 35 | our solution it is realized as a device driver, called Netgroup Packet Filter (NPF); 36 | we provide different versions of the driver for Windows 95, Windows 98, Windows ME, 37 | Windows NT 4, 38 | Windows 2000 and Windows XP. These drivers offer both basic features like packet capture 39 | and injection, as well as more advanced ones like a programmable filtering system and a 40 | monitoring engine. The first one can be used to restrict a capture session to a 41 | subset of the network traffic (e.g. it is possible to capture only the ftp 42 | traffic generated by a particular host), the second one provides a powerful but 43 | simple to use mechanism to obtain statistics on the traffic (e.g. it is possible 44 | to obtain the network load or the amount of data exchanged between two hosts).

45 |

Second, the capture system must export an interface that user-level 46 | applications will use to take advantage of the features provided by the kernel 47 | driver. WinPcap provides two different libraries: packet.dll and wpcap.dll

48 |

49 | The first one offers a low-level API that can be used to directly access the 50 | functions of the driver, with a programming interface independent from the 51 | Microsoft OS. 

52 |

The second one exports a more powerful set of high level capture 53 | primitives that are compatible with libpcap, the well known Unix capture 54 | library. These functions enable packet capture in a manner that is independent 55 | of the 56 | underlying network hardware and operating system.

57 |

Throughout this documentation we will refer to the Packet Driver API or 58 | packet.dll as the first set of functions, whereas wpcap, wpcap.dll or libpcap 59 | will refer to the to the second one.

60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /dox/libpcap/incs/pcap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/libpcap/incs/pcap.h -------------------------------------------------------------------------------- /dox/main.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | \mainpage WinPcap Documentation 4 | 5 | \image html winpcap.gif 6 | 7 | \htmlonly 8 | 9 |
10 |
Authors:
11 |
The WinPcap Team
12 |
Home page:
13 |
http://www.winpcap.org
14 |
15 |
16 | 17 |

Modules

18 | 19 | \endhtmlonly 20 | 21 | - \ref wpcap 22 | - \ref wpcap_def 23 | - \ref wpcapfunc 24 | - \ref language 25 | - \ref wpcapsamps 26 | - \ref wpcap_tut 27 | - \ref wpcap_tut1 28 | - \ref wpcap_tut2 29 | - \ref wpcap_tut3 30 | - \ref wpcap_tut4 31 | - \ref wpcap_tut5 32 | - \ref wpcap_tut6 33 | - \ref wpcap_tut7 34 | - \ref wpcap_tut8 35 | - \ref wpcap_tut9 36 | - \ref internals 37 | - \ref NPF 38 | - \ref NPF_include 39 | - \ref NPF_code 40 | - \ref packetapi 41 | - \ref compilation 42 | - \ref remote 43 | - \ref remote_struct 44 | - Exported Functions. For a reference of the functions that support remote capture, see the "Windows-specific Extensions" in the WinPcap \ref wpcapfunc section. 45 | - \ref remote_pri_struct 46 | 47 | \htmlinclude intro.htm 48 | 49 | 50 | */ 51 | 52 | -------------------------------------------------------------------------------- /dox/main_packetdll.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | \mainpage WinPcap Documentation 4 | 5 | \image html winpcap.gif 6 | 7 | \htmlonly 8 | 9 |
10 |
Authors:
11 |
The WinPcap Team
12 |
Home page:
13 |
http://www.winpcap.org
14 |
15 |
16 | 17 |

Modules

18 | 19 | \endhtmlonly 20 | 21 | - \ref wpcap 22 | - \ref wpcap_def 23 | - \ref wpcapfunc 24 | - \ref language 25 | - \ref wpcapsamps 26 | - \ref wpcap_tut 27 | - \ref wpcap_tut1 28 | - \ref wpcap_tut2 29 | - \ref wpcap_tut3 30 | - \ref wpcap_tut4 31 | - \ref wpcap_tut5 32 | - \ref wpcap_tut6 33 | - \ref wpcap_tut7 34 | - \ref wpcap_tut8 35 | - \ref wpcap_tut9 36 | - \ref internals 37 | - \ref NPF 38 | - \ref NPF_include 39 | - \ref NPF_code 40 | - \ref packetapi 41 | - \ref packet32h 42 | - \ref packet32 43 | - \ref packetsamps 44 | - \ref compilation 45 | - \ref remote 46 | - \ref remote_struct 47 | - \ref remotefunc 48 | - \ref remote_pri_struct 49 | - \ref remote_pri_struct 50 | 51 | \htmlinclude intro.htm 52 | 53 | 54 | */ 55 | 56 | -------------------------------------------------------------------------------- /dox/note.txt: -------------------------------------------------------------------------------- 1 | per far linkare correttamente gli esempi di libpcap: 2 | - editare il file funcs\pcap.h 3 | - cambiare il blocco a inizio file: 4 | /** @defgroup wpcapfunc Exported functions 5 | * @ingroup wpcap 6 | * Functions exported by wpcap.dll 7 | * @{ 8 | */ 9 | 10 | in 11 | 12 | /** @ingroup wpcapfunc 13 | * @{ 14 | */ 15 | - generare la documentazione 16 | - salvare il file "funcs_2pcap_8h.html" 17 | - rimettere tutto a posto 18 | - rigenerare la documentazione 19 | - sovrascrivere il file salvato su quello nuovo 20 | 21 | per far si' che gli esempi puntino al manuale in maniera corretta: 22 | - generare la documentazione winpcap_noc.dox 23 | - backuppare i vari group__wpcap__tutXXX.html, pcap__filter_8c-source.html, Pktdump_8c-source.html, group__wpcapsampsXXX.html 24 | - generare la documentazione winpcap_c.dox 25 | - copiare i file backuppati sui nuovi 26 | 27 | l'immagine nella pagina principale e' da mettere: al centro -------------------------------------------------------------------------------- /dox/npf-dump.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/npf-dump.gif -------------------------------------------------------------------------------- /dox/npf-ndis.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/npf-ndis.gif -------------------------------------------------------------------------------- /dox/npf-npf.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/npf-npf.gif -------------------------------------------------------------------------------- /dox/npf.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/npf.htm -------------------------------------------------------------------------------- /dox/packet.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Packet.dll is a dynamic link library that offers a set of low level functions 12 | to: 13 |
    14 |
  • install, start and stop the NPF device driver
  • 15 |
  • Receive packets from the NPF driver
  • 16 |
  • send packets to the NPF driver
  • 17 |
  • obtain the list of the available network adapters
  • 18 |
  • retrieve various information about an adapter, like the description and 19 | the list of addresses and netmasks
  • 20 |
  • query and set various low-level parameters of an adapter
  • 21 |
22 |

There are two versions of packet.dll: the first one runs under Windows 95/98/ME, the second 23 | one is for  Windows 24 | NT/2000/XP.

25 |

Packet.dll was created to provide a layer to access the low level 26 | functionalities of WinPcap in a system independent way. This library handles all 27 | the system-dependent details (like managing the devices, interacting with the OS 28 | to manage the adapters, looking for the information in the registry and so on), 29 | and exports an API that is uniform across all Windows OSes. In this way, 30 | applications or libraries based on it can run without being recompiled 31 | under any Windows operating system.

32 |

However, not all of the packet.dll API is totally portable: some advanced features, like kernel-mode dump, are present only in the WinNTx version of WinPcap, 33 | while packet.dll for Win9x does not provide them. On the other side, the NTx 34 | version is a superset of the 9x one, in other words all the function present in 35 | the Win9x version are present in WinNTx too.

36 |

The other important feature of this library is its ability to handle NPF driver. 37 | Packet.dll transparently installs and starts the driver when an application 38 | attempts to access an adapter. This avoids the manual installation of the driver 39 | through the control panel.

40 |

Important note, read carefully!

41 |

The source code of Packet.dll is freely available and completely documented. 42 | However, packet.dll should be considered an internal API, because its purpose 43 | inside WinPcap is to be a building block for the real public API: wpcap.dll.

44 |

As a consequence, since the normal and suggested way for an 45 | application to use WinPcap is through wpcap.dll, we don't guarantee that the packet.dll 46 | API will not be changed in future releases of winpcap, and we don't provide 47 | support for this API. For the same reason, this manual doesn't contain 48 | any more the Doxygen-generated documentation of Packet.dll: the user will 49 | have to run Doxygen on his own to create it, or read the comments in the source 50 | code.

51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /dox/packet_samp.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

How to create an application that uses packet.dll

12 |

The creation of an application that uses packet.dll requires the following 13 | steps:

14 |
    15 |
  • Include the file packet32.h at the beginning of every source file 16 | that uses the functions exported by the dll. Packet32.h is 17 | distributed both with the packet.dll source code and with the WinPcap 18 | developer's pack. It is platform-independent. 19 |
  • Include packet.lib in the project. Packet.lib is generated 20 | compiling the packet driver and can be found in the developer's pack.
  • 21 |
22 |

Remember that:

23 |
    24 |
  • To add a new library to the project with Microsoft Visual C++, you must 25 | select Settings from the Project menu, then select Link 26 | from the tab control, and then add the name of the new library in the Objcet/library 27 | modules editbox. 28 |
  • To add a new path where Microsoft Visual C++ will look for the libraries, 29 | you must select Options from the Tools menu, then Link 30 | from the tab control, library files from the show directories 31 | for combobox, and the add the path in the directories box. 32 |
  • To add a new path where Microsoft Visual C++ will look for the include 33 | files, you must select Options from the Tools menu, then Link 34 | from the tab control, include files from the show directories 35 | for combobox, and the add the path in the directories box.
  • 36 |
37 |

Sample programs

38 |

A couple of sample programs are provided to show how to use packet.dll. The 39 | source code of the examples, along with all the files needed to compile and run 40 | them, can be found in the Developer's 41 | Pack.

42 |

TestPacketCapture

43 |

This is a very simple capture program that tests packet.dll. It is a console 44 | application that once complied can be executed both under Win9x and under WinNTx. 45 | When executed, TestPacketCapture gives to the user the opportunity to choose one of the 46 | adapters installed on the machine, then it captures packets from the specified 47 | network adapter until a key is pressed, dumping the contents of each packet on 48 | the screen. 

49 |

Traffic Generator (TestPacketSend)

50 |

This example shows how to use packet.dll to send packets to the network. It 51 | receives three input parameters: the interface that will be used, the number of 52 | packets to send and their size. The generated packets will have 1:1:1:1:1:1 as 53 | source MAC address, and 2:2:2:2:2:2 as destination address. The 'multiple write' 54 | feature of the driver is used to obtain a higher transmit rate.

55 |

56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /dox/pics/dump.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/pics/dump.gif -------------------------------------------------------------------------------- /dox/pics/encoding.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/pics/encoding.gif -------------------------------------------------------------------------------- /dox/pics/stats.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/pics/stats.gif -------------------------------------------------------------------------------- /dox/pics/stats_wpcap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/pics/stats_wpcap.gif -------------------------------------------------------------------------------- /dox/pics/winpcap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/pics/winpcap.gif -------------------------------------------------------------------------------- /dox/pics/winpcap_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/pics/winpcap_small.gif -------------------------------------------------------------------------------- /dox/slides.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/dox/slides.ppt -------------------------------------------------------------------------------- /dox/wpcap.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

This section contains the user manual of wpcap.dll, the 12 | dynamic library that contains the public WinPcap API. 13 | wpcap.dll exports a set of 14 | system-independent functions for packet capture and network analysis. These 15 | functions can be used to:

16 |
    17 |
  • obtain the list of the available network adapters 18 |
  • retrieve various information about an adapter, like the description and the list of addresses
  • 19 |
  • sniff the packets using one of the network interface cards of the PC
  • 20 |
  • send packets to the network 21 |
  • efficiently save packets to disk and load them with an interface similar to the one of 22 | live capture
  • 23 |
  • create packet filters using a high level language and apply them to the captured 24 | packets
  • 25 |
26 |

wpcap.dll is compatible with libpcap, the well known packet capture library 27 | for Unix. This compatibility means that one can develop portable network tools 28 | that will run on the Win32 OS family and on all of the major Unix flavors.

29 |

Several portions of the manual present in this section derive directly from the man pages of tcpdump and libpcap, maintained by the tcpdump.org developers. Therefore, if you 30 | are looking for updated docs, you can consult the web site www.tcpdump.org.

31 |

Note

32 |

Some functions are marked deprecated 33 | or discouraged. The meanings of these labels are:

34 |
    35 |
  • discouraged: the use of another function with similar purpose is 36 | suggested, however this one is still valid.
  • 37 |
  • deprecated: the function is present only for portability and 38 | backward compatibility. It should be avoided, and it is strongly suggested 39 | to use another equivalent function instead.
    40 |
  • 41 |
42 |

43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /dox/wpcap_samp1.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Packet Dump

13 |

This program reads packets from a file or a network adapter, depending on 14 | a command line switch. If a source is not provided, the program shows a list of 15 | available adapters, one of which can be selected. Once the 16 | capture is started, the program prints the timestamp, the length and the raw 17 | contents of the packets. Once compiled, it will run on all the Win32 platforms. It 18 | can be compiled to run on Unix as well (the makefile is provided).

19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /dox/wpcap_samp2.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Packet Filter

13 | 14 |

This is a more complete example of libpcap usage. It shows, among other 15 | things, how to create and set filters and how to save a capture to disk. It can 16 | be compiled under Win32 or Unix (projects and makefiles are provided). 17 | Pcap_filter (pf.exe) is a general-purpose packet filtering application: its 18 | input parameters are a source of packets (it can be a physical interface or a 19 | file), a filter and an output file. It takes packets from the source until 20 | CTRL+C is pressed or the whole file is processed, applies the filter to the 21 | incoming packets and saves them to the output file if they satisfy the filter. 22 | Pcap_filter can be used to dump network data according to a particular filter, 23 | but also to extract a set of packets from a previously saved file. The format of 24 | both input and output files is the format used by libpcap, i.e. same of WinDump, tcpdump 25 | and many other network tools.

26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /dox/wpcap_tut.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap 2 | */ 3 | 4 | 5 | /** @defgroup wpcap_tut WinPcap tutorial: a step by step guide to using WinPcap 6 | * @{ 7 | 8 | 9 | This section shows how to use the features of the WinPcap API. It is organized as a tutorial, subdivided into a set of lessons that will introduce the reader, in a step-by-step fashion, to program development using WinPcap, from the basic functions (obtaining the adapter list, starting a capture, etc.) to the most advanced ones (handling send queues and gathering statistics about network traffic). 10 | 11 | Several code snippets, as well as simple but complete programs are provided as a reference: all of the source code contains links to the rest of the manual, making it is possible to click on functions and data structures to jump to the corresponding documentation. 12 | 13 | The samples are written in plain C, so a basic knowledge of C programming is required. Also, since this is a tutorial about a library dealing with "raw" networking packets, good knowledge of networks and network protocols is assumed. 14 | 15 | \ref wpcap_tut1 "Next >>>" 16 | 17 | @}*/ 18 | -------------------------------------------------------------------------------- /dox/wpcap_tut1.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | 5 | /** @defgroup wpcap_tut1 Obtaining the device list 6 | * @{ 7 | 8 | Typically, the first thing that a WinPcap-based application does is get a list of attached network adapters. Both libpcap and WinPcap provide the pcap_findalldevs_ex() function for this purpose: this function returns a linked list of pcap_if structures, each of which contains comprehensive information about an attached adapter. In particular, the fields \e name and \e description contain the name and a human readable description, respectively, of the corresponding device. 9 | 10 | The following code retrieves the adapter list and shows it on the screen, printing an error if no adapters are found. 11 | 12 | \code 13 | #include "pcap.h" 14 | 15 | main() 16 | { 17 | pcap_if_t *alldevs; 18 | pcap_if_t *d; 19 | int i=0; 20 | char errbuf[PCAP_ERRBUF_SIZE]; 21 | 22 | /* Retrieve the device list from the local machine */ 23 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1) 24 | { 25 | fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf); 26 | exit(1); 27 | } 28 | 29 | /* Print the list */ 30 | for(d= alldevs; d != NULL; d= d->next) 31 | { 32 | printf("%d. %s", ++i, d->name); 33 | if (d->description) 34 | printf(" (%s)\n", d->description); 35 | else 36 | printf(" (No description available)\n"); 37 | } 38 | 39 | if (i == 0) 40 | { 41 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 42 | return; 43 | } 44 | 45 | /* We don't need any more the device list. Free it */ 46 | pcap_freealldevs(alldevs); 47 | } 48 | \endcode 49 | 50 | Some comments about this code. 51 | 52 | First of all, pcap_findalldevs_ex(), like other libpcap functions, has an \e errbuf parameter. This parameter points to a string filled by libpcap with a description of the error if something goes wrong. 53 | 54 | Second, remember that not all the OSes supported by libpcap provide a description of the network interfaces, therefore if we want to write a portable application, we must consider the case in which \e description is null: we print the string "No description available" in that situation. 55 | 56 | Note finally that we free the list with pcap_freealldevs() once when we have finished with it. 57 | 58 | Let's try to compile and run the code of this first sample. In order to compile it under Unix or Cygwin, simply type: 59 | 60 |
61 |   gcc -o testprog testprog.c -lpcap
62 | 
63 | 64 | On Windows, you will need to create a project, following the instructions in the \ref wpcapsamps section of this manual. However, we suggest that you use the WinPcap developer's pack (available at the WinPcap website, http://www.winpcap.org ), since it provides many examples already configured as projects including all the code presented in this tutorial and the \e includes and \e libraries needed to compile and run the examples. 65 | 66 | Assuming we have compiled the program, let's try to run it. On a particular WinXP workstation, the result we optained is 67 | 68 |
69 |    1. \\Device\\NPF_{4E273621-5161-46C8-895A-48D0E52A0B83} (Realtek RTL8029(AS) Ethernet Adapter)
70 |    2. \\Device\\NPF_{5D24AE04-C486-4A96-83FB-8B5EC6C7F430} (3Com EtherLink PCI) 
71 | 
72 | 73 | As you can see, the name of the network adapters (that will be passed to libpcap when opening the devices) under Windows are quite unreadable, so the parenthetical descriptions can be very helpful. 74 | 75 | \ref wpcap_tut "<<< Previous" \ref wpcap_tut2 "Next >>>" 76 | 77 | @}*/ 78 | -------------------------------------------------------------------------------- /dox/wpcap_tut2.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | /** @defgroup wpcap_tut2 Obtaining advanced information about installed devices 5 | * @{ 6 | 7 | Lesson 1 (\ref wpcap_tut1) demonstrated how to get basic information (i.e. device name and description) about available adapters. Actually, WinPcap provides also other advanced information. In particular, every pcap_if structure returned by pcap_findalldevs_ex() contains also a list of pcap_addr structures, with: 8 | - a list of addresses for that interface. 9 | - a list of netmasks (each of which corresponds to an entry in the addresses list). 10 | - a list of broadcast addresses (each of which corresponds to an entry in the addresses list). 11 | - a list of destination addresses (each of which corresponds to an entry in the addresses list). 12 | 13 | Additionally, pcap_findalldevs_ex() can also return remote adapters and a list of pcap files that are located in a given local folder. 14 | 15 | The following sample provides an ifprint() function that prints the complete contents of a pcap_if structure. It is invoked by the program for every entry returned by pcap_findalldevs_ex(). 16 | 17 | \include iflist/iflist.c 18 | 19 | \ref wpcap_tut1 "<<< Previous" \ref wpcap_tut3 "Next >>>" 20 | 21 | @}*/ 22 | -------------------------------------------------------------------------------- /dox/wpcap_tut3.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | 5 | /** @defgroup wpcap_tut3 Opening an adapter and capturing the packets 6 | * @{ 7 | 8 | Now that we've seen how to obtain an adapter to play with, let's start the real job, opening an adapter and capturing some traffic. In this lesson we'll write a program that prints some information about each packet flowing through the adapter. 9 | 10 | The function that opens a capture device is pcap_open(). The parameters, \e snaplen, \e flags and \e to_ms deserve some explanation. 11 | 12 | \e snaplen specifies the portion of the packet to capture. On some OSes (like xBSD and Win32), the packet driver can be configured to capture only the initial part of any packet: this decreases the amount of data to copy to the application and therefore improves the efficiency of the capture. In this case we use the value 65536 which is higher than the greatest MTU that we could encounter. In this manner we ensure that the application will always receive the whole packet. 13 | 14 | \e flags: the most important flag is the one that indicates if the adapter will be put in promiscuous mode. In normal operation, an adapter only captures packets from the network that are destined to it; the packets exchanged by other hosts are therefore ignored. Instead, when the adapter is in promiscuous mode it captures all packets whether they are destined to it or not. This means that on shared media (like non-switched Ethernet), WinPcap will be able to capture the packets of other hosts. Promiscuous mode is the default for most capture applications, so we enable it in the following example. 15 | 16 | \e to_ms specifies the read timeout, in milliseconds. A read on the adapter (for example, with pcap_dispatch() or pcap_next_ex()) will always return after \e to_ms milliseconds, even if no packets are available from the network. \e to_ms also defines the interval between statistical reports if the adapter is in statistical mode (see the lesson "\ref wpcap_tut9" for information about statistical mode). Setting \e to_ms to 0 means no timeout, a read on the adapter never returns if no packets arrive. A -1 timeout on the other side causes a read on the adapter to always return immediately. 17 | 18 | 19 | \include misc/basic_dump.c 20 | 21 | Once the adapter is opened, the capture can be started with pcap_dispatch() or pcap_loop(). These two functions are very similar, the difference is that pcap_ dispatch() returns (although not guaranteed) when the timeout expires while pcap_loop() doesn't return until \e cnt packets have been captured, so it can block for an arbitrary period on an under-utilized network. pcap_loop() is enough for the purpose of this sample, while pcap_dispatch() is normally used in a more complex program. 22 | 23 | Both of these functions have a \e callback parameter, \e packet_handler, pointing to a function that will receive the packets. This function is invoked by libpcap for every new packet coming from the network and receives a generic status (corresponding to the \e user parameter of pcap_loop() and pcap_dispatch()), a header with some information on the packet like the timestamp and the length and the actual data of the packet including all the protocol headers. Note that the frame CRC is normally not present, because it is removed by the network adapter after frame validation. Note also that most adapters discard packets with wrong CRCs, therefore WinPcap is normally not able to capture them. 24 | 25 | The above example extracts the timestamp and the length of every packet from the pcap_pkthdr header and prints them on the screen. 26 | 27 | Please note that there may be a drawback using pcap_loop() mainly related to the fact that the handler is called by the packet capture driver; therefore the user application does not have direct control over it. Another approach (and to have more readable programs) is to use the pcap_next_ex() function, which is presented in the next example (\ref wpcap_tut4). 28 | 29 | \ref wpcap_tut2 "<<< Previous" \ref wpcap_tut4 "Next >>>" 30 | 31 | @}*/ 32 | -------------------------------------------------------------------------------- /dox/wpcap_tut4.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | 5 | /** @defgroup wpcap_tut4 Capturing the packets without the callback 6 | * @{ 7 | 8 | The example program in this lesson behaves exactly like the previous program (\ref wpcap_tut3), but it uses pcap_next_ex() instead of pcap_loop(). 9 | 10 | The callback-based capture mechanism of pcap_loop() is elegant and it could be a good choice in some situations. However, handling a callback is sometimes not practical -- it often makes the program more complex especially in situations with multithreaded applications or C++ classes. 11 | 12 | In these cases, pcap_next_ex() retrievs a packet with a direct call -- using pcap_next_ex() packets are received only when the programmer wants them. 13 | 14 | The parameters of this function are the same as a capture callback -- it takes an adapter descriptor and a couple of pointers that will be initialized and returned to the user (one to a pcap_pkthdr structure and another to a buffer with the packet data). 15 | 16 | In the following program, we recycle the callback code of the previous lesson's example and move it inside main() right after the call to pcap_next_ex(). 17 | 18 | 19 | \include misc/basic_dump_ex.c 20 | 21 | Why do we use pcap_next_ex() instead of the old pcap_next()? Because pcap_next() has some drawbacks. First of all, it is inefficient because it hides the callback method but still relies on pcap_dispatch(). Second, it is not able to detect EOF, so it's not very useful when gathering packets from a file. 22 | 23 | Notice also that pcap_next_ex() returns different values for success, timeout elapsed, error and EOF conditions. 24 | 25 | \ref wpcap_tut3 "<<< Previous" \ref wpcap_tut5 "Next >>>" 26 | 27 | @}*/ 28 | -------------------------------------------------------------------------------- /dox/wpcap_tut5.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | 5 | /** @defgroup wpcap_tut5 Filtering the traffic 6 | * @{ 7 | 8 | One of the most powerful features offered by WinPcap (and by libpcap as well) is the filtering engine. It provides a very efficient way to receive subsets of the network traffic, and is (usually) integrated with the capture mechanism provided by WinPcap. The functions used to filter packets are pcap_compile() and pcap_setfilter(). 9 | 10 | pcap_compile() takes a string containing a high-level Boolean (filter) expression and produces a low-level byte code that can be interpreted by the fileter engine in the packet driver. The syntax of the boolean expression can be found in the \ref language section of this documentation. 11 | 12 | pcap_setfilter() associates a filter with a capture session in the kernel driver. Once pcap_setfilter() is called, the associated filter will be applied to all the packets coming from the network, and all the conformant packets (i.e., packets for which the Boolean expression evaluates to true) will be actually copied to the application. 13 | 14 | The following code shows how to compile and set a filter. Note that we must retrieve the netmask from the pcap_if structure that describes the adapter, because some filters created by pcap_compile() require it. 15 | 16 | The filter passed to pcap_compile() in this code snippet is "ip and tcp", which means to "keep only the packets that are both IPv4 and TCP and deliver them to the application". 17 | 18 | \code 19 | if (d->addresses != NULL) 20 | /* Retrieve the mask of the first address of the interface */ 21 | netmask=((struct sockaddr_in *)(d->addresses->netmask))->sin_addr.S_un.S_addr; 22 | else 23 | /* If the interface is without an address we suppose to be in a C class network */ 24 | netmask=0xffffff; 25 | 26 | 27 | //compile the filter 28 | if (pcap_compile(adhandle, &fcode, "ip and tcp", 1, netmask) < 0) 29 | { 30 | fprintf(stderr,"\nUnable to compile the packet filter. Check the syntax.\n"); 31 | /* Free the device list */ 32 | pcap_freealldevs(alldevs); 33 | return -1; 34 | } 35 | 36 | //set the filter 37 | if (pcap_setfilter(adhandle, &fcode) < 0) 38 | { 39 | fprintf(stderr,"\nError setting the filter.\n"); 40 | /* Free the device list */ 41 | pcap_freealldevs(alldevs); 42 | return -1; 43 | } 44 | \endcode 45 | 46 | If you want to see some code that uses the filtering functions shown in this lesson, look at the example presented in the next Lesson, \ref wpcap_tut6. 47 | 48 | \ref wpcap_tut4 "<<< Previous" \ref wpcap_tut6 "Next >>>" 49 | 50 | @}*/ 51 | -------------------------------------------------------------------------------- /dox/wpcap_tut6.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | /** @defgroup wpcap_tut6 Interpreting the packets 5 | * @{ 6 | 7 | Now that we are able to capture and filter network traffic, we want to put our knowledge to work with a simple "real world" application. 8 | 9 | In this lesson we will take code from the previous lessons and use these pieces to build a more useful program. the main purpose of the current program is to show how the protocol headers of a captured packet can be parsed and interpreted. 10 | The resulting application, called UDPdump, prints a summary of the UDP traffic on our network. 11 | 12 | We have chosen to parse and display the UDP protocol because it is more accessible than other protocols such as TCP and consequently is an excellent initial example. Let's look at the code: 13 | 14 | \include UDPdump/udpdump.c 15 | 16 | First of all, we set the filter to "ip and udp". In this way we are sure that packet_handler() will receive only UDP packets over IPv4: this simplifies the parsing and increases the efficiency of the program. 17 | 18 | We have also created a couple of structs that describe the IP and UDP headers. These structs are used by packet_handler() to properly locate the various header fields. 19 | 20 | packet_handler(), although limited to a single protocol dissector (UDP over IPv4), shows how complex "sniffers" like tcpdump/WinDump decode the network traffic. Since we aren't interested in the MAC header, we skip it. 21 | For simplicity and before starting the capture, we check the MAC layer with pcap_datalink() to make sure that 22 | we are dealing with an Ethernet network. This way we can be sure that the MAC header is exactly 14 bytes. 23 | 24 | The IP header is located just after the MAC header. We will extract the IP source and destination addresses from the 25 | IP header. 26 | 27 | Reaching the UDP header is a bit more complicated, because the IP header doesn't have a fixed length. 28 | Therefore, we use the IP header's length field to know its size. 29 | Once we know the location of the UDP header, we extract the source and destination ports. 30 | 31 | The extracted values are printed on the screen, and the result is something like: 32 | 33 | 34 | 1. \\Device\\Packet_{A7FD048A-5D4B-478E-B3C1-34401AC3B72F} (Xircom 35 | t 10/100 Adapter) \n 36 | Enter the interface number (1-2):1\n 37 | 38 | listening on Xircom CardBus Ethernet 10/100 Adapter... \n 39 | 16:13:15.312784 len:87 130.192.31.67.2682 -> 130.192.3.21.53 \n 40 | 16:13:15.314796 len:137 130.192.3.21.53 -> 130.192.31.67.2682 \n 41 | 16:13:15.322101 len:78 130.192.31.67.2683 -> 130.192.3.21.53 \n 42 | 43 | 44 | Each of the final 3 lines represents a different packet. 45 | 46 | \ref wpcap_tut5 "<<< Previous" \ref wpcap_tut7 "Next >>>" 47 | 48 | @}*/ 49 | -------------------------------------------------------------------------------- /dox/wpcap_tut8.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | /** @defgroup wpcap_tut8 Sending Packets 5 | * @{ 6 | 7 | Although the name \e WinPcap indicates clearly that the purpose of the library is packet capture, other useful features for raw networking are provided. Among them, the user can find a complete set of functions to send packets. 8 | 9 | Note that the original libpcap library at the moment doesn't provide any way to send packets, therefore all the functions shown here are WinPcap extensions and will not work under Unix. 10 | 11 | Sending a single packet with pcap_sendpacket() 12 | 13 | The simplest way to send a packet is shown in the following code snippet. After opening an adapter, pcap_sendpacket() is called to send a hand-crafted packet. 14 | pcap_sendpacket() takes as arguments a buffer containing the data to send, the length of the buffer 15 | and the adapter that will send it. 16 | Notice that the buffer is sent to the net as is, without any manipulation. This means that the application has to create the correct protocol headers in order to send something meaningful. 17 | 18 | \include misc/sendpack.c 19 | 20 | Send queues 21 | 22 | While pcap_sendpacket() offers a simple and immediate way to send a single packet, send queues provides an advanced, powerful and optimized mechanism to send a collection of packets. 23 | A send queue is a container for a variable number of packets that will be sent to the network. 24 | It has a size, that represents the maximum amount of bytes it can store. 25 | 26 | A send queue is created calling the pcap_sendqueue_alloc() function, specifying the size of the new send queue. 27 | 28 | Once the send queue is created, pcap_sendqueue_queue() can be used to add a packet to the send queue. 29 | This function takes a pcap_pkthdr with the timestamp and the length and a buffer with the data of the packet. 30 | These parameters are the same as those received by pcap_next_ex() and pcap_handler(), therefore queuing a packet that was 31 | just captured or read from a file is a matter of passing these parameters to pcap_sendqueue_queue(). 32 | 33 | To transmit a send queue, WinPcap provides the pcap_sendqueue_transmit() function. 34 | Note the third parameter: if nonzero, the send will be \e synchronized, 35 | i.e. the relative timestamps of the packets will be respected. 36 | This operation requires a remarkable amount of CPU, because the synchronization takes place in the 37 | kernel driver using "busy wait" loops. Although this operation is quite CPU intensive, 38 | it often results in very high precision 39 | packet transmissions (often around few microseconds or less). 40 | 41 | Note that transmitting a send queue with pcap_sendqueue_transmit() is much more efficient than performing a series of pcap_sendpacket(), because the send queue is buffered at kernel level drastically decreasing the number of context switches. 42 | 43 | When a queue is no longer needed, 44 | it can be deleted with pcap_sendqueue_destroy() that frees all the buffers associated with the send queue. 45 | 46 | The next program shows how to use send queues. 47 | It opens a capture file with pcap_open_offline(), 48 | then it moves the packets from the file to a properly allocated send queue. 49 | At his point it transmits the queue, synchronizing it if requested by the user. 50 | 51 | Note that the link-layer of the dumpfile is compared with the one of the interface that will send the packets using pcap_datalink(), and a warning is printed if they are different -- it is important that the capture-file link-layer be the 52 | same as the adapter's link layer for otherwise the tranmission is pointless. 53 | 54 | \include sendcap/sendcap.c 55 | 56 | \ref wpcap_tut7 "<<< Previous" \ref wpcap_tut9 "Next >>>" 57 | 58 | 59 | @}*/ 60 | -------------------------------------------------------------------------------- /dox/wpcap_tut9.txt: -------------------------------------------------------------------------------- 1 | /** @ingroup wpcap_tut 2 | */ 3 | 4 | /** @defgroup wpcap_tut9 Gathering Statistics on the network traffic 5 | * @{ 6 | 7 | This lesson shows another advanced feature of WinPcap: the ability to collect statistics about network traffic. The statistical engine makes use of the kernel-level packet filter to efficiently classify the incoming packet. 8 | You can take a look at the \ref NPF if you want to know more details. 9 | 10 | In order to use this feature, the programmer must open an adapter and put it in \e statistical \e mode. 11 | This can be done with pcap_setmode(). In particular, MODE_STAT must be used as the \e mode argument of this function. 12 | 13 | With statistical mode, making an application that monitors the TCP traffic load is a matter of few lines of code. 14 | The following sample shows how to do it. 15 | 16 | \include tcptop/tcptop.c 17 | 18 | Before enabling statistical mode, the user has the option to set a filter that defines the subset of network traffic that will be monitored. See the paragraph on the \ref language for details. 19 | If no filter has been set, all of the traffic will be monitored. 20 | 21 | Once 22 | 23 | - the filter is set 24 | - pcap_setmode() is called 25 | - callback invocation is enabled with pcap_loop() 26 | 27 | the interface descriptor starts to work in statistical mode. 28 | Notice the fourth parameter (\e to_ms) of pcap_open(): it defines the interval among the statistical samples. 29 | The callback function receives the samples calculated by the driver every \e to_ms milliseconds. These samples are encapsulated in the second and third parameters of the callback function, as shown in the following figure: 30 | 31 | \image html stats_wpcap.gif 32 | 33 | 34 | Two 64-bit counters are provided: the number of packets and the amount of bytes received during the last interval. 35 | 36 | In the example, the adapter is opened with a timeout of 1000 ms. 37 | This means that dispatcher_handler() is called once per second. 38 | At this point a filter that keeps only tcp packets is compiled and set. 39 | Then pcap_setmode() and pcap_loop() are called. 40 | Note that a struct timeval pointer is passed to pcap_loop() as the \e user parameter. 41 | This structure will be used to store a timestamp in order to calculate the interval between two samples. 42 | dispatcher_handler()uses this interval to obtain the bits per second and the 43 | packets per second and then prints these values on the screen. 44 | 45 | Note finally that this example is by far more efficient than a program that captures the packets in the traditional way and calculates statistics at user-level. 46 | Statistical mode requires the minumum amount of data copies and context switches and therefore the CPU is optimized. Moreover, a very small amount of memory is required. 47 | 48 | \ref wpcap_tut8 "<<< Previous" 49 | 50 | @}*/ 51 | 52 | 53 | -------------------------------------------------------------------------------- /integrate_libpcap.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo Copying files... 4 | 5 | set LIBPCAP_FOLDER=..\libpcap 6 | set LIBPCAP_TEMP_FOLDER=.\libpcap_temp 7 | 8 | rmdir /S /Q %LIBPCAP_TEMP_FOLDER% >NUL 2>NUL 9 | 10 | mkdir %LIBPCAP_TEMP_FOLDER% >NUL 11 | 12 | xcopy /s/e/v %LIBPCAP_FOLDER%\*.* %LIBPCAP_TEMP_FOLDER%\ >NUL 13 | 14 | xcopy /s/e/v /y %LIBPCAP_TEMP_FOLDER%\*.* .\wpcap\libpcap >NUL 15 | 16 | rmdir /S /Q %LIBPCAP_TEMP_FOLDER% >NUL 17 | 18 | set LIBPCAP_FOLDER= 19 | set LIBPCAP_TEMP_FOLDER= 20 | 21 | echo Copying files -- Done 22 | 23 | echo --------------------------------------- 24 | 25 | echo Applying remote code patch... 26 | pushd .\wpcap\libpcap\ 27 | patch -p1 -s < remote_code.patch 28 | chmod -R guoa+rw * 29 | del /s *.orig >NUL 2>NUL 30 | popd 31 | echo Applying remote code patch -- Done 32 | 33 | echo --------------------------------------- 34 | 35 | echo Applying TurboCap code patch... 36 | pushd .\wpcap\libpcap\ 37 | patch -p1 -s < tc.patch 38 | chmod -R guoa+rw * 39 | del /s *.orig >NUL 2>NUL 40 | popd 41 | echo Applying TurboCap code patch -- Done 42 | 43 | echo --------------------------------------- 44 | 45 | echo DOS'ifing the libpcap makefile... 46 | pushd .\wpcap\libpcap\win32\prj 47 | unix2dos libpcap.dsp 48 | popd 49 | echo DOS'ifing the libpcap makefile -- Done 50 | 51 | echo --------------------------------------- 52 | 53 | echo Generating the compiler files... 54 | pushd .\wpcap\prj\ 55 | call build_scanner_parser.bat 56 | popd 57 | echo Generating the compiler files -- Done 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /packetWin7/Dll/Extra_lib_x64/npptools.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/packetWin7/Dll/Extra_lib_x64/npptools.lib -------------------------------------------------------------------------------- /packetWin7/Dll/Packet.def: -------------------------------------------------------------------------------- 1 | LIBRARY packet 2 | 3 | EXPORTS 4 | PacketLibraryVersion 5 | PacketGetVersion 6 | PacketGetDriverVersion 7 | PacketGetDriverName 8 | PacketOpenAdapter 9 | PacketSendPacket 10 | PacketSendPackets 11 | PacketAllocatePacket 12 | PacketInitPacket 13 | PacketFreePacket 14 | PacketReceivePacket 15 | PacketCloseAdapter 16 | PacketSetHwFilter 17 | PacketGetAdapterNames 18 | PacketRequest 19 | PacketSetBuff 20 | PacketSetBpf 21 | PacketSetSnapLen 22 | PacketGetStats 23 | PacketGetStatsEx 24 | PacketGetNetType 25 | PacketIsLoopbackAdapter 26 | PacketIsMonitorModeSupported 27 | PacketSetMonitorMode 28 | PacketGetMonitorMode 29 | PacketSetReadTimeout 30 | PacketSetMode 31 | PacketSetNumWrites 32 | PacketGetNetInfoEx 33 | PacketSetMinToCopy 34 | PacketGetReadEvent 35 | PacketStopDriver 36 | PacketSetDumpName 37 | PacketSetDumpLimits 38 | PacketIsDumpEnded 39 | PacketSetLoopbackBehavior 40 | PacketGetAirPcapHandle 41 | -------------------------------------------------------------------------------- /packetWin7/Dll/Packet32.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/packetWin7/Dll/Packet32.cpp -------------------------------------------------------------------------------- /packetWin7/Dll/Project/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | # OPTFLAGS = -g -DDBG 5 | OPTFLAGS = -O -D_WINNT4 6 | # I am suspicious of -O2 since it hosed wpcap.dll. To be safe, use -O only 7 | 8 | CFLAGS = -I ../../../common -shared -mno-cygwin ${OPTFLAGS} -I.. 9 | LDFLAGS = -Wl,--out-implib,libpacket.a 10 | OBJS = ../Packet32.o ../AdInfo.o 11 | LIBS = -lws2_32 -lversion 12 | 13 | Packet.dll: ${OBJS} 14 | ${CC} ${CFLAGS} ${LDFLAGS} -o Packet.dll ../Packet.def ${OBJS} ${LIBS} 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -o $*.o -c $< 18 | 19 | clean: 20 | ${RM} ${OBJS} libpacket.a Packet.dll 21 | 22 | install: Packet.dll 23 | cp Packet.dll c:/winnt/system32 24 | -------------------------------------------------------------------------------- /packetWin7/Dll/Project/Packet.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | 64 | 65 | Resource Files 66 | 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/Dll/WanPacket/WanPacket.def: -------------------------------------------------------------------------------- 1 | LIBRARY WanPacket 2 | EXPORTS 3 | WanPacketOpenAdapter 4 | WanPacketCloseAdapter 5 | WanPacketReceivePacket 6 | WanPacketSetBufferSize 7 | WanPacketSetBpfFilter 8 | WanPacketSetMinToCopy 9 | WanPacketSetReadTimeout 10 | WanPacketGetStats 11 | WanPacketGetReadEvent 12 | WanPacketSetMode 13 | WanPacketTestAdapter -------------------------------------------------------------------------------- /packetWin7/Dll/WanPacket/WanPacket.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "WanPacket"=.\WanPacket.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /packetWin7/Dll/WanPacket/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "Version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/Dll/WanPacket/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // WinPcapOem.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK 0x17L 16 | #ifdef _DEBUG 17 | FILEFLAGS 0x1L 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS 0x4L 22 | FILETYPE 0x2L 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "WinPcap low level NetMon wrapper library" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "WanPacket.dll" 33 | VALUE "LegalCopyright", WINPCAP_WANPACKET_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "WanPacket.dll" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/Dll/version.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/packetWin7/Dll/version.aps -------------------------------------------------------------------------------- /packetWin7/Dll/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/Dll/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK 0x17L 16 | #ifdef _DEBUG 17 | FILEFLAGS 0x1L 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS 0x4L 22 | FILETYPE 0x2L 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "The Packet API for Windows" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "Packet.dll" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "Packet.dll" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NpcapHelper", "NpcapHelper\NpcapHelper.vcxproj", "{917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NpcapHelperTest", "NpcapHelperTest\NpcapHelperTest.vcxproj", "{3F697FA8-4C35-416C-A381-2631AAB79D39}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | OEM Release|Win32 = OEM Release|Win32 15 | OEM Release|x64 = OEM Release|x64 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|Win32.Build.0 = Debug|Win32 22 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|x64.ActiveCfg = Debug|x64 23 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|x64.Build.0 = Debug|x64 24 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|Win32.ActiveCfg = OEM Release|Win32 25 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|Win32.Build.0 = OEM Release|Win32 26 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|x64.ActiveCfg = OEM Release|x64 27 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|x64.Build.0 = OEM Release|x64 28 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|Win32.ActiveCfg = Release|Win32 29 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|Win32.Build.0 = Release|Win32 30 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|x64.ActiveCfg = Release|x64 31 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|x64.Build.0 = Release|x64 32 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|Win32.Build.0 = Debug|Win32 34 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|x64.ActiveCfg = Debug|x64 35 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|x64.Build.0 = Debug|x64 36 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|Win32.ActiveCfg = Release|Win32 37 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|Win32.Build.0 = Release|Win32 38 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|x64.ActiveCfg = Release|x64 39 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|x64.Build.0 = Release|x64 40 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|Win32.ActiveCfg = Release|Win32 41 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|Win32.Build.0 = Release|Win32 42 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|x64.ActiveCfg = Release|x64 43 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|x64.Build.0 = Release|x64 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/NpcapHelper.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | 31 | 32 | Resource Files 33 | 34 | 35 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by version.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK 0x17L 16 | #ifdef _DEBUG 17 | FILEFLAGS 0x1L 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS 0x4L 22 | FILETYPE 0x2L 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "The helper program for \x22Admin-only Mode\x22" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "NpcapHelper.exe" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "NpcapHelper.exe" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelperTest/NpcapHelperTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NPFInstall", "NPFInstall\NPFInstall.vcxproj", "{5D8A2717-4F35-4402-B868-45612D27291B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug(WinPcap Mode)|Win32 = Debug(WinPcap Mode)|Win32 11 | Debug(WinPcap Mode)|x64 = Debug(WinPcap Mode)|x64 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | OEM Release(WinPcap Mode)|Win32 = OEM Release(WinPcap Mode)|Win32 15 | OEM Release(WinPcap Mode)|x64 = OEM Release(WinPcap Mode)|x64 16 | OEM Release|Win32 = OEM Release|Win32 17 | OEM Release|x64 = OEM Release|x64 18 | Release(WinPcap Mode)|Win32 = Release(WinPcap Mode)|Win32 19 | Release(WinPcap Mode)|x64 = Release(WinPcap Mode)|x64 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug(WinPcap Mode)|Win32.ActiveCfg = Debug(WinPcap Mode)|Win32 25 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug(WinPcap Mode)|Win32.Build.0 = Debug(WinPcap Mode)|Win32 26 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug(WinPcap Mode)|x64.ActiveCfg = Debug(WinPcap Mode)|x64 27 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug(WinPcap Mode)|x64.Build.0 = Debug(WinPcap Mode)|x64 28 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|Win32.Build.0 = Debug|Win32 30 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|x64.ActiveCfg = Debug|x64 31 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|x64.Build.0 = Debug|x64 32 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release(WinPcap Mode)|Win32.ActiveCfg = OEM Release(WinPcap Mode)|Win32 33 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release(WinPcap Mode)|Win32.Build.0 = OEM Release(WinPcap Mode)|Win32 34 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release(WinPcap Mode)|x64.ActiveCfg = OEM Release(WinPcap Mode)|x64 35 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release(WinPcap Mode)|x64.Build.0 = OEM Release(WinPcap Mode)|x64 36 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|Win32.ActiveCfg = OEM Release|Win32 37 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|Win32.Build.0 = OEM Release|Win32 38 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|x64.ActiveCfg = OEM Release|x64 39 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|x64.Build.0 = OEM Release|x64 40 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release(WinPcap Mode)|Win32.ActiveCfg = Release(WinPcap Mode)|Win32 41 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release(WinPcap Mode)|Win32.Build.0 = Release(WinPcap Mode)|Win32 42 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release(WinPcap Mode)|x64.ActiveCfg = Release(WinPcap Mode)|x64 43 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release(WinPcap Mode)|x64.Build.0 = Release(WinPcap Mode)|x64 44 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|Win32.ActiveCfg = Release|Win32 45 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|Win32.Build.0 = Release|Win32 46 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|x64.ActiveCfg = Release|x64 47 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|x64.Build.0 = Release|x64 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | EndGlobal 53 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/NPFInstall.exe.manifest.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/rc_ids.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Module Name: 6 | 7 | rc_ids.h 8 | 9 | Abstract: 10 | 11 | Header for devcon resources 12 | 13 | --*/ 14 | 15 | #define IDS_ENABLED 3000 16 | #define IDS_ENABLED_REBOOT 3001 17 | #define IDS_ENABLE_FAILED 3002 18 | #define IDS_DISABLED 3003 19 | #define IDS_DISABLED_REBOOT 3004 20 | #define IDS_DISABLE_FAILED 3005 21 | #define IDS_RESTARTED 3006 22 | #define IDS_REQUIRES_REBOOT 3007 23 | #define IDS_RESTART_FAILED 3008 24 | #define IDS_REMOVED 3009 25 | #define IDS_REMOVED_REBOOT 3010 26 | #define IDS_REMOVE_FAILED 3011 27 | 28 | 29 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK 0x17L 16 | #ifdef _DEBUG 17 | FILEFLAGS 0x1L 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS 0x4L 22 | FILETYPE 0x2L 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "A LWF & WFP driver installation tool" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "NPFInstall.exe" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "NPFInstall.exe" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WlanHelper", "WlanHelper\WlanHelper.vcxproj", "{044CB4DC-827D-4134-B14B-DE114E884BB9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | OEM Release|Win32 = OEM Release|Win32 13 | OEM Release|x64 = OEM Release|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|Win32.Build.0 = Debug|Win32 20 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|x64.ActiveCfg = Debug|x64 21 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|x64.Build.0 = Debug|x64 22 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|Win32.ActiveCfg = OEM Release|Win32 23 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|Win32.Build.0 = OEM Release|Win32 24 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|x64.ActiveCfg = OEM Release|x64 25 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|x64.Build.0 = OEM Release|x64 26 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|Win32.ActiveCfg = Release|Win32 27 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|Win32.Build.0 = Release|Win32 28 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|x64.ActiveCfg = Release|x64 29 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|x64.Build.0 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/WlanHelper.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | 31 | 32 | Resource Files 33 | 34 | 35 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/version.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/packetWin7/WlanHelper/WlanHelper/version.rc -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK 0x17L 16 | #ifdef _DEBUG 17 | FILEFLAGS 0x1L 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS 0x4L 22 | FILETYPE 0x2L 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "A tool for wireless adapter settings" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "WlanHelper.exe" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "WlanHelper.exe" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/npf/npf/npcap.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/packetWin7/npf/npf/npcap.rc -------------------------------------------------------------------------------- /packetWin7/npf/npf/npcap_wfp.inf: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------- 2 | ; NPCAP_WFP.INF -- Npcap NDIS 6.x LightWeight Filter Driver 3 | ; 4 | ; Copyright (c) 2015, Insecure.Com LLC. All rights reserved. 5 | ;------------------------------------------------------------------------ 6 | [version] 7 | Signature = "$Windows NT$" 8 | Class = WFPCALLOUTS 9 | ClassGUID = {57465043-616C-6C6F-7574-5F636C617373} 10 | CatalogFile = %NPF_DriverName%.cat 11 | Provider = %Insecure% 12 | DriverVer=05/15/2015,14.48.38.905 13 | 14 | 15 | [Manufacturer] 16 | %Insecure%=Insecure,NTx86,NTia64,NTamd64 17 | 18 | [Insecure.NTx86] 19 | %NPF_Desc%=Install, INSECURE_NPCAP 20 | 21 | [Insecure.NTia64] 22 | %NPF_Desc%=Install, INSECURE_NPCAP 23 | 24 | [Insecure.NTamd64] 25 | %NPF_Desc%=Install, INSECURE_NPCAP 26 | 27 | ;------------------------------------------------------------------------- 28 | ; Installation Section 29 | ;------------------------------------------------------------------------- 30 | [Install] 31 | AddReg=Inst_Ndi 32 | Characteristics=0x40000 33 | NetCfgInstanceId="{7daf2ac8-e9f6-4765-a842-f1f5d2501341}" 34 | Copyfiles = npf.copyfiles.sys 35 | 36 | [SourceDisksNames] 37 | 1=%NPF_Desc%,"",, 38 | 39 | [SourceDisksFiles] 40 | npcap.sys=1 41 | 42 | [DestinationDirs] 43 | DefaultDestDir=12 44 | npf.copyfiles.sys=12 45 | 46 | [npf.copyfiles.sys] 47 | %NPF_DriverName%.sys,,,2 48 | 49 | 50 | ;------------------------------------------------------------------------- 51 | ; Ndi installation support 52 | ;------------------------------------------------------------------------- 53 | [Inst_Ndi] 54 | HKR, Ndi,Service,,%NPF_DriverName% 55 | HKR, Ndi,CoServices,0x00010000,%NPF_DriverName% 56 | HKR, Ndi,HelpText,,%NPF_HelpText% 57 | 58 | ;------------------------------------------------------------------------- 59 | ; Service installation support 60 | ;------------------------------------------------------------------------- 61 | [Install.Services] 62 | AddService=%NPF_DriverName%,,NPF_Service_Inst 63 | 64 | [NPF_Service_Inst] 65 | DisplayName = %NPF_Desc% 66 | ServiceType = 1 ;SERVICE_KERNEL_DRIVER 67 | StartType = 1 ;SERVICE_SYSTEM_START 68 | ErrorControl = 1 ;SERVICE_ERROR_NORMAL 69 | ServiceBinary = %12%\%NPF_DriverName%.sys 70 | LoadOrderGroup = NDIS 71 | Description = %NPF_Desc% 72 | AddReg = Common.Params.reg 73 | 74 | [Common.Params.reg] 75 | 76 | [Strings] 77 | NPF_DriverName = "npcap" 78 | Insecure = "Nmap Project" 79 | NPF_Desc = "Npcap Packet Driver (NPCAP)" 80 | NPF_HelpText = "A NDIS 6 filter driver & WFP callout driver to support packet capturing and sending under Windows 7, 8 & 10" 81 | -------------------------------------------------------------------------------- /packetWin7/npf/npf/npf.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/packetWin7/npf/npf/npf.rc -------------------------------------------------------------------------------- /packetWin7/npf/npf/npf_wfp.inf: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------- 2 | ; NPF_WFP.INF -- Npcap NDIS 6.x LightWeight Filter Driver 3 | ; 4 | ; Copyright (c) 2015, Insecure.Com LLC. All rights reserved. 5 | ;------------------------------------------------------------------------ 6 | [version] 7 | Signature = "$Windows NT$" 8 | Class = WFPCALLOUTS 9 | ClassGUID = {57465043-616C-6C6F-7574-5F636C617373} 10 | CatalogFile = %NPF_DriverName%.cat 11 | Provider = %Insecure% 12 | DriverVer=05/15/2015,14.48.38.905 13 | 14 | 15 | [Manufacturer] 16 | %Insecure%=Insecure,NTx86,NTia64,NTamd64 17 | 18 | [Insecure.NTx86] 19 | %NPF_Desc%=Install, INSECURE_NPF 20 | 21 | [Insecure.NTia64] 22 | %NPF_Desc%=Install, INSECURE_NPF 23 | 24 | [Insecure.NTamd64] 25 | %NPF_Desc%=Install, INSECURE_NPF 26 | 27 | ;------------------------------------------------------------------------- 28 | ; Installation Section 29 | ;------------------------------------------------------------------------- 30 | [Install] 31 | AddReg=Inst_Ndi 32 | Characteristics=0x40000 33 | NetCfgInstanceId="{7daf2ac8-e9f6-4765-a842-f1f5d2501340}" 34 | Copyfiles = npf.copyfiles.sys 35 | 36 | [SourceDisksNames] 37 | 1=%NPF_Desc%,"",, 38 | 39 | [SourceDisksFiles] 40 | npf.sys=1 41 | 42 | [DestinationDirs] 43 | DefaultDestDir=12 44 | npf.copyfiles.sys=12 45 | 46 | [npf.copyfiles.sys] 47 | %NPF_DriverName%.sys,,,2 48 | 49 | 50 | ;------------------------------------------------------------------------- 51 | ; Ndi installation support 52 | ;------------------------------------------------------------------------- 53 | [Inst_Ndi] 54 | HKR, Ndi,Service,,%NPF_DriverName% 55 | HKR, Ndi,CoServices,0x00010000,%NPF_DriverName% 56 | HKR, Ndi,HelpText,,%NPF_HelpText% 57 | 58 | ;------------------------------------------------------------------------- 59 | ; Service installation support 60 | ;------------------------------------------------------------------------- 61 | [Install.Services] 62 | AddService=%NPF_DriverName%,,NPF_Service_Inst 63 | 64 | [NPF_Service_Inst] 65 | DisplayName = %NPF_Desc% 66 | ServiceType = 1 ;SERVICE_KERNEL_DRIVER 67 | StartType = 1 ;SERVICE_SYSTEM_START 68 | ErrorControl = 1 ;SERVICE_ERROR_NORMAL 69 | ServiceBinary = %12%\%NPF_DriverName%.sys 70 | LoadOrderGroup = NDIS 71 | Description = %NPF_Desc% 72 | AddReg = Common.Params.reg 73 | 74 | [Common.Params.reg] 75 | 76 | [Strings] 77 | NPF_DriverName = "npf" 78 | Insecure = "Nmap Project" 79 | NPF_Desc = "Npcap Packet Driver (NPF)" 80 | NPF_HelpText = "A NDIS 6 filter driver & WFP callout driver to support packet capturing and sending under Windows 7, 8 & 10" 81 | -------------------------------------------------------------------------------- /todo.txt: -------------------------------------------------------------------------------- 1 | - Implement the kernel dump with the new buffering mode 2 | - Check the buffered write functionality, in particular with the new gigabit adapters that caused problems to some users 3 | - Change the #define WIN32 with #define _WIN32 4 | -------------------------------------------------------------------------------- /wpcap/Win32-Extensions/version.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BajlandoKG/nmap-npcap/cf7bfc3973f7ae9683c4732e0dcc89abcd5a2d52/wpcap/Win32-Extensions/version.aps -------------------------------------------------------------------------------- /wpcap/Win32-Extensions/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /wpcap/Win32-Extensions/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // Version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK 0x17L 16 | #ifdef _DEBUG 17 | FILEFLAGS 0x1L 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS 0x4L 22 | FILETYPE 0x2L 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "The libpcap API" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "wpcap.dll" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "wpcap.dll" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | --------------------------------------------------------------------------------