我正在尝试将Nmap安装为静态二进制文件。我尝试了几个configure / make节。错误发生了变化,但问题是Nmap源代码中包含了nsock
依赖项。
对于openssl,我有一个静态二进制文件;对于zlib,我有一个静态lib。
这是最新的节和错误(注意:出于可读性考虑,多行上发布的长命令,实际上是1个衬里):
CPPFLAGS="-I/opt/laura/zlib-1.2.11
-I/opt/laura/openssl-1.1.0h_bis
-I/opt/laura/openssl-1.1.0h_bis/include
-I./liblinear
-I./liblua
-I./libdnet-stripped/include
-I./libpcap
-I./nbase
-I./nsock
-I./nsock/include" LDFLAGS="-L/opt/laura/zlib-1.2.11
-L/opt/laura/openssl-1.1.0h_bis
-L./liblinear
-L./liblua
-L./libpcap
-L./nbase
-L./nsock"
LIBS="-ldl"
./configure --prefix=/opt/laura/nmap-7.70
--with-libz=/opt/laura/zlib-1.2.11/
--with-openssl=/opt/laura/openssl-1.1.0h_bis/include/
--with-libnsock=/opt/src/nmap-7.70/nsock
NMAP IS A POWERFUL TOOL -- USE CAREFULLY AND RESPONSIBLY
Configured with: ndiff zenmap nping openssl zlib libssh2 lua ncat
Configured without: localdirs nmap-update
Type make (or gmake on some *BSD machines) to compile.
make LDFLAGS="-L/opt/laura/zlib-1.2.11
-L/opt/laura/openssl-1.1.0h_bis
-L/opt/src/nmap-7.70/nsock -static"
[...]
编译nmap
rm -f nmap
g++ -L/opt/laura/zlib-1.2.11 -L/opt/laura/openssl-1.1.0h_bis -L/opt/src/nmap-7.70/nsock -static -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 NewTargets.o TargetGroup.o Target.o targets.o tcpip.o timing.o traceroute.o utils.o xml.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 ./liblinear/liblinear.a -ldl
/usr/bin/ld: cannot find -lnsock
collect2: ld returned 1 exit status
make: *** [nmap] Error 1
nsock目录具有以下内容:
include nsock.vcxproj src tests
在src dir中找到configure,而nsock.h在include dir中。
有帮助吗?
KR
答案 0 :(得分:0)
Nsock始终在Nmap中静态链接。使用--with-lib*
选项指示这些库的安装位置 ,但是您已将其指向 source 。只需从配置行中删除--with-libnsock
选项,它就可以正常构建。您可能还需要添加--with-lib{pcap,pcre,z,ssh2,dnet,lua,linear}=included
来构建和静态链接所包含的库(除非您已构建并安装了静态库,并希望将其链接到其他位置)。
答案 1 :(得分:0)
感谢您的快速回复:)。如果我明白您的意思,那么删除--with-libnsock选项并添加“ included”选项就可以解决问题。
新的配置节:
CPPFLAGS =“ -I / opt / laura / zlib-1.2.11 -I / opt / laura / openssl-1.1.0h_bis -I / opt / laura / openssl-1.1.0h_bis / include -I./liblinear- I./liblua -I./libdnet-stripped/include -I./libpcap -I./nbase -I./nsock -I./nsock/include“ LDFLAGS =”-L / opt / laura / zlib-1.2。 11 -L / opt / laura / openssl-1.1.0h_bis -L./liblinear -L./liblua -L./libpcap -L./nbase -L./nsock“ LIBS =”-ldl“ ./configure-前缀= / opt / laura / nmap-7.70 --with-libz = / opt / laura / zlib-1.2.11 / --with-openssl = / opt / laura / openssl-1.1.0h_bis / include / --with- liblinear = included --with-liblua = included --with-libssh2 = included --with-libpcre = included --with-libpcap = included
它识别通过的选项:
NMAP是一种强大的工具-请认真负责地使用 配置为:ndiff zenmap nping openssl zlib libssh2 lua ncat 配置时不使用:localdirs nmap-update
make节:
make LDFLAGS =“-L / opt / laura / zlib-1.2.11 -L / opt / laura / openssl-1.1.0h_bis -L / opt / src / nmap-7.70 / nsock -static”
同样的错误:
g ++ -L / opt / laura / zlib-1.2.11 -L / opt / laura / openssl-1.1.0h_bis -L / opt / src / nmap-7.70 / nsock -static -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.opayload.o portlist.o portreasons .o协议.o scan_engine.o scan_engine_connect.o scan_engine_raw.o scan_lists.o service_scan.o services.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_libsp2o一个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 / usr / bin / ld:找不到-lnsock collect2:ld返回1退出状态 make:*** [nmap]错误1
实际上,我再次尝试删除CPPFLAGS和LDFLAGS中的所有nsock引用,但我有相同的错误:
另一个配置节:
CPPFLAGS =“ -I / opt / laura / zlib-1.2.11 -I / opt / laura / openssl-1.1.0h_bis -I / opt / laura / openssl-1.1.0h_bis / include -I./liblinear- I./liblua -I./libdnet-stripped/include -I./libpcap -I./nbase“ LDFLAGS =”-L / opt / laura / zlib-1.2.11 -L / opt / laura / openssl-1.1。 0h_bis -L./liblinear -L./liblua -L./libpcap -L./nbase“ LIBS =”-ldl“ ./configure --prefix = / opt / laura / nmap-7.70 --with-libz = / opt / laura / zlib-1.2.11 / --with-openssl = / opt / laura / openssl-1.1.0h_bis / include / --with-liblinear = included --with-liblua = included --with-libssh2 = included --with-libpcre =包括--with-libpcap =包括
另一个节:
make LDFLAGS =“-L / opt / laura / zlib-1.2.11 -L / opt / laura / openssl-1.1.0h_bis -static”
错误:
编译nmap rm -f nmap g ++ -L / opt / laura / zlib-1.2.11 -L / opt / laura / openssl-1.1.0h_bis -static -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有效载荷.o portlist.o portreasons.o协议.o scan_engine.o scan_engine_connect.o scan_engine_raw.o scan_lists .o service_scan.o services.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 libpcre / libpcre.a libpcap / libpcap.a libssh2 / lib。 -lcrypto -lz libnetutil / libnetutil.a ./libdnet-stripped/src/.libs/libdnet.a ./liblua/liblua.a ./liblinear/liblinear.a -ldl / usr / bin / ld:找不到-lnsock collect2:ld返回1退出状态 make:*** [nmap]错误1
谢谢!