- 下载安装包
https://nmap.org/download.html
- 编译
$ ./configure --prefix=/path/to/nmap/install --without-nping --without-ncat
$ make
$ make install
如果在编译中遇到如下错误:
g++ -Wl,-E -Lnbase -Lnsock/src/ -o nmap charpool.o FingerPrintResults.o FPEngine.o FPModel.o idle_scan.o MACLookup.o nmap_dns.o nmap_error.o nmap.o nmap_ftp.o NmapOps.o NmapOutputTable.o nmap_tty.o osscan2.o osscan.o output.o payload.o portlist.o portreasons.o protocols.o scan_engine.o scan_engine_connect.o scan_engine_raw.o scan_lists.o service_scan.o services.o string_pool.o NewTargets.o TargetGroup.o Target.o targets.o tcpip.o timing.o traceroute.o utils.o xml.o nse_main.o nse_utility.o nse_nsock.o nse_dnet.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_lpeg.o nse_openssl.o nse_ssl_cert.o nse_libssh2.o nse_zlib.o main.o -lnsock -lnbase -lpcre libpcap/libpcap.a libssh2/lib/libssh2.a -lssl -lcrypto -lz libnetutil/libnetutil.a ./libdnet-stripped/src/.libs/libdnet.a ./liblua/liblua.a ./liblinear/liblinear.a -ldl
libpcap/libpcap.a(pcap-rdmasniff.o): In function `rdmasniff_read':
nmap-7.91/libpcap/./pcap-rdmasniff.c:125: undefined reference to `ibv_get_cq_event'
nmap-7.91/libpcap/./pcap-rdmasniff.c:134: undefined reference to `ibv_ack_cq_events'
nmap-7.91/libpcap/./pcap-rdmasniff.c:146: undefined reference to `ibv_wc_status_str'
libpcap/libpcap.a(pcap-rdmasniff.o): In function `rdmasniff_activate':
nmap-7.91/libpcap/./pcap-rdmasniff.c:198: undefined reference to `ibv_open_device'
nmap-7.91/libpcap/./pcap-rdmasniff.c:205: undefined reference to `ibv_alloc_pd'
nmap-7.91/libpcap/./pcap-rdmasniff.c:212: undefined reference to `ibv_create_comp_channel'
nmap-7.91/libpcap/./pcap-rdmasniff.c:219: undefined reference to `ibv_create_cq'
nmap-7.91/libpcap/./pcap-rdmasniff.c:234: undefined reference to `ibv_create_qp'
nmap-7.91/libpcap/./pcap-rdmasniff.c:244: undefined reference to `ibv_modify_qp'
nmap-7.91/libpcap/./pcap-rdmasniff.c:322: undefined reference to `ibv_dereg_mr'
nmap-7.91/libpcap/./pcap-rdmasniff.c:330: undefined reference to `ibv_destroy_qp'
nmap-7.91/libpcap/./pcap-rdmasniff.c:334: undefined reference to `ibv_destroy_cq'
nmap-7.91/libpcap/./pcap-rdmasniff.c:338: undefined reference to `ibv_destroy_comp_channel'
nmap-7.91/libpcap/./pcap-rdmasniff.c:342: undefined reference to `ibv_dealloc_pd'
nmap-7.91/libpcap/./pcap-rdmasniff.c:346: undefined reference to `ibv_close_device'
nmap-7.91/libpcap/./pcap-rdmasniff.c:252: undefined reference to `ibv_modify_qp'
nmap-7.91/libpcap/./pcap-rdmasniff.c:284: undefined reference to `ibv_reg_mr'
libpcap/libpcap.a(pcap-rdmasniff.o): In function `___ibv_query_port':
/usr/include/infiniband/verbs.h:1617: undefined reference to `ibv_query_port'
libpcap/libpcap.a(pcap-rdmasniff.o): In function `rdmasniff_cleanup':
nmap-7.91/libpcap/./pcap-rdmasniff.c:82: undefined reference to `ibv_dereg_mr'
nmap-7.91/libpcap/./pcap-rdmasniff.c:84: undefined reference to `ibv_destroy_qp'
nmap-7.91/libpcap/./pcap-rdmasniff.c:85: undefined reference to `ibv_destroy_cq'
nmap-7.91/libpcap/./pcap-rdmasniff.c:86: undefined reference to `ibv_dealloc_pd'
nmap-7.91/libpcap/./pcap-rdmasniff.c:87: undefined reference to `ibv_destroy_comp_channel'
nmap-7.91/libpcap/./pcap-rdmasniff.c:88: undefined reference to `ibv_close_device'
libpcap/libpcap.a(pcap-rdmasniff.o): In function `rdmasniff_create':
nmap-7.91/libpcap/./pcap-rdmasniff.c:370: undefined reference to `ibv_get_device_list'
nmap-7.91/libpcap/./pcap-rdmasniff.c:405: undefined reference to `ibv_free_device_list'
libpcap/libpcap.a(pcap-rdmasniff.o): In function `rdmasniff_findalldevs':
nmap-7.91/libpcap/./pcap-rdmasniff.c:417: undefined reference to `ibv_get_device_list'
nmap-7.91/libpcap/./pcap-rdmasniff.c:434: undefined reference to `ibv_free_device_list'
returned 1 exit status
参考这里的解决办法:
https://www.huaweicloud.com/articles/0bdb5288bb5597949f61a3d0e84a8d51.html
主要原因是由于libpacp.a这个静态库使用了libibverbs.so这个动态库,libpacp.a只是添加了使用的符号标记但是并没有真正的将使用的libibverbs.so库中的函数内容导致程序连接时找不到对应的函数实现。
现在有两个方法进行解决:
(1)如果电脑中安装了libpcap,可以在运行configure程序的时候指定pcap的安装位置比如我的安装位置是/usr/local
进行如下设置./configure --with-libpcap=/usr/local/
(2)修改Makefile文件:在LIBS中添加-libverbs
如下所示:
LIBS = -lnsock -lnbase -lpcre $(LIBPCAPDIR)/libpcap.a $(LIBSSH2_LIBS) $(OPENSSL_LIBS) $(ZLIB_LIBS) libnetutil/libnet util.a $(top_srcdir)/libdnet-stripped/src/.libs/libdnet.a $(top_srcdir)/liblua/liblua.a $(top_srcdir)/liblinear/libli near.a -ldl -libverbs
试验过第二种方法有效。
- 运行
$ sudo sh -c "LD_LIBRARY_PATH=/directory/path/to/libibverbs.so.1 ./nmap -sO <targethost>"
网友评论