{"id":445,"date":"2018-11-12T22:38:15","date_gmt":"2018-11-13T03:38:15","guid":{"rendered":"http:\/\/www.rajatswarup.com\/blog\/?p=445"},"modified":"2018-11-12T22:38:15","modified_gmt":"2018-11-13T03:38:15","slug":"pcaprub-installation-on-win-10-x64","status":"publish","type":"post","link":"https:\/\/www.rajatswarup.com\/blog\/2018\/11\/12\/pcaprub-installation-on-win-10-x64\/","title":{"rendered":"Pcaprub installation on Win 10 x64"},"content":{"rendered":"<p>If you encounter the following error, the issue is pcaprub uses a hardcoded path for Winpcap.\u00a0 I downloaded winpcap v4.1.3 and downloaded the dev kit for Winpcap and put it in c:\\WpdPack.\u00a0\u00a0 Additionally, since I use an x64 machine I had to copy the file C:\\WpdPack\\Lib\\x64\\*.lib into C:\\WpdPack\\Lib and then the compilation worked.<\/p>\n<p>You need pcaprub for things like msf.<\/p>\n<p>&nbsp;<\/p>\n<pre>C:\\dev\\kit&gt;gem install pcaprub\r\nTemporarily enhancing PATH for MSYS\/MINGW...\r\nBuilding native extensions. This could take a while...\r\nERROR: Error installing pcaprub:\r\nERROR: Failed to build gem native extension.\r\n\r\ncurrent directory: C:\/Ruby24-x64\/lib\/ruby\/gems\/2.4.0\/gems\/pcaprub-0.13.0\/ext\/pcaprub_c\r\nC:\/Ruby24-x64\/bin\/ruby.exe -r .\/siteconf20181112-2628-1wqgu6f.rb extconf.rb\r\n\r\n[*] Running checks for pcaprub_c code...\r\nplatform is x64-mingw32\r\nchecking for -lws2_32... yes\r\nchecking for -liphlpapi... yes\r\nchecking for windows.h... yes\r\nchecking for winsock2.h... yes\r\nchecking for iphlpapi.h... yes\r\nchecking for ruby\/thread.h... yes\r\nchecking for rb_thread_blocking_region()... no\r\nchecking for rb_thread_call_without_gvl()... yes\r\nchecking for pcap_open_live() in -lwpcap... no\r\nchecking for pcap_setnonblock() in -lwpcap... no\r\ncreating Makefile\r\n\r\ncurrent directory: C:\/Ruby24-x64\/lib\/ruby\/gems\/2.4.0\/gems\/pcaprub-0.13.0\/ext\/pcaprub_c\r\nmake \"DESTDIR=\" clean\r\n\r\ncurrent directory: C:\/Ruby24-x64\/lib\/ruby\/gems\/2.4.0\/gems\/pcaprub-0.13.0\/ext\/pcaprub_c\r\nmake \"DESTDIR=\"\r\ngenerating pcaprub_c-x64-mingw32.def\r\ncompiling pcaprub.c\r\nIn file included from C:\/WpdPack\/include\/pcap\/pcap.h:41,\r\nfrom C:\/WpdPack\/include\/pcap.h:45,\r\nfrom pcaprub.c:11:\r\nC:\/WpdPack\/include\/pcap-stdinc.h:64: warning: \"snprintf\" redefined\r\n#define snprintf _snprintf\r\n\r\nIn file included from C:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby\/ruby.h:2429,\r\nfrom C:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby.h:33,\r\nfrom pcaprub.c:1:\r\nC:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby\/subst.h:6: note: this is the location of the previous definition\r\n#define snprintf ruby_snprintf\r\n\r\nIn file included from C:\/WpdPack\/include\/pcap\/pcap.h:41,\r\nfrom C:\/WpdPack\/include\/pcap.h:45,\r\nfrom pcaprub.c:11:\r\nC:\/WpdPack\/include\/pcap-stdinc.h:65: warning: \"vsnprintf\" redefined\r\n#define vsnprintf _vsnprintf\r\n\r\nIn file included from C:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby\/ruby.h:2429,\r\nfrom C:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby.h:33,\r\nfrom pcaprub.c:1:\r\nC:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby\/subst.h:7: note: this is the location of the previous definition\r\n#define vsnprintf ruby_vsnprintf\r\n\r\npcaprub.c: In function 'rbpcap_each_data':\r\npcaprub.c:992:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]\r\nfno = (int)pcap_getevent(rbp-&gt;pd);\r\n^\r\npcaprub.c:992:7: warning: assignment to 'HANDLE' {aka 'void *'} from 'int' makes pointer from integer without a cast [-W\r\nint-conversion]\r\nfno = (int)pcap_getevent(rbp-&gt;pd);\r\n^\r\npcaprub.c: In function 'rbpcap_each_packet':\r\npcaprub.c:1034:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]\r\nfno = (int)pcap_getevent(rbp-&gt;pd);\r\n^\r\npcaprub.c:1034:7: warning: assignment to 'HANDLE' {aka 'void *'} from 'int' makes pointer from integer without a cast [-\r\nWint-conversion]\r\nfno = (int)pcap_getevent(rbp-&gt;pd);\r\n^\r\npcaprub.c: In function 'rbpcap_thread_wait_handle':\r\npcaprub.c:1274:7: warning: passing argument 1 of 'rb_thread_call_without_gvl' from incompatible pointer type [-Wincompat\r\nible-pointer-types]\r\nrbpcap_thread_wait_handle_blocking,\r\n^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nIn file included from pcaprub.c:4:\r\nC:\/Ruby24-x64\/include\/ruby-2.4.0\/ruby\/thread.h:28:7: note: expected 'void * (*)(void *)' but argument is of type 'VALUE\r\n(*)(void *)' {aka 'long long unsigned int (*)(void *)'}\r\nvoid *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,\r\n^~~~~~~~~~~~~~~~~~~~~~~~~~\r\nlinking shared-object pcaprub_c.so\r\npcaprub.o:pcaprub.c:(.text+0x1a0): undefined reference to `pcap_lib_version'\r\npcaprub.o:pcaprub.c:(.text+0x1e0): undefined reference to `pcap_findalldevs'\r\npcaprub.o:pcaprub.c:(.text+0x2b8): undefined reference to `pcap_freealldevs'\r\npcaprub.o:pcaprub.c:(.text+0x32f): undefined reference to `pcap_lookupnet'\r\npcaprub.o:pcaprub.c:(.text+0x43d): undefined reference to `pcap_close'\r\npcaprub.o:pcaprub.c:(.text+0x45a): undefined reference to `pcap_dump_close'\r\npcaprub.o:pcaprub.c:(.text+0x67c): undefined reference to `pcap_set_timeout'\r\npcaprub.o:pcaprub.c:(.text+0x6ce): undefined reference to `pcap_list_datalinks'\r\npcaprub.o:pcaprub.c:(.text+0x707): undefined reference to `pcap_datalink_val_to_name'\r\npcaprub.o:pcaprub.c:(.text+0x76d): undefined reference to `pcap_free_datalinks'\r\npcaprub.o:pcaprub.c:(.text+0x782): undefined reference to `pcap_geterr'\r\npcaprub.o:pcaprub.c:(.text+0x828): undefined reference to `pcap_datalink_name_to_val'\r\npcaprub.o:pcaprub.c:(.text+0x895): undefined reference to `pcap_set_datalink'\r\npcaprub.o:pcaprub.c:(.text+0x8b3): undefined reference to `pcap_geterr'\r\npcaprub.o:pcaprub.c:(.text+0x93f): undefined reference to `pcap_set_snaplen'\r\npcaprub.o:pcaprub.c:(.text+0x9d4): undefined reference to `pcap_set_promisc'\r\npcaprub.o:pcaprub.c:(.text+0xae1): undefined reference to `pcap_lookupnet'\r\npcaprub.o:pcaprub.c:(.text+0xb57): undefined reference to `pcap_compile'\r\npcaprub.o:pcaprub.c:(.text+0xb6d): undefined reference to `pcap_geterr'\r\npcaprub.o:pcaprub.c:(.text+0xb9f): undefined reference to `pcap_setfilter'\r\npcaprub.o:pcaprub.c:(.text+0xbaf): undefined reference to `pcap_freecode'\r\npcaprub.o:pcaprub.c:(.text+0xbc1): undefined reference to `pcap_geterr'\r\npcaprub.o:pcaprub.c:(.text+0xbe9): undefined reference to `pcap_freecode'\r\npcaprub.o:pcaprub.c:(.text+0xc62): undefined reference to `pcap_compile'\r\npcaprub.o:pcaprub.c:(.text+0xc75): undefined reference to `pcap_geterr'\r\npcaprub.o:pcaprub.c:(.text+0xc9d): undefined reference to `pcap_freecode'\r\npcaprub.o:pcaprub.c:(.text+0xccf): undefined reference to `pcap_activate'\r\npcaprub.o:pcaprub.c:(.text+0xd33): undefined reference to `pcap_close'\r\npcaprub.o:pcaprub.c:(.text+0xe0b): undefined reference to `pcap_close'\r\npcaprub.o:pcaprub.c:(.text+0xe43): undefined reference to `pcap_create'\r\npcaprub.o:pcaprub.c:(.text+0x109e): undefined reference to `pcap_close'\r\npcaprub.o:pcaprub.c:(.text+0x110d): undefined reference to `pcap_open_live'\r\npcaprub.o:pcaprub.c:(.text+0x129f): undefined reference to `pcap_open_offline'\r\npcaprub.o:pcaprub.c:(.text+0x1419): undefined reference to `pcap_open_dead'\r\npcaprub.o:pcaprub.c:(.text+0x1532): undefined reference to `pcap_dump_open'\r\npcaprub.o:pcaprub.c:(.text+0x15d9): undefined reference to `pcap_dump_close'\r\npcaprub.o:pcaprub.c:(.text+0x171e): undefined reference to `pcap_dump'\r\npcaprub.o:pcaprub.c:(.text+0x17e7): undefined reference to `pcap_sendpacket'\r\npcaprub.o:pcaprub.c:(.text+0x17fa): undefined reference to `pcap_geterr'\r\npcaprub.o:pcaprub.c:(.text+0x18ea): undefined reference to `pcap_setnonblock'\r\npcaprub.o:pcaprub.c:(.text+0x1912): undefined reference to `pcap_dispatch'\r\npcaprub.o:pcaprub.c:(.text+0x19fd): undefined reference to `pcap_setnonblock'\r\npcaprub.o:pcaprub.c:(.text+0x1a25): undefined reference to `pcap_dispatch'\r\npcaprub.o:pcaprub.c:(.text+0x1b35): undefined reference to `pcap_getevent'\r\npcaprub.o:pcaprub.c:(.text+0x1be3): undefined reference to `pcap_getevent'\r\npcaprub.o:pcaprub.c:(.text+0x1c91): undefined reference to `pcap_datalink'\r\npcaprub.o:pcaprub.c:(.text+0x1cdc): undefined reference to `pcap_major_version'\r\npcaprub.o:pcaprub.c:(.text+0x1d27): undefined reference to `pcap_minor_version'\r\npcaprub.o:pcaprub.c:(.text+0x1d72): undefined reference to `pcap_snapshot'\r\npcaprub.o:pcaprub.c:(.text+0x1dca): undefined reference to `pcap_stats'\r\ncollect2.exe: error: ld returned 1 exit status\r\nmake: *** [Makefile:259: pcaprub_c.so] Error 1\r\n\r\nmake failed, exit code 2\r\n\r\nGem files will remain installed in C:\/Ruby24-x64\/lib\/ruby\/gems\/2.4.0\/gems\/pcaprub-0.13.0 for inspection.\r\nResults logged to C:\/Ruby24-x64\/lib\/ruby\/gems\/2.4.0\/extensions\/x64-mingw32\/2.4.0\/pcaprub-0.13.0\/gem_make.out<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you encounter the following error, the issue is pcaprub uses a hardcoded path for Winpcap.\u00a0 I downloaded winpcap v4.1.3 and downloaded the dev kit for Winpcap and put it in c:\\WpdPack.\u00a0\u00a0 Additionally, since I use an x64 machine I had to copy the file C:\\WpdPack\\Lib\\x64\\*.lib into C:\\WpdPack\\Lib and then the compilation worked. You need [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[230],"tags":[229,221],"class_list":["post-445","post","type-post","status-publish","format-standard","hentry","category-howto","tag-error","tag-metasploit"],"_links":{"self":[{"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/posts\/445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":1,"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":446,"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions\/446"}],"wp:attachment":[{"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rajatswarup.com\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}