1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-14 11:49:01 +00:00
Commit Graph

103 Commits

Author SHA1 Message Date
david
422b43be22 Call nsp_setdevice after nsp_new in our Nsock pools.
The exceptions are the calls in ncat/ncat_connect.c and
nping/EchoServer.cc. Ncat doesn't have an option for the interface, and
I think Nping's -e option is only meant to apply to probes, not to the
echo server listener.
2012-10-03 15:43:18 +00:00
david
a41633cd85 Close an NSE socket before making a second attempt to connect.
Without this, we were leaking socket descriptors. See
http://seclists.org/nmap-dev/2012/q3/971.
2012-09-21 21:13:28 +00:00
henri
b56c25a972 Fixed memory leak. 2012-08-04 16:05:24 +00:00
dmiller
92008abcfa Fix assertion error on pcap nsock_iod reuse
Discussion: http://seclists.org/nmap-dev/2012/q3/458
2012-07-31 16:20:43 +00:00
david
2404fc7d64 Return nil and an error message when a socket is not connected.
Daniel Miller noticed that the behavior of socket functions didn't match
the documentation when a socket was not connected. The code would raise
a Lua error (ending the script) instead of returning a false status code
as documented.

http://seclists.org/nmap-dev/2011/q3/840
http://seclists.org/nmap-dev/2012/q2/505
2012-06-21 03:11:17 +00:00
david
091d848838 Prevent a null pointer dereference in nse_nsock_get_ssl.
This could be provoked by a script calling nmap.get_ssl_certificate on
an unconnected socket.
2012-05-28 17:44:10 +00:00
david
fc49819007 Remove condition with no effect. 2012-05-28 17:08:18 +00:00
david
8175095717 Typo. 2012-05-28 17:08:17 +00:00
batrick
000f6dc4d9 Lua 5.2 upgrade [1] for NSE.
[1] http://seclists.org/nmap-dev/2012/q2/34
2012-05-27 08:53:32 +00:00
henri
97402a0d95 Removed variables "status" to get rid of GCC (4.6.1) warnings concerning set but
never used variables.
2011-12-14 15:01:14 +00:00
djalal
6562877ed6 Fixed a bug: use sockaddr_storage instead of sockaddr. 2011-06-09 17:38:04 +00:00
batrick
9d2463b9cd comment clarifying -1 case 2011-04-05 19:34:34 +00:00
david
bf99fb231b Check that the argument to freeaddrinfo is not NULL. The behavior may be
unspecified and causes a segmentation fault on Android Bionic libc.
Vlatko fixed the bug in his Android binaries and it was first reported
by @alexismm2.
2011-02-15 08:19:58 +00:00
david
47030f71db o [NSE] Made it a controlled Lua stack trace instead of a fatal error
when an NSE script sets a negative socket timeout. Vlatko Kosturjak
  reported the bug. [David]
2011-02-01 21:20:29 +00:00
david
18157ed081 Merge from /nmap-exp/david/nmap-unconnected. This adds unconnected
socket support to NSE, with updates in scripts and libraries.

o [NSE] Added the ability to send and receive on unconnected sockets.
  This can be used, for example, to receive UDP broadcasts without
  using pcap. A number of scripts have been changed so that they can
  work as prerule scripts to discover services by UDP broadcasting,
  optionally add the discovered targets to the scanning queue:
    - ms-sql-info
    - upnp-info
    - dns-service-discovery
  The nmap.new_socket function can now optionally take a default
  protocol and address family, which will be used if the socket is not
  connected. There is a new nmap.sendto function to be used with
  unconnected UDP sockets. [David, Patrik]
2010-10-16 00:48:44 +00:00
david
85d81f76ce Add another parameter to nsp_settrace that allows setting the FILE
stream to write to. It defaults to stdout like before if NULL is
provided. Ncat uses this to write to stderr instead.
2010-10-01 18:12:22 +00:00
david
1723949c05 Revert r20455; I meant to do this in a branch. 2010-10-01 06:29:17 +00:00
david
87ee8343f3 Provide a new nsock_setup_udp function to create a UDP socket without connecting it. Provide an NSE interface to the function. Add broadcast.nse, a script that receives UDP broadcasts with an unconnected socket. 2010-10-01 06:26:22 +00:00
djalal
85030874ea Fix a bug that prevents Nmap to compile on systems that lacks OpenSSL. This patch was contributed by Patrik Karlsson. 2010-09-26 10:43:32 +00:00
batrick
31fbab7eba Moved receive_buf function (not in use yet, until Lua 5.2) next to other
receive functions.
2010-09-21 20:01:16 +00:00
batrick
de4ba536de Merge from /nmap-exp/patrick/nse-nsock-maintenance.
This is a maintenance fix for the NSE Nsock library binding. The patch focuses
on code correctness and simplicity. The patch also brings some initial updates
with an eye towards the upcoming Lua 5.2 release. See [1] for a post concerning
this branch.

[1] http://seclists.org/nmap-dev/2010/q3/710
2010-09-18 20:35:09 +00:00
david
745a49d24a Upgrade the included Windows OpenSSL to version 1.0.0a. 2010-09-16 03:49:43 +00:00
david
1e80229708 Change "ncap" to "pcap" in some function names so the C names match the
Lua names.
2010-08-24 17:49:39 +00:00
david
bfffa53616 When nmap.connect gets a port table, let port.protocol be the default
protocol (instead of always "tcp"). You can still override it by
providing an explicit protocol after the table.
2010-08-16 18:09:04 +00:00
david
0e3c861ea0 Let nmap.connect take a host table and port table in place of a string
and an integer. This is going to be used to easily support Server Name
Indication for SSL connections.
2010-08-16 17:35:20 +00:00
kris
cc33a59ca4 Add nmap.clock() for providing scripts with the current time in floating
point seconds since the epoch, and add clock_ms() and clock_us() to stdnse
for convenience (millisecond and microsecond).

qscan.nse now provides microsecond resolution.
2010-07-23 19:49:42 +00:00
kris
ee3c89afe4 o [NSE] When receiving raw packets from Pcap, the packet capture time
is now available to scripts as an additional return value from
  pcap_receive().  It is returned as the floating point number of
  seconds since the epoch.  The qscan.nse script was updated to use
  this more accurate data instead of using the clock_ms() function
  (which returns the current time). [Kris]
2010-07-23 10:43:04 +00:00
batrick
885bc6e034 SCRIPT_ENGINE is defined in nse_main.h. 2010-07-07 15:01:19 +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
djalal
24807128d2 Merge r17640:18062 from /nmap-exp/djalal/nmap, this is a port of the LuaFileSystem directory iterator in order to use Lua code to list scripts. 2010-06-12 21:41:09 +00:00
batrick
9ead4dec87 Removed an old false comment. 2010-04-30 19:56:16 +00:00
david
5e8f88194d Use socket_errno() instead of errno in NSE raw socket code, to get
Windows errors.
2010-03-02 18:29:22 +00:00
kris
a42ea72a97 Merge through r16884 from /nmap-exp/kris/nse-rawip plus the following changelog
entries:

o [NSE] Raw packet sending at the IP layer is now supported, in addition to
  the Ethernet sending functionality.  Packets to send start with an IPv4
  header and can be sent to arbitrary hosts. [Kris]

o [NSE] Added the ipidseq script to classify a host's IP ID sequence numbers
  in the same way Nmap does.  This can be used to test hosts' suitability for
  Nmap's Idle Scan (-sI), i.e. check if a host is an idle zombie.  This is
  the first script to use the new raw IP sending functionality in NSE. [Kris]

o [NSE] Added the function nmap.is_privileged() to tell a script if, as far
  as Nmap's concerned, it can do privileged operations.  For instance, this
  can be used to see if a script should be able to open a raw socket or
  Ethernet interface. [Kris]

o [NSE] Added the function nmap.get_ports() to allow a script to iterate
  over a host's port tables matching a certain protocol and state. [Kris,
  Patrick]
2010-02-26 20:42:10 +00:00
david
f21a07cfde Revert r16464. 2010-01-15 03:55:23 +00:00
david
c73b250615 Factor out a function that reports the failure to open an Ethernet
device and exits. On Windows, print a hint about "net start npf" to
start the NPF service.
2010-01-15 00:37:39 +00:00
david
0f8c77ba4c Restore all threads that are waiting on a socket lock when a thread
relinquishes its lock. We expect only one of them to be able to grab the
newly freed lock, and the rest to go back to waiting. This seems to have
helped with a deadlock in running a large-scale favicon survey.
2009-11-28 16:58:02 +00:00
david
9d4e947b4b Revert r16121, which changed when NSE sockets are created, as it seems
to be the cause of a segfault reported by Ron Bowes.

nmap -PN -p4567 -sV --script=http-* x.x.x.x
Program received signal SIGSEGV, Segmentation fault.
nsock_connect_tcp (nsp=0x83b8b38, ms_iod=0x0, handler=0x80b5cf0
<l_nsock_connect_handler(void*, void*, void*)>, timeout_msecs=10000,
userdata=0x8729308, saddr=0x871a6f8, sslen=16, port=4567)
    at nsock_connect.c:154
2009-11-19 03:46:53 +00:00
david
8b89e83df2 Create an Nsock iod with nsi_new as soon as nmap.new_socket is called,
instead of waiting until a request is made to connect. This eliminates a
little bit of bookkeeping that needed to be done to retain state on the
NSE socket. Unfortunately this alone doesn't allow binding a socket to a
source address to receive UDP data, because Nsock doesn't create the
physical socket until a connection is made.
2009-11-18 05:35:39 +00:00
david
91478be449 Don't use the AI_NUMERICSERV flag, which isn't available on OS X, in the
getaddrinfo call in l_nsock_bind. We always use decimal port numbers anyway.
2009-10-21 18:04:15 +00:00
david
a8821f3cf4 Add the NSE function nmap.bind, which sets the source address of a
socket.
2009-10-11 23:08:43 +00:00
david
3fd8f0a0c5 Remove the allocation and freeing of a fixed-size dynamic buffer and
replace it with a static buffer.
2009-10-11 21:54:39 +00:00
david
dd6eb63b36 Fix NSE trace printing of IPv6 addresses. The code was using a plain
sockaddr instead of sockaddr_storage so it got only a fraction of the
address and the inet_ntop function would look outside of the structure
into adjacent memory. A scan of localhost would look like this:

NSE: TCP ::a00:0:600:0:1234 > ::a00:4d2:0:0:25 | CONNECT

Here, for example, that 4d2 is the port number 1234 from the other
structure. Now it prints correctly:

NSE: TCP ::1:1234 > ::1:25 | CONNECT
2009-10-11 21:51:51 +00:00
batrick
afa84d2320 [NSE] Added the reconnect_ssl method for sockets. We sometimes need
to reconnect a socket with SSL because the initial communication on the socket
is done without SSL. See this thread [1] for more details.

[1] http://seclists.org/nmap-dev/2009/q4/3
2009-10-06 13:02:12 +00:00
david
cac58924e0 Avoid dereferencing a NULL key in l_nsock_ncap_close. 2009-08-24 21:18:26 +00:00
david
ddf05afe1b Fix a memory leak in l_nsock_get_info when trying to get information
from a closed socket.
2009-08-24 21:09:47 +00:00
david
cb226847e5 Move a couple of allocated string variables into the same scope where
they are freed to avoid a memory leak.
2009-08-24 21:02:32 +00:00
david
7d87fe7aa5 Remove the const qualifier from the SSL pointer returned from
nse_nsock_get_ssl. In older versions of OpenSSL (I don't know how old)
the argument to SSL_get_peer_certificate is not const and it caused a
compiler error reported by Ron Bowes.
2009-08-19 16:33:11 +00:00
david
6c766c58cd Add the nmap.get_ssl_certificate NSE function, which returns the peer
certificate of an SSL socket.
2009-08-13 23:32:33 +00:00
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
david
9aebba220c Merge from svn://svn.insecure.org/nmap-exp/daniel/{nmap,ncat,nsock}-sctp.
This adds SCTP support (including SSL over SCTP) to Nsock and Ncat.
2009-07-25 00:03:48 +00:00