1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-14 03:39:02 +00:00
Commit Graph

187 Commits

Author SHA1 Message Date
josh
df71e36084 Updated uses of the ctype function to support explict casting of the arguments
to (int)(unsigned char).
2009-08-06 15:10:00 +00:00
fyodor
1736dde56c Applied patch:
o Fixed a log_write call and a pfatal call to use a syntax which is
  safer from format strings bugs.  This allows Nmap to build with the
  gcc -Wformat -Werror=format-security options. [Guillaume Rousse]
2009-07-19 07:23:32 +00:00
fyodor
e033940fa1 when the normal 8192-byte write buffer for log_write isn't big enough, we previously jumped it to 1,228,800 bytes. It turns out even that isn't enough in some cases, like the guy who just wrote me that was using '-p1-65535 -d6 -vvv -oA remotehost'. Sheesh. I had another person report the same sort of thing recently. So I'm upping it to 4MB. That ought to be enough for anybody :). On UNIX, vsnprintf is nice enough to tell us how much space we will need and so we don't have to worry about this. I also updated the error message to ask people to report it to nmap-dev rather than to me specifically 2009-07-18 09:53:08 +00:00
david
d8925b3c11 Rename the o.pingscan variable to o.noportscan to reflect its true
purpose. Make o.listscan imply o.noportscan to simplify some conditions.
2009-07-17 01:02:57 +00:00
ithilgore
5016893ab8 Fixed another typo in a comment. 2009-06-28 17:44:07 +00:00
ithilgore
aca370f88d Fixed typos with vsnprintf (was vnsprintf). 2009-06-28 17:33:35 +00:00
daniel
50830f7488 o Added initial SCTP port scanning support to Nmap. SCTP is
a layer 4 protocol used mostly for telephony related applications.
  This brings the following new features:
  o SCTP INIT chunk port scan (-sY): open ports return an INIT-ACK
    chunk, closed ones an ABORT chunk.  This is the SCTP equivalent
    of a TCP SYN stealth scan.
  o SCTP COOKIE-ECHO chunk port scan (-sZ): open ports are silent,
    closed ports return an ABORT chunk.
  o SCTP INIT chunk ping probes (-PY): host discovery using SCTP
    INIT chunk packets.
  o SCTP-specific IP protocol scan (-sO -p sctp).
  o SCTP-specific traceroute support (--traceroute).
  o The ability to use the deprecated Adler32 algorithm as specified
    in RFC 2960 instead of CRC32C from RFC 4960 (--adler32).
  o 42 well-known SCTP ports were added to the nmap-services file.
  Part of the work on SCTP support was kindly sponsored by
  Compass Security AG, Switzerland.  [Daniel Roethlisberger]
2009-06-03 23:15:45 +00:00
jah
99c4008c03 Disable traceroute when -6 is requested. Before this, it was possible to reach
traceroute() with IPv6 targets if a ping scan was requested.
2009-06-03 21:39:53 +00:00
david
fac82a011b Only increment o.numhosts_scanned when we have truly finished scanning a
host, which means that it is either found down or else all
port/script/traceroute/etc. scanning is finished. In r12798 I made it be
updated as soon as DNS resolution happened, to make the status display
"X undergoing Ping Scan" accurate. However the main loop also uses this
variable to count how many addresses have been generated so it knows
when to stop scanning random addresses. If -iR was used, only the first
hostgroup out of all the random addresses would be fully scanned and
then the scan would end. This change fixes that and also makes the
output more like it was pre-r12798; for example, if you had done name
resolution on 1024 hosts with --max-hostgroup 8, and had found the 8th
up host at the 280th one pinged, the output was
Stats: 0:00:29 elapsed; 1016 hosts completed (8 up), 8 undergoing Connect Scan
and is now
Stats: 0:00:29 elapsed; 272 hosts completed (8 up), 8 undergoing Connect Scan
2009-05-04 22:59:35 +00:00
david
b4243e23f2 Fix all the compiler warnings when building with Visual C++ 2008. 2009-04-29 17:56:30 +00:00
fyodor
d0e21e1d03 Suggest that people send patches to nmap-dev rather than to me directly 2009-04-15 00:37:03 +00:00
fyodor
b9d845b9ab Change 10 to 10.0 in pow() calls to make it clear that it is a double 2009-03-31 22:29:03 +00:00
david
16121b372c Add a round trip time estimate to host status lines. It looks like
Host scanme.nmap.org (64.13.134.52) is up (0.071s latency).
2009-03-31 21:21:36 +00:00
david
d1a77bb85e Simplify and combine the write_host_status code for ping scan and port
scans. This is the code that prints
	Host ... appears to be up.
	Host ... appears to be down.
	Host ... appears to be up ... good.
	Host ... appears to be down, skipping it
Except that now these messages are uniform and are
	Host ... is up.
	Host ... is down.
In addition, the host state --reason information is printed for port
scans just as for ping scans, which appears to have been an oversight
before.
2009-03-31 19:57:25 +00:00
fyodor
eccc235d5a Increase copyright year to 2009, simplify/reword some derivative works text, and remove a confusing clause about selling proprietary front-ends to Nmap 2009-03-31 04:16:12 +00:00
david
5ed0e17ea0 Treat a service named "unknown" as if it were not named in nmap-services for
purposes of output. What this means is that the port name will not be
"unknown?" or "ssl/unknown?" if version detection failed to find a match, but
simply "unknown" or "ssl/unknown".
2009-03-03 18:56:21 +00:00
david
6a6d18df6f Fix a bug in the printing of OS fingerprints. When a perfect match was found,
the value of the SEQ.G test (print suitable for submission) was the opposite of
what it should have been. This doesn't matter much because in the case of a
perfect match the submission URL isn't shown and the print itself is not
normally displayed. We want perfect matches with the new SEQ.CI test and the
online submitter will reject them if G=N.
2009-02-25 17:44:37 +00:00
david
aaaed61c52 Improve the efficiency of xml_convert. The old version was wasteful of space;
it started by allocating six times the size of the input string because in the
worst case each byte can take up to six bytes when escaped (&#xXX;). It was
wasteful of time because it built the string up with strncat, which pads the
entire destination buffer with null bytes every time it was called. This led to
quadratic time complexity, not linear as expected.

The new version uses the usual strategy of doubling the size of the buffer
whenever it runs out of space. It builds up the string using memcpy, checking
each time that there is space for the new copy.
2009-02-08 05:28:38 +00:00
fyodor
a8ff6858b4 o The conditions for printing OS fingerprints to XML output are now
the same as are used to decide whether to print them in the other
  formats. So they will be printed if submission is desirable,
  otherwise they are only printed if debuging is enabled or verbosity
  is 2 or higher. [Tom Sellers]
2009-02-01 21:08:39 +00:00
kris
20ec1c416e o An "elapsed" attribute has been added to the XML output, representing
the total scan time in seconds (floating point).
2009-01-05 05:57:35 +00:00
david
c561222685 Fix spelling in some identifiers. wierd_responses -> weird_responses,
printStatsIfNeccessary -> printStatsIfNecessary.
2008-12-04 17:04:48 +00:00
david
4ff30d9b99 Show a warning whenever raw socket sending is attempted on Windows--not just
when using --send-ip.
2008-11-24 17:52:25 +00:00
david
47c268568d Use the math function floor instead of casting to an int to truncate OS scan
match percentages. Casting to an int rounds (0.98 * 100) to 97 on some
architectures.
2008-11-20 17:03:11 +00:00
david
a4f6dc6b6e Merge from /nmap-exp/david/nmap-os.
This brings in four discrete changes:

1. The widening of ranges for T test expressions in nmap-os-db. Any expressions
   that were not already ranges were expanded to cover plus and minus five of
   their original values.
2. The normalization of TG expressions in nmap-os-db. Nmap is only capable of
   outputting 0x20, 0x40, 0x80, and 0xFF for a TG value, but many fingerprints
   had values other than these. They have all been rounded to their nearest
   likely value.
3. The elimination of the U1.TOS and IE.TOSI tests (both having to do with type
   of service). This was effected by setting their MatchPoints to 0.
4. A cleanup and refactoring of OS fingerprint output code. This should not
   have any impact on output, except in one case: when debugging is non-zero or
   verbosity is greater than one, and at least one perfect match was found,
   Nmap used to print "OS Fingerprint:" before the fingerprint. Now it prints
   "TCP/IP fingerprint:" in this case like in all the others.
2008-10-31 22:46:07 +00:00
david
0d372367c0 Remove "\r\r" in script output. If you print "\r\n", the Windows C library will
transform it to "\r\r\n". So we just print "\n" with no special case for
Windows.
2008-09-12 21:33:14 +00:00
david
20853ec49f Make xml_convert escape any character > 0x7F, and use xml_convert to escape the
value of the "args" attribute.

On Windows, I created a user account with the name "Kurt Gödel". When I ran a
scan in Zenmap, Nmap created a temporary XML file that started like

<?xml version="1.0" ?>
<?xml-stylesheet href="nmap.xsl" type="text/xsl"?>
<!-- Nmap 4.75 scan initiated Wed Sep 10 11:16:58 2008 as: nmap -T4 -F -oX c:\docume~1\kurtgö~1\locals~1\temp\zenmap-bcbuy6.xml 192.168.0.1 -->
<nmaprun scanner="nmap" args="nmap -T4 -F -oX c:\docume~1\kurtgö~1\locals~1\temp\zenmap-bcbuy6.xml 192.168.0.1" start="1221067018" startstr="Wed Sep 10 11:16:58 2008" version="4.75" xmloutputversion="1.02">

Notice the ö characters in the file names. They were not in UTF-8 but probably
whatever the filesystem encoding is. Because Nmap's XML does not declare an
encoding, it defaults to UTF-8, meaning this particular file was not even
well-formed. In Zenmap it caused a crash like

CRASH REPORTED:
SYS.PLATFORM: win32
OS.NAME: nt
Zenmap Version: 4.75
TRACEBACK:
Traceback (most recent call last):
  File "C:\cygwin\home\david\nmap\zenmap\zenmapGUI\ScanNotebook.py", line 387, in verify_execution
    self.load_from_command(scan)
  File "C:\cygwin\home\david\nmap\zenmap\zenmapGUI\ScanNotebook.py", line 400, in load_from_command
    parsed = self._parse(command.get_xml_output_filename())
  File "C:\cygwin\home\david\nmap\zenmap\zenmapGUI\ScanNotebook.py", line 444, in _parse
    parsed.parse_file(file_to_parse)
  File "C:\cygwin\home\david\nmap\zenmap\zenmapCore\NmapParser.py", line 749, in parse_file
    self.parse(f)
  File "C:\cygwin\home\david\nmap\zenmap\zenmapCore\NmapParser.py", line 743, in parse
    self.parser.parse(f)
  File "c:\Python25\lib\xml\sax\expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "c:\Python25\lib\xml\sax\xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "c:\Python25\lib\xml\sax\expatreader.py", line 211, in feed
    self._err_handler.fatalError(exc)
  File "c:\Python25\lib\xml\sax\handler.py", line 38, in fatalError
    raise exception
SAXParseException: c:\docume~1\kurtgö~1\locals~1\temp\zenmap-bcbuy6.xml:3:92: not well-formed (invalid token)

Plus Internet Explorer wouldn't even open it.

This change escapes the XML so it looks like

<?xml version="1.0" ?>
<?xml-stylesheet href="nmap.xsl" type="text/xsl"?>
<!-- Nmap 4.75 scan initiated Wed Sep 10 11:52:19 2008 as: nmap -PE -PA21,23,80,3389 -A -v -T4 -oX c:\docume~1\kurtg&#xF6;~1\locals~1\temp\zenmap-zih7f5.xml 192.168.0.1 -->
<nmaprun scanner="nmap" args="nmap -PE -PA21,23,80,3389 -A -v -T4 -oX c:\docume~1\kurtg&#xF6;~1\locals~1\temp\zenmap-zih7f5.xml 192.168.0.1" start="1221069139" startstr="Wed Sep 10 11:52:19 2008" version="4.75" xmloutputversion="1.02">
2008-09-10 18:32:35 +00:00
david
0a64626a4c Change the output label "Uptime" to "Uptime guess" and print it only in verbose
mode.
2008-08-26 17:40:19 +00:00
michael
931285f765 Updated DTD, XML version, and anded scanflags attribute to scaninfo element. 2008-08-13 00:59:22 +00:00
david
c5d4075db5 Oops, move the definition of the now-static function formatScriptOutput to
above where it's used.
2008-08-05 19:58:21 +00:00
david
9621ab338a Make some change to make --without-liblua work again. 2008-08-05 19:28:51 +00:00
michael
4a7022bf04 Updated as per Davids request. I misinterpreted what David said and made a change, when he really meant for me to suggest the change in the mailing list rather then just committing it. 2008-08-02 20:42:11 +00:00
michael
64219d7e41 Change suggested by Fyodor 2008-08-02 20:05:38 +00:00
michael
aaf2a60970 Fixed typo from previous patch 2008-08-02 19:45:04 +00:00
michael
a4542861a8 Nmaps XML output will now report that an idle scan has occurred in the 'scaninfo' element when applicable. 2008-08-02 19:28:30 +00:00
fyodor
7f9dff09c3 report scan time to hundredths of a second, not thousandths 2008-07-11 07:29:09 +00:00
batrick
13452505a5 Added ScriptResult class change in order to avoid managing string memory
created via strdup(). Script output and id (strings) are now C++ std::string.
2008-07-07 17:37:08 +00:00
kris
d0a2ec9d50 Adding support for NSE + Ping Scan (-sP) for executing host scripts. So "-sPC", "-sP --script all" and "-sP --script ripeQuery" all work correctly 2008-07-03 04:11:42 +00:00
fyodor
f810762936 Increase write buffer length for Nmap output on Windows. This should
prevent error messages like: "log_vwrite: vnsprintf failed.  Even after
increasing bufferlen to 819200, Vsnprintf returned -1 (logt == 1)."
Thanks to prozente0 for the report.
2008-06-28 21:23:39 +00:00
michael
30d60b97ed setServiceXMLBuf now uses the string class exclusively instead of the old c-string & string class combination. So it is no longer necessary to calculate the length of the XML service element before writing it to its buffer. 2008-06-21 05:45:11 +00:00
michael
f0cbbe45f8 Fixed a segfault in printportoutput() and setServiceXMLBuf() in output.cc.
Thanks for pointing this out Brandon.
2008-06-20 22:00:40 +00:00
michael
4863010770 Service fingerprints are no longer truncated in XML logs. 2008-06-20 03:25:53 +00:00
david
902d3dcf0f Break the libdnet->libpcap mapping output into its own function. 2008-06-12 16:58:16 +00:00
david
07515db1d5 Int the DEV/WINDEVICE output, additionally show the "leftover" libpcap devices,
those that don't have a libdnet name that maps to them. This should be a help
in debugging, as it now shows all the libdnet names, all the libpcap names, and
how they all relate to each other.
2008-06-12 16:42:03 +00:00
david
d8ad54907c Protect the WINDEVICE output code with #ifdef WIN32. 2008-06-12 01:45:06 +00:00
david
0101e9e0ab Change the DEV/WINDEVICE output (the part that shows the mapping from
dnet names to WinPcap names) to use the no-nonsense approach of simply
calling DnetName2PcapName for every interface returned by getinterfaces.
DnetName2PcapName calls intf_get_pcap_devname, which is same function
called by eth_open on Windows, so now the output really reflects Nmap's
view of the world.

This doesn't remove interface aliases, so if you have any aliases
enabled, you will see what look like duplicated lines. I have chosen to
leave them in for now to assist with debugging if any alias-related
problems come up in the future. They could be taken out easily if this
is not desired.

This brings what may be a startling change: the lo0 loopback interface
no longer maps to /Device/NPF_GenericDialupAdapter, but to no adapter at
all (signified by "<none>"). I believe the old behavior was wrong,
merely an artifact of the way the code happened to line up two lists of
interfaces. /Device/NFP_GenericDialupAdapter is for dialup and VPN
capture, and the loopback interface isn't supported by WinPcap (or
Windows for that matter) at all. See
http://www.winpcap.org/misc/faq.htm#Q-5
http://www.winpcap.org/misc/faq.htm#Q-13
2008-06-12 00:57:49 +00:00
michael
9f64691427 On windows, the --iflist option was not reporting correct windevice values and not displaying all ethernet devices if the user had interface aliases set up. Now all Windevice values and interface device ID's will be properly linked together. 2008-06-03 18:05:45 +00:00
david
d3263f0f1a Fix grepable output "Ignored State" reporting. Only one ignored state (the one
with the highest numbers of ports) is output.
2008-05-29 20:05:02 +00:00
fyodor
779b96a197 trivial copyright text tweak: filename nmap-os-fingerprints has changed to nmap-os-db 2008-05-22 20:45:32 +00:00
fyodor
e843583ef3 o Nmap now reports scan start and end times for individual hosts
within a larger scan. The information is added to the XML host
  element like so: [host starttime="1198292349" endtime="1198292370"]
  (but of couse with angle brackets rather than square ones).  It is
  also printed in normal output if -d or "-v -v" are
  specified. [Brandon, Kris, Fyodor]
2008-05-09 05:21:44 +00:00
bmenrigh
9b9d2bd85e Updated all the stray calls to rand() to use nbase_rnd instead. The
only code left in Nmap that still uses rand() is in the Lua math 
library.  Perhaps at some point we'll need to expose high-quality random 
numbers to Lua via our custom nmap library.
2008-05-06 01:05:51 +00:00