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

130 Commits

Author SHA1 Message Date
dmiller
3749c04310 Sanity check in pcap_recieve to avoid crash. Fixes #313 2016-03-07 16:44:52 +00:00
dmiller
0577e3bb1e Avoid crashing when Nsock connect calls the callback immediately due to parameter errors 2016-03-04 23:04:01 +00:00
henri
b55ff2d68f Don't associate nsock logging info to a nspool.
Make current loglevel and current log callback global
to the library. Attaching them to the nsock pool doesn't
bring any benefit and prevents from logging activity in
code sections that don't have access to a pool (such as
proxy chain specification parsing).

Updated external calls and nsock tests accordingly.
2015-06-27 08:21:53 +00:00
henri
b75233ce98 Consistently renamed nsi_XXX calls into nsock_iod_XXX
This is part of the effort to make nsock expose only
nsock_ prefixed symbols and simplify the API.
2015-06-27 08:21:33 +00:00
henri
fd40b8df08 Simplify Nsock SSL init API
Replaced nsock_pool_ssl_init_max_speed() by a NSOCK_SSL_MAX_SPEED
flag to be passed to nsock_pool_ssl_init(). Default (flag=0) means
secure.
2015-06-27 08:21:22 +00:00
henri
0348359f60 Enforce nsock naming scheme.
convert nsp_* calls into nsock_pool_*. Separate words with underscores
where appropriate.
2015-06-27 08:21:16 +00:00
dmiller
84d0e45641 Remove some unneeded includes of utils.h 2015-06-23 15:52:55 +00:00
dmiller
6a8f12e165 Prevent NSE from connecting to the wrong AF: http://seclists.org/nmap-dev/2012/q3/871 2015-05-15 19:35:18 +00:00
dmiller
2f02fa2935 Fix build when building without OpenSSL (since r33781) 2015-01-01 21:09:02 +00:00
dmiller
2871ba3e6c New function, sslcert.parse_ssl_certificate
For reasons, the function is exported from nse_ssl_cert.cc into
nmap.socket, then included and documented in sslcert.lua because it fits
better there.
2014-11-05 05:55:52 +00:00
dmiller
3ecd0452d5 Fix a memory leak in NSE's bind function 2014-09-15 22:49:17 +00:00
d33tah
421176fc00 Get rid of double newline at the EOF I accidentally introduced in the
last commit.
2014-06-18 11:30:02 +00:00
d33tah
e3d1c178e3 Add newlines at the EOF in conformance to Daniel's coding standards
proposal. This only affects Nmap's root directory. We might also need to
modify the code which autogenerates Nmap's source code files such as IPv6
fingerprinting code.
2014-06-18 10:18:58 +00:00
dmiller
c9714990c7 Remove trailing whitespace from C/C++ files
https://secwiki.org/w/Nmap/Code_Standards
2014-02-12 20:25:51 +00:00
d33tah
4816358475 Replace all tab characters at the beginnings of lines with 8 spaces.
Mixed indentation annoyed my vim.
2014-01-05 19:14:26 +00:00
henri
694a8fe825 Nsock-pcap cleanup
Make the API follow the general nsock style. Report errors properly using the
nsock logging facilities.
2013-07-31 19:11:16 +00:00
henri
4685d44ff8 Removed a superfluous nsock_set_proxychain() statement.
This call got duplicated during the merge and provoked
non-fatal nsock errors like:

NSOCK ERROR [0.0310s] nsp_set_proxychain(): Invalid call. Existing proxychain on this nsock_pool
2013-04-30 07:12:03 +00:00
henri
1b45bfef14 Made NSE use proxychains too. 2013-04-22 19:35:42 +00:00
henri
18cf677548 Let NSE use nsock proxy chains. 2013-04-22 19:33:15 +00:00
henri
99258673ad Added handling of the new NSE_STATUS_PROXYERROR case. 2013-04-22 19:32:36 +00:00
david
40dc37e30b Comment typo. 2013-02-26 05:28:33 +00:00
henri
809f1eda68 Merged nsock-logging from nmap-exp/henri/nsock-logging/
Reworked the logging infrastructure to make it more flexible
and consistent.

Updated nmap, nping and ncat accordingly.  Nsock log level can
now be adjusted at runtime by pressing d/D in nmap.
2012-12-15 10:59:30 +00:00
david
26816736b5 Revert part of r29016.
nsock_check_udata needs this parameter indicating whether to set up an
unconnected UDP socket or not. r29016 wrongly made this setup
unconditional and moved the check for connectedness into the calling
function. What went wrong is that the unconnected UDP socket could be
set up prematurely--before calling bind, for example. This broke scripts
using unconnected UDP sockets.

This was reported by Dhiru Kholia.
http://seclists.org/nmap-dev/2012/q4/422
2012-12-15 07:55:31 +00:00
batrick
9754682420 Cancel the sleep event if the thread is destroyed by NSE. This
solves an assertion failure when the thread was garbage collected
by Lua before the sleep callback occurred.

Reported by Henri Doreau [1].

[1] http://seclists.org/nmap-dev/2012/q4/43
2012-11-23 03:47:43 +00:00
david
bfaed0ce34 Use the name "nspp" for a variable of type "pointer to nsock_pool." 2012-10-22 05:17:00 +00:00
david
5c8272b3c9 Chack for a NULL pointer return in get_pool. 2012-10-22 05:16:59 +00:00
david
d27e378879 Comment typo. 2012-10-17 18:48:32 +00:00
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