Blocked for possible web abuse
The IP address you are coming from has requested an inordinately large number of pages in a short amount of time and has been temporarily blocked to conserve our resources. This often happens when people try to use web spidering programs to download large portions of the site. The block will be removed 24 hours after the latest period of high traffic. If you feel this IP ban was made in error, you can email fyodor@nmap.org.
NSE Libraries
In addition to the significant built-in capabilities of
Lua, we have written or integrated many extension libraries which make
script writing more powerful and convenient. These libraries (sometimes called modules) are compiled if necessary and installed along with
Nmap. They have their own directory, nselib
, which
is installed in the configured Nmap data directory. Scripts need only
require
the default libraries in order to use them.
List of All Libraries
This list is just an overview to give an idea of what libraries
are available. Developers will want to consult the complete
documentation at https://nmap.org/nsedoc/
.
-
afp
-
ajp
A basic AJP 1.3 implementation based on documentation available from Apache mod_proxy_ajp;
http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html
-
amqp
-
asn1
-
base32
-
base64
-
bin
-
bit
-
bitcoin
-
bittorrent
-
bjnp
-
brute
-
cassandra
Library methods for handling Cassandra Thrift communication as client
-
citrixxml
-
comm
Common communication functions for network discovery tasks like banner grabbing and data exchange.
-
creds
The credential class stores found credentials in the Nmap registry
-
cvs
-
datafiles
-
dhcp
Implement a Dynamic Host Configuration Protocol (DHCP) client.
-
dhcp6
-
dns
Simple DNS library supporting packet creation, encoding, decoding, and querying.
-
dnsbl
-
dnssd
-
drda
DRDA Library supporting a very limited subset of operations.
-
eap
EAP (Extensible Authentication Protocol) library supporting a limited subset of features.
-
eigrp
A library supporting parsing and generating a limited subset of the Cisco' EIGRP packets.
-
ftp
-
giop
-
gps
A smallish gps parsing module. Currently does GPRMC NMEA decoding
-
http
Implements the HTTP client protocol in a standard form that Nmap scripts can take advantage of.
-
httpspider
-
iax2
-
imap
-
informix
Informix Library supporting a very limited subset of Informix operations
-
ipOps
Utility functions for manipulating and comparing IP addresses.
-
ipp
A small CUPS ipp (Internet Printing Protocol) library implementation
-
iscsi
-
isns
A minimal Internet Storage Name Service (iSNS) implementation
-
jdwp
-
json
Library methods for handling JSON data. It handles JSON encoding and decoding according to RFC 4627.
-
ldap
-
lfs
-
listop
-
match
-
membase
A smallish implementation of the Couchbase Membase TAP protocol Based on the scarce documentation from the Couchbase Wiki: x
http://www.couchbase.org/wiki/display/membase/SASL+Authentication+Example
-
mobileme
-
mongodb
Library methods for handling MongoDB, creating and parsing packets.
-
msrpc
-
msrpcperformance
-
msrpctypes
-
mssql
MSSQL Library supporting a very limited subset of operations.
-
mysql
Simple MySQL Library supporting a very limited subset of operations.
-
natpmp
This library implements the basics of NAT-PMP as described in the NAT Port Mapping Protocol (NAT-PMP) draft: o
http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
-
ncp
-
ndmp
A minimalistic NDMP (Network Data Management Protocol) library
-
netbios
Creates and parses NetBIOS traffic. The primary use for this is to send NetBIOS name requests.
-
nmap
-
nrpc
-
nsedebug
-
omp2
-
openssl
-
ospf
-
packet
-
pcre
-
pgsql
-
pop3
-
pppoe
-
proxy
-
rdp
-
redis
A minimalistic Redis (in-memory key-value data store) library.
-
rmi
Library method for communicating over RMI (JRMP + java serialization)
-
rpc
-
rpcap
-
rsync
-
rtsp
-
sasl
-
shortport
-
sip
A SIP library supporting a limited subset of SIP commands and methods
-
smb
-
smbauth
This module takes care of the authentication used in SMB (LM, NTLM, LMv2, NTLMv2).
-
smtp
-
snmp
-
socks
-
srvloc
-
ssh1
-
ssh2
-
sslcert
-
stdnse
-
strbuf
-
strict
Strict declared global library. Checks for undeclared global variables during runtime execution.
-
stun
A library that implements the basics of the STUN protocol (Session Traversal Utilities for NAT) per RFC3489 and RFC5389. A protocol overview is available at
http://en.wikipedia.org/wiki/STUN
.-
tab
-
target
Utility functions to add new discovered targets to Nmap scan queue.
-
tftp
-
tns
TNS Library supporting a very limited subset of Oracle operations
-
unpwdb
-
upnp
-
url
-
versant
A tiny library allowing some basic information enumeration from Versant object database software (see
http://en.wikipedia.org/wiki/Versant_Corporation
). The code is entirely based on packet dumps captured when using the Versant Management Center administration application.-
vnc
-
vulns
-
vuzedht
A Vuze DHT protocol implementation based on the following documentation: o
http://wiki.vuze.com/w/Distributed_hash_table
-
wsdd
-
xdmcp
Implementation of the XDMCP (X Display Manager Control Protocol) based on: x
http://www.xfree86.org/current/xdmcp.pdf
-
xmpp
To help correct this problem, NSE uses a library adapted from
the standard Lua distribution called
strict.lua
.
The library will
raise a runtime error on any access or modification of a global
variable which was undeclared in the file scope. A global variable is
considered declared if the library makes an assignment to the global
name (even nil
) in the file scope.
Adding C Modules to Nselib
A few of the modules included in nselib are written in C or C++
rather than Lua. Two examples are bit
and pcre
. We recommend that modules
be written in Lua if possible, but C and C++ may be more
appropriate if performance is critical or (as with
the pcre
and openssl
modules) you are linking to an existing C library. This section
describes how to write your own compiled extensions to nselib.
The Lua C API is described at length in
Programming in Lua, Second Edition,
so this is a short summary. C modules consist of functions that
follow the protocol of the
lua_CFunction
type. The functions are registered with Lua and assembled into a
library by calling the
luaL_newlib
function. A special initialization function provides the interface
between the module and the rest of the NSE code. By convention the
initialization function is named in the form
luaopen_
.
<module>
The most straightforward compiled module that comes with NSE is
openssl
.
This module serves as a good example for a beginning module
writer. The
source code for
openssl
source is in nse_openssl.cc
and
nse_openssl.h
. Most of the other compiled modules
follow this nse_
naming convention.
<module name>
.cc
Reviewing the openssl
module shows that one of the
functions in nse_openssl.cc
is
l_md5
, which calculates an MD5 digest. Its
function prototype is:
static int l_md5(lua_State *L);
The prototype shows that l_md5
matches the
lua_CFunction type. The function is static because it
does not have to be visible to other compiled code. Only an address is required
to register it with Lua. Later in the file,
l_md5
is entered into an array of type
luaL_Reg and associated with the name
md5
:
static const struct luaL_Reg openssllib[] = { { "md5", l_md5 }, { NULL, NULL } };
This function will now be known as md5
to NSE. Next the library is registered with a call to
luaL_newlib
inside the initialization
function luaopen_openssl
, as shown
next. Some lines relating to the registration of
OpenSSL BIGNUM types have been omitted:
LUALIB_API int luaopen_openssl(lua_State *L) { luaL_newlib(L, openssllib); return 1; }
The function luaopen_openssl
is the only function in the file that is exposed in
nse_openssl.h
. OPENSSLLIBNAME
is simply the string
"openssl"
.
After a compiled module is written, it must be added to NSE by including
it in the list of standard libraries in
nse_main.cc
. Then the module's
source file names must be added to
Makefile.in
in the appropriate places. For both these tasks you can
simply follow the example of the other C modules. For the
Windows build, the new source files must be added to the
mswin32/nmap.vcproj
project file using MS Visual Studio (see the section called “Compile from Source Code”).