diff options
Diffstat (limited to 'meta-oe/recipes-security/nmap')
10 files changed, 619 insertions, 2 deletions
diff --git a/meta-oe/recipes-security/nmap/files/0001-fix-racing-between-build-ncat-and-build-lua.patch b/meta-oe/recipes-security/nmap/files/0001-fix-racing-between-build-ncat-and-build-lua.patch new file mode 100644 index 0000000000..aad8b1ee92 --- /dev/null +++ b/meta-oe/recipes-security/nmap/files/0001-fix-racing-between-build-ncat-and-build-lua.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | From 0cde425abfcacdde725dccff29d01c9fce7c3888 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | ||
3 | Date: Sun, 9 Feb 2025 00:45:36 +0000 | ||
4 | Subject: [PATCH] fix racing between build-ncat and build-lua | ||
5 | |||
6 | There are two build-lua rules, one in Makefile.in, another in | ||
7 | ncat/Makefile.in which is required by build-ncat | ||
8 | |||
9 | Build them may cause potential racing | ||
10 | |||
11 | $ bitbake lib32-nmap | ||
12 | $ grep -e "Compiling liblua" -e 'nmap-7.95/liblua' -e ": error" -n patch-to/temp/log.do_compile | ||
13 | Compiling liblua | ||
14 | make[1]: Entering directory 'path-to/build/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
15 | Compiling liblua | ||
16 | make[2]: Entering directory 'path-to/build/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
17 | make[2]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
18 | path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/recipe-sysroot-native/usr/bin/i686-wrsmllib32-linux/../../libexec/i686-wrsmllib32-linux/gcc/i686-wrsmllib32-linux/14.2.0/ld: ./../liblua/liblua.a: error adding symbols: no more archived files | ||
19 | collect2: error: ld returned 1 exit status | ||
20 | make[1]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
21 | |||
22 | Explicitly make build-ncat depends on build-lua to avoid racing, | ||
23 | after applying the patch | ||
24 | ... | ||
25 | Compiling liblua | ||
26 | make[1]: Entering directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
27 | make[1]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
28 | Compiling liblua | ||
29 | make[2]: Entering directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
30 | make[2]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
31 | ... | ||
32 | |||
33 | Upstream-Status: Submitted [https://github.com/nmap/nmap/pull/3025] | ||
34 | |||
35 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
36 | --- | ||
37 | Makefile.in | 2 +- | ||
38 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
39 | |||
40 | diff --git a/Makefile.in b/Makefile.in | ||
41 | index e2f79c9..0e634a3 100644 | ||
42 | --- a/Makefile.in | ||
43 | +++ b/Makefile.in | ||
44 | @@ -159,7 +159,7 @@ build-netutil: libnetutil/Makefile | ||
45 | @echo Compiling libnetutil; | ||
46 | cd libnetutil && $(MAKE) | ||
47 | |||
48 | -build-ncat: $(NCATDIR)/Makefile build-nbase build-nsock $(NCATDIR)/ncat.h @PCAP_BUILD@ | ||
49 | +build-ncat: $(NCATDIR)/Makefile build-nbase build-nsock build-lua $(NCATDIR)/ncat.h @PCAP_BUILD@ | ||
50 | cd $(NCATDIR) && $(MAKE) | ||
51 | |||
52 | build-lua: $(LIBLUADIR)/Makefile | ||
53 | -- | ||
54 | 2.47.1 | ||
55 | |||
diff --git a/meta-oe/recipes-security/nmap/files/0003-Fix-off-by-one-overflow-in-the-IP-protocol-table.patch b/meta-oe/recipes-security/nmap/files/0003-Fix-off-by-one-overflow-in-the-IP-protocol-table.patch new file mode 100644 index 0000000000..bcb04250bb --- /dev/null +++ b/meta-oe/recipes-security/nmap/files/0003-Fix-off-by-one-overflow-in-the-IP-protocol-table.patch | |||
@@ -0,0 +1,165 @@ | |||
1 | From 364d089250d1acf459e9e8580161e7bb06268106 Mon Sep 17 00:00:00 2001 | ||
2 | From: Wang Mingyu <wangmy@fujitsu.com> | ||
3 | Date: Tue, 15 Oct 2024 02:47:38 +0000 | ||
4 | Subject: [PATCH] Fix off-by-one overflow in the IP protocol table. | ||
5 | |||
6 | Fixes #2896, closes #2897, closes #2900 | ||
7 | |||
8 | Upstream-Status: Backport [https://github.com/nmap/nmap/commit/efa0dc36f2ecade6ba8d2ed25dd4d5fbffdea308] | ||
9 | |||
10 | Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> | ||
11 | --- | ||
12 | CHANGELOG | 3 +++ | ||
13 | portlist.cc | 8 ++++---- | ||
14 | protocols.cc | 6 +++--- | ||
15 | protocols.h | 2 ++ | ||
16 | scan_lists.cc | 10 +++++----- | ||
17 | 5 files changed, 17 insertions(+), 12 deletions(-) | ||
18 | |||
19 | diff --git a/CHANGELOG b/CHANGELOG | ||
20 | index f01262c..5b204bd 100644 | ||
21 | --- a/CHANGELOG | ||
22 | +++ b/CHANGELOG | ||
23 | @@ -1,5 +1,8 @@ | ||
24 | #Nmap Changelog ($Id: CHANGELOG 38849 2024-04-18 17:16:42Z dmiller $); -*-text-*- | ||
25 | |||
26 | +o [GH#2900, GH#2896, GH#2897] Nmap is now able to scan IP protocol 255. | ||
27 | + [nnposter] | ||
28 | + | ||
29 | Nmap 7.95 [2024-04-19] | ||
30 | |||
31 | o [Windows] Upgraded Npcap (our Windows raw packet capturing and | ||
32 | diff --git a/portlist.cc b/portlist.cc | ||
33 | index 8258853..cd08437 100644 | ||
34 | --- a/portlist.cc | ||
35 | +++ b/portlist.cc | ||
36 | @@ -480,7 +480,7 @@ void PortList::setPortState(u16 portno, u8 protocol, int state, int *oldstate) { | ||
37 | state != PORT_CLOSEDFILTERED) | ||
38 | fatal("%s: attempt to add port number %d with illegal state %d\n", __func__, portno, state); | ||
39 | |||
40 | - assert(protocol!=IPPROTO_IP || portno<256); | ||
41 | + assert(protocol!=IPPROTO_IP || portno<=MAX_IPPROTONUM); | ||
42 | |||
43 | bool created = false; | ||
44 | current = createPort(portno, protocol, &created); | ||
45 | @@ -566,7 +566,7 @@ Port *PortList::nextPort(const Port *cur, Port *next, | ||
46 | if (cur) { | ||
47 | proto = INPROTO2PORTLISTPROTO(cur->proto); | ||
48 | assert(port_map[proto]!=NULL); // Hmm, it's not possible to handle port that doesn't have anything in map | ||
49 | - assert(cur->proto!=IPPROTO_IP || cur->portno<256); | ||
50 | + assert(cur->proto!=IPPROTO_IP || cur->portno<=MAX_IPPROTONUM); | ||
51 | mapped_pno = port_map[proto][cur->portno]; | ||
52 | mapped_pno++; // we're interested in next port after current | ||
53 | } else { // running for the first time | ||
54 | @@ -615,7 +615,7 @@ void PortList::mapPort(u16 *portno, u8 *protocol) const { | ||
55 | mapped_protocol = INPROTO2PORTLISTPROTO(*protocol); | ||
56 | |||
57 | if (*protocol == IPPROTO_IP) | ||
58 | - assert(*portno < 256); | ||
59 | + assert(*portno <= MAX_IPPROTONUM); | ||
60 | if(port_map[mapped_protocol]==NULL || port_list[mapped_protocol]==NULL) { | ||
61 | fatal("%s(%i,%i): you're trying to access uninitialized protocol", __func__, *portno, *protocol); | ||
62 | } | ||
63 | @@ -713,7 +713,7 @@ int PortList::port_list_count[PORTLIST_PROTO_MAX]; | ||
64 | * should be sorted. */ | ||
65 | void PortList::initializePortMap(int protocol, u16 *ports, int portcount) { | ||
66 | int i; | ||
67 | - int ports_max = (protocol == IPPROTO_IP) ? 256 : 65536; | ||
68 | + int ports_max = (protocol == IPPROTO_IP) ? MAX_IPPROTONUM + 1 : 65536; | ||
69 | int proto = INPROTO2PORTLISTPROTO(protocol); | ||
70 | |||
71 | if (port_map[proto] != NULL || port_map_rev[proto] != NULL) | ||
72 | diff --git a/protocols.cc b/protocols.cc | ||
73 | index 76e42c7..85e55e4 100644 | ||
74 | --- a/protocols.cc | ||
75 | +++ b/protocols.cc | ||
76 | @@ -79,7 +79,7 @@ struct strcmp_comparator { | ||
77 | |||
78 | // IP Protocol number is 8 bits wide | ||
79 | // protocol_table[IPPROTO_TCP] == {"tcp", 6} | ||
80 | -static struct nprotoent *protocol_table[UCHAR_MAX]; | ||
81 | +static struct nprotoent *protocol_table[MAX_IPPROTONUM + 1]; | ||
82 | // proto_map["tcp"] = {"tcp", 6} | ||
83 | typedef std::map<const char *, struct nprotoent, strcmp_comparator> ProtoMap; | ||
84 | static ProtoMap proto_map; | ||
85 | @@ -119,7 +119,7 @@ static int nmap_protocols_init() { | ||
86 | if (*p == '#' || *p == '\0') | ||
87 | continue; | ||
88 | res = sscanf(line, "%127s %hu", protocolname, &protno); | ||
89 | - if (res !=2 || protno > UCHAR_MAX) { | ||
90 | + if (res !=2 || protno > MAX_IPPROTONUM) { | ||
91 | error("Parse error in protocols file %s line %d", filename, lineno); | ||
92 | continue; | ||
93 | } | ||
94 | @@ -191,7 +191,7 @@ const struct nprotoent *nmap_getprotbynum(int num) { | ||
95 | if (nmap_protocols_init() == -1) | ||
96 | return NULL; | ||
97 | |||
98 | - assert(num >= 0 && num < UCHAR_MAX); | ||
99 | + assert(num >= 0 && num <= MAX_IPPROTONUM); | ||
100 | return protocol_table[num]; | ||
101 | } | ||
102 | |||
103 | diff --git a/protocols.h b/protocols.h | ||
104 | index 8934284..2de0aa4 100644 | ||
105 | --- a/protocols.h | ||
106 | +++ b/protocols.h | ||
107 | @@ -79,6 +79,8 @@ int addprotocolsfromservmask(char *mask, u8 *porttbl); | ||
108 | const struct nprotoent *nmap_getprotbynum(int num); | ||
109 | const struct nprotoent *nmap_getprotbyname(const char *name); | ||
110 | |||
111 | +#define MAX_IPPROTONUM 255 | ||
112 | + | ||
113 | #define MAX_IPPROTOSTRLEN 4 | ||
114 | #define IPPROTO2STR(p) \ | ||
115 | ((p)==IPPROTO_TCP ? "tcp" : \ | ||
116 | diff --git a/scan_lists.cc b/scan_lists.cc | ||
117 | index f02e279..ebe1357 100644 | ||
118 | --- a/scan_lists.cc | ||
119 | +++ b/scan_lists.cc | ||
120 | @@ -165,7 +165,7 @@ void getpts(const char *origexpr, struct scan_lists *ports) { | ||
121 | ports->udp_count++; | ||
122 | if (porttbl[i] & SCAN_SCTP_PORT) | ||
123 | ports->sctp_count++; | ||
124 | - if (porttbl[i] & SCAN_PROTOCOLS && i < 256) | ||
125 | + if (porttbl[i] & SCAN_PROTOCOLS && i <= MAX_IPPROTONUM) | ||
126 | ports->prot_count++; | ||
127 | } | ||
128 | |||
129 | @@ -192,7 +192,7 @@ void getpts(const char *origexpr, struct scan_lists *ports) { | ||
130 | ports->udp_ports[udpi++] = i; | ||
131 | if (porttbl[i] & SCAN_SCTP_PORT) | ||
132 | ports->sctp_ports[sctpi++] = i; | ||
133 | - if (porttbl[i] & SCAN_PROTOCOLS && i < 256) | ||
134 | + if (porttbl[i] & SCAN_PROTOCOLS && i <= MAX_IPPROTONUM) | ||
135 | ports->prots[proti++] = i; | ||
136 | } | ||
137 | |||
138 | @@ -388,7 +388,7 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_ | ||
139 | } else if (isdigit((int) (unsigned char) *current_range)) { | ||
140 | rangestart = strtol(current_range, &endptr, 10); | ||
141 | if (range_type & SCAN_PROTOCOLS) { | ||
142 | - if (rangestart < 0 || rangestart > 255) | ||
143 | + if (rangestart < 0 || rangestart > MAX_IPPROTONUM) | ||
144 | fatal("Protocols specified must be between 0 and 255 inclusive"); | ||
145 | } else { | ||
146 | if (rangestart < 0 || rangestart > 65535) | ||
147 | @@ -429,13 +429,13 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_ | ||
148 | if (!*current_range || *current_range == ',' || *current_range == ']') { | ||
149 | /* Ended with a -, meaning up until the last possible port */ | ||
150 | if (range_type & SCAN_PROTOCOLS) | ||
151 | - rangeend = 255; | ||
152 | + rangeend = MAX_IPPROTONUM; | ||
153 | else | ||
154 | rangeend = 65535; | ||
155 | } else if (isdigit((int) (unsigned char) *current_range)) { | ||
156 | rangeend = strtol(current_range, &endptr, 10); | ||
157 | if (range_type & SCAN_PROTOCOLS) { | ||
158 | - if (rangeend < 0 || rangeend > 255) | ||
159 | + if (rangeend < 0 || rangeend > MAX_IPPROTONUM) | ||
160 | fatal("Protocols specified must be between 0 and 255 inclusive"); | ||
161 | } else { | ||
162 | if (rangeend < 0 || rangeend > 65535) | ||
163 | -- | ||
164 | 2.34.1 | ||
165 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap-7.92/0001-redefine-the-python-library-install-dir.patch b/meta-oe/recipes-security/nmap/nmap-7.92/0001-redefine-the-python-library-install-dir.patch new file mode 100644 index 0000000000..6298f7ea26 --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap-7.92/0001-redefine-the-python-library-install-dir.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From 67b4614ea529460dca9326bfe5d355bad6f9bdee Mon Sep 17 00:00:00 2001 | ||
2 | From: Roy Li <rongqing.li@windriver.com> | ||
3 | Date: Sun, 27 Apr 2025 16:33:08 +0800 | ||
4 | Subject: [PATCH] redefine the python library install dir | ||
5 | |||
6 | If install-lib is not defined, it is always /usr/lib/, but it | ||
7 | maybe /usr/lib64 for multilib | ||
8 | |||
9 | Upstream-Status: Pending | ||
10 | |||
11 | Signed-off-by: Roy Li <rongqing.li@windriver.com> | ||
12 | --- | ||
13 | Makefile.in | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/Makefile.in b/Makefile.in | ||
17 | index ccfceda..6b25d27 100644 | ||
18 | --- a/Makefile.in | ||
19 | +++ b/Makefile.in | ||
20 | @@ -387,7 +387,7 @@ build-nping: $(NPINGDIR)/Makefile build-nbase build-nsock build-netutil $(NPINGD | ||
21 | @cd $(NPINGDIR) && $(MAKE) | ||
22 | |||
23 | install-ndiff: | ||
24 | - cd $(NDIFFDIR) && $(PYTHON) setup.py install --prefix "$(prefix)" $(if $(DESTDIR),--root "$(DESTDIR)") | ||
25 | + cd $(NDIFFDIR) && $(PYTHON) setup.py install --prefix "$(prefix)" --install-lib="${PYTHON_SITEPACKAGES_DIR}" $(if $(DESTDIR),--root "$(DESTDIR)") | ||
26 | |||
27 | NSE_FILES = scripts/script.db scripts/*.nse | ||
28 | NSE_LIB_LUA_FILES = nselib/*.lua nselib/*.luadoc | ||
29 | -- | ||
30 | 2.34.1 | ||
31 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap-7.92/0002-replace-.-shtool-mkdir-with-coreutils-mkdir-command.patch b/meta-oe/recipes-security/nmap/nmap-7.92/0002-replace-.-shtool-mkdir-with-coreutils-mkdir-command.patch new file mode 100644 index 0000000000..f81e230b28 --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap-7.92/0002-replace-.-shtool-mkdir-with-coreutils-mkdir-command.patch | |||
@@ -0,0 +1,38 @@ | |||
1 | From 783333de42b06020f5c0852c415cd34972a773fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Roy Li <rongqing.li@windriver.com> | ||
3 | Date: Sun, 27 Apr 2025 16:35:11 +0800 | ||
4 | Subject: [PATCH] replace "./shtool mkdir" with coreutils mkdir command | ||
5 | |||
6 | "./shtool mkdir" is used when mkdir has not -p parameter, but mkdir in | ||
7 | today most release has supportted the -p parameter, not need to use | ||
8 | shtool, and it can not fix the race if two process are running mkdir to | ||
9 | create same dir | ||
10 | |||
11 | Upstream-Status: Pending | ||
12 | |||
13 | Signed-off-by: Roy Li <rongqing.li@windriver.com> | ||
14 | --- | ||
15 | ncat/Makefile.in | 4 ++-- | ||
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/ncat/Makefile.in b/ncat/Makefile.in | ||
19 | index 4632a78..11a5e7c 100644 | ||
20 | --- a/ncat/Makefile.in | ||
21 | +++ b/ncat/Makefile.in | ||
22 | @@ -166,11 +166,11 @@ $(NSOCKDIR)/libnsock.a: $(NSOCKDIR)/Makefile | ||
23 | |||
24 | install: $(TARGET) | ||
25 | @echo Installing Ncat; | ||
26 | - $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 | ||
27 | + mkdir -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 | ||
28 | $(INSTALL) -c -m 755 ncat $(DESTDIR)$(bindir)/ncat | ||
29 | $(STRIP) -x $(DESTDIR)$(bindir)/ncat | ||
30 | if [ -n "$(DATAFILES)" ]; then \ | ||
31 | - $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(pkgdatadir); \ | ||
32 | + mkdir -p -m 755 $(DESTDIR)$(pkgdatadir); \ | ||
33 | $(INSTALL) -c -m 644 $(DATAFILES) $(DESTDIR)$(pkgdatadir)/; \ | ||
34 | fi | ||
35 | $(INSTALL) -c -m 644 docs/$(TARGET).1 $(DESTDIR)$(mandir)/man1/$(TARGET).1 | ||
36 | -- | ||
37 | 2.34.1 | ||
38 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap-7.92/0003-Include-time.h-header-to-pass-clang-compilation.patch b/meta-oe/recipes-security/nmap/nmap-7.92/0003-Include-time.h-header-to-pass-clang-compilation.patch new file mode 100644 index 0000000000..b940124f98 --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap-7.92/0003-Include-time.h-header-to-pass-clang-compilation.patch | |||
@@ -0,0 +1,76 @@ | |||
1 | From e9d876bedc8a7bc96856ecf38bbeeafee2d5b206 Mon Sep 17 00:00:00 2001 | ||
2 | From: Peiran Hong <peiran.hong@windriver.com> | ||
3 | Date: Fri, 20 Sep 2019 15:02:45 -0400 | ||
4 | Subject: [PATCH] Include time.h header to pass clang compilation | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Peiran Hong <peiran.hong@windriver.com> | ||
9 | --- | ||
10 | nmap_error.cc | 11 +---------- | ||
11 | nping/EchoServer.cc | 1 + | ||
12 | osscan2.cc | 1 + | ||
13 | service_scan.cc | 1 + | ||
14 | 4 files changed, 4 insertions(+), 10 deletions(-) | ||
15 | |||
16 | diff --git a/nmap_error.cc b/nmap_error.cc | ||
17 | index 5ec938f..83ba6cc 100644 | ||
18 | --- a/nmap_error.cc | ||
19 | +++ b/nmap_error.cc | ||
20 | @@ -67,16 +67,7 @@ | ||
21 | #include "xml.h" | ||
22 | |||
23 | #include <errno.h> | ||
24 | -#if TIME_WITH_SYS_TIME | ||
25 | -# include <sys/time.h> | ||
26 | -# include <time.h> | ||
27 | -#else | ||
28 | -# if HAVE_SYS_TIME_H | ||
29 | -# include <sys/time.h> | ||
30 | -# else | ||
31 | -# include <time.h> | ||
32 | -# endif | ||
33 | -#endif | ||
34 | +#include <time.h> | ||
35 | |||
36 | extern NmapOps o; | ||
37 | |||
38 | diff --git a/nping/EchoServer.cc b/nping/EchoServer.cc | ||
39 | index dea2851..c80efb4 100644 | ||
40 | --- a/nping/EchoServer.cc | ||
41 | +++ b/nping/EchoServer.cc | ||
42 | @@ -69,6 +69,7 @@ | ||
43 | #include "NpingOps.h" | ||
44 | #include "ProbeMode.h" | ||
45 | #include <signal.h> | ||
46 | +#include <time.h> | ||
47 | |||
48 | extern NpingOps o; | ||
49 | extern EchoServer es; | ||
50 | diff --git a/osscan2.cc b/osscan2.cc | ||
51 | index efe6da0..392c65f 100644 | ||
52 | --- a/osscan2.cc | ||
53 | +++ b/osscan2.cc | ||
54 | @@ -80,6 +80,7 @@ | ||
55 | |||
56 | #include <list> | ||
57 | #include <math.h> | ||
58 | +#include <time.h> | ||
59 | |||
60 | extern NmapOps o; | ||
61 | #ifdef WIN32 | ||
62 | diff --git a/service_scan.cc b/service_scan.cc | ||
63 | index 66e0d92..161f2a1 100644 | ||
64 | --- a/service_scan.cc | ||
65 | +++ b/service_scan.cc | ||
66 | @@ -77,6 +77,7 @@ | ||
67 | #include "nmap_tty.h" | ||
68 | |||
69 | #include <errno.h> | ||
70 | +#include <time.h> | ||
71 | |||
72 | #if HAVE_OPENSSL | ||
73 | /* OpenSSL 1.0.0 needs _WINSOCKAPI_ to be defined, otherwise it loads | ||
74 | -- | ||
75 | 2.34.1 | ||
76 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap-7.92/0004-Fix-building-with-libc.patch b/meta-oe/recipes-security/nmap/nmap-7.92/0004-Fix-building-with-libc.patch new file mode 100644 index 0000000000..295abe6d50 --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap-7.92/0004-Fix-building-with-libc.patch | |||
@@ -0,0 +1,79 @@ | |||
1 | From 4c54b00e6f3749924532c2636eae01daff9e4bcd Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 20 Jan 2019 23:11:56 -0800 | ||
4 | Subject: [PATCH] Fix building with libc++ | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | nping/EchoServer.cc | 16 ++++++++-------- | ||
11 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
12 | |||
13 | diff --git a/nping/EchoServer.cc b/nping/EchoServer.cc | ||
14 | index c80efb4..914bd54 100644 | ||
15 | --- a/nping/EchoServer.cc | ||
16 | +++ b/nping/EchoServer.cc | ||
17 | @@ -214,14 +214,14 @@ int EchoServer::nep_listen_socket(){ | ||
18 | server_addr6.sin6_len = sizeof(struct sockaddr_in6); | ||
19 | #endif | ||
20 | /* Bind to local address and the specified port */ | ||
21 | - if( bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ | ||
22 | + if( ::bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ | ||
23 | nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr6.sin6_addr), port); | ||
24 | /* If the bind failed for the supplied address, just try again with in6addr_any */ | ||
25 | if( o.spoofSource() ){ | ||
26 | server_addr6.sin6_addr = in6addr_any; | ||
27 | - if( bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ | ||
28 | + if( ::bind(master_sd, (struct sockaddr *)&server_addr6, sizeof(server_addr6)) != 0 ){ | ||
29 | nping_fatal(QT_3, "Could not bind to port %d (%s).", port, strerror(errno)); | ||
30 | - }else{ | ||
31 | + }else{ | ||
32 | nping_print(VB_1, "Server bound to port %d", port); | ||
33 | } | ||
34 | } | ||
35 | @@ -252,12 +252,12 @@ int EchoServer::nep_listen_socket(){ | ||
36 | #endif | ||
37 | |||
38 | /* Bind to local address and the specified port */ | ||
39 | - if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ | ||
40 | + if( ::bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ | ||
41 | nping_warning(QT_3, "Failed to bind to source address %s. Trying to bind to port %d...", IPtoa(server_addr4.sin_addr), port); | ||
42 | /* If the bind failed for the supplied address, just try again with in6addr_any */ | ||
43 | if( o.spoofSource() ){ | ||
44 | server_addr4.sin_addr.s_addr=INADDR_ANY; | ||
45 | - if( bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ | ||
46 | + if( ::bind(master_sd, (struct sockaddr *)&server_addr4, sizeof(server_addr4)) != 0 ){ | ||
47 | nping_fatal(QT_3, "Could not bind to port %d (%s).", port, strerror(errno)); | ||
48 | }else{ | ||
49 | nping_print(VB_1, "Server bound to port %d", port); | ||
50 | @@ -493,7 +493,7 @@ clientid_t EchoServer::nep_match_headers(IPv4Header *ip4, IPv6Header *ip6, TCPHe | ||
51 | nping_print(DBG_3, ";"); | ||
52 | /* The payload magic may affect the score only between | ||
53 | * zero and 4 bytes. This is done to prevent long | ||
54 | - * common strings like "GET / HTTP/1.1\r\n" | ||
55 | + * common strings like "GET / HTTP/1.1\r\n" | ||
56 | * increasing the score a lot and cause problems for | ||
57 | * the matching logic. */ | ||
58 | current_score+= MIN(4, fspec->len)*FACTOR_PAYLOAD_MAGIC; | ||
59 | @@ -503,7 +503,7 @@ clientid_t EchoServer::nep_match_headers(IPv4Header *ip4, IPv6Header *ip6, TCPHe | ||
60 | default: | ||
61 | nping_warning(QT_2, "Bogus field specifier found in client #%d context. Please report a bug", ctx->getIdentifier()); | ||
62 | break; | ||
63 | - } | ||
64 | + } | ||
65 | } /* End of field specifiers loop */ | ||
66 | |||
67 | nping_print(DBG_3, "%s() current_score=%.02f candidate_score=%.02f", __func__, current_score, candidate_score); | ||
68 | @@ -582,7 +582,7 @@ clientid_t EchoServer::nep_match_packet(const u8 *pkt, size_t pktlen){ | ||
69 | }else{ | ||
70 | if( (tcplen=tcp.validate())==OP_FAILURE){ | ||
71 | return CLIENT_NOT_FOUND; | ||
72 | - }else{ | ||
73 | + }else{ | ||
74 | if( (int)pktlen > (iplen+tcplen) ){ | ||
75 | if( payload.storeRecvData(pkt+iplen+tcplen, pktlen-iplen-tcplen)!=OP_FAILURE) | ||
76 | payload_included=true; | ||
77 | -- | ||
78 | 2.34.1 | ||
79 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap-7.92/0005-fix-racing-between-build-ncat-and-build-lua.patch b/meta-oe/recipes-security/nmap/nmap-7.92/0005-fix-racing-between-build-ncat-and-build-lua.patch new file mode 100644 index 0000000000..f660719640 --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap-7.92/0005-fix-racing-between-build-ncat-and-build-lua.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | From c1b436da46a7e3089b657f3f92308defc0ebb735 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | ||
3 | Date: Sun, 9 Feb 2025 00:45:36 +0000 | ||
4 | Subject: [PATCH] fix racing between build-ncat and build-lua | ||
5 | |||
6 | There are two build-lua rules, one in Makefile.in, another in | ||
7 | ncat/Makefile.in which is required by build-ncat | ||
8 | |||
9 | Build them may cause potential racing | ||
10 | |||
11 | $ bitbake lib32-nmap | ||
12 | $ grep -e "Compiling liblua" -e 'nmap-7.95/liblua' -e ": error" -n patch-to/temp/log.do_compile | ||
13 | Compiling liblua | ||
14 | make[1]: Entering directory 'path-to/build/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
15 | Compiling liblua | ||
16 | make[2]: Entering directory 'path-to/build/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
17 | make[2]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
18 | path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/recipe-sysroot-native/usr/bin/i686-wrsmllib32-linux/../../libexec/i686-wrsmllib32-linux/gcc/i686-wrsmllib32-linux/14.2.0/ld: ./../liblua/liblua.a: error adding symbols: no more archived files | ||
19 | collect2: error: ld returned 1 exit status | ||
20 | make[1]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
21 | |||
22 | Explicitly make build-ncat depends on build-lua to avoid racing, | ||
23 | after applying the patch | ||
24 | ... | ||
25 | Compiling liblua | ||
26 | make[1]: Entering directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
27 | make[1]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
28 | Compiling liblua | ||
29 | make[2]: Entering directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
30 | make[2]: Leaving directory 'path-to/tmp/work/corei7-32-wrsmllib32-linux/lib32-nmap/7.95/nmap-7.95/liblua' | ||
31 | ... | ||
32 | |||
33 | Upstream-Status: Submitted [https://github.com/nmap/nmap/pull/3025] | ||
34 | |||
35 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
36 | --- | ||
37 | Makefile.in | 2 +- | ||
38 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
39 | |||
40 | diff --git a/Makefile.in b/Makefile.in | ||
41 | index 6b25d27..b0a2719 100644 | ||
42 | --- a/Makefile.in | ||
43 | +++ b/Makefile.in | ||
44 | @@ -159,7 +159,7 @@ build-netutil: libnetutil/Makefile | ||
45 | @echo Compiling libnetutil; | ||
46 | cd libnetutil && $(MAKE) | ||
47 | |||
48 | -build-ncat: $(NCATDIR)/Makefile build-nbase build-nsock $(NCATDIR)/ncat.h @PCAP_BUILD@ | ||
49 | +build-ncat: $(NCATDIR)/Makefile build-nbase build-nsock build-lua $(NCATDIR)/ncat.h @PCAP_BUILD@ | ||
50 | cd $(NCATDIR) && $(MAKE) | ||
51 | |||
52 | build-lua: $(LIBLUADIR)/Makefile | ||
53 | -- | ||
54 | 2.34.1 | ||
55 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap-7.92/0006-Fix-build-with-libpcap-1.10.5.patch b/meta-oe/recipes-security/nmap/nmap-7.92/0006-Fix-build-with-libpcap-1.10.5.patch new file mode 100644 index 0000000000..4ee4a7295e --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap-7.92/0006-Fix-build-with-libpcap-1.10.5.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | From ba7b4a8cc570f0ce154f186fbe840f0ac23b2b96 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yi Zhao <yi.zhao@windriver.com> | ||
3 | Date: Mon, 28 Apr 2025 10:04:46 +0800 | ||
4 | Subject: [PATCH] Fix build with libpcap 1.10.5 | ||
5 | |||
6 | Fixes: | ||
7 | In file included from /build/tmp/work/core2-64-poky-linux/nmap/7.92/recipe-sysroot/usr/include/pcap/pcap.h:130, | ||
8 | from /build/tmp/work/core2-64-poky-linux/nmap/7.92/recipe-sysroot/usr/include/pcap.h:43, | ||
9 | from tcpip.h:72, | ||
10 | from nse_nsock.cc:4: | ||
11 | nse_nsock.cc:36:3: error: expected identifier before 'int' | ||
12 | 36 | PCAP_SOCKET = lua_upvalueindex(3), /* pcap socket metatable */ | ||
13 | | ^~~~~~~~~~~ | ||
14 | nse_nsock.cc:36:3: error: expected '}' before 'int' | ||
15 | nse_nsock.cc:33:6: note: to match this '{' | ||
16 | 33 | enum { | ||
17 | | ^ | ||
18 | nse_nsock.cc:36:15: error: expected unqualified-id before '=' token | ||
19 | 36 | PCAP_SOCKET = lua_upvalueindex(3), /* pcap socket metatable */ | ||
20 | | ^ | ||
21 | nse_nsock.cc:40:1: error: expected declaration before '}' token | ||
22 | 40 | }; | ||
23 | | ^ | ||
24 | |||
25 | Upstream-Status: Pending | ||
26 | |||
27 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
28 | --- | ||
29 | nse_nsock.cc | 2 ++ | ||
30 | 1 file changed, 2 insertions(+) | ||
31 | |||
32 | diff --git a/nse_nsock.cc b/nse_nsock.cc | ||
33 | index 75ddeb6..a3c5186 100644 | ||
34 | --- a/nse_nsock.cc | ||
35 | +++ b/nse_nsock.cc | ||
36 | @@ -29,6 +29,8 @@ | ||
37 | |||
38 | #define DEFAULT_TIMEOUT 30000 | ||
39 | |||
40 | +#undef PCAP_SOCKET | ||
41 | + | ||
42 | /* Upvalues for library variables */ | ||
43 | enum { | ||
44 | NSOCK_POOL = lua_upvalueindex(1), | ||
45 | -- | ||
46 | 2.34.1 | ||
47 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap_7.92.bb b/meta-oe/recipes-security/nmap/nmap_7.92.bb new file mode 100644 index 0000000000..98969fe001 --- /dev/null +++ b/meta-oe/recipes-security/nmap/nmap_7.92.bb | |||
@@ -0,0 +1,66 @@ | |||
1 | SUMMARY = "network auditing tool" | ||
2 | DESCRIPTION = "Nmap (Network Mapper) is a free and open source (license) utility for network discovery and security auditing.\nGui support via appending to IMAGE_FEATURES x11-base in local.conf" | ||
3 | SECTION = "security" | ||
4 | LICENSE = "GPL-2.0-only" | ||
5 | |||
6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=b8823a06822788010eae05b4f5e921b3" | ||
7 | |||
8 | SRC_URI = "http://nmap.org/dist/${BP}.tar.bz2 \ | ||
9 | file://0001-redefine-the-python-library-install-dir.patch \ | ||
10 | file://0002-replace-.-shtool-mkdir-with-coreutils-mkdir-command.patch \ | ||
11 | file://0003-Include-time.h-header-to-pass-clang-compilation.patch \ | ||
12 | file://0004-Fix-building-with-libc.patch \ | ||
13 | file://0005-fix-racing-between-build-ncat-and-build-lua.patch \ | ||
14 | file://0006-Fix-build-with-libpcap-1.10.5.patch \ | ||
15 | " | ||
16 | SRC_URI[sha256sum] = "a5479f2f8a6b0b2516767d2f7189c386c1dc858d997167d7ec5cfc798c7571a1" | ||
17 | |||
18 | UPSTREAM_CHECK_REGEX = "nmap-(?P<pver>\d+(\.\d+)+)\.tar" | ||
19 | |||
20 | inherit autotools-brokensep pkgconfig python3native | ||
21 | |||
22 | PACKAGECONFIG ?= "pcre ncat nping pcap" | ||
23 | |||
24 | PACKAGECONFIG[pcap] = "--with-pcap=linux, --without-pcap, libpcap, libpcap" | ||
25 | PACKAGECONFIG[pcre] = "--with-libpcre=${STAGING_LIBDIR}/.., --with-libpcre=included, libpcre" | ||
26 | PACKAGECONFIG[ssl] = "--with-openssl=${STAGING_LIBDIR}/.., --without-openssl, openssl, openssl" | ||
27 | PACKAGECONFIG[ssh2] = "--with-openssh2=${STAGING_LIBDIR}/.., --without-openssh2, libssh2, libssh2" | ||
28 | PACKAGECONFIG[libz] = "--with-libz=${STAGING_LIBDIR}/.., --without-libz, zlib, zlib" | ||
29 | |||
30 | # disable/enable packages | ||
31 | PACKAGECONFIG[nping] = ",--without-nping," | ||
32 | PACKAGECONFIG[ncat] = ",--without-ncat," | ||
33 | PACKAGECONFIG[ndiff] = "--with-ndiff=yes,--without-ndiff,python3 python3-setuptools-native" | ||
34 | PACKAGECONFIG[update] = ",--without-nmap-update," | ||
35 | |||
36 | EXTRA_OECONF = "--with-libdnet=included --with-liblinear=included --without-subversion --with-liblua=included" | ||
37 | |||
38 | # zenmap needs python-pygtk which has been removed | ||
39 | # it also only works with python2 | ||
40 | # disable for now until py3 is supported | ||
41 | EXTRA_OECONF += "--without-zenmap" | ||
42 | |||
43 | export PYTHON_SITEPACKAGES_DIR | ||
44 | |||
45 | do_configure() { | ||
46 | autoconf | ||
47 | install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.guess ${S} | ||
48 | install -m 0755 ${STAGING_DATADIR_NATIVE}/gnu-config/config.sub ${S} | ||
49 | oe_runconf | ||
50 | } | ||
51 | |||
52 | do_install:append() { | ||
53 | for f in ndiff uninstall_ndiff; do | ||
54 | if [ -f ${D}${bindir}/$f ]; then | ||
55 | sed -i 's@^#!.*$@#!/usr/bin/env python3@g' ${D}${bindir}/$f | ||
56 | fi | ||
57 | done | ||
58 | } | ||
59 | |||
60 | FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR} ${datadir}/ncat" | ||
61 | |||
62 | RDEPENDS:${PN} += " \ | ||
63 | python3-difflib \ | ||
64 | python3-asyncio \ | ||
65 | python3-xml \ | ||
66 | " | ||
diff --git a/meta-oe/recipes-security/nmap/nmap_7.95.bb b/meta-oe/recipes-security/nmap/nmap_7.95.bb index 79c28e71f0..a892c1e910 100644 --- a/meta-oe/recipes-security/nmap/nmap_7.95.bb +++ b/meta-oe/recipes-security/nmap/nmap_7.95.bb | |||
@@ -1,7 +1,7 @@ | |||
1 | SUMMARY = "network auditing tool" | 1 | SUMMARY = "network auditing tool" |
2 | DESCRIPTION = "Nmap (Network Mapper) is a free and open source (license) utility for network discovery and security auditing.\nGui support via appending to IMAGE_FEATURES x11-base in local.conf" | 2 | DESCRIPTION = "Nmap (Network Mapper) is a free and open source (license) utility for network discovery and security auditing.\nGui support via appending to IMAGE_FEATURES x11-base in local.conf" |
3 | SECTION = "security" | 3 | SECTION = "security" |
4 | LICENSE = "GPL-2.0-only" | 4 | LICENSE = "NPSL" |
5 | 5 | ||
6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=895af8527fe4bcb72f271fd1841fd2f6" | 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=895af8527fe4bcb72f271fd1841fd2f6" |
7 | 7 | ||
@@ -10,8 +10,13 @@ SRC_URI = "http://nmap.org/dist/${BP}.tar.bz2 \ | |||
10 | file://nmap-replace-shtool-mkdir-with-coreutils-mkdir-command.patch \ | 10 | file://nmap-replace-shtool-mkdir-with-coreutils-mkdir-command.patch \ |
11 | file://0001-Include-time.h-header-to-pass-clang-compilation.patch \ | 11 | file://0001-Include-time.h-header-to-pass-clang-compilation.patch \ |
12 | file://0002-Fix-building-with-libc.patch \ | 12 | file://0002-Fix-building-with-libc.patch \ |
13 | file://0003-Fix-off-by-one-overflow-in-the-IP-protocol-table.patch \ | ||
14 | file://0001-fix-racing-between-build-ncat-and-build-lua.patch \ | ||
13 | " | 15 | " |
14 | SRC_URI[sha256sum] = "e14ab530e47b5afd88f1c8a2bac7f89cd8fe6b478e22d255c5b9bddb7a1c5778" | 16 | SRC_URI[sha256sum] = "e14ab530e47b5afd88f1c8a2bac7f89cd8fe6b478e22d255c5b9bddb7a1c5778" |
17 | |||
18 | UPSTREAM_CHECK_REGEX = "nmap-(?P<pver>\d+(\.\d+)+)\.tar" | ||
19 | |||
15 | inherit autotools-brokensep pkgconfig python3native | 20 | inherit autotools-brokensep pkgconfig python3native |
16 | 21 | ||
17 | PACKAGECONFIG ?= "pcre ncat nping pcap" | 22 | PACKAGECONFIG ?= "pcre ncat nping pcap" |
@@ -25,7 +30,7 @@ PACKAGECONFIG[libz] = "--with-libz=${STAGING_LIBDIR}/.., --without-libz, zlib, z | |||
25 | #disable/enable packages | 30 | #disable/enable packages |
26 | PACKAGECONFIG[nping] = ",--without-nping," | 31 | PACKAGECONFIG[nping] = ",--without-nping," |
27 | PACKAGECONFIG[ncat] = ",--without-ncat," | 32 | PACKAGECONFIG[ncat] = ",--without-ncat," |
28 | PACKAGECONFIG[ndiff] = "--with-ndiff=yes,--without-ndiff,python3" | 33 | PACKAGECONFIG[ndiff] = "--with-ndiff=yes,--without-ndiff,python3 python3-setuptools-native" |
29 | PACKAGECONFIG[update] = ",--without-nmap-update," | 34 | PACKAGECONFIG[update] = ",--without-nmap-update," |
30 | 35 | ||
31 | EXTRA_OECONF = "--with-libdnet=included --with-liblinear=included --without-subversion --with-liblua=included" | 36 | EXTRA_OECONF = "--with-libdnet=included --with-liblinear=included --without-subversion --with-liblua=included" |