mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Here is a mostly exhaustive list of the changes: o Removes the SCRIPT_ENGINE_* status defines and replaces the instances with regular boolean integer returns or changes the procedure to return void. The latter case is better generally because the caller ignores any status return (e.g. nmap.cc calling open_nse) and/or the procedure raises a fatal error when unsuccessful. o Moves the SCRIPT_ENGINE_LUA_DIR and the like to the nse_main.h header file. o Removes the use of the SCRIPT_ENGINE_TRY (there was only one left) and thus changes the call to l_dnet_open to a void function called directly by luaopen_nsock (in nse_nsock.cc) instead of luaopen_nmap (in nse_nmaplib.cc). I felt moving the function was also an appropriate (but somewhat unrelated to the intent of the patch) change as opening the dnet metatable is very related to opening up the nsock library. This confines errors in opening the nsock library, including opening the dnet metatable, to the call to luaopen_nsock. o The FILES and DIRS defines are moved in to nse_fs.h where they are more appropriate and localalized.
57 lines
1.0 KiB
C++
57 lines
1.0 KiB
C++
#ifndef NMAP_LUA_H
|
|
#define NMAP_LUA_H
|
|
|
|
#include <vector>
|
|
#include <list>
|
|
#include <string>
|
|
#include <string.h>
|
|
#include <iostream>
|
|
|
|
extern "C" {
|
|
#include "lua.h"
|
|
#include "lualib.h"
|
|
#include "lauxlib.h"
|
|
}
|
|
|
|
class ScriptResult
|
|
{
|
|
private:
|
|
std::string output;
|
|
std::string id;
|
|
public:
|
|
void set_output (const char *);
|
|
std::string get_output (void);
|
|
void set_id (const char *);
|
|
std::string get_id (void);
|
|
};
|
|
|
|
typedef std::vector<ScriptResult> ScriptResults;
|
|
|
|
class Target;
|
|
|
|
|
|
/* API */
|
|
void nse_restore (lua_State *, int);
|
|
void nse_destructor (lua_State *, char);
|
|
|
|
void open_nse (void);
|
|
void script_scan (std::vector<Target *> &targets);
|
|
void close_nse (void);
|
|
|
|
int script_updatedb (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.db"
|
|
#define SCRIPT_ENGINE_EXTENSION ".nse"
|
|
|
|
#endif
|