mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 22:21:29 +00:00
Updated NSE's bit library to no longer be a shared library.
See this thread: http://seclists.org/nmap-dev/2008/q3/0404.html
This commit is contained in:
24
Makefile.in
24
Makefile.in
@@ -59,9 +59,9 @@ INSTALLZENMAP=@INSTALLZENMAP@
|
|||||||
UNINSTALLZENMAP=@UNINSTALLZENMAP@
|
UNINSTALLZENMAP=@UNINSTALLZENMAP@
|
||||||
|
|
||||||
ifneq (@LIBLUA_LIBS@,)
|
ifneq (@LIBLUA_LIBS@,)
|
||||||
NSE_SRC=nse_main.cc nse_nsock.cc nse_init.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_binlib.cc nse_hash.cc
|
NSE_SRC=nse_main.cc nse_nsock.cc nse_init.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_binlib.cc nse_hash.cc nse_bit.cc
|
||||||
NSE_HDRS=nse_main.h nse_nsock.h nse_init.h nse_fs.h nse_nmaplib.h nse_debug.h nse_macros.h nse_pcrelib.h nse_binlib.h nse_hash.h
|
NSE_HDRS=nse_main.h nse_nsock.h nse_init.h nse_fs.h nse_nmaplib.h nse_debug.h nse_macros.h nse_pcrelib.h nse_binlib.h nse_hash.h nse_bit.h
|
||||||
NSE_OBJS=nse_main.o nse_nsock.o nse_init.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_binlib.o nse_hash.o
|
NSE_OBJS=nse_main.o nse_nsock.o nse_init.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_binlib.o nse_hash.o nse_bit.o
|
||||||
NSESTDLIB=nsestdlib
|
NSESTDLIB=nsestdlib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ $(TARGET): @LUA_DEPENDS@ @PCAP_DEPENDS@ @PCRE_DEPENDS@ @DNET_DEPENDS@ $(NBASEDIR
|
|||||||
rm -f $@
|
rm -f $@
|
||||||
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||||
|
|
||||||
nsestdlib: nselib-bin/Makefile
|
#nsestdlib: nselib-bin/Makefile
|
||||||
@echo Compiling nse-standard-library; cd nselib-bin && $(MAKE)
|
# @echo Compiling nse-standard-library; cd nselib-bin && $(MAKE)
|
||||||
|
|
||||||
|
|
||||||
pcre_build: $(LIBPCREDIR)/Makefile
|
pcre_build: $(LIBPCREDIR)/Makefile
|
||||||
@@ -143,8 +143,8 @@ nsock_clean:
|
|||||||
-cd $(NSOCKDIR)/src && $(MAKE) clean
|
-cd $(NSOCKDIR)/src && $(MAKE) clean
|
||||||
lua_clean:
|
lua_clean:
|
||||||
-cd $(LIBLUADIR) && $(MAKE) clean
|
-cd $(LIBLUADIR) && $(MAKE) clean
|
||||||
nselib_clean:
|
#nselib_clean:
|
||||||
-cd nselib-bin && $(MAKE) clean
|
# -cd nselib-bin && $(MAKE) clean
|
||||||
zenmap_clean:
|
zenmap_clean:
|
||||||
-cd $(ZENMAPDIR) && $(PYTHON) setup.py clean --all
|
-cd $(ZENMAPDIR) && $(PYTHON) setup.py clean --all
|
||||||
pcap_dist_clean:
|
pcap_dist_clean:
|
||||||
@@ -155,8 +155,8 @@ dnet_dist_clean:
|
|||||||
-cd $(LIBDNETDIR) && $(MAKE) distclean
|
-cd $(LIBDNETDIR) && $(MAKE) distclean
|
||||||
lua_dist_clean:
|
lua_dist_clean:
|
||||||
-cd $(LIBLUADIR) && $(MAKE) clean
|
-cd $(LIBLUADIR) && $(MAKE) clean
|
||||||
nselib_dist_clean:
|
#nselib_dist_clean:
|
||||||
-cd nselib-bin && $(MAKE) distclean
|
#-cd nselib-bin && $(MAKE) distclean
|
||||||
nbase_dist_clean:
|
nbase_dist_clean:
|
||||||
-cd $(NBASEDIR) && $(MAKE) distclean
|
-cd $(NBASEDIR) && $(MAKE) distclean
|
||||||
nsock_dist_clean:
|
nsock_dist_clean:
|
||||||
@@ -220,15 +220,15 @@ install-zenmap: $(ZENMAPDIR)/setup.py
|
|||||||
|
|
||||||
NSE_FILES = scripts/script.db scripts/*.nse
|
NSE_FILES = scripts/script.db scripts/*.nse
|
||||||
NSE_LIB_LUA_FILES = nselib/*.lua
|
NSE_LIB_LUA_FILES = nselib/*.lua
|
||||||
NSE_LIB_SO_FILES = nselib-bin/*.so
|
#NSE_LIB_SO_FILES = nselib-bin/*.so
|
||||||
|
|
||||||
install-nse: $(TARGET)
|
install-nse: $(TARGET)
|
||||||
$(INSTALL) -d $(DESTDIR)$(nmapdatadir)/scripts
|
$(INSTALL) -d $(DESTDIR)$(nmapdatadir)/scripts
|
||||||
cp -f $(NSE_FILES) $(DESTDIR)$(nmapdatadir)/scripts
|
cp -f $(NSE_FILES) $(DESTDIR)$(nmapdatadir)/scripts
|
||||||
$(INSTALL) -d $(DESTDIR)$(nmapdatadir)/nselib
|
$(INSTALL) -d $(DESTDIR)$(nmapdatadir)/nselib
|
||||||
cp -f $(NSE_LIB_LUA_FILES) $(DESTDIR)$(nmapdatadir)/nselib
|
cp -f $(NSE_LIB_LUA_FILES) $(DESTDIR)$(nmapdatadir)/nselib
|
||||||
$(INSTALL) -d $(DESTDIR)$(nmaplibexecdir)/nselib-bin
|
#$(INSTALL) -d $(DESTDIR)$(nmaplibexecdir)/nselib-bin
|
||||||
cp -f $(NSE_LIB_SO_FILES) $(DESTDIR)$(nmaplibexecdir)/nselib-bin
|
#cp -f $(NSE_LIB_SO_FILES) $(DESTDIR)$(nmaplibexecdir)/nselib-bin
|
||||||
|
|
||||||
install: install-nmap $(INSTALLNSE) $(INSTALLZENMAP)
|
install: install-nmap $(INSTALLNSE) $(INSTALLZENMAP)
|
||||||
@echo "NMAP SUCCESSFULLY INSTALLED"
|
@echo "NMAP SUCCESSFULLY INSTALLED"
|
||||||
|
|||||||
@@ -294,6 +294,9 @@
|
|||||||
RelativePath="..\nse_hash.cc"
|
RelativePath="..\nse_hash.cc"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\nse_bit.cc"
|
||||||
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\osscan.cc"
|
RelativePath="..\osscan.cc"
|
||||||
>
|
>
|
||||||
@@ -487,6 +490,10 @@
|
|||||||
RelativePath="..\nse_hash.h"
|
RelativePath="..\nse_hash.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\nse_bit.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\osscan.h"
|
RelativePath="..\osscan.h"
|
||||||
>
|
>
|
||||||
|
|||||||
70
nse_bit.cc
Normal file
70
nse_bit.cc
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/* Bitwise operations library
|
||||||
|
* by Reuben Thomas (rrt@sc3d.org)
|
||||||
|
* bitlib is a C library for Lua 5.x that provides bitwise operations
|
||||||
|
* It is copyright Reuben Thomas 2000-2006, and is released under the
|
||||||
|
* MIT license, like Lua (see http://www.lua.org/copyright.html for the
|
||||||
|
* full license; it's basically the same as the BSD license). There is no
|
||||||
|
* warranty.
|
||||||
|
* the most recent copy can be found at http://rrt.sc3d.org/Software/Lua/
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "nse_bit.h"
|
||||||
|
|
||||||
|
typedef long long Integer;
|
||||||
|
typedef unsigned long long UInteger;
|
||||||
|
|
||||||
|
#define luaL_checkbit(L, n) ((Integer)luaL_checknumber(L, n))
|
||||||
|
#define luaL_checkubit(L, n) ((UInteger)luaL_checkbit(L, n))
|
||||||
|
|
||||||
|
#define TDYADIC(name, op, checkbit1, checkbit2) \
|
||||||
|
static int bit_ ## name(lua_State* L) { \
|
||||||
|
lua_pushnumber(L, \
|
||||||
|
(lua_Number)(checkbit1(L, 1) op checkbit2(L, 2))); \
|
||||||
|
return 1; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DYADIC(name, op) \
|
||||||
|
TDYADIC(name, op, luaL_checkbit, luaL_checkbit)
|
||||||
|
|
||||||
|
#define MONADIC(name, op) \
|
||||||
|
static int bit_ ## name(lua_State* L) { \
|
||||||
|
lua_pushnumber(L, (lua_Number)(op luaL_checkbit(L, 1))); \
|
||||||
|
return 1; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define VARIADIC(name, op) \
|
||||||
|
static int bit_ ## name(lua_State *L) { \
|
||||||
|
int n = lua_gettop(L), i; \
|
||||||
|
Integer w = luaL_checkbit(L, 1); \
|
||||||
|
for (i = 2; i <= n; i++) \
|
||||||
|
w op luaL_checkbit(L, i); \
|
||||||
|
lua_pushnumber(L, (lua_Number)w); \
|
||||||
|
return 1; \
|
||||||
|
}
|
||||||
|
|
||||||
|
MONADIC(bnot, ~)
|
||||||
|
VARIADIC(band, &=)
|
||||||
|
VARIADIC(bor, |=)
|
||||||
|
VARIADIC(bxor, ^=)
|
||||||
|
TDYADIC(lshift, <<, luaL_checkbit, luaL_checkubit)
|
||||||
|
TDYADIC(rshift, >>, luaL_checkubit, luaL_checkubit)
|
||||||
|
TDYADIC(arshift, >>, luaL_checkbit, luaL_checkubit)
|
||||||
|
DYADIC(mod, %)
|
||||||
|
|
||||||
|
static const struct luaL_reg bitlib[] = {
|
||||||
|
{"bnot", bit_bnot},
|
||||||
|
{"band", bit_band},
|
||||||
|
{"bor", bit_bor},
|
||||||
|
{"bxor", bit_bxor},
|
||||||
|
{"lshift", bit_lshift},
|
||||||
|
{"rshift", bit_rshift},
|
||||||
|
{"arshift", bit_arshift},
|
||||||
|
{"mod", bit_mod},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUALIB_API int luaopen_bit(lua_State *L) {
|
||||||
|
luaL_openlib(L, BITLIBNAME, bitlib, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
14
nse_bit.h
Normal file
14
nse_bit.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef BITLIB
|
||||||
|
#define BITLIB
|
||||||
|
|
||||||
|
#define BITLIBNAME "bit"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "lauxlib.h"
|
||||||
|
#include "lua.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
LUALIB_API int luaopen_bit(lua_State *L);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
// 3rd Party libs
|
// 3rd Party libs
|
||||||
#include "nse_pcrelib.h"
|
#include "nse_pcrelib.h"
|
||||||
|
#include "nse_bit.h"
|
||||||
|
|
||||||
#include "nse_binlib.h"
|
#include "nse_binlib.h"
|
||||||
#include "nse_hash.h"
|
#include "nse_hash.h"
|
||||||
@@ -218,9 +219,10 @@ int init_lua (lua_State *L)
|
|||||||
int i;
|
int i;
|
||||||
static const luaL_Reg libs[] = {
|
static const luaL_Reg libs[] = {
|
||||||
{NSE_PCRELIBNAME, luaopen_pcrelib}, // pcre library
|
{NSE_PCRELIBNAME, luaopen_pcrelib}, // pcre library
|
||||||
{"nmap", luaopen_nmap} // nmap bindings
|
{"nmap", luaopen_nmap}, // nmap bindings
|
||||||
,{NSE_BINLIBNAME, luaopen_binlib}
|
{NSE_BINLIBNAME, luaopen_binlib},
|
||||||
,{NSE_HASHLIBNAME, luaopen_hashlib}
|
{NSE_HASHLIBNAME, luaopen_hashlib},
|
||||||
|
{BITLIBNAME, luaopen_bit}, // bit library
|
||||||
};
|
};
|
||||||
|
|
||||||
luaL_openlibs(L); // opens all standard libraries
|
luaL_openlibs(L); // opens all standard libraries
|
||||||
|
|||||||
Reference in New Issue
Block a user