Skip to content

Commit

Permalink
Merge branch 'nse-lua53'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
batrick committed Jul 2, 2016
1 parent 0f22680 commit 7f5ec52
Show file tree
Hide file tree
Showing 120 changed files with 9,896 additions and 6,256 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ UNINSTALLNDIFF=@UNINSTALLNDIFF@
UNINSTALLNPING=@UNINSTALLNPING@

ifneq (@LIBLUA_LIBS@,)
NSE_SRC=nse_main.cc nse_utility.cc nse_nsock.cc nse_dnet.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_binlib.cc nse_bit.cc nse_lpeg.cc
NSE_HDRS=nse_main.h nse_utility.h nse_nsock.h nse_dnet.h nse_fs.h nse_nmaplib.h nse_debug.h nse_pcrelib.h nse_binlib.h nse_bit.h nse_lpeg.h
NSE_OBJS=nse_main.o nse_utility.o nse_nsock.o nse_dnet.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_binlib.o nse_bit.o nse_lpeg.o
NSE_SRC=nse_main.cc nse_utility.cc nse_nsock.cc nse_dnet.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_lpeg.cc
NSE_HDRS=nse_main.h nse_utility.h nse_nsock.h nse_dnet.h nse_fs.h nse_nmaplib.h nse_debug.h nse_pcrelib.h nse_lpeg.h
NSE_OBJS=nse_main.o nse_utility.o nse_nsock.o nse_dnet.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_lpeg.o
ifneq (@OPENSSL_LIBS@,)
NSE_SRC+=nse_openssl.cc nse_ssl_cert.cc
NSE_HDRS+=nse_openssl.h nse_ssl_cert.h
Expand Down
80 changes: 40 additions & 40 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -6663,21 +6663,21 @@ else

# If they didn't specify it, we try to find it
if test $have_lua != yes; then
for ac_header in lua.h lua/lua.h lua5.2/lua.h
for ac_header in lua5.3/lua.h lua/5.3/lua.h lua.h lua/lua.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_yieldk in -llua" >&5
$as_echo_n "checking for lua_yieldk in -llua... " >&6; }
if ${ac_cv_lib_lua_lua_yieldk+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_isyieldable in -llua5.3" >&5
$as_echo_n "checking for lua_isyieldable in -llua5.3... " >&6; }
if ${ac_cv_lib_lua5_3_lua_isyieldable+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llua -lm $LIBS"
LIBS="-llua5.3 -lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -6687,37 +6687,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
char lua_yieldk ();
char lua_isyieldable ();
int
main ()
{
return lua_yieldk ();
return lua_isyieldable ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lua_lua_yieldk=yes
ac_cv_lib_lua5_3_lua_isyieldable=yes
else
ac_cv_lib_lua_lua_yieldk=no
ac_cv_lib_lua5_3_lua_isyieldable=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_lua_yieldk" >&5
$as_echo "$ac_cv_lib_lua_lua_yieldk" >&6; }
if test "x$ac_cv_lib_lua_lua_yieldk" = xyes; then :
have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua5_3_lua_isyieldable" >&5
$as_echo "$ac_cv_lib_lua5_3_lua_isyieldable" >&6; }
if test "x$ac_cv_lib_lua5_3_lua_isyieldable" = xyes; then :
have_lua=yes; LIBLUA_LIBS="-llua5.3"; CPPFLAGS="-I/usr/include/lua5.3 $CPPFLAGS"; break
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_yieldk in -llua52" >&5
$as_echo_n "checking for lua_yieldk in -llua52... " >&6; }
if ${ac_cv_lib_lua52_lua_yieldk+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_isyieldable in -llua53" >&5
$as_echo_n "checking for lua_isyieldable in -llua53... " >&6; }
if ${ac_cv_lib_lua53_lua_isyieldable+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llua52 -lm $LIBS"
LIBS="-llua53 -lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -6727,37 +6727,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
char lua_yieldk ();
char lua_isyieldable ();
int
main ()
{
return lua_yieldk ();
return lua_isyieldable ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lua52_lua_yieldk=yes
ac_cv_lib_lua53_lua_isyieldable=yes
else
ac_cv_lib_lua52_lua_yieldk=no
ac_cv_lib_lua53_lua_isyieldable=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua52_lua_yieldk" >&5
$as_echo "$ac_cv_lib_lua52_lua_yieldk" >&6; }
if test "x$ac_cv_lib_lua52_lua_yieldk" = xyes; then :
have_lua=yes; LIBLUA_LIBS="-llua52"; CPPFLAGS="-I/usr/include/lua52 $CPPFLAGS"; break
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua53_lua_isyieldable" >&5
$as_echo "$ac_cv_lib_lua53_lua_isyieldable" >&6; }
if test "x$ac_cv_lib_lua53_lua_isyieldable" = xyes; then :
have_lua=yes; LIBLUA_LIBS="-llua53"; CPPFLAGS="-I/usr/include/lua53 $CPPFLAGS"; break
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_yieldk in -llua5.2" >&5
$as_echo_n "checking for lua_yieldk in -llua5.2... " >&6; }
if ${ac_cv_lib_lua5_2_lua_yieldk+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_isyieldable in -llua" >&5
$as_echo_n "checking for lua_isyieldable in -llua... " >&6; }
if ${ac_cv_lib_lua_lua_isyieldable+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llua5.2 -lm $LIBS"
LIBS="-llua -lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -6767,28 +6767,28 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
char lua_yieldk ();
char lua_isyieldable ();
int
main ()
{
return lua_yieldk ();
return lua_isyieldable ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lua5_2_lua_yieldk=yes
ac_cv_lib_lua_lua_isyieldable=yes
else
ac_cv_lib_lua5_2_lua_yieldk=no
ac_cv_lib_lua_lua_isyieldable=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua5_2_lua_yieldk" >&5
$as_echo "$ac_cv_lib_lua5_2_lua_yieldk" >&6; }
if test "x$ac_cv_lib_lua5_2_lua_yieldk" = xyes; then :
have_lua=yes; LIBLUA_LIBS="-llua5.2"; CPPFLAGS="-I/usr/include/lua5.2 $CPPFLAGS"; break
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_lua_isyieldable" >&5
$as_echo "$ac_cv_lib_lua_lua_isyieldable" >&6; }
if test "x$ac_cv_lib_lua_lua_isyieldable" = xyes; then :
have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break
fi


Expand All @@ -6804,8 +6804,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

# We need Lua 5.2 exactly
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua version == 502" >&5
$as_echo_n "checking for lua version == 502... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua version == 503" >&5
$as_echo_n "checking for lua version == 503... " >&6; }

if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: cross-compiling -- assuming yes" >&5
Expand All @@ -6817,7 +6817,7 @@ else
int
main ()
{
if(LUA_VERSION_NUM != 502) return 1;
if(LUA_VERSION_NUM != 503) return 1;
;
return 0;
}
Expand Down
12 changes: 6 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -635,18 +635,18 @@ else

# If they didn't specify it, we try to find it
if test $have_lua != yes; then
AC_CHECK_HEADERS([lua.h lua/lua.h lua5.2/lua.h],
AC_CHECK_LIB(lua, lua_yieldk, [have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break],, [-lm])
AC_CHECK_LIB(lua52, lua_yieldk, [have_lua=yes; LIBLUA_LIBS="-llua52"; CPPFLAGS="-I/usr/include/lua52 $CPPFLAGS"; break],, [-lm])
AC_CHECK_LIB(lua5.2, lua_yieldk, [have_lua=yes; LIBLUA_LIBS="-llua5.2"; CPPFLAGS="-I/usr/include/lua5.2 $CPPFLAGS"; break],, [-lm])
AC_CHECK_HEADERS([lua5.3/lua.h lua/5.3/lua.h lua.h lua/lua.h],
AC_CHECK_LIB(lua5.3, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua5.3"; CPPFLAGS="-I/usr/include/lua5.3 $CPPFLAGS"; break],, [-lm])
AC_CHECK_LIB(lua53, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua53"; CPPFLAGS="-I/usr/include/lua53 $CPPFLAGS"; break],, [-lm])
AC_CHECK_LIB(lua, lua_isyieldable, [have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break],, [-lm])
)

AC_LANG_PUSH(C++)
# We need Lua 5.2 exactly
AC_MSG_CHECKING([for lua version == 502])
AC_MSG_CHECKING([for lua version == 503])
AC_RUN_IFELSE([ AC_LANG_PROGRAM(
[[#include <lua.h>]],
[[if(LUA_VERSION_NUM != 502) return 1;]])],
[[if(LUA_VERSION_NUM != 503) return 1;]])],
have_lua=yes, have_lua=no, AC_MSG_RESULT(cross-compiling -- assuming yes); have_lua=yes)
AC_LANG_POP(C++)

Expand Down
10 changes: 3 additions & 7 deletions docs/scripting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1547,15 +1547,11 @@ details of how different return values are handled.
</para>

<para>
The smallest compiled module that comes with NSE is
<literal>bit</literal>,<indexterm><primary><varname>bit</varname> NSE library</primary></indexterm>
and one of the most straightforward is
The most straightforward compiled module that comes with NSE is
<literal>openssl</literal>.<indexterm><primary><varname>openssl</varname> NSE library</primary></indexterm>
These modules serve as good examples for a beginning module
This module serves as a good example for a beginning module
writer. The
source code for <literal>bit</literal> is found in
<filename>nse_bit.cc</filename> and
<filename>nse_bit.h</filename>, while the
source code for
<literal>openssl</literal> source is in <filename>nse_openssl.cc</filename> and
<filename>nse_openssl.h</filename>. Most of the other compiled modules
follow this <literal>nse_<replaceable>module name</replaceable>.cc</literal> naming convention.
Expand Down
Loading

0 comments on commit 7f5ec52

Please sign in to comment.