diff --git a/nselib/bin.luadoc b/nselib/bin.luadoc index fec29881a..c3e4e326b 100644 --- a/nselib/bin.luadoc +++ b/nselib/bin.luadoc @@ -52,7 +52,7 @@ module "bin" -- @param format Format string, used to pack following arguments. -- @param ... The values to pack. -- @return String containing packed data. -function bin.pack(format, ...) +function pack(format, ...) --- Returns values read from the binary packed data string. @@ -70,5 +70,5 @@ function bin.pack(format, ...) -- @param init Optional starting position within the string. -- @return Position in the data string where unpacking stopped. -- @return All unpacked values. -function bin.unpack(format, data, init) +function unpack(format, data, init) diff --git a/nselib/bit.luadoc b/nselib/bit.luadoc index ea343a090..0c2ac624a 100644 --- a/nselib/bit.luadoc +++ b/nselib/bit.luadoc @@ -25,45 +25,45 @@ module "bit" --- Cast a to an internal integer type. -- @param a Number. -function bit.cast(a) +function cast(a) --- Returns the one's complement of a. -- @param a Number. -- @return The one's complement of a. -function bit.bnot(a) +function bnot(a) --- Returns the bitwise and of all its arguments. -- @param ... A variable number of Numbers to and. -- @return The anded result. -function bit.band(...) +function band(...) --- Returns the bitwise or of all its arguments. -- @param ... A variable number of Numbers to or. -- @return The ored result. -function bit.bor(...) +function bor(...) --- Returns the bitwise exclusive or of all its arguments. -- @param ... A variable number of Numbers to exclusive or. -- @return The exclusive ored result. -function bit.bxor(...) +function bxor(...) --- Returns a left-shifted by b places. -- @param a Number to perform the shift on. -- @param b Number of shifts. -function bit.lshift(a, b) +function lshift(a, b) --- Returns a right-shifted by b places. -- @param a Number to perform the shift on. -- @param b Number of shifts. -function bit.rshift(a, b) +function rshift(a, b) --- Returns a arithmetically right-shifted by b -- places. -- @param a Number to perform the shift on. -- @param b Number of shifts. -function bit.arshift(a, b) +function arshift(a, b) --- Returns the integer remainder of a divided by b. -- @param a Dividend. -- @param b Divisor. -function bit.mod(a, b) +function mod(a, b) diff --git a/nselib/nmap.luadoc b/nselib/nmap.luadoc index d4af10db5..01fb0696b 100644 --- a/nselib/nmap.luadoc +++ b/nselib/nmap.luadoc @@ -13,20 +13,20 @@ module "nmap" -- The debugging level can be set with the -d option. -- @return The debugging level. -- @usage if nmap.debugging() > 0 then ... end -function nmap.debugging() +function debugging() --- Determines whether Nmap was compiled with SSL support. -- \n\n -- This can be used to avoid sending SSL probes when SSL is not available. -- @return true if Nmap was compiled with SSL support, false otherwise. -function nmap.have_ssl() +function have_ssl() --- Returns the verbosity level as a non-negative integer. -- \n\n -- The verbosity level can be set with the -v option. -- @return The verbosity level. -- @usage if nmap.verbosity() > 0 then ... end -function nmap.verbosity() +function verbosity() --- Searches for the specified file and returns a string containing its path if -- it is found and readable (to the process). @@ -37,13 +37,13 @@ function nmap.verbosity() -- "/usr/local/share/nmap/nmap-rpc". -- @param filename Filename to search for. -- @return String representing the full path to the file or nil. -function nmap.fetchfile(filename) +function fetchfile(filename) --- Returns the timing level as a non-negative integer. Possible return values -- vary from 0 to 5, corresponding to the six built-in Nmap timing templates. -- The timing level can be set with the -T option. -- @return The timing level. -function nmap.timing_level() +function timing_level() --- Gets a port table for a port on a given host. -- \n\n @@ -64,7 +64,7 @@ function nmap.timing_level() -- @param protocol Protocol string ("tcp" or "udp") -- @return A new port table holding the status and information for the port. -- @usage p = nmap.get_port_state({ip="127.0.0.1"}, {number="80", protocol="tcp"}) -function nmap.get_port_state(host, port) +function get_port_state(host, port) --- Sets the state of a port on a given host. -- \n\n @@ -77,7 +77,7 @@ function nmap.get_port_state(host, port) -- @param host Host table, containing an "ip" field. -- @param port Port table, containing "number" and "protocol" fields. -- @param state Port state, like "open" or "closed". -function nmap.set_port_state(host, port, state) +function set_port_state(host, port, state) --- Sets version information on a port. -- \n\n @@ -104,12 +104,13 @@ function nmap.set_port_state(host, port, state) -- any additional version information fields. -- @param probestate The state of the probe: "hardmatched", "softmatched", -- "nomatch", "tcpwrapped", or "incomplete". -function nmap.set_port_version(host, port, probestate) +function set_port_version(host, port, probestate) --- Returns the current date and time in milliseconds. -- @return The number of milliseconds since the epoch (on most systems this is -- 01/01/1970). -function nmap.clock_ms() +-- @usage local now = nmap.clock_ms() +function clock_ms() --- Gets the link-level hardware type of an interface. -- \n\n @@ -118,7 +119,8 @@ function nmap.clock_ms() -- "ethernet", "loopback", "p2p", or nil if none of the other types apply. -- @param interface_name The name of the interface. -- @return "ethernet", "loopback", "p2p", or nil. -function nmap.get_interface_link(interface_name) +-- @usage iface_type = nmap.get_interface_list("eth0") +function get_interface_link(interface_name) --- Create a mutex on an object. -- \n\n @@ -150,7 +152,7 @@ function nmap.get_interface_link(interface_name) -- mutex "done";\n -- return script_output;\n -- end -function nmap.mutex(object) +function mutex(object) --- Creates a new exception handler. -- \n\n @@ -175,7 +177,7 @@ function nmap.mutex(object) -- try(socket:connect(host.ip, port.number))\n -- result = try(socket:receive_lines(1))\n -- try(socket:send(result)) -function nmap.new_try(handler) +function new_try(handler) --- Returns a new NSE socket object. -- \n\n @@ -193,8 +195,9 @@ function nmap.new_try(handler) -- connect-style sending and receiving over TCP and UDP (and SSL), as well as -- raw socket receiving. -- @return A new NSE socket. --- @see nmap.new_dnet -function nmap.new_socket() +-- @see pcap_open +-- @usage local socket = nmap.new_socket() +function new_socket() --- Establishes a connection. -- \n\n @@ -228,7 +231,9 @@ function nmap.new_socket() -- @param protocol "tcp", "udp", or "ssl" (default "tcp"). -- @return Status (true or false). -- @return Error code (if status is false). -function socket:connect(hostid, port, protocol) +-- @see new_socket +-- @usage local status, err = socket:connect(host.ip, port, "udp") +function connect(hostid, port, protocol) --- Sends data on an open socket. -- \n\n @@ -247,7 +252,9 @@ function socket:connect(hostid, port, protocol) -- @param data The data to send. -- @return Status (true or false). -- @return Error code (if status is false). -function socket:send(data) +-- @see new_socket +-- @usage local status, err = socket:send(data) +function send(data) --- Receives data from an open socket. -- \n\n @@ -260,7 +267,9 @@ function socket:send(data) -- send operation. -- @return Status (true or false). -- @return Data (if status is true) or error string (if status is false). -function socket:receive() +-- @see new_socket +-- @usage local status, data = socket:receive() +function receive() --- Receives lines from an open connection. -- \n\n @@ -276,7 +285,9 @@ function socket:receive() -- @param n Minimum number of lines to read. -- @return Status (true or false). -- @return Data (if status is true) or error string (if status is false). -function socket:receive_lines(n) +-- @see new_socket +-- @usage local status, lines = socket:receive_lines(1) +function receive_lines(n) --- Receives bytes from an open connection. -- \n\n @@ -291,7 +302,9 @@ function socket:receive_lines(n) -- @param n Minimum number of bytes to read. -- @return Status (true or false). -- @return Data (if status is true) or error string (if status is false). -function socket:receive_bytes(n) +-- @see new_socket +-- @usage local status, bytes = socket:receive_bytes(1) +function receive_bytes(n) --- Reads from a socket using a buffer and an arbitrary delimiter. -- \n\n @@ -332,7 +345,9 @@ function socket:receive_bytes(n) -- data. -- @return Status (true or false). -- @return Data (if status is true) or error string (if status is false). -function socket:receive_buf(delimiter, keeppattern) +-- @see new_socket +-- @usage local status, line = socket:receive_buf("\r?\n", false) +function receive_buf(delimiter, keeppattern) --- Closes an open connection. -- \n\n @@ -347,7 +362,9 @@ function socket:receive_buf(delimiter, keeppattern) -- difficult to predict, it is considered good practice to close opened sockets. -- @return Status (true or false). -- @return Error code (if status is false). -function socket:close() +-- @see new_socket +-- @usage socket:close() +function close() --- Gets information about a socket. -- \n\n @@ -364,7 +381,9 @@ function socket:close() -- @return Local port number (if status is true). -- @return Remote IP address (if status is true). -- @return Remote port number (if status is true). -function socket:get_info() +-- @see new_socket +-- @usage local status, lhost, lport, rhost, rport = socket:get_info() +function get_info() --- Sets a timeout for socket input and output operations. -- \n\n @@ -372,7 +391,9 @@ function socket:get_info() -- return. The default value is 30,000 (30 seconds). The lowest allowed value is -- 10 ms, since this is the granularity of NSE network I/O. -- @param t Timeout in milliseconds. -function socket:set_timeout(t) +-- @see new_socket +-- @usage socket:set_timeout(10000) +function set_timeout(t) --- Opens a socket for raw packet capture. -- \n\n @@ -390,8 +411,11 @@ function socket:set_timeout(t) -- @param test_function Callback function used to compute the packet hash. -- @param bpf A string describing a Berkeley packet filter expression (like -- those provided to tcpdump). --- @see socket:pcap_register -function socket:pcap_open(device, snaplen, promisc, test_function, bpf) +-- @see new_socket, pcap_register, pcap_receive +-- @usage +-- local socket = nmap.new_socket() +-- socket:pcap_open("eth0", 64, 0, callback, "tcp") +function pcap_open(device, snaplen, promisc, test_function, bpf) --- Starts listening for incoming packages. -- \n\n @@ -400,8 +424,9 @@ function socket:pcap_open(device, snaplen, promisc, test_function, bpf) -- to receive all packets, just provide the empty string (""). There has to be a -- call to pcap_register() before a call to pcap_receive(). -- @param packet_hash A binary string that is compared against packet hashes. --- @see socket:pcap_open -function socket:pcap_register(packet_hash) +-- @see pcap_open, pcap_receive +-- @usage socket:pcap_register("") +function pcap_register(packet_hash) --- Receives a captured packet. -- \n\n @@ -414,20 +439,27 @@ function socket:pcap_register(packet_hash) -- parameter is smaller than the total packet length). -- @return Data from the second OSI layer (e.g. ethernet headers). -- @return Data from the third OSI layer (e.g. IPv4 headers). -function socket:pcap_receive() +-- @see pcap_open, pcap_register +-- @usage status, plen, l2_data, l3_data = socket:pcap_receive() +function pcap_receive() --- Closes the pcap device. -function socket:pcap_close() +-- @see close, pcap_close +-- @usage socket:pcap_close() +function pcap_close() --- Creates a new dnet object, used to send raw packets. -function nmap.new_dnet() +-- @usage local dnet = nmap.new_dnet() +function new_dnet() --- Opens an ethernet interface for raw packet sending. -- \n\n -- An error ("device is not valid ethernet interface") is thrown in case the -- provided argument is not valid. -- @param interface_name The dnet-style name of the interface to open. -function dnet:ethernet_open(interface_name) +-- @see new_dnet +-- @usage dnet:ethernet_open("eth0") +function ethernet_open(interface_name) --- Sends a raw ethernet frame. -- \n\n @@ -436,10 +468,14 @@ function dnet:ethernet_open(interface_name) -- ethernet header. If there was no previous valid call to ethernet_open() an -- error is thrown ("dnet is not valid opened ethernet interface"). -- @param packet -function dnet:ethernet_send(packet) +-- @see new_dnet +-- @usage dnet:ethernet_open(packet) +function ethernet_send(packet) --- Closes an ethernet interface. -- \n\n -- An error ("device is not valid ethernet interface") is thrown in case the -- provided argument is not valid. -function dnet:ethernet_close() +-- @see new_dnet, ethernet_open +-- @usage dnet:ethernet_close() +function ethernet_close() diff --git a/nselib/openssl.luadoc b/nselib/openssl.luadoc index 562966a0d..0f97698d5 100644 --- a/nselib/openssl.luadoc +++ b/nselib/openssl.luadoc @@ -23,101 +23,101 @@ module "openssl" --- Returns the size of bignum in bits. -function openssl.bignum_num_bits(bignum) +function bignum_num_bits(bignum) --- Returns the size of bignum in bytes. -function openssl.bignum_num_bytes(bignum) +function bignum_num_bytes(bignum) --- Sets the bit at position in bignum. -function openssl.bignum_set_bit(bignum, position) +function bignum_set_bit(bignum, position) --- Clears the bit at position in bignum. -function openssl.bignum_clear_bit(bignum, position) +function bignum_clear_bit(bignum, position) --- Gets the state of the bit at position in bignum. -function openssl.bignum_is_bit_set(bignum, position) +function bignum_is_bit_set(bignum, position) --- Sets the sign of bignum. If negative is true the sign becomes negative, -- otherwise it becomes positive. -function openssl.bignum_set_negative(bignum, negative) +function bignum_set_negative(bignum, negative) --- Returns true if bignum is negative, false otherwise. -function openssl.bignum_is_negative(bignum) +function bignum_is_negative(bignum) --- Converts the binary-encoded string into a bignum. -function openssl.bignum_bin2bn(string) +function bignum_bin2bn(string) --- Converts the decimal-encoded string into a bignum. -function openssl.bignum_dec2bn(string) +function bignum_dec2bn(string) --- Converts the hex-encoded string into a bignum. -function openssl.bignum_hex2bn(string) +function bignum_hex2bn(string) --- Converts bignum into a binary-encoded string. -function openssl.bignum_bn2bin(bignum) +function bignum_bn2bin(bignum) --- Converts bignum into a decimal-encoded string. -function openssl.bignum_bn2dec(bignum) +function bignum_bn2dec(bignum) --- Converts bignum into a hex-encoded string. -function openssl.bignum_bn2hex(bignum) +function bignum_bn2hex(bignum) --- Returns a random bignum with a -function openssl.bignum_rand(bits) +function bignum_rand(bits) --- Returns a pseudorandom bignum with a the given size in bits. -function openssl.bignum_pseudo_rand(bits) +function bignum_pseudo_rand(bits) --- Returns the bignum which is the result of a^p mod m. -function openssl.bignum_mod_exp(a, p, m) +function bignum_mod_exp(a, p, m) --- Returns a string of length bytes containing random data. -function openssl.rand_bytes(bytes) +function rand_bytes(bytes) --- Returns a string of length bytes containing pseudorandom data. -function openssl.rand_pseudo_bytes(bytes) +function rand_pseudo_bytes(bytes) --- Returns the MD2 digest of message. -function openssl.md2(message) +function md2(message) --- Returns the MD4 digest of message. -function openssl.md4(message) +function md4(message) --- Returns the MD5 digest of message. -function openssl.md5(message) +function md5(message) --- Returns the SHA-1 digest of message. -function openssl.sha1(message) +function sha1(message) --- Returns the RIPEMD-160 digest of message. -function openssl.ripemd160(message) +function ripemd160(message) --- Returns the digest of message using the algorithm given by the string -- algorithm. The algorithm name may be anything returned by the -- openssl.supported_digests function. -function openssl.digest(algorithm, message) +function digest(algorithm, message) --- Returns the message authentication code of message using the given algorithm -- and key. algorithm may be anything returned by the openssl.supported_digests -- function. -function openssl.hmac(algorithm, key, message) +function hmac(algorithm, key, message) --- Encrypt data with the given algorithm, key, and initialization vector. -- algorithm may be anything returned by the openssl.supported_ciphers function. -- If padding is true then a partial final block will be padded and encrypted. -function openssl.encrypt(algorithm, key, iv, data, padding = false) +function encrypt(algorithm, key, iv, data, padding = false) --- Encrypt data with the given algorithm, key, and initialization vector. -- algorithm may be anything returned by the openssl.supported_ciphers function. -- If padding is true then the final block must be padded correctly. -function openssl.decrypt(algorithm, key, iv, data, padding = false) +function decrypt(algorithm, key, iv, data, padding = false) --- Returns a table with the names of the supported cipher algorithms. -function openssl.supported_ciphers() +function supported_ciphers() --- Returns a table with the names of the supported digest algorithms. -function openssl.supported_digests() +function supported_digests() --- Converts data, which must be a 7-byte string, into an 8-byte DES key and -- sets the parity. -function openssl.DES_string_to_key(string data) +function DES_string_to_key(string data) diff --git a/nselib/pcre.luadoc b/nselib/pcre.luadoc index c9f59ed8d..a7a0d08da 100644 --- a/nselib/pcre.luadoc +++ b/nselib/pcre.luadoc @@ -51,8 +51,8 @@ module "pcre" -- the regular expression (optional). The value is a string which is passed to -- the C standard library function setlocale. For more information on this -- argument refer to the documentation of setlocale. --- @usage my_regex = pcre.new("pcre-pattern",0,"C") -function pcre.new(pattern, flags, locale) +-- @usage local regex = pcre.new("pcre-pattern",0,"C") +function new(pattern, flags, locale) --- Returns a table of the available PCRE option flags (numbers) keyed by their -- names (strings). @@ -61,12 +61,12 @@ function pcre.new(pattern, flags, locale) -- documentation of the PCRE library used to link against Nmap. The key is the -- option name in the manual minus the PCRE prefix. PCRE_CASELESS becomes -- CASELESS for example. -function pcre.flags() +function flags() --- Returns the version of the PCRE library in use as a string. -- \n\n -- For example "6.4 05-Sep-2005". -function pcre.version() +function version() --- Matches a string against a compiled regular expression. -- \n\n @@ -81,9 +81,9 @@ function pcre.version() -- not match. If named sub-patterns were used, the table also contains substring -- matches keyed by their sub-pattern name. -- @usage --- s = pcre_obj:match("string to be searched", 0,0);\n --- if(s) code_to_be_done_on_match end -function pcre_obj:match(string, start, flags) +-- i, j = regex:match("string to be searched", 0, 0) +-- if (i) then ... end +function match(string, start, flags) --- Matches a string against a compiled regular expression, returning positions -- of substring matches. @@ -99,7 +99,10 @@ function pcre_obj:match(string, start, flags) -- @param flags execution flags (optional). -- @return a table which contains a list of substring match start and end -- positions. -function pcre_obj:exec(string, start, flags) +-- @usage +-- i, j, substrings = regex:exec("string to be searched", 0, 0) +-- if (i) then ... end +function exec(string, start, flags) --- Matches a string against a regular expression multiple times. -- \n\n @@ -113,7 +116,12 @@ function pcre_obj:exec(string, start, flags) -- sub-pattern names (strings). If func returns a true value, then gmatch -- immediately returns; gmatch returns the number of matches made. -- @param string the string to match against. +-- @param func the function to call for each match. -- @param n the maximum number of matches to do (optional). -- @param ef execution flags (optional). -- @return the number of matches made. +-- @usage +-- local t = {} +-- local function match(m) t[#t + 1] = m end +-- local n = regex:gmatch("string to be searched", match) function pcre_obj:gmatch(string, func, n, ef)