mirror of
https://github.com/nmap/nmap.git
synced 2026-11-20 06:30:40 +00:00
Compare commits
32 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c947f2dd1e | ||
|
|
bb81d13921 | ||
|
|
c3770c298e | ||
|
|
394da47a0a | ||
|
|
7d19be12f3 | ||
|
|
68739db8e4 | ||
|
|
c3a229da67 | ||
|
|
4394ae5c1f | ||
|
|
a6812db720 | ||
|
|
987df0afab | ||
|
|
8b515f26b8 | ||
|
|
f9aa1f31ca | ||
|
|
2cd2931826 | ||
|
|
7d7946773b | ||
|
|
c75732fb03 | ||
|
|
6467d39c17 | ||
|
|
0b2b71a97c | ||
|
|
ec562e9e8b | ||
|
|
68cdcb93b5 | ||
|
|
64d96f268d | ||
|
|
4bb08f8844 | ||
|
|
367d5296f8 | ||
|
|
628feef6d6 | ||
|
|
d675509e72 | ||
|
|
01f4ed2968 | ||
|
|
58763ff0de | ||
|
|
13d8e22c07 | ||
|
|
29cb897062 | ||
|
|
e374dff13c | ||
|
|
f06480daed | ||
|
|
2243ae9758 | ||
|
|
d5134b0181 |
41 changed files with 2865 additions and 2570 deletions
48
CHANGELOG
48
CHANGELOG
|
|
@ -1,11 +1,48 @@
|
||||||
#Nmap Changelog ($Id$); -*-text-*-
|
#Nmap Changelog ($Id$); -*-text-*-
|
||||||
|
|
||||||
Nmap 7.992 [2026-10-07]
|
o [NSE][GH#3307] ASN.1 sequence encoding in the iec61850mms library was broken.
|
||||||
|
[RyugaXhypeR]
|
||||||
|
|
||||||
|
o [NSE][GH#3597][GH#3617] Script ssh2-enum-algos was failing on targets that
|
||||||
|
evaluate client KEX proposals before sending theirs. [Anders Henke, nnposter]
|
||||||
|
|
||||||
|
o [NSE] The ssh2 library was conflating host key (signature) algorithms with
|
||||||
|
host key types. One of the effects was that scripts, such as ssh-hostkey,
|
||||||
|
were not detecting RSA keys unless the target supported legacy ssh-rsa host
|
||||||
|
key algorithm. [nnposter]
|
||||||
|
|
||||||
|
o [NSE][GH#3567][GH#3575] TLS 1.2 connections were failing with some servers
|
||||||
|
when a script offered modern curves. This was particularly impacting results
|
||||||
|
from ssl-enum-ciphers. [Alexandre Quercia, nnposter]
|
||||||
|
|
||||||
|
o [GH#3565][GH#3573] Fixed an issue with addrset: When a CIDR spec was added
|
||||||
|
after a narrower one, its prefix exactly the common prefix of the two, the
|
||||||
|
addrset trie did not cover the whole broader range. [Dennys Kaluzny Pereira]
|
||||||
|
|
||||||
|
Nmap 7.993 [2026-10-23]
|
||||||
|
|
||||||
|
o [NSE][GH#3557] Fixed a regression which prevented most scripts in the version
|
||||||
|
category from running.
|
||||||
|
|
||||||
|
o [Windows] Upgraded the included version of Npcap from 1.89 to 1.90, resolving
|
||||||
|
an issue that prevented most installations on Windows older than Windows 10.
|
||||||
|
See https://npcap.com/changelog
|
||||||
|
|
||||||
|
o [Ncat] Updated Ncat's ca-bundle.crt.
|
||||||
|
|
||||||
|
o [Zenmap][GH#3561] Fix Zenmap's handling of multiple osclass elements in Nmap
|
||||||
|
XML. Previously, each subsequent osclass in a host would overwrite the
|
||||||
|
previous osclass. [Derek Martin]
|
||||||
|
|
||||||
|
Nmap 7.992 [2026-10-15]
|
||||||
|
|
||||||
o Upgraded included libraries:
|
o Upgraded included libraries:
|
||||||
- Source: libpcap 1.10.7, pcre2 10.49, lua 5.4.9, libdnet 1.18.2
|
- Source: libpcap 1.10.7, pcre2 10.49, lua 5.4.9, libdnet 1.18.2
|
||||||
- Binary installers: OpenSSL 3.5.9, Python 3.14.8
|
- Binary installers: OpenSSL 3.5.9, Python 3.14.8
|
||||||
|
|
||||||
|
o [Windows] Upgraded the included version of Npcap from 1.88 to 1.89, resolving
|
||||||
|
one crash and upgrading to libpcap 1.10.7. See https://npcap.com/changelog
|
||||||
|
|
||||||
o [Security][NSE] Karan Bamal of SentinelOne reported the following issues with
|
o [Security][NSE] Karan Bamal of SentinelOne reported the following issues with
|
||||||
NSE scripts and libraries, which have all been fixed:
|
NSE scripts and libraries, which have all been fixed:
|
||||||
- afp.lua used a hardcoded DH private exponent, so that credentials passed
|
- afp.lua used a hardcoded DH private exponent, so that credentials passed
|
||||||
|
|
@ -31,7 +68,11 @@ o [Security] Zach Hanley of Horizon3.ai, in collaboration with Claude and
|
||||||
o [Security][NSE] In some non-standard builds (e.g. --without-openssl), NSE
|
o [Security][NSE] In some non-standard builds (e.g. --without-openssl), NSE
|
||||||
scripts were attempting to load missing Lua modules from the current working
|
scripts were attempting to load missing Lua modules from the current working
|
||||||
directory. Fixed by removing Lua's default package searchers, leaving only
|
directory. Fixed by removing Lua's default package searchers, leaving only
|
||||||
the existing nselib file fetcher.
|
the existing nselib file fetcher. Reported by じゃっく.
|
||||||
|
|
||||||
|
o [Windows][Zenmap] The .pyd support files for Python, which are DLLs, have
|
||||||
|
been signed with our code signing certificate. Windows Smart App Control
|
||||||
|
warned about the files being unsigned in previous releases.
|
||||||
|
|
||||||
o Added a libfuzzer-based framework for fuzzing internal functions of Nmap,
|
o Added a libfuzzer-based framework for fuzzing internal functions of Nmap,
|
||||||
Ncat, and Nping. So far, 10 functions have been instrumented and 3 minor
|
Ncat, and Nping. So far, 10 functions have been instrumented and 3 minor
|
||||||
|
|
@ -174,6 +215,9 @@ Nmap 7.991 [2026-08-06]
|
||||||
|
|
||||||
o Upgraded included OpenSSL to version 3.0.21 on all platforms.
|
o Upgraded included OpenSSL to version 3.0.21 on all platforms.
|
||||||
|
|
||||||
|
o [Windows] Upgraded the included version of Npcap from 1.87 to 1.88, resolving
|
||||||
|
some stability-related issues. See https://npcap.com/changelog
|
||||||
|
|
||||||
o Fixed a memory-consumption hang in Ncat's HTTP proxy code that affected both
|
o Fixed a memory-consumption hang in Ncat's HTTP proxy code that affected both
|
||||||
connect and listen modes, reported by kumama_nui.
|
connect and listen modes, reported by kumama_nui.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
.\" Title: nmap
|
.\" Title: nmap
|
||||||
.\" Author: [see the "Authors" section]
|
.\" Author: [see the "Authors" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 10/07/2026
|
.\" Date: 10/23/2026
|
||||||
.\" Manual: Nmap Reference Guide
|
.\" Manual: Nmap Reference Guide
|
||||||
.\" Source: Nmap
|
.\" Source: Nmap
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "NMAP" "1" "10/07/2026" "Nmap" "Nmap Reference Guide"
|
.TH "NMAP" "1" "10/23/2026" "Nmap" "Nmap Reference Guide"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
|
|
@ -119,7 +119,7 @@ This options summary is printed when Nmap is run with no arguments, and the late
|
||||||
.RS 4
|
.RS 4
|
||||||
.\}
|
.\}
|
||||||
.nf
|
.nf
|
||||||
Nmap 7\&.992 ( https://nmap\&.org )
|
Nmap 7\&.993 ( https://nmap\&.org )
|
||||||
Usage: nmap [Scan Type(s)] [Options] {target specification}
|
Usage: nmap [Scan Type(s)] [Options] {target specification}
|
||||||
TARGET SPECIFICATION:
|
TARGET SPECIFICATION:
|
||||||
Can pass hostnames, IP addresses, networks, etc\&.
|
Can pass hostnames, IP addresses, networks, etc\&.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Nmap 7.992 ( https://nmap.org )
|
Nmap 7.993SVN ( https://nmap.org )
|
||||||
Usage: nmap [Scan Type(s)] [Options] {target specification}
|
Usage: nmap [Scan Type(s)] [Options] {target specification}
|
||||||
TARGET SPECIFICATION:
|
TARGET SPECIFICATION:
|
||||||
Can pass hostnames, IP addresses, networks, etc.
|
Can pass hostnames, IP addresses, networks, etc.
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
.\" Title: zenmap
|
.\" Title: zenmap
|
||||||
.\" Author: [see the "Authors" section]
|
.\" Author: [see the "Authors" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 10/07/2026
|
.\" Date: 10/23/2026
|
||||||
.\" Manual: Zenmap Reference Guide
|
.\" Manual: Zenmap Reference Guide
|
||||||
.\" Source: Zenmap
|
.\" Source: Zenmap
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "ZENMAP" "1" "10/07/2026" "Zenmap" "Zenmap Reference Guide"
|
.TH "ZENMAP" "1" "10/23/2026" "Zenmap" "Zenmap Reference Guide"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE moduleset SYSTEM "moduleset.dtd" [
|
<!DOCTYPE moduleset SYSTEM "moduleset.dtd" [
|
||||||
<!ENTITY nmap_version "7.992">
|
<!ENTITY nmap_version "7.993">
|
||||||
<!ENTITY openssl_version "3.5.9">
|
<!ENTITY openssl_version "3.5.9">
|
||||||
<!ENTITY libpcap_version "1.10.7">
|
<!ENTITY libpcap_version "1.10.7">
|
||||||
<!ENTITY libssh2_version "1.11.1">
|
<!ENTITY libssh2_version "1.11.1">
|
||||||
|
|
|
||||||
|
|
@ -331,8 +331,11 @@ static void trie_split (struct trie_node *this, const u32 *addr, const u32 *mask
|
||||||
/* Addrs have more bits in common than we care about for this node. */
|
/* Addrs have more bits in common than we care about for this node. */
|
||||||
new_mask[i] = this->mask[i];
|
new_mask[i] = this->mask[i];
|
||||||
}
|
}
|
||||||
if (new_mask[i] > mask[i]) {
|
if (new_mask[i] > mask[i]
|
||||||
/* new addr's mask is broader, so this node is superseded. */
|
|| (new_mask[i] == mask[i] && mask[i] != U32_ALL_BITS)) {
|
||||||
|
/* new addr's mask is no longer than the common prefix, so this node is
|
||||||
|
* superseded. Equal full words don't count: the new mask continues in
|
||||||
|
* the next word, so keep comparing. */
|
||||||
this->mask[i] = mask[i];
|
this->mask[i] = mask[i];
|
||||||
for (i++; i < 4; i++) {
|
for (i++; i < 4; i++) {
|
||||||
this->mask[i] = 0;
|
this->mask[i] = 0;
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,5 @@ ready-made PEM files to download. See http://curl.haxx.se/docs/caextract.html.
|
||||||
|
|
||||||
Here is how to download Mozilla's trust store:
|
Here is how to download Mozilla's trust store:
|
||||||
|
|
||||||
$ wget https://raw.github.com/bagder/curl/master/lib/mk-ca-bundle.pl
|
$ wget https://raw.github.com/curl/curl/master/scripts/mk-ca-bundle.pl
|
||||||
$ perl mk-ca-bundle.pl
|
$ perl mk-ca-bundle.pl
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,12 +2,12 @@
|
||||||
.\" Title: Ncat
|
.\" Title: Ncat
|
||||||
.\" Author: [see the "Authors" section]
|
.\" Author: [see the "Authors" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 10/07/2026
|
.\" Date: 10/23/2026
|
||||||
.\" Manual: Ncat Reference Guide
|
.\" Manual: Ncat Reference Guide
|
||||||
.\" Source: Ncat
|
.\" Source: Ncat
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "NCAT" "1" "10/07/2026" "Ncat" "Ncat Reference Guide"
|
.TH "NCAT" "1" "10/23/2026" "Ncat" "Ncat Reference Guide"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
|
|
@ -43,7 +43,7 @@ Among Ncat\*(Aqs vast number of features there is the ability to chain Ncats tog
|
||||||
.RS 4
|
.RS 4
|
||||||
.\}
|
.\}
|
||||||
.nf
|
.nf
|
||||||
Ncat 7\&.992 ( https://nmap\&.org/ncat )
|
Ncat 7\&.993 ( https://nmap\&.org/ncat )
|
||||||
Usage: ncat [options] [hostname] [port]
|
Usage: ncat [options] [hostname] [port]
|
||||||
|
|
||||||
Options taking a time assume seconds\&. Append \*(Aqms\*(Aq for milliseconds,
|
Options taking a time assume seconds\&. Append \*(Aqms\*(Aq for milliseconds,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Ncat 7.992 ( https://nmap.org/ncat )
|
Ncat 7.993SVN ( https://nmap.org/ncat )
|
||||||
Usage: ncat [options] [hostname] [port]
|
Usage: ncat [options] [hostname] [port]
|
||||||
|
|
||||||
Options taking a time assume seconds. Append 'ms' for milliseconds,
|
Options taking a time assume seconds. Append 'ms' for milliseconds,
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
/* Ncat information for output, etc. */
|
/* Ncat information for output, etc. */
|
||||||
#define NCAT_NAME "Ncat"
|
#define NCAT_NAME "Ncat"
|
||||||
#define NCAT_URL "https://nmap.org/ncat"
|
#define NCAT_URL "https://nmap.org/ncat"
|
||||||
#define NCAT_VERSION "7.992"
|
#define NCAT_VERSION "7.993SVN"
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
#ifndef __attribute__
|
#ifndef __attribute__
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,43 @@ test_addrset "192.168.0.0/24" "192.168.0.5 192.168.0.90" <<EOF
|
||||||
1.2.3.4
|
1.2.3.4
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Overlapping CIDR netmasks: order must not matter.
|
||||||
|
test_addrset "10.200.0.0/16 10.0.0.0/8" "10.150.0.20 10.200.1.1 10.0.0.1" <<EOF
|
||||||
|
10.150.0.20
|
||||||
|
10.200.1.1
|
||||||
|
10.0.0.1
|
||||||
|
11.0.0.1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_addrset "10.0.0.0/8 10.200.0.0/16" "10.150.0.20 10.200.1.1 10.0.0.1" <<EOF
|
||||||
|
10.150.0.20
|
||||||
|
10.200.1.1
|
||||||
|
10.0.0.1
|
||||||
|
11.0.0.1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_addrset "10.200.0.0/16 10.0.0.0/16 10.0.0.0/8" "10.150.0.20 10.200.1.1 10.0.0.1" <<EOF
|
||||||
|
10.150.0.20
|
||||||
|
10.200.1.1
|
||||||
|
10.0.0.1
|
||||||
|
11.0.0.1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# A broader IPv4 /0 after a narrower spec.
|
||||||
|
test_addrset "200.0.0.0/16 0.0.0.0/0" "200.1.1.1 200.0.0.1 1.2.3.4" <<EOF
|
||||||
|
200.1.1.1
|
||||||
|
200.0.0.1
|
||||||
|
1.2.3.4
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Overlapping IPv6 netmasks, with the broader mask on a 32-bit boundary.
|
||||||
|
test_addrset "1:2:8000::/48 1:2::/32" "1:2::1 1:2:8000::1 1:2:c000::1" <<EOF
|
||||||
|
1:2::1
|
||||||
|
1:2:8000::1
|
||||||
|
1:2:c000::1
|
||||||
|
1:3::1
|
||||||
|
EOF
|
||||||
|
|
||||||
# /32 netmask.
|
# /32 netmask.
|
||||||
test_addrset "1.2.3.4/32" "1.2.3.4" <<EOF
|
test_addrset "1.2.3.4/32" "1.2.3.4" <<EOF
|
||||||
192.168.0.10
|
192.168.0.10
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
VERSION = "7.992"
|
VERSION = "7.993+SVN"
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
.\" Title: ndiff
|
.\" Title: ndiff
|
||||||
.\" Author: [see the "Authors" section]
|
.\" Author: [see the "Authors" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 10/07/2026
|
.\" Date: 10/23/2026
|
||||||
.\" Manual: User Commands
|
.\" Manual: User Commands
|
||||||
.\" Source: Ndiff
|
.\" Source: Ndiff
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "NDIFF" "1" "10/07/2026" "Ndiff" "User Commands"
|
.TH "NDIFF" "1" "10/23/2026" "Ndiff" "User Commands"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -13907,9 +13907,10 @@ ports 3388,3389
|
||||||
fallback TerminalServer
|
fallback TerminalServer
|
||||||
|
|
||||||
# varies on flags:
|
# varies on flags:
|
||||||
# 0x10 - Remote Credential Guard (Windows 10 1607 or later)
|
|
||||||
# 0x08 - Restricted Admin mode (Windows 8.1 or later)
|
# 0x08 - Restricted Admin mode (Windows 8.1 or later)
|
||||||
match ms-wbt-server m|^\x03\0\0\x13\x0e\xd0\0\0\x124\0\x02[\x07\x0f\x1f]\x08\0\x02\0\0\0| p/Microsoft Terminal Services/ o/Windows/ cpe:/o:microsoft:windows/a
|
# 0x10 - Remote Credential Guard (Windows 10 1607 or later)
|
||||||
|
# 0x20 - Undocumented; observed on Windows build 10.26100 (Server 2025, Windows 11 24H2)
|
||||||
|
match ms-wbt-server m|^\x03\0\0\x13\x0e\xd0\0\0\x124\0\x02[\x07\x0f\x17\x1f\x27\x2f\x37\x3f]\x08\0\x02\0\0\0| p/Microsoft Terminal Services/ o/Windows/ cpe:/o:microsoft:windows/a
|
||||||
match ms-wbt-server m|^\x03\0\0\x0b\x06\xd0\0\0\x124\0$| p/Microsoft Terminal Services/ o/Windows XP/ cpe:/o:microsoft:windows_xp/a
|
match ms-wbt-server m|^\x03\0\0\x0b\x06\xd0\0\0\x124\0$| p/Microsoft Terminal Services/ o/Windows XP/ cpe:/o:microsoft:windows_xp/a
|
||||||
|
|
||||||
##############################NEXT PROBE##############################
|
##############################NEXT PROBE##############################
|
||||||
|
|
|
||||||
6
nmap.h
6
nmap.h
|
|
@ -123,10 +123,10 @@
|
||||||
/* Edit this definition only within the quotes, because it is read from this
|
/* Edit this definition only within the quotes, because it is read from this
|
||||||
file by the makefiles. */
|
file by the makefiles. */
|
||||||
#define NMAP_MAJOR 7
|
#define NMAP_MAJOR 7
|
||||||
#define NMAP_MINOR 992
|
#define NMAP_MINOR 993
|
||||||
#define NMAP_BUILD 0
|
#define NMAP_BUILD 1
|
||||||
/* SVN, BETA, etc. */
|
/* SVN, BETA, etc. */
|
||||||
#define NMAP_SPECIAL ""
|
#define NMAP_SPECIAL "SVN"
|
||||||
|
|
||||||
#define NMAP_VERSION STR(NMAP_MAJOR) "." STR(NMAP_MINOR) NMAP_SPECIAL
|
#define NMAP_VERSION STR(NMAP_MAJOR) "." STR(NMAP_MINOR) NMAP_SPECIAL
|
||||||
#define NMAP_NUM_VERSION STR(NMAP_MAJOR) "." STR(NMAP_MINOR) "." STR(NMAP_BUILD) ".0"
|
#define NMAP_NUM_VERSION STR(NMAP_MAJOR) "." STR(NMAP_MINOR) "." STR(NMAP_BUILD) ".0"
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
.\" Title: nping
|
.\" Title: nping
|
||||||
.\" Author: [see the "Authors" section]
|
.\" Author: [see the "Authors" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 10/07/2026
|
.\" Date: 10/23/2026
|
||||||
.\" Manual: Nping Reference Guide
|
.\" Manual: Nping Reference Guide
|
||||||
.\" Source: Nping
|
.\" Source: Nping
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "NPING" "1" "10/07/2026" "Nping" "Nping Reference Guide"
|
.TH "NPING" "1" "10/23/2026" "Nping" "Nping Reference Guide"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@
|
||||||
/* General tunable defines **************************************************/
|
/* General tunable defines **************************************************/
|
||||||
#define NPING_NAME "Nping"
|
#define NPING_NAME "Nping"
|
||||||
#define NPING_URL "https://nmap.org/nping"
|
#define NPING_URL "https://nmap.org/nping"
|
||||||
#define NPING_VERSION "7.992"
|
#define NPING_VERSION "7.993SVN"
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_VERBOSITY VB_0
|
#define DEFAULT_VERBOSITY VB_0
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ extern NpingOps o;
|
||||||
|
|
||||||
int atoIP(const char *hostname, struct in_addr *dst){
|
int atoIP(const char *hostname, struct in_addr *dst){
|
||||||
struct sockaddr_in i;
|
struct sockaddr_in i;
|
||||||
unsigned int stlen=0;
|
size_t stlen=0;
|
||||||
if ( resolve(hostname, 0, (sockaddr_storage*)&i, (size_t *)&stlen , PF_INET) != 0 )
|
if ( resolve(hostname, 0, (sockaddr_storage*)&i, &stlen , PF_INET) != 0 )
|
||||||
return OP_FAILURE;
|
return OP_FAILURE;
|
||||||
*dst=i.sin_addr;
|
*dst=i.sin_addr;
|
||||||
return OP_SUCCESS;
|
return OP_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
#include "nse_lua.h"
|
#include "nse_lua.h"
|
||||||
#include "nse_debug.h"
|
#include "nse_debug.h"
|
||||||
|
#include "nse_nmaplib.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -89,7 +90,7 @@ void lua_state_dump (lua_State *L)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("=== nmap.registry\n");
|
printf("=== nmap.registry\n");
|
||||||
lua_getglobal(L, "nmap");
|
luaL_requiref(L, "nmap", luaopen_nmap, 0);
|
||||||
lua_getfield(L, -1, "registry");
|
lua_getfield(L, -1, "registry");
|
||||||
table_dump(L, -1, 1);
|
table_dump(L, -1, 1);
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ extern "C" {
|
||||||
#include "nse_lua.h"
|
#include "nse_lua.h"
|
||||||
|
|
||||||
#include "nse_nsock.h"
|
#include "nse_nsock.h"
|
||||||
|
#include "nse_nmaplib.h"
|
||||||
#include "nse_utility.h"
|
#include "nse_utility.h"
|
||||||
#include "nbase.h"
|
#include "nbase.h"
|
||||||
#include "nmap_error.h"
|
#include "nmap_error.h"
|
||||||
|
|
@ -41,7 +42,9 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SSH2_UDATA = lua_upvalueindex(1)
|
SSH2_UDATA = lua_upvalueindex(1),
|
||||||
|
NEW_SOCKET = lua_upvalueindex(2),
|
||||||
|
BASE64_DEC = lua_upvalueindex(3)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct userauth_context {
|
struct userauth_context {
|
||||||
|
|
@ -356,7 +359,7 @@ static int l_session_open (lua_State *L) {
|
||||||
state->sp[0] = -1;
|
state->sp[0] = -1;
|
||||||
state->sp[1] = -1;
|
state->sp[1] = -1;
|
||||||
state->L = L;
|
state->L = L;
|
||||||
lua_pushvalue(L, lua_upvalueindex(1)); /* metatable */
|
lua_pushvalue(L, SSH2_UDATA); /* metatable */
|
||||||
lua_setmetatable(L, 3);
|
lua_setmetatable(L, 3);
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
@ -395,9 +398,7 @@ static int l_session_open (lua_State *L) {
|
||||||
return nseU_safeerror(L, "%s", strerror(errno));
|
return nseU_safeerror(L, "%s", strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lua_getglobal(L, "nmap");
|
lua_pushvalue(L, NEW_SOCKET); /* nmap.new_socket */
|
||||||
lua_getfield(L, -1, "new_socket");
|
|
||||||
lua_replace(L, -2);
|
|
||||||
lua_call(L, 0, 1);
|
lua_call(L, 0, 1);
|
||||||
lua_setfield(L, 4, "sock");
|
lua_setfield(L, 4, "sock");
|
||||||
lua_pushliteral(L, "");
|
lua_pushliteral(L, "");
|
||||||
|
|
@ -574,10 +575,7 @@ static int l_read_publickey (lua_State *L) {
|
||||||
const char* publickeyfile = luaL_checkstring(L, 1);
|
const char* publickeyfile = luaL_checkstring(L, 1);
|
||||||
luaL_Buffer publickey_data;
|
luaL_Buffer publickey_data;
|
||||||
|
|
||||||
lua_getglobal(L, "require");
|
lua_pushvalue(L, BASE64_DEC);
|
||||||
lua_pushliteral(L, "base64");
|
|
||||||
lua_call(L, 1, 1);
|
|
||||||
lua_getfield(L, -1, "dec");
|
|
||||||
|
|
||||||
fd = fopen(publickeyfile, "r");
|
fd = fopen(publickeyfile, "r");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
|
|
@ -1086,7 +1084,20 @@ int luaopen_libssh2 (lua_State *L) {
|
||||||
lua_pushcclosure(L, filter, 1);
|
lua_pushcclosure(L, filter, 1);
|
||||||
lua_setfield(L, -2, "filter");
|
lua_setfield(L, -2, "filter");
|
||||||
|
|
||||||
luaL_setfuncs(L, libssh2, 1);
|
/* nmap.new_socket is upvalue 2 */
|
||||||
|
luaL_requiref(L, "nmap", luaopen_nmap, 0);
|
||||||
|
lua_getfield(L, -1, "new_socket");
|
||||||
|
lua_replace(L, -2);
|
||||||
|
|
||||||
|
/* base64.dec is upvalue 3 */
|
||||||
|
lua_getglobal(L, "require");
|
||||||
|
lua_pushliteral(L, "base64");
|
||||||
|
lua_call(L, 1, 1);
|
||||||
|
lua_getfield(L, -1, "dec");
|
||||||
|
lua_replace(L, -2);
|
||||||
|
|
||||||
|
|
||||||
|
luaL_setfuncs(L, libssh2, 3);
|
||||||
|
|
||||||
static bool libssh2_initialized = false;
|
static bool libssh2_initialized = false;
|
||||||
if (!libssh2_initialized && (libssh2_init(0) != 0))
|
if (!libssh2_initialized && (libssh2_init(0) != 0))
|
||||||
|
|
|
||||||
|
|
@ -680,14 +680,13 @@ static int l_get_version_intensity (lua_State *L)
|
||||||
int is_script_intensity_set;
|
int is_script_intensity_set;
|
||||||
int script_intensity;
|
int script_intensity;
|
||||||
|
|
||||||
lua_getglobal(L, "nmap");
|
lua_pushvalue(L, lua_upvalueindex(1)); /* nmap.registry */
|
||||||
lua_getfield(L, -1, "registry");
|
|
||||||
lua_getfield(L, -1, "args");
|
lua_getfield(L, -1, "args");
|
||||||
lua_getfield(L, -1, "script-intensity");
|
lua_getfield(L, -1, "script-intensity");
|
||||||
|
|
||||||
script_intensity = lua_tointegerx(L, lua_gettop(L), &is_script_intensity_set);
|
script_intensity = lua_tointegerx(L, lua_gettop(L), &is_script_intensity_set);
|
||||||
|
|
||||||
lua_pop(L, 4);
|
lua_pop(L, 3);
|
||||||
|
|
||||||
if (is_script_intensity_set) {
|
if (is_script_intensity_set) {
|
||||||
if (script_intensity < 0 || script_intensity > 9)
|
if (script_intensity < 0 || script_intensity > 9)
|
||||||
|
|
@ -1041,8 +1040,13 @@ int luaopen_nmap (lua_State *L)
|
||||||
lua_pushcclosure(L, l_condvar, 1); /* condvar function */
|
lua_pushcclosure(L, l_condvar, 1); /* condvar function */
|
||||||
lua_setfield(L, nmap_idx, "condvar");
|
lua_setfield(L, nmap_idx, "condvar");
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L); /* nmap.registry */
|
||||||
|
/* Copy nmap.registry. One copy to set nmap["registry"] */
|
||||||
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, nmap_idx, "registry");
|
lua_setfield(L, nmap_idx, "registry");
|
||||||
|
/* and the other as upvalue for l_get_version_intensity. */
|
||||||
|
lua_pushcclosure(L, l_get_version_intensity, 1);
|
||||||
|
lua_setfield(L, nmap_idx, "version_intensity");
|
||||||
|
|
||||||
/* Pull out some functions from the nmap.socket and nmap.dnet libraries.
|
/* Pull out some functions from the nmap.socket and nmap.dnet libraries.
|
||||||
http://seclists.org/nmap-dev/2012/q1/299. */
|
http://seclists.org/nmap-dev/2012/q1/299. */
|
||||||
|
|
|
||||||
|
|
@ -778,9 +778,7 @@ static int receive_buf (lua_State *L, int status, lua_KContext ctx)
|
||||||
}
|
}
|
||||||
else /* string */
|
else /* string */
|
||||||
{
|
{
|
||||||
lua_getglobal(L, "string");
|
lua_getfield(L, 2, "find");
|
||||||
lua_getfield(L, -1, "find");
|
|
||||||
lua_replace(L, -2);
|
|
||||||
lua_pushvalue(L, 5);
|
lua_pushvalue(L, 5);
|
||||||
lua_pushvalue(L, 2);
|
lua_pushvalue(L, 2);
|
||||||
lua_call(L, 2, 2); /* we do not allow yields */
|
lua_call(L, 2, 2); /* we do not allow yields */
|
||||||
|
|
|
||||||
|
|
@ -625,6 +625,7 @@ static int lzstream_lines(lua_State *L) {
|
||||||
static int lzstream_docompress(lua_State *L, lz_stream *s, int from, int to, int flush) {
|
static int lzstream_docompress(lua_State *L, lz_stream *s, int from, int to, int flush) {
|
||||||
int r, arg;
|
int r, arg;
|
||||||
int self = 0;
|
int self = 0;
|
||||||
|
size_t avail_in;
|
||||||
size_t b_size = s->o_buffer_max;
|
size_t b_size = s->o_buffer_max;
|
||||||
unsigned char *b = (unsigned char *)s->o_buffer;
|
unsigned char *b = (unsigned char *)s->o_buffer;
|
||||||
|
|
||||||
|
|
@ -636,7 +637,8 @@ static int lzstream_docompress(lua_State *L, lz_stream *s, int from, int to, int
|
||||||
}
|
}
|
||||||
|
|
||||||
for (arg = from; arg <= to; arg++) {
|
for (arg = from; arg <= to; arg++) {
|
||||||
s->zstream.next_in = (unsigned char*)luaL_checklstring(L, arg, (size_t*)&s->zstream.avail_in);
|
s->zstream.next_in = (unsigned char*)luaL_checklstring(L, arg, &avail_in);
|
||||||
|
s->zstream.avail_in = avail_in;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
s->zstream.next_out = b;
|
s->zstream.next_out = b;
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,20 @@ LONG_VRS = {
|
||||||
SV = true, UV = true,
|
SV = true, UV = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- All valid DICOM Value Representations (PS3.5 Table 6.2-1). Used to detect a
|
||||||
|
-- corrupt File Meta element whose VR bytes are not a real VR, so the Explicit
|
||||||
|
-- VR walk can stop instead of misaligning on a bogus length.
|
||||||
|
-- @class table
|
||||||
|
-- @name KNOWN_VRS
|
||||||
|
KNOWN_VRS = {
|
||||||
|
AE = true, AS = true, AT = true, CS = true, DA = true, DS = true,
|
||||||
|
DT = true, FL = true, FD = true, IS = true, LO = true, LT = true,
|
||||||
|
OB = true, OD = true, OF = true, OL = true, OV = true, OW = true,
|
||||||
|
PN = true, SH = true, SL = true, SQ = true, SS = true, ST = true,
|
||||||
|
SV = true, TM = true, UC = true, UI = true, UL = true, UN = true,
|
||||||
|
UR = true, US = true, UT = true, UV = true,
|
||||||
|
}
|
||||||
|
|
||||||
--- CommandDataSetType (0000,0800) sentinel: a dataset follows the command.
|
--- CommandDataSetType (0000,0800) sentinel: a dataset follows the command.
|
||||||
DATASET_PRESENT = 0x0001
|
DATASET_PRESENT = 0x0001
|
||||||
--- CommandDataSetType (0000,0800) sentinel: no dataset follows the command.
|
--- CommandDataSetType (0000,0800) sentinel: no dataset follows the command.
|
||||||
|
|
@ -1518,14 +1532,32 @@ function read_dcm_dataset(filepath)
|
||||||
local sop_instance = ""
|
local sop_instance = ""
|
||||||
local ts_uid = TRANSFER_SYNTAX.EXPLICIT_LE
|
local ts_uid = TRANSFER_SYNTAX.EXPLICIT_LE
|
||||||
|
|
||||||
-- Parse File Meta Information (always Explicit VR LE, group 0002)
|
-- Parse File Meta Information (always Explicit VR LE, group 0002).
|
||||||
|
-- A 5th return value carries a diagnostic string when the meta cannot be
|
||||||
|
-- walked cleanly (e.g. a corrupt VR); callers treat empty SOP UIDs as
|
||||||
|
-- "meta unparseable" rather than as a deliberate empty-UID test.
|
||||||
while pos <= #data - 8 do
|
while pos <= #data - 8 do
|
||||||
local grp = string.unpack("<I2", data, pos)
|
local grp = string.unpack("<I2", data, pos)
|
||||||
if grp ~= 0x0002 then
|
if grp ~= 0x0002 then
|
||||||
|
-- Clean end of File Meta: the main dataset starts here.
|
||||||
return data:sub(pos), sop_class, sop_instance, ts_uid
|
return data:sub(pos), sop_class, sop_instance, ts_uid
|
||||||
end
|
end
|
||||||
local elem = string.unpack("<I2", data, pos + 2)
|
local elem = string.unpack("<I2", data, pos + 2)
|
||||||
local vr = data:sub(pos + 4, pos + 5)
|
local vr = data:sub(pos + 4, pos + 5)
|
||||||
|
|
||||||
|
-- A File Meta element whose VR is not a real DICOM VR means the
|
||||||
|
-- Explicit-VR framing is corrupt. Continuing would misread the length
|
||||||
|
-- field, misalign, and silently drop the SOP Class/Instance UIDs (and
|
||||||
|
-- split the dataset at the wrong offset). Stop and report instead.
|
||||||
|
if not KNOWN_VRS[vr] then
|
||||||
|
local b1, b2 = vr:byte(1, 2)
|
||||||
|
local detail = string.format(
|
||||||
|
"File Meta (%04X,%04X) has invalid VR 0x%02X%02X at offset %d"
|
||||||
|
.. " -- meta parsing stopped", grp, elem, b1 or 0, b2 or 0, pos)
|
||||||
|
stdnse.debug1("read_dcm_dataset: %s", detail)
|
||||||
|
return data:sub(pos), sop_class, sop_instance, ts_uid, detail
|
||||||
|
end
|
||||||
|
|
||||||
local vlen, next_pos
|
local vlen, next_pos
|
||||||
if LONG_VRS[vr] then
|
if LONG_VRS[vr] then
|
||||||
vlen = string.unpack("<I4", data, pos + 8)
|
vlen = string.unpack("<I4", data, pos + 8)
|
||||||
|
|
@ -1534,14 +1566,23 @@ function read_dcm_dataset(filepath)
|
||||||
vlen = string.unpack("<I2", data, pos + 6)
|
vlen = string.unpack("<I2", data, pos + 6)
|
||||||
next_pos = pos + 8 + vlen
|
next_pos = pos + 8 + vlen
|
||||||
end
|
end
|
||||||
local val_start = next_pos - vlen
|
|
||||||
local val = data:sub(val_start, next_pos - 1)
|
|
||||||
|
|
||||||
if grp == 0x0002 and elem == 0x0002 then
|
-- A length that does not advance, or that overruns the buffer, is also
|
||||||
|
-- a corrupt-framing signal; stop rather than loop or read out of bounds.
|
||||||
|
if next_pos <= pos or next_pos > #data + 1 then
|
||||||
|
local detail = string.format(
|
||||||
|
"File Meta (%04X,%04X) length %d overruns buffer at offset %d"
|
||||||
|
.. " -- meta parsing stopped", grp, elem, vlen, pos)
|
||||||
|
stdnse.debug1("read_dcm_dataset: %s", detail)
|
||||||
|
return data:sub(pos), sop_class, sop_instance, ts_uid, detail
|
||||||
|
end
|
||||||
|
|
||||||
|
local val = data:sub(next_pos - vlen, next_pos - 1)
|
||||||
|
if elem == 0x0002 then
|
||||||
sop_class = val:gsub("%z", ""):gsub("%s+$", "")
|
sop_class = val:gsub("%z", ""):gsub("%s+$", "")
|
||||||
elseif grp == 0x0002 and elem == 0x0003 then
|
elseif elem == 0x0003 then
|
||||||
sop_instance = val:gsub("%z", ""):gsub("%s+$", "")
|
sop_instance = val:gsub("%z", ""):gsub("%s+$", "")
|
||||||
elseif grp == 0x0002 and elem == 0x0010 then
|
elseif elem == 0x0010 then
|
||||||
ts_uid = val:gsub("%z", ""):gsub("%s+$", "")
|
ts_uid = val:gsub("%z", ""):gsub("%s+$", "")
|
||||||
end
|
end
|
||||||
pos = next_pos
|
pos = next_pos
|
||||||
|
|
@ -1555,4 +1596,36 @@ function read_dcm_dataset(filepath)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Read a .dcm file and return its bytes VERBATIM for faithful fuzzing.
|
||||||
|
--
|
||||||
|
-- Unlike read_dcm_dataset (which strips the Part-10 preamble + File Meta and
|
||||||
|
-- returns only the main dataset), this returns the file exactly as stored, so
|
||||||
|
-- structure-, meta- and dataset-level mutations all reach the target on the
|
||||||
|
-- wire. It still parses the File Meta best-effort to recover a SOP Class,
|
||||||
|
-- SOP Instance and transfer syntax for the C-STORE command set and the
|
||||||
|
-- A-ASSOCIATE negotiation; those come back empty / default when the meta is
|
||||||
|
-- corrupt (the caller substitutes safe values).
|
||||||
|
--
|
||||||
|
-- @param filepath path to the .dcm file.
|
||||||
|
-- @param after_preamble if true, drop the 128-byte preamble and the "DICM"
|
||||||
|
-- magic, returning File Meta + dataset; otherwise the
|
||||||
|
-- whole file (default).
|
||||||
|
-- @return raw_bytes (string or nil), sop_class, sop_instance, ts_uid,
|
||||||
|
-- meta_note (diagnostic string when the File Meta was unparseable,
|
||||||
|
-- else nil) or, on read failure, nil + error in the 5th slot.
|
||||||
|
function read_dcm_raw(filepath, after_preamble)
|
||||||
|
local data, err = read_file(filepath)
|
||||||
|
if not data then
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
end
|
||||||
|
-- Best-effort UID/TS discovery (reuses the hardened meta walk).
|
||||||
|
local _, sop_class, sop_instance, ts_uid, meta_note =
|
||||||
|
read_dcm_dataset(filepath)
|
||||||
|
local payload = data
|
||||||
|
if after_preamble and #data >= 132 and data:sub(129, 132) == "DICM" then
|
||||||
|
payload = data:sub(133)
|
||||||
|
end
|
||||||
|
return payload, sop_class, sop_instance, ts_uid, meta_note
|
||||||
|
end
|
||||||
|
|
||||||
return _ENV
|
return _ENV
|
||||||
|
|
|
||||||
|
|
@ -1706,7 +1706,7 @@ end
|
||||||
-- @return url table as returned by <code>url.parse</code> or nil if there's no
|
-- @return url table as returned by <code>url.parse</code> or nil if there's no
|
||||||
-- redirect taking place
|
-- redirect taking place
|
||||||
function parse_redirect(host, port, path, response)
|
function parse_redirect(host, port, path, response)
|
||||||
if ( not(tostring(response.status):match("^30[01237]$")) or
|
if ( not(tostring(response.status):find("^30[012378]$")) or
|
||||||
not(response.header) or
|
not(response.header) or
|
||||||
not(response.header.location) ) then
|
not(response.header.location) ) then
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -1111,7 +1111,7 @@ MMSEncoder = {
|
||||||
return str
|
return str
|
||||||
end,
|
end,
|
||||||
|
|
||||||
encodeSeq = asn1.ASN1Encoder.encodeSeq,
|
encodeSeq = function (...) return asn1.ASN1Encoder:encodeSeq(...) end,
|
||||||
}
|
}
|
||||||
|
|
||||||
MMSQueries = {
|
MMSQueries = {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ local string = require "string"
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local openssl = stdnse.silent_require "openssl"
|
local openssl = stdnse.silent_require "openssl"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
local tableaux = require "tableaux"
|
||||||
_ENV = stdnse.module("ssh2", stdnse.seeall)
|
_ENV = stdnse.module("ssh2", stdnse.seeall)
|
||||||
|
|
||||||
-- table holding transport layer functions
|
-- table holding transport layer functions
|
||||||
|
|
@ -154,11 +156,11 @@ end
|
||||||
--- Fetch an SSH-2 host key.
|
--- Fetch an SSH-2 host key.
|
||||||
-- @param host Nmap host table.
|
-- @param host Nmap host table.
|
||||||
-- @param port Nmap port table.
|
-- @param port Nmap port table.
|
||||||
-- @param key_type key type to fetch.
|
-- @param host_key_algo host key algorithm to use for fetching the key.
|
||||||
-- @return A table with the following fields: <code>key</code>,
|
-- @return A table with the following fields: <code>key</code>,
|
||||||
-- <code>key_type</code>, <code>fp_input</code>, <code>bits</code>,
|
-- <code>key_type</code>, <code>fp_input</code>, <code>bits</code>,
|
||||||
-- <code>full_key</code>, <code>algorithm</code>, and <code>fingerprint</code>.
|
-- <code>full_key</code>, <code>algorithm</code>, and <code>fingerprint</code>.
|
||||||
fetch_host_key = function( host, port, key_type )
|
fetch_host_key = function( host, port, host_key_algo )
|
||||||
local socket = nmap.new_socket()
|
local socket = nmap.new_socket()
|
||||||
local status
|
local status
|
||||||
|
|
||||||
|
|
@ -215,7 +217,7 @@ fetch_host_key = function( host, port, key_type )
|
||||||
if not status then socket:close(); return end
|
if not status then socket:close(); return end
|
||||||
|
|
||||||
local packet = transport.build( transport.kex_init( {
|
local packet = transport.build( transport.kex_init( {
|
||||||
host_key_algorithms=key_type,
|
host_key_algorithms=host_key_algo,
|
||||||
kex_algorithms="diffie-hellman-group1-sha1,\z
|
kex_algorithms="diffie-hellman-group1-sha1,\z
|
||||||
diffie-hellman-group14-sha1,\z
|
diffie-hellman-group14-sha1,\z
|
||||||
diffie-hellman-group14-sha256,\z
|
diffie-hellman-group14-sha256,\z
|
||||||
|
|
@ -231,9 +233,8 @@ fetch_host_key = function( host, port, key_type )
|
||||||
if not status then socket:close(); return end
|
if not status then socket:close(); return end
|
||||||
kex_init = transport.parse_kex_init( transport.payload( kex_init ) )
|
kex_init = transport.parse_kex_init( transport.payload( kex_init ) )
|
||||||
|
|
||||||
if not tostring(kex_init.server_host_key_algorithms):find( key_type, 1, true ) then
|
if not tableaux.contains(stringaux.strsplit(",", kex_init.server_host_key_algorithms or ""), host_key_algo) then
|
||||||
-- server does not support host key type
|
stdnse.debug2("Host key algorithm '%s' not supported by server.", host_key_algo)
|
||||||
stdnse.debug2("Hostkey type '%s' not supported by server.", key_type )
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -312,48 +313,53 @@ fetch_host_key = function( host, port, key_type )
|
||||||
status, kexdh_reply = transport.receive_packet( socket )
|
status, kexdh_reply = transport.receive_packet( socket )
|
||||||
if not status then socket:close(); return end
|
if not status then socket:close(); return end
|
||||||
kexdh_reply = transport.payload( kexdh_reply )
|
kexdh_reply = transport.payload( kexdh_reply )
|
||||||
|
socket:close()
|
||||||
-- check for proper msg code
|
-- check for proper msg code
|
||||||
local msg_code = kexdh_reply:byte(1)
|
local msg_code = kexdh_reply:byte(1)
|
||||||
|
|
||||||
if ( kexdh_gex_used and msg_code ~= SSH2.SSH_MSG_KEX_DH_GEX_REPLY )
|
if ( kexdh_gex_used and msg_code ~= SSH2.SSH_MSG_KEX_DH_GEX_REPLY )
|
||||||
or ( not kexdh_gex_used and msg_code ~= SSH2.SSH_MSG_KEXDH_REPLY )
|
or ( not kexdh_gex_used and msg_code ~= SSH2.SSH_MSG_KEXDH_REPLY )
|
||||||
then
|
then
|
||||||
socket:close()
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local bits, algorithm
|
local key_type, bits, algorithm
|
||||||
local _, public_host_key = string.unpack( ">Bs4", kexdh_reply )
|
local _, public_host_key = string.unpack( ">Bs4", kexdh_reply )
|
||||||
|
|
||||||
if key_type == 'ssh-dss' then
|
if host_key_algo == "ssh-dss" then
|
||||||
|
key_type = host_key_algo
|
||||||
algorithm = "DSA"
|
algorithm = "DSA"
|
||||||
local _, p = string.unpack( ">s4s4", public_host_key )
|
local _, p = string.unpack( ">s4s4", public_host_key )
|
||||||
bits = openssl.bignum_bin2bn( p ):num_bits()
|
bits = openssl.bignum_bin2bn( p ):num_bits()
|
||||||
elseif key_type == 'ssh-rsa' then
|
elseif host_key_algo == "ssh-rsa" or host_key_algo:find("^rsa%-sha2%-%d+$") then
|
||||||
|
key_type = "ssh-rsa"
|
||||||
algorithm = "RSA"
|
algorithm = "RSA"
|
||||||
local _, _, n = string.unpack( ">s4s4s4", public_host_key )
|
local _, _, n = string.unpack( ">s4s4s4", public_host_key )
|
||||||
bits = openssl.bignum_bin2bn( n ):num_bits()
|
bits = openssl.bignum_bin2bn( n ):num_bits()
|
||||||
elseif key_type == 'ecdsa-sha2-nistp256' then
|
elseif host_key_algo:find("^ecdsa%-sha2%-nistp%d+$") then
|
||||||
|
key_type = host_key_algo
|
||||||
algorithm = "ECDSA"
|
algorithm = "ECDSA"
|
||||||
bits = "256"
|
bits = host_key_algo:match("%d+$")
|
||||||
elseif key_type == 'ecdsa-sha2-nistp384' then
|
elseif host_key_algo == "ssh-ed25519" then
|
||||||
algorithm = "ECDSA"
|
key_type = host_key_algo
|
||||||
bits = "384"
|
|
||||||
elseif key_type == 'ecdsa-sha2-nistp521' then
|
|
||||||
algorithm = "ECDSA"
|
|
||||||
bits = "521"
|
|
||||||
elseif key_type == 'ssh-ed25519' then
|
|
||||||
algorithm = "ED25519"
|
algorithm = "ED25519"
|
||||||
bits = "256"
|
bits = "256"
|
||||||
|
elseif host_key_algo == "ssh-mldsa44-ed25519" then
|
||||||
|
key_type = host_key_algo
|
||||||
|
algorithm = "MLDSA44-ED25519"
|
||||||
|
bits = "512"
|
||||||
else
|
else
|
||||||
stdnse.debug1("Unsupported key type: %s", key_type )
|
stdnse.debug1("Unsupported host key algorithm: %s", host_key_algo)
|
||||||
end
|
end
|
||||||
|
|
||||||
socket:close()
|
return { key=base64.enc(public_host_key),
|
||||||
return { key=base64.enc(public_host_key), key_type=key_type, fp_input=public_host_key, bits=bits,
|
key_type=key_type,
|
||||||
|
fp_input=public_host_key,
|
||||||
|
bits=bits,
|
||||||
full_key=('%s %s'):format(key_type,base64.enc(public_host_key)),
|
full_key=('%s %s'):format(key_type,base64.enc(public_host_key)),
|
||||||
algorithm=algorithm, fingerprint=openssl.md5(public_host_key),
|
algorithm=algorithm,
|
||||||
fp_sha256=openssl.digest("sha256",public_host_key)}
|
fingerprint=openssl.md5(public_host_key),
|
||||||
|
fp_sha256=openssl.digest("sha256", public_host_key)}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- constants
|
-- constants
|
||||||
|
|
|
||||||
|
|
@ -205,15 +205,20 @@ ELLIPTIC_CURVES = {
|
||||||
arbitrary_explicit_char2_curves = 0xFF02,
|
arbitrary_explicit_char2_curves = 0xFF02,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Most likely set, supported by Firefox and Chrome
|
-- Most likely elliptic curves, supported by Firefox and Chrome, sent by tls.client_hello for TLSv1.2 or earlier
|
||||||
DEFAULT_ELLIPTIC_CURVES = {
|
DEFAULT_TLS12_ELLIPTIC_CURVES = {
|
||||||
"secp256r1",
|
"secp256r1",
|
||||||
"secp384r1",
|
"secp384r1",
|
||||||
"secp521r1",
|
"secp521r1",
|
||||||
"ecdh_x25519",
|
"ecdh_x25519",
|
||||||
"ffdhe2048", -- added for TLSv1.3
|
|
||||||
"X25519MLKEM768", -- Chrome offers this one
|
|
||||||
}
|
}
|
||||||
|
-- Same (now called supported groups), but for TLSv1.3
|
||||||
|
DEFAULT_ELLIPTIC_CURVES = {table.unpack(DEFAULT_TLS12_ELLIPTIC_CURVES)}
|
||||||
|
for _, name in ipairs({"ffdhe2048",
|
||||||
|
"X25519MLKEM768", -- Chrome offers this one
|
||||||
|
}) do
|
||||||
|
table.insert(DEFAULT_ELLIPTIC_CURVES, name)
|
||||||
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- RFC 4492 section 5.1.2 "Supported Point Formats Extension".
|
-- RFC 4492 section 5.1.2 "Supported Point Formats Extension".
|
||||||
|
|
@ -1949,7 +1954,12 @@ function client_hello(t)
|
||||||
insert(extensions, pack(">s2", "\0\0"))
|
insert(extensions, pack(">s2", "\0\0"))
|
||||||
end
|
end
|
||||||
if need_elliptic_curves then
|
if need_elliptic_curves then
|
||||||
local curves = {table.unpack(DEFAULT_ELLIPTIC_CURVES)}
|
-- TODO: Determine desire to comply with RFC 4492, section 4:
|
||||||
|
-- "The client MUST NOT include these extensions in the ClientHello
|
||||||
|
-- message if it does not propose any ECC cipher suites."
|
||||||
|
-- OTOH, OpenSSL 1.1.1 sends them always so it is probably safe.
|
||||||
|
local curves = proto_ver < PROTOCOLS["TLSv1.3"] and DEFAULT_TLS12_ELLIPTIC_CURVES -- non-TLSv1.3
|
||||||
|
or DEFAULT_ELLIPTIC_CURVES
|
||||||
if shangmi then
|
if shangmi then
|
||||||
curves[#curves+1] = "curveSM2"
|
curves[#curves+1] = "curveSM2"
|
||||||
end
|
end
|
||||||
|
|
@ -2070,4 +2080,8 @@ test_suite = unittest.TestSuite:new()
|
||||||
for name, code in pairs(CIPHERS) do
|
for name, code in pairs(CIPHERS) do
|
||||||
test_suite:add_test(unittest.not_nil(cipher_info(name).kex), name .. ".kex")
|
test_suite:add_test(unittest.not_nil(cipher_info(name).kex), name .. ".kex")
|
||||||
end
|
end
|
||||||
|
-- Make sure that all default elliptic curves are in fact defined
|
||||||
|
for _, name in ipairs(DEFAULT_ELLIPTIC_CURVES) do
|
||||||
|
test_suite:add_test(unittest.not_nil(ELLIPTIC_CURVES[name]), name .. " default elliptic curve (supported group)")
|
||||||
|
end
|
||||||
return _ENV;
|
return _ENV;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ is 0. The payload is consisted of random bytes.
|
||||||
-- --script broadcast-ping [--script-args [broadcast-ping.timeout=<ms>],[num-probes=<n>]]
|
-- --script broadcast-ping [--script-args [broadcast-ping.timeout=<ms>],[num-probes=<n>]]
|
||||||
--
|
--
|
||||||
-- @args broadcast-ping.interface string specifying which interface to use for this script (default all interfaces)
|
-- @args broadcast-ping.interface string specifying which interface to use for this script (default all interfaces)
|
||||||
-- @args broadcast-ping.num_probes number specifying how many ICMP probes should be sent (default 1)
|
-- @args broadcast-ping.num-probes number specifying how many ICMP probes should be sent (default 1)
|
||||||
-- @args broadcast-ping.timeout timespec specifying how long to wait for response (default 3s)
|
-- @args broadcast-ping.timeout timespec specifying how long to wait for response (default 3s)
|
||||||
--
|
--
|
||||||
-- @output
|
-- @output
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,11 @@ Requires the dicom.lua library (place in nselib/ or same directory).
|
||||||
-- class rejected (default: true)
|
-- class rejected (default: true)
|
||||||
-- @args dicom-store-fuzzer.baseline Send baseline before fuzzing to verify
|
-- @args dicom-store-fuzzer.baseline Send baseline before fuzzing to verify
|
||||||
-- C-STORE works (default: true)
|
-- C-STORE works (default: true)
|
||||||
|
-- @args dicom-store-fuzzer.payload What bytes to send as the C-STORE
|
||||||
|
-- dataset: "file" (default, the whole .dcm verbatim -- preamble + File Meta +
|
||||||
|
-- dataset, so structure/meta/dataset mutations all reach the target), "raw"
|
||||||
|
-- (everything after the 128-byte preamble + "DICM"), or "dataset" (only the
|
||||||
|
-- parsed main dataset, a DICOM-conformant C-STORE)
|
||||||
-- @args dicom-store-fuzzer.max_pdu Max PDU Length to propose in bytes
|
-- @args dicom-store-fuzzer.max_pdu Max PDU Length to propose in bytes
|
||||||
-- (default: 16384)
|
-- (default: 16384)
|
||||||
-- @args dicom-store-fuzzer.resume Resume from this case ID after a
|
-- @args dicom-store-fuzzer.resume Resume from this case ID after a
|
||||||
|
|
@ -436,6 +441,17 @@ action = function(host, port)
|
||||||
local results_file = arg("dicom-store-fuzzer.results_file")
|
local results_file = arg("dicom-store-fuzzer.results_file")
|
||||||
or string.format("/tmp/dicom-store-fuzzer-%s.json",
|
or string.format("/tmp/dicom-store-fuzzer-%s.json",
|
||||||
host.ip or "unknown")
|
host.ip or "unknown")
|
||||||
|
-- Payload fidelity: what bytes to transmit as the C-STORE dataset.
|
||||||
|
-- "file" (default) the whole .dcm verbatim (preamble + meta + dataset)
|
||||||
|
-- "raw" everything after the 128-byte preamble + "DICM" (meta+dataset)
|
||||||
|
-- "dataset" only the parsed main dataset (DICOM-conformant C-STORE)
|
||||||
|
-- "file"/"raw" ensure structure- and meta-level mutations actually reach the
|
||||||
|
-- target; "dataset" is the conformant mode for pure dataset-level testing.
|
||||||
|
local payload_mode = (arg("dicom-store-fuzzer.payload") or "file"):lower()
|
||||||
|
if payload_mode ~= "file" and payload_mode ~= "raw"
|
||||||
|
and payload_mode ~= "dataset" then
|
||||||
|
payload_mode = "file"
|
||||||
|
end
|
||||||
|
|
||||||
local verbose = (output_lvl == "verbose" or output_lvl == "debug")
|
local verbose = (output_lvl == "verbose" or output_lvl == "debug")
|
||||||
local dbg = (output_lvl == "debug")
|
local dbg = (output_lvl == "debug")
|
||||||
|
|
@ -613,10 +629,18 @@ action = function(host, port)
|
||||||
|
|
||||||
stdnse.debug2("Case %s: %s", tc.id, tc.description)
|
stdnse.debug2("Case %s: %s", tc.id, tc.description)
|
||||||
|
|
||||||
-- Read DCM file
|
-- Read DCM file. In "file"/"raw" mode send the bytes verbatim so every
|
||||||
|
-- mutation (structure, File Meta and dataset) reaches the target; in
|
||||||
|
-- "dataset" mode send only the parsed main dataset (conformant C-STORE).
|
||||||
local filepath = corpus_path:gsub("[/\\]+$", "") .. "/" .. tc.filename
|
local filepath = corpus_path:gsub("[/\\]+$", "") .. "/" .. tc.filename
|
||||||
local dataset_bytes, sop_class, sop_instance,
|
local dataset_bytes, sop_class, sop_instance, file_ts_uid, meta_note
|
||||||
file_ts_uid = dicom.read_dcm_dataset(filepath)
|
if payload_mode == "dataset" then
|
||||||
|
dataset_bytes, sop_class, sop_instance, file_ts_uid, meta_note =
|
||||||
|
dicom.read_dcm_dataset(filepath)
|
||||||
|
else
|
||||||
|
dataset_bytes, sop_class, sop_instance, file_ts_uid, meta_note =
|
||||||
|
dicom.read_dcm_raw(filepath, payload_mode == "raw")
|
||||||
|
end
|
||||||
|
|
||||||
if not dataset_bytes then
|
if not dataset_bytes then
|
||||||
record(res, "FAILURE", tc)
|
record(res, "FAILURE", tc)
|
||||||
|
|
@ -627,10 +651,26 @@ action = function(host, port)
|
||||||
goto next_case
|
goto next_case
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- If the File Meta could not be parsed (corrupt VR, overrun), the SOP
|
||||||
|
-- Class/Instance come back empty. Synthesize valid command UIDs so the
|
||||||
|
-- DATASET corruption is what gets exercised, and remember that we did so:
|
||||||
|
-- a resulting hang must be attributed to the dataset (or flagged as an
|
||||||
|
-- unparseable-meta artifact), NOT mistaken for the deliberate empty-UID
|
||||||
|
-- C-STORE primitive (which the empty-command-set cases test on purpose).
|
||||||
|
local synth_uids = false
|
||||||
|
if not (sop_class and #sop_class > 0) then synth_uids = true end
|
||||||
|
if not (sop_instance and #sop_instance > 0) then synth_uids = true end
|
||||||
sop_class = (sop_class and #sop_class > 0) and sop_class
|
sop_class = (sop_class and #sop_class > 0) and sop_class
|
||||||
or dicom.SOP_CLASS.CT_IMAGE_STORAGE
|
or dicom.SOP_CLASS.CT_IMAGE_STORAGE
|
||||||
sop_instance = (sop_instance and #sop_instance > 0) and sop_instance
|
sop_instance = (sop_instance and #sop_instance > 0) and sop_instance
|
||||||
or dicom.generate_fake_uid()
|
or dicom.generate_fake_uid()
|
||||||
|
local synth_tag = ""
|
||||||
|
if synth_uids then
|
||||||
|
synth_tag = meta_note
|
||||||
|
and " [synthesized UIDs: File Meta unparseable]"
|
||||||
|
or " [synthesized UIDs: no SOP Class/Instance in File Meta]"
|
||||||
|
if meta_note then stdnse.debug1("%s: %s", tc.id, meta_note) end
|
||||||
|
end
|
||||||
|
|
||||||
-- Open/reuse association (propose file's native transfer syntax)
|
-- Open/reuse association (propose file's native transfer syntax)
|
||||||
if not sock_open or cases_in_batch >= batch_size then
|
if not sock_open or cases_in_batch >= batch_size then
|
||||||
|
|
@ -722,7 +762,7 @@ action = function(host, port)
|
||||||
id=tc.id, file=tc.filename,
|
id=tc.id, file=tc.filename,
|
||||||
result=result .. (error_comment ~= "" and (":" .. error_comment)
|
result=result .. (error_comment ~= "" and (":" .. error_comment)
|
||||||
or ""),
|
or ""),
|
||||||
desc=tc.description, elapsed=elapsed}
|
desc=tc.description .. synth_tag, elapsed=elapsed}
|
||||||
if is_critical(result) then
|
if is_critical(result) then
|
||||||
res.crashes[#res.crashes + 1] = entry
|
res.crashes[#res.crashes + 1] = entry
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,11 @@ http library.
|
||||||
--
|
--
|
||||||
-- @xmloutput
|
-- @xmloutput
|
||||||
-- <elem key="title">Go ahead and ScanMe!</elem>
|
-- <elem key="title">Go ahead and ScanMe!</elem>
|
||||||
|
-- <elem key="status">200</elem>
|
||||||
-- @xmloutput
|
-- @xmloutput
|
||||||
-- <elem key="title">Wikipedia, the free encyclopedia</elem>
|
-- <elem key="title">Wikipedia, the free encyclopedia</elem>
|
||||||
-- <elem key="redirect_url">http://en.wikipedia.org/wiki/Main_Page</elem>
|
-- <elem key="redirect_url">http://en.wikipedia.org/wiki/Main_Page</elem>
|
||||||
|
-- <elem key="status">301</elem>
|
||||||
|
|
||||||
author = "Diman Todorov"
|
author = "Diman Todorov"
|
||||||
|
|
||||||
|
|
@ -41,8 +43,9 @@ action = function(host, port)
|
||||||
-- check for a redirect
|
-- check for a redirect
|
||||||
if resp.location then
|
if resp.location then
|
||||||
redirect_url = resp.location[#resp.location]
|
redirect_url = resp.location[#resp.location]
|
||||||
if resp.status and tostring( resp.status ):match( "30%d" ) then
|
local status = resp.status
|
||||||
return {redirect_url = redirect_url}, ("Did not follow redirect to %s"):format( redirect_url )
|
if redirect_url and status and status >= 300 and status < 400 then
|
||||||
|
return {redirect_url = redirect_url, status = status}, ("Did not follow redirect to %s"):format( redirect_url )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -56,7 +59,7 @@ action = function(host, port)
|
||||||
local display_title = title
|
local display_title = title
|
||||||
|
|
||||||
if display_title and display_title ~= "" then
|
if display_title and display_title ~= "" then
|
||||||
display_title = string.gsub(display_title , "[\n\r\t]", "")
|
display_title = string.gsub(display_title, "%s+", " ")
|
||||||
if #display_title > 65 then
|
if #display_title > 65 then
|
||||||
display_title = string.sub(display_title, 1, 62) .. "..."
|
display_title = string.sub(display_title, 1, 62) .. "..."
|
||||||
end
|
end
|
||||||
|
|
@ -72,6 +75,7 @@ action = function(host, port)
|
||||||
local output_tab = stdnse.output_table()
|
local output_tab = stdnse.output_table()
|
||||||
output_tab.title = title
|
output_tab.title = title
|
||||||
output_tab.redirect_url = redirect_url
|
output_tab.redirect_url = redirect_url
|
||||||
|
output_tab.status = resp.status
|
||||||
|
|
||||||
local output_str = display_title
|
local output_str = display_title
|
||||||
if redirect_url then
|
if redirect_url then
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ For additional information:
|
||||||
-- | READ_ONLY
|
-- | READ_ONLY
|
||||||
-- |_ ROTATIONAL
|
-- |_ ROTATIONAL
|
||||||
--
|
--
|
||||||
-- @args nbd-info.export_names Either a single name, or a table of
|
-- @args nbd-info.export-names Either a single name, or a table of
|
||||||
-- names to about which to request information from the server.
|
-- names to about which to request information from the server.
|
||||||
|
|
||||||
author = "Mak Kolybabi <mak@kolybabi.com>"
|
author = "Mak Kolybabi <mak@kolybabi.com>"
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,8 @@ end
|
||||||
|
|
||||||
local function ssh_get_modulus(host, port)
|
local function ssh_get_modulus(host, port)
|
||||||
local key = ssh2.fetch_host_key( host, port, "ssh-rsa" )
|
local key = ssh2.fetch_host_key( host, port, "ssh-rsa" )
|
||||||
|
or ssh2.fetch_host_key( host, port, "rsa-sha2-256" )
|
||||||
|
or ssh2.fetch_host_key( host, port, "rsa-sha2-512" )
|
||||||
if not key then
|
if not key then
|
||||||
stdnse.debug1("No RSA hostkey, not vulnerable to ROCA")
|
stdnse.debug1("No RSA hostkey, not vulnerable to ROCA")
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ end
|
||||||
--- and if there is, compare the keys
|
--- and if there is, compare the keys
|
||||||
local function check_keys(host, keys, f)
|
local function check_keys(host, keys, f)
|
||||||
local keys_found = {}
|
local keys_found = {}
|
||||||
for _,k in ipairs(keys) do
|
for _,k in pairs(keys) do
|
||||||
table.insert(keys_found, k.full_key)
|
table.insert(keys_found, k.full_key)
|
||||||
end
|
end
|
||||||
local keys_from_file = {}
|
local keys_from_file = {}
|
||||||
|
|
@ -265,6 +265,29 @@ local function check_keys(host, keys, f)
|
||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local HOST_KEY_ALGOS = {"ssh-dss", "ssh-rsa", "rsa-sha2-256", "rsa-sha2-512",
|
||||||
|
"ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521",
|
||||||
|
"ssh-ed25519", "ssh-mldsa44-ed25519"}
|
||||||
|
|
||||||
|
local function fetch_host_keys (host, port, algos)
|
||||||
|
algos = algos or HOST_KEY_ALGOS
|
||||||
|
local keys = stdnse.output_table()
|
||||||
|
|
||||||
|
local ssh1key = ssh1.fetch_host_key(host, port)
|
||||||
|
if ssh1key then
|
||||||
|
keys[ssh1key.fingerprint] = ssh1key
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, algo in ipairs(algos) do
|
||||||
|
local key = ssh2.fetch_host_key(host, port, algo)
|
||||||
|
if key and not keys[key.fingerprint] then
|
||||||
|
keys[key.fingerprint] = key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return keys
|
||||||
|
end
|
||||||
|
|
||||||
--- gather host keys
|
--- gather host keys
|
||||||
--@param host nmap host table
|
--@param host nmap host table
|
||||||
--@param port nmap port table of the currently probed port
|
--@param port nmap port table of the currently probed port
|
||||||
|
|
@ -283,8 +306,6 @@ local function portaction(host, port)
|
||||||
sock:close()
|
sock:close()
|
||||||
end
|
end
|
||||||
local output_tab = {}
|
local output_tab = {}
|
||||||
local keys = {}
|
|
||||||
local key
|
|
||||||
local format = nmap.registry.args.ssh_hostkey or "md5"
|
local format = nmap.registry.args.ssh_hostkey or "md5"
|
||||||
local format_bits = {
|
local format_bits = {
|
||||||
md5 = 1,
|
md5 = 1,
|
||||||
|
|
@ -300,32 +321,12 @@ local function portaction(host, port)
|
||||||
format_mask = format_mask | (format_bits[word] or 0)
|
format_mask = format_mask | (format_bits[word] or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
key = ssh1.fetch_host_key( host, port )
|
local keys = fetch_host_keys(host, port)
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
key = ssh2.fetch_host_key( host, port, "ssh-dss" )
|
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
key = ssh2.fetch_host_key( host, port, "ssh-rsa" )
|
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
key = ssh2.fetch_host_key( host, port, "ecdsa-sha2-nistp256" )
|
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
key = ssh2.fetch_host_key( host, port, "ecdsa-sha2-nistp384" )
|
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
key = ssh2.fetch_host_key( host, port, "ecdsa-sha2-nistp521" )
|
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
key = ssh2.fetch_host_key( host, port, "ssh-ed25519" )
|
|
||||||
if key then table.insert( keys, key ) end
|
|
||||||
|
|
||||||
if #keys == 0 then
|
if #keys == 0 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, key in ipairs( keys ) do
|
for _, key in pairs( keys ) do
|
||||||
add_key_to_registry( host, key )
|
add_key_to_registry( host, key )
|
||||||
local output = {}
|
local output = {}
|
||||||
local out = {
|
local out = {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ local string = require "string"
|
||||||
local stringaux = require "stringaux"
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
local openssl = stdnse.silent_require "openssl"
|
|
||||||
local ssh2 = stdnse.silent_require "ssh2"
|
local ssh2 = stdnse.silent_require "ssh2"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
|
|
@ -105,6 +104,59 @@ categories = {"safe", "discovery"}
|
||||||
|
|
||||||
portrule = shortport.ssh
|
portrule = shortport.ssh
|
||||||
|
|
||||||
|
-- Offer as many options as possible. Some servers require a common KEX
|
||||||
|
-- and host key algorithm before sending their proposal.
|
||||||
|
local KEX_OPTIONS = {
|
||||||
|
kex_algorithms = "\z
|
||||||
|
mlkem768x25519-sha256,\z
|
||||||
|
sntrup761x25519-sha512,\z
|
||||||
|
sntrup761x25519-sha512@openssh.com,\z
|
||||||
|
curve25519-sha256,\z
|
||||||
|
curve25519-sha256@libssh.org,\z
|
||||||
|
ecdh-sha2-nistp521,\z
|
||||||
|
ecdh-sha2-nistp384,\z
|
||||||
|
ecdh-sha2-nistp256,\z
|
||||||
|
diffie-hellman-group18-sha512,\z
|
||||||
|
diffie-hellman-group16-sha512,\z
|
||||||
|
diffie-hellman-group15-sha512,\z
|
||||||
|
diffie-hellman-group14-sha256,\z
|
||||||
|
diffie-hellman-group14-sha1,\z
|
||||||
|
diffie-hellman-group-exchange-sha256,\z
|
||||||
|
diffie-hellman-group-exchange-sha1,\z
|
||||||
|
diffie-hellman-group1-sha1",
|
||||||
|
host_key_algorithms = "\z
|
||||||
|
ssh-mldsa44-ed25519,\z
|
||||||
|
ssh-ed25519,\z
|
||||||
|
ecdsa-sha2-nistp521,\z
|
||||||
|
ecdsa-sha2-nistp384,\z
|
||||||
|
ecdsa-sha2-nistp256,\z
|
||||||
|
rsa-sha2-512,\z
|
||||||
|
rsa-sha2-256,\z
|
||||||
|
ssh-rsa,\z
|
||||||
|
ssh-dss",
|
||||||
|
encryption_algorithms = "\z
|
||||||
|
chacha20-poly1305@openssh.com,\z
|
||||||
|
aes256-gcm@openssh.com,\z
|
||||||
|
aes128-gcm@openssh.com,\z
|
||||||
|
aes256-ctr,\z
|
||||||
|
aes192-ctr,\z
|
||||||
|
aes128-ctr,\z
|
||||||
|
aes256-cbc,\z
|
||||||
|
aes192-cbc,\z
|
||||||
|
aes128-cbc,\z
|
||||||
|
3des-cbc,\z
|
||||||
|
blowfish-cbc",
|
||||||
|
mac_algorithms = "\z
|
||||||
|
hmac-sha2-512-etm@openssh.com,\z
|
||||||
|
hmac-sha2-256-etm@openssh.com,\z
|
||||||
|
hmac-sha2-512,\z
|
||||||
|
hmac-sha2-256,\z
|
||||||
|
hmac-sha1-etm@openssh.com,\z
|
||||||
|
hmac-sha1,\z
|
||||||
|
hmac-md5,\z
|
||||||
|
hmac-ripemd160",
|
||||||
|
}
|
||||||
|
|
||||||
-- Build onto lists{} and possibly modify parsed{} based on whether the
|
-- Build onto lists{} and possibly modify parsed{} based on whether the
|
||||||
-- algorithm name-lists are identical between the server-to-client and
|
-- algorithm name-lists are identical between the server-to-client and
|
||||||
-- client-to-server types. Note that this simply modifies the passed tables.
|
-- client-to-server types. Note that this simply modifies the passed tables.
|
||||||
|
|
@ -115,15 +167,15 @@ local combine_types = function(parsed, lists)
|
||||||
"compression_algorithms"
|
"compression_algorithms"
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, i in ipairs(doubles) do
|
for _, list in ipairs(doubles) do
|
||||||
local c2s = i .. "_client_to_server"
|
local c2s = list .. "_client_to_server"
|
||||||
local s2c = i .. "_server_to_client"
|
local s2c = list .. "_server_to_client"
|
||||||
|
|
||||||
if parsed[c2s] == parsed[s2c] then
|
if parsed[c2s] == parsed[s2c] then
|
||||||
parsed[i] = parsed[c2s]
|
parsed[list] = parsed[c2s]
|
||||||
parsed[c2s] = nil
|
parsed[c2s] = nil
|
||||||
parsed[s2c] = nil
|
parsed[s2c] = nil
|
||||||
table.insert(lists, i)
|
table.insert(lists, list)
|
||||||
else
|
else
|
||||||
table.insert(lists, c2s)
|
table.insert(lists, c2s)
|
||||||
table.insert(lists, s2c)
|
table.insert(lists, s2c)
|
||||||
|
|
@ -135,9 +187,9 @@ end
|
||||||
local output = function(parsed, lists)
|
local output = function(parsed, lists)
|
||||||
local out = stdnse.output_table()
|
local out = stdnse.output_table()
|
||||||
|
|
||||||
for _, l in ipairs(lists) do
|
for _, list in ipairs(lists) do
|
||||||
local v = parsed[l]
|
local v = parsed[list]
|
||||||
local a = v:len() > 0 and stringaux.strsplit(",", v) or {}
|
local a = v and #v > 0 and stringaux.strsplit(",", v) or {}
|
||||||
if nmap.verbosity() > 0 then
|
if nmap.verbosity() > 0 then
|
||||||
setmetatable(a, {
|
setmetatable(a, {
|
||||||
__tostring = function(t)
|
__tostring = function(t)
|
||||||
|
|
@ -151,7 +203,7 @@ local output = function(parsed, lists)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
out[l] = a
|
out[list] = a
|
||||||
end
|
end
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
@ -183,7 +235,7 @@ action = function(host, port)
|
||||||
|
|
||||||
-- send the client key exchange
|
-- send the client key exchange
|
||||||
-- NB: The protocol does not prescribe which side sends the kex init first
|
-- NB: The protocol does not prescribe which side sends the kex init first
|
||||||
status = sock:send(ssh.build(ssh.kex_init()))
|
status = sock:send(ssh.build(ssh.kex_init(KEX_OPTIONS)))
|
||||||
if not status then
|
if not status then
|
||||||
sock:close()
|
sock:close()
|
||||||
return
|
return
|
||||||
|
|
@ -197,6 +249,10 @@ action = function(host, port)
|
||||||
end
|
end
|
||||||
|
|
||||||
local parsed = ssh.parse_kex_init(ssh.payload(response))
|
local parsed = ssh.parse_kex_init(ssh.payload(response))
|
||||||
|
if not (parsed and next(parsed)) then
|
||||||
|
stdnse.debug1("Failed to parse server Key Exchange Init")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local lists = {
|
local lists = {
|
||||||
"kex_algorithms",
|
"kex_algorithms",
|
||||||
|
|
|
||||||
|
|
@ -518,14 +518,6 @@ end
|
||||||
local function base_extensions(host)
|
local function base_extensions(host)
|
||||||
local tlsname = tls.servername(host)
|
local tlsname = tls.servername(host)
|
||||||
return {
|
return {
|
||||||
-- Claim to support common elliptic curves
|
|
||||||
-- TODO: Determine desire to comply with RFC 4492, section 4:
|
|
||||||
-- "The client MUST NOT include these extensions in the ClientHello
|
|
||||||
-- message if it does not propose any ECC cipher suites."
|
|
||||||
-- OTOH, OpenSSL 1.1.1 sends them always so it is probably safe.
|
|
||||||
["elliptic_curves"] = tls.EXTENSION_HELPERS["elliptic_curves"](tls.DEFAULT_ELLIPTIC_CURVES),
|
|
||||||
-- Some servers require Supported Point Formats Extension
|
|
||||||
["ec_point_formats"] = tls.EXTENSION_HELPERS["ec_point_formats"]({"uncompressed"}),
|
|
||||||
-- Enable SNI if a server name is available
|
-- Enable SNI if a server name is available
|
||||||
["server_name"] = tlsname and tls.EXTENSION_HELPERS["server_name"](tlsname),
|
["server_name"] = tlsname and tls.EXTENSION_HELPERS["server_name"](tlsname),
|
||||||
}
|
}
|
||||||
|
|
@ -606,6 +598,17 @@ local function get_hello_table(host, protocol)
|
||||||
t.extensions.supported_versions = tls13supported
|
t.extensions.supported_versions = tls13supported
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Claim to support common elliptic curves
|
||||||
|
-- TODO: Determine desire to comply with RFC 4492, section 4:
|
||||||
|
-- "The client MUST NOT include these extensions in the ClientHello
|
||||||
|
-- message if it does not propose any ECC cipher suites."
|
||||||
|
-- OTOH, OpenSSL 1.1.1 sends them always so it is probably safe.
|
||||||
|
local curves = tls.PROTOCOLS[protocol] < tls13proto and tls.DEFAULT_TLS12_ELLIPTIC_CURVES -- non-TLSv1.3
|
||||||
|
or tls.DEFAULT_ELLIPTIC_CURVES
|
||||||
|
t.extensions.elliptic_curves = tls.EXTENSION_HELPERS["elliptic_curves"](curves)
|
||||||
|
-- Some servers require Supported Point Formats Extension
|
||||||
|
t.extensions.ec_point_formats = tls.EXTENSION_HELPERS["ec_point_formats"]({"uncompressed"})
|
||||||
|
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
17
zenmap/test/xml_test_osclasses.xml
Normal file
17
zenmap/test/xml_test_osclasses.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<nmaprun scanner="nmap" version="7.992+SVN" start="1000000000" args="synthetic saved XML fixture" xmloutputversion="1.05">
|
||||||
|
<scaninfo type="syn" protocol="tcp" numservices="1" services="80"/>
|
||||||
|
<verbose level="0"/>
|
||||||
|
<debugging level="0"/>
|
||||||
|
<host>
|
||||||
|
<status state="up" reason="user-set" reason_ttl="0"/>
|
||||||
|
<address addr="192.0.2.1" addrtype="ipv4"/>
|
||||||
|
<os>
|
||||||
|
<osmatch name="OS-first" accuracy="100" line="1">
|
||||||
|
<osclass type="general purpose" vendor="Vendor-A" osfamily="Family-A" osgen="A" accuracy="100"/>
|
||||||
|
<osclass type="general purpose" vendor="Vendor-B" osfamily="Family-B" osgen="B" accuracy="100"/>
|
||||||
|
</osmatch>
|
||||||
|
</os>
|
||||||
|
</host>
|
||||||
|
<runstats><finished time="1000000001" elapsed="1" exit="success"/><hosts up="1" down="0" total="1"/></runstats>
|
||||||
|
</nmaprun>
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -60,6 +60,8 @@ import locale
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
import copy
|
import copy
|
||||||
|
import unittest
|
||||||
|
import os
|
||||||
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
|
@ -72,6 +74,7 @@ from xml.sax import SAXException
|
||||||
from xml.sax.handler import ContentHandler, EntityResolver
|
from xml.sax.handler import ContentHandler, EntityResolver
|
||||||
from xml.sax.saxutils import XMLGenerator
|
from xml.sax.saxutils import XMLGenerator
|
||||||
from xml.sax.xmlreader import AttributesImpl as Attributes
|
from xml.sax.xmlreader import AttributesImpl as Attributes
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||||
from zenmapCore.NmapOptions import NmapOptions, join_quoted
|
from zenmapCore.NmapOptions import NmapOptions, join_quoted
|
||||||
|
|
@ -940,12 +943,12 @@ class NmapParserSAX(ParserBasics, ContentHandler):
|
||||||
self.in_os = True
|
self.in_os = True
|
||||||
self.list_portused = []
|
self.list_portused = []
|
||||||
self.list_osmatch = []
|
self.list_osmatch = []
|
||||||
|
self.list_osclass = []
|
||||||
elif self.in_host and self.in_os and name == "osmatch":
|
elif self.in_host and self.in_os and name == "osmatch":
|
||||||
self._parse_host_osmatch(attrs)
|
self._parse_host_osmatch(attrs)
|
||||||
elif self.in_host and self.in_os and name == "portused":
|
elif self.in_host and self.in_os and name == "portused":
|
||||||
self._parse_host_portused(attrs)
|
self._parse_host_portused(attrs)
|
||||||
elif self.in_host and self.in_os and name == "osclass":
|
elif self.in_host and self.in_os and name == "osclass":
|
||||||
self.list_osclass = []
|
|
||||||
self._parse_host_osclass(attrs)
|
self._parse_host_osclass(attrs)
|
||||||
elif self.in_host and name == "uptime":
|
elif self.in_host and name == "uptime":
|
||||||
self._parse_host_uptime(attrs)
|
self._parse_host_uptime(attrs)
|
||||||
|
|
@ -1315,6 +1318,152 @@ def nmap_parser_sax():
|
||||||
NmapParser = nmap_parser_sax
|
NmapParser = nmap_parser_sax
|
||||||
|
|
||||||
|
|
||||||
|
class NmapParserTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.xml = self.read_fixture("xml_test_osclasses.xml")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_fixture(name):
|
||||||
|
filename = os.path.join(
|
||||||
|
os.path.dirname(__file__), os.pardir, "test", name)
|
||||||
|
with open(filename, "r", encoding="utf-8") as source:
|
||||||
|
return source.read()
|
||||||
|
|
||||||
|
def set_matches(self, groups):
|
||||||
|
root = ET.fromstring(self.xml)
|
||||||
|
os_element = root.find("./host/os")
|
||||||
|
template = os_element.find("./osmatch/osclass")
|
||||||
|
for match in list(os_element):
|
||||||
|
os_element.remove(match)
|
||||||
|
for index, group in enumerate(groups):
|
||||||
|
match = ET.SubElement(
|
||||||
|
os_element, "osmatch",
|
||||||
|
name="OS-%d" % index, accuracy="100", line="1")
|
||||||
|
for label in group:
|
||||||
|
osclass = copy.deepcopy(template)
|
||||||
|
osclass.set("vendor", "Vendor-%s" % label)
|
||||||
|
osclass.set("osfamily", "Family-%s" % label)
|
||||||
|
osclass.set("osgen", label)
|
||||||
|
match.append(osclass)
|
||||||
|
self.xml = ET.tostring(root, encoding="unicode")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def xml_matches(xml):
|
||||||
|
matches = []
|
||||||
|
for element in ET.fromstring(xml).findall("./host/os/osmatch"):
|
||||||
|
match = dict(element.attrib)
|
||||||
|
match["osclasses"] = [
|
||||||
|
dict(osclass.attrib)
|
||||||
|
for osclass in element.findall("osclass")]
|
||||||
|
matches.append(match)
|
||||||
|
return matches
|
||||||
|
|
||||||
|
def assert_matches(self, matches, expected):
|
||||||
|
self.assertEqual(matches, expected)
|
||||||
|
# Each match owns its list, including empty matches.
|
||||||
|
for index, match in enumerate(matches):
|
||||||
|
for other in matches[index + 1:]:
|
||||||
|
self.assertIsNot(match["osclasses"], other["osclasses"])
|
||||||
|
|
||||||
|
def check_roundtrip(self):
|
||||||
|
expected = self.xml_matches(self.xml)
|
||||||
|
scan = NmapParser()
|
||||||
|
scan.parse(StringIO(self.xml))
|
||||||
|
self.assert_matches(scan.hosts[0].osmatches, expected)
|
||||||
|
|
||||||
|
saved = StringIO()
|
||||||
|
scan.write_xml(saved)
|
||||||
|
self.assertEqual(self.xml_matches(saved.getvalue()), expected)
|
||||||
|
|
||||||
|
reparsed = NmapParser()
|
||||||
|
reparsed.parse(StringIO(saved.getvalue()))
|
||||||
|
self.assert_matches(reparsed.hosts[0].osmatches, expected)
|
||||||
|
|
||||||
|
def test_single_class(self):
|
||||||
|
self.set_matches([["A"]])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_multiple_classes(self):
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_consecutive_matches(self):
|
||||||
|
self.set_matches([["A"], ["B"]])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_consecutive_multiple_classes(self):
|
||||||
|
self.set_matches([["A", "B"], ["C", "D"]])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_empty_match(self):
|
||||||
|
self.set_matches([[]])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_empty_then_populated_match(self):
|
||||||
|
self.set_matches([[], ["A"]])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_populated_empty_populated_matches(self):
|
||||||
|
self.set_matches([["A"], [], ["B"]])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_no_matches(self):
|
||||||
|
self.set_matches([])
|
||||||
|
self.check_roundtrip()
|
||||||
|
|
||||||
|
def test_legacy_direct_classes(self):
|
||||||
|
scan = NmapParser()
|
||||||
|
scan.parse(StringIO(self.read_fixture("xml_test11.xml")))
|
||||||
|
linux_classes = [
|
||||||
|
dict(type="general purpose", vendor="Linux",
|
||||||
|
osfamily="Linux", osgen=gen, accuracy="100")
|
||||||
|
for gen in ("2.4.X", "2.5.X", "2.6.X")]
|
||||||
|
linux_match = dict(
|
||||||
|
name="Linux 2.4.18 - 2.6.7", accuracy="100", line="",
|
||||||
|
osclasses=linux_classes)
|
||||||
|
expected = [
|
||||||
|
[linux_match],
|
||||||
|
[dict(name="Alcatel Speed Touch *DSL modem/router",
|
||||||
|
accuracy="100", line="", osclasses=[
|
||||||
|
dict(type="broadband router", vendor="Alcatel",
|
||||||
|
osfamily="embedded", osgen="",
|
||||||
|
accuracy="100")])],
|
||||||
|
[linux_match],
|
||||||
|
[dict(name="Linux 2.5.25 - 2.6.3 or Gentoo 1.2 "
|
||||||
|
"Linux 2.4.19 rc1-rc7)",
|
||||||
|
accuracy="100", line="", osclasses=linux_classes),
|
||||||
|
dict(name="Linux 2.6.3 - 2.6.8", accuracy="100", line="",
|
||||||
|
osclasses=[])]]
|
||||||
|
self.assertEqual([host.osmatches for host in scan.hosts], expected)
|
||||||
|
|
||||||
|
saved = StringIO()
|
||||||
|
scan.write_xml(saved)
|
||||||
|
# Legacy direct classes are serialized inside the first match.
|
||||||
|
root = ET.fromstring(saved.getvalue())
|
||||||
|
self.assertEqual(root.findall("./host/os/osclass"), [])
|
||||||
|
self.assertEqual(
|
||||||
|
self.xml_matches(saved.getvalue()),
|
||||||
|
[match for matches in expected for match in matches])
|
||||||
|
reparsed = NmapParser()
|
||||||
|
reparsed.parse(StringIO(saved.getvalue()))
|
||||||
|
self.assertEqual(
|
||||||
|
[host.osmatches for host in reparsed.hosts], expected)
|
||||||
|
|
||||||
|
def test_existing_xml_fixtures_roundtrip(self):
|
||||||
|
for number in range(1, 18):
|
||||||
|
name = "xml_test%d.xml" % number
|
||||||
|
with self.subTest(fixture=name):
|
||||||
|
scan = NmapParser()
|
||||||
|
scan.parse(StringIO(self.read_fixture(name)))
|
||||||
|
expected = copy.deepcopy(
|
||||||
|
[host.osmatches for host in scan.hosts])
|
||||||
|
saved = StringIO()
|
||||||
|
scan.write_xml(saved)
|
||||||
|
reparsed = NmapParser()
|
||||||
|
reparsed.parse(StringIO(saved.getvalue()))
|
||||||
|
self.assertEqual(
|
||||||
|
[host.osmatches for host in reparsed.hosts], expected)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
VERSION = "7.992"
|
VERSION = "7.993+SVN"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue