1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 22:21:29 +00:00
Commit Graph

187 Commits

Author SHA1 Message Date
david
523c4f7104 Remove -sR o.rpcscan handling; make -sR an alias for -sV. 2011-03-12 18:20:09 +00:00
fyodor
86e59a8c4e Update copyright statements from 2010 to 2011 2011-01-21 00:04:16 +00:00
fyodor
e9697cb936 Remove an excess space in output 2010-12-08 08:02:22 +00:00
david
1f333be278 Fix compilation with --without-liblua. This was reported by Nuno
Gonçalves and Henri Doreau.
2010-11-24 23:37:42 +00:00
david
cec33e3aad o The command line in XML output (/nmaprun/@args attribute) now does
quoting of whitespace using double quotes and backslashes. This
  allows recovering the original command line array even when
  arguments contain whitespace. [David]
2010-11-14 02:09:58 +00:00
david
69e1295384 Change the way ScriptResult::get_id and ScriptResult::get_output work to avoid
referencing deallocated memory.

The class was defined basically as follows:

class ScriptResult
{
private:
	std::string output;
public:
	std::string get_output() const
	{
		return this->output;
	}
};

The problem was when it was used like this, as in our script output
routines:

const char *s = sr.get_output().c_str();
printf("%s\n", s);

The reason is that the temporary std::string returned by get_output goes
out of scope after the line containing it, which invalidates the memory
pointed to by c_str(). By the time of the printf, s may be pointing to
deallocated memory.

This could have been fixed by returning a const reference that would
remain valid as long as the ScriptResult's output member is valid:

	const std::string& get_output() const
	{
		return this->output;
	}

However I noticed that get_output() was always immediately followed by a
c_str(), so I just had get_output return that instead, which has the
same period of validity.

This problem became visiable when compiling with Visual C++ 2010. The
first four bytes of script output in normal output would be garbage
(probably some kind of free list pointer). It didn't happen in XML
output, because the get_output-returned string happened to remain in
scope during that.
2010-11-09 19:47:18 +00:00
david
6f370e012d Whitespace. 2010-11-09 18:48:49 +00:00
david
d4e49f1075 Rearrange some headers to make sure that out nbase errno defines are seen early,
avoiding warning about symbol redefinitions. This is mostly moving "nmap.h" to
the top of the list.
2010-11-04 22:43:00 +00:00
david
7653cf7d4a Move COPYING.OpenSSL to OpenSSL.txt, update copyright notices to match. 2010-10-30 03:01:50 +00:00
david
f9c55c71b6 Fix an error I added in formatScriptOutput. It caused a segmentation
fault when a script produced an empty string as a result.
2010-10-16 02:21:44 +00:00
david
fe55182068 Remove the stripping of newlines from the beginning of script output. 2010-09-30 05:03:03 +00:00
david
9d57567b62 Format script output without using sctring replacement. This fixes the case when the last legitimate occurrence of "| " in the output would get replaced with "|_". 2010-09-29 23:14:12 +00:00
kris
57664a51cf Committing MTU-related changes:
* Adding path-mtu.nse for Path MTU Discovery
* Nmap now stores the MTU for interfaces (from SIOCGIFMTU or libdnet)
* Scripts can access the MTU for host.interface via host.interface_mtu
* Nmap prints the MTU for interfaces in --iflist
2010-08-24 01:47:12 +00:00
djalal
f0c5e154c3 Merge r18689:r19511 from /nmap-exp/djalal/nse-rules.
o Add two new Script scan phases:
  Script Pre-scanning phase: before any Nmap scan operation, activated by the new "prerule".
  Script Post-scanning phase: after all Nmap scan operations, activated by the new "postrule".
o New environment variables:
  SCRIPT_PATH
  SCRIPT_NAME
  SCRIPT_TYPE: the type of the rule that activated the script.
2010-08-06 16:40:03 +00:00
david
02e612c596 Make data_file_record::operator< const. The lack of this might have been
causing a compile error reported by Nuno Gonçalves:

error: passing 'const data_file_record' as 'this' argument of 'bool data_file_record::operator<(const data_file_record&)' discards qualifiers
make[4]: *** [output.o] Error 1
2010-08-04 21:05:02 +00:00
david
45468ba2a0 Fix compiler warnings seen on OpenBSD. 2010-08-02 20:30:29 +00:00
luis
da126c8b78 Merged nmap-dedup branch from nmap-exp/luis/nmap-dedup. This completes the Nmap/Nping code de-duplication phase. 2010-06-22 17:24:34 +00:00
david
57238b7df5 Print the addresses that were resolved but not scanned in each scan
report. It looks like this.

$ ./nmap google.com -sn

Starting Nmap 5.30BETA1 ( http://nmap.org ) at 2010-05-10 23:57 MDT
Nmap scan report for google.com (66.102.7.99)
Host is up (0.073s latency).
Other addresses for google.com (not scanned): 66.102.7.104
rDNS record for 66.102.7.99: lax04s01-in-f99.1e100.net

This replaces the line

Hostname google.com resolves to 2 IPs. Only scanned 66.102.7.99
2010-05-11 05:59:09 +00:00
fyodor
1aecac420f Update copyright year from 2009 to 2010 2010-05-03 21:20:25 +00:00
david
859ef5ecaf Merge r17202:17298 from /nmap-exp/david/nmap-xml. This brings in
structured XML output, automatic closing of XML elements on error, and
inclusion of error messages in XML output.
2010-04-14 01:05:51 +00:00
david
d375aa25e9 Print a "TRACEROUTE" header for directly connected hosts, even though it
lacks a probe specification like "(using proto 1/icmp)".
2010-03-23 23:38:34 +00:00
david
e976c2c3b9 Don't call htonl on a netmask before displaying it in --iflist; it's
already in network byte order. This bug made any mask that wasn't /32
appear as /0.
2010-03-11 17:46:27 +00:00
david
48654df805 Switch to -sn and -Pn as the new preferred synonyms for -sP and -P0.
This establishes a more regular syntax for some options that disable
phases of a scan:
	-n  no reverse DNS
	-Pn no host discovery
	-sn no port scan
Also, the -sP was possibly misleading because the 'P' suggests "ping
scan," when you can now do more than just pinging when you disable port
scanning. For example, -sC -sn and -sn -Pn --traceroute make sense.
2010-03-11 01:16:06 +00:00
david
7db7da0007 Merge again from /nmap-exp/david/nmap-mem; this fixes a couple of bugs. 2009-12-20 03:22:19 +00:00
david
1c6030709b Revert r16307:16309, the merge from nmap-mem. I just found a
segmentation fault which I am investigating.
2009-12-19 22:49:16 +00:00
david
b838242e01 Merge from /nmap-exp/david/nmap-mem. This brings in two memory-reducing
changes. The first is that Port objects don't allocate memory for
service and RPC results unless that information is set. This reduces the
size of a bare Port from 92 to 40 bytes on my machine. The second change
is that PortList now has the notion of a "default port state," which is
the state of any ports that didn't receive a response. These ports don't
need an allocated Port object, which saves a lot of memory in scans
where most ports didn't get a response.
2009-12-19 21:26:14 +00:00
fyodor
b8d10b7154 Reduce the first level of NSE indention to 2 spaces rather than
three. This corresponds to the 2 spaces now used in Ron's
stdnse.format_output function for further levels of indentation.  The
first level is still special in that it contains "| " or "|_" rather
than just spaces. Here is example output from before this change:

2049/tcp open  rpcbind
8080/tcp open  http        Apache httpd 2.2.13 ((Fedora))
|_ http-favicon: Unknown favicon MD5: 5A49412557709B4EDF6BBA9A1710B418
|_ html-title: Insecure.Org - Nmap Free Security Scanner, Tools & Hacking res...
|_ http-open-proxy: Proxy might be redirecting requests
8081/tcp open  http        Apache httpd 2.2.13 ((Fedora))
|  html-title: 302 Found
|_ Did not follow redirect to http://seclists.org/
8082/tcp open  http        Apache httpd 2.2.13 ((Fedora))
|_ html-title: Nmap - Free Security Scanner For Network Exploration & Securit...
|_ http-favicon: Apache Web Server (seen on SuSE, Linux Tux favicon)
Device type: general purpose
[...]
ost script results:
|  smb-os-discovery:  
|    OS: Unix (Samba 3.4.2-0.42.fc11)
|    Name: Unknown\Unknown
|_   System time: 2009-11-24 17:18:49 UTC-8
|_ smbv2-enabled: Server doesn't support SMBv2 protocol

And after the change:

2049/tcp open  rpcbind
8080/tcp open  http        Apache httpd 2.2.13 ((Fedora))
|_html-title: Insecure.Org - Nmap Free Security Scanner, Tools & Hacking res...
|_http-favicon: Unknown favicon MD5: 5A49412557709B4EDF6BBA9A1710B418
8081/tcp open  http        Apache httpd 2.2.13 ((Fedora))
| html-title: 302 Found
|_Did not follow redirect to http://seclists.org/
8082/tcp open  http        Apache httpd 2.2.13 ((Fedora))
|_http-favicon: Apache Web Server (seen on SuSE, Linux Tux favicon)
|_html-title: Nmap - Free Security Scanner For Network Exploration & Securit...
Device type: general purpose
...
Host script results:
| smb-os-discovery:  
|   OS: Unix (Samba 3.4.2-0.42.fc11)
|   Name: Unknown\Unknown
|_  System time: 2009-11-24 17:19:21 UTC-8
|_smbv2-enabled: Server doesn't support SMBv2 protocol
2009-11-25 01:23:34 +00:00
david
a06b900f00 Merge from /nmap-exp/david/nmap-mem. This reduces the memory usage of OS
scan by about 95%. (66832396 bytes to 2815061 bytes according to
Massif.)
2009-11-23 21:22:07 +00:00
david
e2315ae075 Remove the unused Port::owner member. 2009-11-20 20:17:33 +00:00
david
682b8cbc53 Include the reason why a host is down with --reason. It looks like this:
Nmap scan report for 1.2.3.4 [host down, received time-exceeded]
Nmap scan report for 1.2.3.5 [host down, received no-response]
2009-11-16 19:38:37 +00:00
david
300e038aa6 Print host timing information ("Final times for host" and the times
element in XML) even when doing only a ping scan. Don't print the
information if it was never set; i.e., we never measured an RTT to the
target.
2009-11-16 08:36:58 +00:00
david
ecb9aa0565 Print output for down hosts, even when doing scanning past a ping scan.
This always goes to XML and grepable output. It goes to normal in
interactive output in verbose mode. The format for printing a down host
is changed slightly:
Nmap scan report for 1.1.1.1 [host down]
2009-11-16 07:37:01 +00:00
david
2ccb1144da Remove a conditional that printed the "Host is down" line to either
LOG_PLAIN or LOG_STDOUT depending on whether o.resolve_all was set, and
just always print to LOG_PLAIN like we do all the other output. This was
the cause of a discrepancy between interactive and normal output
reported at http://seclists.org/nmap-dev/2009/q4/230.
2009-11-16 04:08:58 +00:00
david
1445ab46a9 Always print out the "Host is up" line with latency, even without
verbosity.
2009-10-27 22:57:50 +00:00
david
779b6cec2e Don't print out a "Host not scanned" line when doing list scan. 2009-10-27 22:49:23 +00:00
david
3889091495 Add a cast to silence a compiler warning. 2009-10-27 19:42:19 +00:00
david
398e53b3de Keep trace of the list of addresses a name resolved to, and print out
how many there were if there were more than one.
2009-10-27 06:08:04 +00:00
david
030411ffd8 Don't repeat the host name and IP address in "Host is up/down" messages.
Don't print the "Nmap scan report" header if there's nothing to put
under it.
2009-10-27 05:26:40 +00:00
david
d837d751bc Don't print an rDNS record if it is blank. 2009-10-26 21:17:13 +00:00
david
01f70c5432 Write an "Nmap scan report" heading before scan results. It includes the
reverse DNS if it differs from the forward hostname.
2009-10-26 19:09:56 +00:00
david
719d9c9442 Add the user's specified host name to XML output, if available. It looks
like this:

<hostnames>
<hostname name="openbsd.org" type="user"/>
<hostname name="cvs.openbsd.org" type="PTR"/>
</hostnames>
2009-10-24 01:01:08 +00:00
david
f037a4828c Remove some dead code. 2009-10-23 23:48:14 +00:00
david
c66cf4f568 Fix some output I missed cleaning up after indent. 2009-10-23 23:45:55 +00:00
david
6ac2ec8a77 Reindent output.cc. 2009-10-23 23:44:17 +00:00
david
d0a1bd3001 Print the proto attribute ("tcp", "udp", etc.) along with the port
number in the XML output for traceroute.
2009-09-28 20:12:46 +00:00
david
45b783c573 Print "--" for the RTT of traceroute hops if the RTT is unknown. This
can only happen in the case of a directly connected target with no ping
or port scan responses, like
nmap -PN -sP --send-ip --traceroute <target>
2009-09-17 15:11:20 +00:00
david
577a1be0e7 Merge from svn://svn.insecure.org/nmap-exp/david/nmap-traceroute. This
brings in a new, faster, parallel version of traceroute.
2009-09-17 00:03:46 +00:00
david
b40356ed3f Fixed an integer overflow that could occur when a target with a low
TCP timestamp clock frequency uses large timestamp values, such that
a naive uptime calculation shows a boot time before the epoch. Also
fixed a printf format specifier mismatch that was revealed by the
overflow. Toby Simmons reported the problem and helped with the fix.
2009-09-10 18:03:18 +00:00
david
6bd9760f3b In xml_convert, handle the case when repl is the empty string on the
first iteration. This can't happen with the current data definitions,
but if it did it would result in memcpy being passed a null pointer.
(memcpy would be asked to do a zero-byte copy, so it would probably be
okay anyway, but it's better to be safe.)
2009-08-24 18:10:12 +00:00
david
4c6bafb3fa o There is a new OS detection pseudo-test, SCAN.DC, which records how
the network distance in SCAN.DS was calculated. Its value can be "L"
  for localhost, "D" for a direct connection, "I" for an ICMP TTL
  calculation, and "T" for a traceroute hop count. This is mainly for
  the benefit of OS integration, when it is sometimes important to
  distinguish between DS=1%DC=I (probably the result of forged TTLs)
  and DS=1%DC=D (a true one-hop connection.) [David]
2009-08-23 23:58:28 +00:00