mirror of
https://github.com/nmap/nmap.git
synced 2026-01-10 00:19:02 +00:00
Added the nmap.get_ttl() which returns the TTL (time to live) specified with the --ttl option;
Added the nmap.get_payload_length() function which returns the value specified with the --data-length option
This commit is contained in:
@@ -753,6 +753,32 @@ static int l_get_interface (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return the ttl (time to live) specified with the
|
||||
* --ttl command line option. If a wrong value is
|
||||
* specified it defaults to 64.
|
||||
*/
|
||||
static int l_get_ttl (lua_State *L)
|
||||
{
|
||||
if (o.ttl < 0 || o.ttl > 255)
|
||||
lua_pushnumber(L, 64); //default TTL
|
||||
else
|
||||
lua_pushnumber(L, o.ttl);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return the payload length specified by the --data-length
|
||||
* command line option. If it * isn't specified or the value
|
||||
* is out of range then the default value (0) is returned.
|
||||
*/
|
||||
static int l_get_payload_length(lua_State *L)
|
||||
{
|
||||
if (o.extra_payload_length < 0)
|
||||
lua_pushnumber(L, 0); //default payload length
|
||||
else
|
||||
lua_pushnumber(L, o.extra_payload_length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int luaopen_nmap (lua_State *L)
|
||||
{
|
||||
static const luaL_reg nmaplib [] = {
|
||||
@@ -780,6 +806,8 @@ int luaopen_nmap (lua_State *L)
|
||||
{"address_family", l_address_family},
|
||||
{"get_interface", l_get_interface},
|
||||
{"get_interface_info", l_dnet_get_interface_info},
|
||||
{"get_ttl", l_get_ttl},
|
||||
{"get_payload_length",l_get_payload_length},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -101,6 +101,28 @@ function get_interface()
|
||||
-- @usage local iface, err = nmap.get_interface_info("eth0")
|
||||
function get_interface_info(interface_name)
|
||||
|
||||
--- Returns the TTL (time to live) value selected by the --ttl option
|
||||
--
|
||||
-- If there is no value specified or if the value specified with the --ttl
|
||||
-- option is out of the range 0 to 255 (inclusive) this function returns 64,
|
||||
-- which is the default TTL for an IP packet. This function would be most
|
||||
-- useful in crafting packets, which we want to comply with the selected
|
||||
-- Nmap TTL value.
|
||||
--
|
||||
-- @return A number containing the TTL value
|
||||
-- @usage local ttl = nmap.get_ttl()
|
||||
function get_ttl()
|
||||
|
||||
--- Returns the payload data length selected with the --data-length option
|
||||
--
|
||||
-- Used when a script is crafting ICMP packets and needs to comply with the
|
||||
-- selected payload data length. If there is no value specified this function
|
||||
-- returns 0 which is the default length of the ICMP payload for Nmap.
|
||||
--
|
||||
-- @return A number containing the value of the payload length
|
||||
-- @usage local payload_length = nmap.get_payload_length
|
||||
function get_payload_length()
|
||||
|
||||
--- Searches for the specified file and returns a string containing its path if
|
||||
-- it is found and readable (to the process).
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user