Skip to content

Commit

Permalink
Remove the nselib-bin directory. Almost all references to it have bee…
Browse files Browse the repository at this point in the history
…n removed

too. The section in scripting.xml about creating C modules is gone. (But maybe
it should be replaced with a tutorial on making static modules?) The only
places where nselib-bin is still referenced are in mswin32/nsis/Nmap.nsi, where
it is still removed on uninstallation; and in mswin32/nmap.vcproj, from where I
don't have the resources now to remove it.
  • Loading branch information
david committed Sep 5, 2008
1 parent 12f272d commit b3eddfe
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 26,229 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

4.69BETA1

o Removed the nselib-bin directory. The last remaining shared NSE
module, bit, has been made static. Shared modules were broken for
static builds of Nmap, such as those in the RPMS. [David]

o Expanded nmap-services to include information on how frequently each
port number is found open. The results were generated by scanning
tens of millions of IPs on the Internet. [Fyodor]
Expand Down
18 changes: 3 additions & 15 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ 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_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_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_bit.o
NSESTDLIB=nsestdlib
endif

export SRCS = main.cc nmap.cc targets.cc tcpip.cc nmap_error.cc utils.cc idle_scan.cc osscan.cc osscan2.cc output.cc scan_engine.cc timing.cc charpool.cc services.cc protocols.cc nmap_rpc.cc portlist.cc NmapOps.cc TargetGroup.cc Target.cc FingerPrintResults.cc service_scan.cc NmapOutputTable.cc MACLookup.cc nmap_tty.cc nmap_dns.cc traceroute.cc portreasons.cc $(NSE_SRC) @COMPAT_SRCS@
Expand All @@ -76,17 +75,13 @@ OBJS = main.o nmap.o targets.o tcpip.o nmap_error.o utils.o idle_scan.o osscan.o
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@

all: @LUA_BUILD@ @PCAP_BUILD@ @PCRE_BUILD@ @DNET_BUILD@ @NBASE_BUILD@ @NSOCK_BUILD@
$(MAKE) $(TARGET) $(NSESTDLIB) $(BUILDZENMAP)
$(MAKE) $(TARGET) $(BUILDZENMAP)

$(TARGET): @LUA_DEPENDS@ @PCAP_DEPENDS@ @PCRE_DEPENDS@ @DNET_DEPENDS@ $(NBASEDIR)/libnbase.a $(NSOCKDIR)/src/libnsock.a $(OBJS)
echo Compiling nmap
rm -f $@
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

nsestdlib: nselib-bin/Makefile
@echo Compiling nse-standard-library; cd nselib-bin && $(MAKE)


pcre_build: $(LIBPCREDIR)/Makefile
@echo Compiling libpcre; cd $(LIBPCREDIR) && $(MAKE)

Expand Down Expand Up @@ -126,7 +121,7 @@ distro:
web:
cd $(NMAPDEVDIR) && $(MAKE) web

clean: @LUA_CLEAN@ @PCAP_CLEAN@ @PCRE_CLEAN@ @DNET_CLEAN@ nsock_clean nbase_clean my_clean @NSELIB_CLEAN@ @ZENMAP_CLEAN@
clean: @LUA_CLEAN@ @PCAP_CLEAN@ @PCRE_CLEAN@ @DNET_CLEAN@ nsock_clean nbase_clean my_clean @ZENMAP_CLEAN@

my_clean:
rm -f dependencies.mk makefile.dep
Expand All @@ -143,8 +138,6 @@ nsock_clean:
-cd $(NSOCKDIR)/src && $(MAKE) clean
lua_clean:
-cd $(LIBLUADIR) && $(MAKE) clean
nselib_clean:
-cd nselib-bin && $(MAKE) clean
zenmap_clean:
-cd $(ZENMAPDIR) && $(PYTHON) setup.py clean --all
pcap_dist_clean:
Expand All @@ -155,8 +148,6 @@ dnet_dist_clean:
-cd $(LIBDNETDIR) && $(MAKE) distclean
lua_dist_clean:
-cd $(LIBLUADIR) && $(MAKE) clean
nselib_dist_clean:
-cd nselib-bin && $(MAKE) distclean
nbase_dist_clean:
-cd $(NBASEDIR) && $(MAKE) distclean
nsock_dist_clean:
Expand All @@ -166,7 +157,7 @@ zenmap_dist_clean: zenmap_clean
debugclean:
rm -f *.gcov *.gcda *.gcno gmon.out

distclean: my_clean my_distclean @LUA_DIST_CLEAN@ @PCAP_DIST_CLEAN@ @PCRE_DIST_CLEAN@ @DNET_DIST_CLEAN@ nbase_dist_clean nsock_dist_clean @NSELIB_DIST_CLEAN@ @ZENMAP_DIST_CLEAN@
distclean: my_clean my_distclean @LUA_DIST_CLEAN@ @PCAP_DIST_CLEAN@ @PCRE_DIST_CLEAN@ @DNET_DIST_CLEAN@ nbase_dist_clean nsock_dist_clean @ZENMAP_DIST_CLEAN@

my_distclean:
rm -f Makefile Makefile.bak makefile.dep nmap_config.h stamp-h stamp-h.in \
Expand Down Expand Up @@ -220,15 +211,12 @@ install-zenmap: $(ZENMAPDIR)/setup.py

NSE_FILES = scripts/script.db scripts/*.nse
NSE_LIB_LUA_FILES = nselib/*.lua
#NSE_LIB_SO_FILES = nselib-bin/*.so

install-nse: $(TARGET)
$(INSTALL) -d $(DESTDIR)$(nmapdatadir)/scripts
cp -f $(NSE_FILES) $(DESTDIR)$(nmapdatadir)/scripts
$(INSTALL) -d $(DESTDIR)$(nmapdatadir)/nselib
cp -f $(NSE_LIB_LUA_FILES) $(DESTDIR)$(nmapdatadir)/nselib
#$(INSTALL) -d $(DESTDIR)$(nmaplibexecdir)/nselib-bin
#cp -f $(NSE_LIB_SO_FILES) $(DESTDIR)$(nmaplibexecdir)/nselib-bin

install: install-nmap $(INSTALLNSE) $(INSTALLZENMAP)
@echo "NMAP SUCCESSFULLY INSTALLED"
Expand Down
16 changes: 1 addition & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,6 @@ LUA_BUILD
LUA_CLEAN
LUA_DIST_CLEAN
INSTALLNSE
NSELIB_CLEAN
NSELIB_DIST_CLEAN
NBASEDIR
NBASE_BUILD
LIBNBASE_LIBS
Expand All @@ -746,7 +744,6 @@ CPP'
ac_subdirs_all='libpcap
libpcre
libdnet-stripped
nselib-bin
nbase
nsock/src'

Expand Down Expand Up @@ -7829,15 +7826,6 @@ echo "${ECHO_T}yes" >&6; }
INSTALLNSE="install-nse"
fi
if test $no_lua != yes; then
subdirs="$subdirs nselib-bin"
NSELIB_CLEAN=nselib_clean
NSELIB_DIST_CLEAN=nselib_dist_clean
fi
Expand Down Expand Up @@ -9438,8 +9426,6 @@ LUA_BUILD!$LUA_BUILD$ac_delim
LUA_CLEAN!$LUA_CLEAN$ac_delim
LUA_DIST_CLEAN!$LUA_DIST_CLEAN$ac_delim
INSTALLNSE!$INSTALLNSE$ac_delim
NSELIB_CLEAN!$NSELIB_CLEAN$ac_delim
NSELIB_DIST_CLEAN!$NSELIB_DIST_CLEAN$ac_delim
NBASEDIR!$NBASEDIR$ac_delim
NBASE_BUILD!$NBASE_BUILD$ac_delim
LIBNBASE_LIBS!$LIBNBASE_LIBS$ac_delim
Expand All @@ -9450,7 +9436,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 20; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 18; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
Expand Down
8 changes: 0 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -574,21 +574,13 @@ else
INSTALLNSE="install-nse"
fi

if test $no_lua != yes; then
AC_CONFIG_SUBDIRS( nselib-bin )
NSELIB_CLEAN=nselib_clean
NSELIB_DIST_CLEAN=nselib_dist_clean
fi

AC_SUBST(LIBLUA_LIBS)
AC_SUBST(LIBLUADIR)
AC_SUBST(LUA_DEPENDS)
AC_SUBST(LUA_BUILD)
AC_SUBST(LUA_CLEAN)
AC_SUBST(LUA_DIST_CLEAN)
AC_SUBST(INSTALLNSE)
AC_SUBST(NSELIB_CLEAN)
AC_SUBST(NSELIB_DIST_CLEAN)
AC_SUBST(CXXFLAGS)

dnl This test is from the configure.in of Unix Network Programming second
Expand Down
64 changes: 0 additions & 64 deletions docs/scripting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4019,69 +4019,5 @@ The mainloop function will work on each runlevel grouping of threads in order.
repeated until no threads exist in either waiting or running.
</para>
</sect2>
<sect2 id="nse-implementation-c-modules">
<title>Adding C Modules to Nselib</title>
<indexterm><primary>Nmap Scripting Engine (NSE)</primary><secondary>C modules</secondary></indexterm>
<para>
This section gives a short walk-through for adding
nselib modules written in C (or C++) to Nmap's build system, since
this has shown to be sometimes tedious. Writing C modules is
described at length in
<web><ulink url="http://www.amazon.com/exec/obidos/ASIN/8590379825/secbks-20"><citetitle>Programming in Lua, Second Edition</citetitle></ulink>.</web>
<print><citetitle>Programming in Lua, Second Edition</citetitle>.</print>
Basically C modules consist of the
functions they provide to Lua, which have to be of type <ulink url="http://www.lua.org/manual/5.1/manual.html#lua_CFunction">lua_CFunction</ulink>. Additionally they have to contain a function
which is used to actually open the module. By convention these function names are <literal>luaopen_<replaceable>modulename</replaceable></literal>.
A good starting point for writing such modules is provided by
<filename>bit.c</filename><indexterm><primary><varname>bit</varname> NSE module</primary></indexterm>
inside
the <filename>nselib-bin/</filename> subdirectory of Nmap's source tree.
<varname>bit</varname> is a C module already provided by the nselib. C modules
basically are shared libraries which get loaded at runtime by Lua.
</para>
<para>
The Unix build system uses <literal>libtool</literal> for
compilation in a platform independent way. As long as the new module
does not depend on foreign libraries, you should only need to add
<literal><replaceable>modulename</replaceable>.so</literal> to the
<literal>all</literal> and <literal>clean</literal> targets in
<filename>Makefile.in</filename>
and copy and adapt the lines from <filename>bit.so</filename>.
If your module does have dependencies you will most probably have to
add checks for those libraries to <filename>configure.ac</filename>
and put the dependencies inside the <literal>libtool</literal>
commands in <filename>Makefile.in</filename>.
</para>

<para>
Of course, theory and practice are rarely the same. Most of
the trouble building nselib actually comes from the
complications of building shared libraries and not nselib
itself. Linking with static libraries
(e.g. <literal>libnbase</literal>) sometimes leads to
problems with exporting symbols on some platforms (in our
case the x86_64-linux platform).<indexterm><primary>x86_64 architecture</primary></indexterm>
To our knowledge no such
problems occur when linking against already existing shared
libraries.</para>

<para>
The Windows build system requires C module developers to create a
MS Visual Studio Project file for their module
(<filename><replaceable>modulename</replaceable>.vcproj</filename>) inside the
<filename>nselib</filename> subdirectory. On Windows you have to
include the <filename>liblua/</filename> subdirectory as
an additional include path as well as a library search path. In addition
you have to tell the project to link against the
<filename>liblua.lib</filename> static library provided with Nmap.
Other properties of the project should be the same as for other
nselib C modules (e.g. see <filename>nse_bitlib.vcproj</filename>).
Afterwards you have to include the newly created project file in
Nmap's Visual Studio solution file
(<filename>mswin32\nmap.sln</filename>) and make sure that
<filename>nse_bitlib.vcproj</filename> depends on your project,
because it is there that nselib modules get copied to their final destinations and are included in Nmap.
</para>
</sect2>
</sect1>
<indexterm class="endofrange" startref="nse-indexterm"/>
1 change: 0 additions & 1 deletion mswin32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ winbuild:
cd Release && cp -f $(NSE_FILES) ../nmap-$(NMAP_VERSION)/scripts/
mkdir nmap-$(NMAP_VERSION)/nselib
cp -a Release/nselib nmap-$(NMAP_VERSION)
cp -a Release/nselib-bin nmap-$(NMAP_VERSION)
cp winpcap/winpcap-nmap-*.exe nmap-$(NMAP_VERSION)
cp vcredist_x86.exe nmap-$(NMAP_VERSION)
zip -r nmap-$(NMAP_VERSION)-win32.zip nmap-$(NMAP_VERSION)
Expand Down
1 change: 0 additions & 1 deletion mswin32/nsis/Nmap.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ Section "Nmap Core Files" SecCore
File ssleay32.dll
File /r /x mswin32 /x .svn ..\..\scripts
File /r /x mswin32 /x .svn ..\Release\nselib
File /r /x mswin32 /x .svn ..\Release\nselib-bin
File ..\icon1.ico

;Store installation folder
Expand Down
30 changes: 0 additions & 30 deletions nselib-bin/Makefile.in

This file was deleted.

Loading

0 comments on commit b3eddfe

Please sign in to comment.