1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00
Files
nmap/nse_main.h
batrick 7f5ec526fe Merge branch 'nse-lua53'
Lua 5.3 adds several awesome features of particular interest to nmap including
bitwise operators and integers, a utf8 library, and standard binary pack/unpack
functions.

In addition to adding Lua 5.3, this branch changes:

o Complete removal of the NSE bit library (in C), It has been replaced with
  a new Lua library wrapping Lua 5.3's bit-wise operators.

o Complete removal of the NSE bin library (in C). It has been replaced with a
  new Lua library wrapping Lua 5.3's string.pack|unpack functions.

o The bin.pack "B" format specifier (which has never worked correctly) is
  unimplemented.  All scripts/libraries which use it have been updated. Most
  usage of this option was to allow string based bit-wise operations which are no
  longer necessary now that Lua 5.3 provides integers and bit-wise operators.

o The base32/base64 libraries have been reimplemented using Lua 5.3's new
  bitwise operators. (This library was the main user of the bin.pack "B" format
  specifier.)

o A new "bits" library has been added for common bit hacks. Currently only has
  a reverse function.

Thanks to David Fifield, Daniel Miller, Jacek Wielemborek, and  Paulino
Calderon for testing this branch.
2016-07-02 17:02:27 +00:00

75 lines
1.8 KiB
C++

#ifndef NMAP_LUA_H
#define NMAP_LUA_H
#include <vector>
#include <list>
#include <string>
extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
#include "nmap.h"
class ScriptResult
{
private:
std::string id;
/* Structured output table, an integer ref in L_NSE[LUA_REGISTRYINDEX]. */
int output_ref;
/* Unstructured output string, for scripts that do not return a structured
table, or return a string in addition to a table. */
std::string output_str;
public:
ScriptResult() {
output_ref = LUA_NOREF;
}
void clear (void);
void set_output_tab (lua_State *, int);
void set_output_str (const char *);
void set_output_str (const char *, size_t);
std::string get_output_str (void) const;
void set_id (const char *);
const char *get_id (void) const;
void write_xml() const;
};
typedef std::list<ScriptResult> ScriptResults;
/* Call this to get a ScriptResults object which can be
* used to store Pre-Scan and Post-Scan script Results */
ScriptResults *get_script_scan_results_obj (void);
class Target;
/* API */
int nse_yield (lua_State *, lua_KContext, lua_KFunction);
void nse_restore (lua_State *, int);
void nse_destructor (lua_State *, char);
void nse_base (lua_State *);
void nse_selectedbyname (lua_State *);
void nse_gettarget (lua_State *, int);
void open_nse (void);
void script_scan (std::vector<Target *> &targets, stype scantype);
void close_nse (void);
#define SCRIPT_ENGINE "NSE"
#ifdef WIN32
# define SCRIPT_ENGINE_LUA_DIR "scripts\\"
# define SCRIPT_ENGINE_LIB_DIR "nselib\\"
#else
# define SCRIPT_ENGINE_LUA_DIR "scripts/"
# define SCRIPT_ENGINE_LIB_DIR "nselib/"
#endif
#define SCRIPT_ENGINE_DATABASE SCRIPT_ENGINE_LUA_DIR "script.db"
#define SCRIPT_ENGINE_EXTENSION ".nse"
#endif