1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

revert the previous commit, git-svn pushed it to the wrong directory.

This commit is contained in:
d33tah
2013-06-13 15:10:07 +00:00
parent 3e3e87f462
commit e9c6e5b925
7 changed files with 13 additions and 203 deletions

View File

@@ -59,11 +59,6 @@ STRIP = @STRIP@
OPENSSL_LIBS = @OPENSSL_LIBS@ OPENSSL_LIBS = @OPENSSL_LIBS@
HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_OPENSSL = @HAVE_OPENSSL@
PCAP_LIBS = @PCAP_LIBS@ PCAP_LIBS = @PCAP_LIBS@
HAVE_LUA = @LIBLUA_LIBS@
LUA_LIBS = @LIBLUA_LIBS@
LIBLUADIR = @LIBLUADIR@
LUA_CFLAGS = @LUA_CFLAGS@
CPPFLAGS += $(DEFS) $(INCLS) CPPFLAGS += $(DEFS) $(INCLS)
@@ -83,13 +78,6 @@ OBJS += http_digest.o
DATAFILES = certs/ca-bundle.crt DATAFILES = certs/ca-bundle.crt
endif endif
ifneq ($(HAVE_LUA),)
SRCS += ncat_lua.c
OBJS += ncat_lua.o
LUA_LIBS += -lm #a quick hack
LUA_CFLAGS += -DHAVE_LUA=1
endif
TARGET = ncat TARGET = ncat
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h CONFIG_HEADER = config.h
@@ -100,17 +88,13 @@ ifneq ($(HAVE_OPENSSL),)
TEST_PROGS += test/test-wildcard TEST_PROGS += test/test-wildcard
endif endif
all: @LUA_BUILD@ $(TARGET) $(TEST_PROGS) all: $(TARGET) $(TEST_PROGS)
lua_build: $(LIBLUADIR)/Makefile $(TARGET): $(OBJS) $(NSOCKLIB)
@echo Compiling liblua; cd $(LIBLUADIR) && $(MAKE) liblua.a CC="$(CC)" MYCFLAGS="$(CFLAGS) $(LUA_CFLAGS)" $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(NSOCKLIB) $(NBASELIB) $(OPENSSL_LIBS) $(PCAP_LIBS) $(LIBS)
$(TARGET): @LUA_DEPENDS@ $(OBJS) $(NSOCKLIB)
$(CC) -o $@ $(CFLAGS) $(lua_cflags) $(LDFLAGS) $(OBJS) $(NSOCKLIB) $(NBASELIB) $(OPENSSL_LIBS) $(PCAP_LIBS) $(LUA_LIBS) $(LIBS)
%.o: %.c %.o: %.c
$(CC) $(CPPFLAGS) $(LUA_CFLAGS) $(CFLAGS) -c $< -o $@ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \ cd $(top_builddir) \
@@ -174,15 +158,9 @@ uninstall:
ncat_clean: ncat_clean:
$(RM) -f *.o test/*.o $(TARGET) $(TEST_PROGS) $(RM) -f *.o test/*.o $(TARGET) $(TEST_PROGS)
clean: ncat_clean @LUA_CLEAN@ clean: ncat_clean
lua_clean: distclean: clean
-cd $(LIBLUADIR) && $(MAKE) clean
lua_dist_clean:
-cd $(LIBLUADIR) && $(MAKE) clean
distclean: clean @LUA_DIST_CLEAN@
-rm -f Makefile makefile.dep $(CONFIG_CLEAN_FILES) -rm -f Makefile makefile.dep $(CONFIG_CLEAN_FILES)
TESTS = ./test-addrset.sh ./test-cmdline-split ./test-uri TESTS = ./test-addrset.sh ./test-cmdline-split ./test-uri

View File

@@ -203,113 +203,10 @@ AC_CHECK_LIB(odm, odm_initialize)
AC_CHECK_LIB(odm, odm_initialize) AC_CHECK_LIB(odm, odm_initialize)
AC_CHECK_LIB(cfg, _system_configuration) AC_CHECK_LIB(cfg, _system_configuration)
LIBLUADIR=../liblua
have_lua=no
requested_included_lua=no
no_lua=no
# First we test whether they specified liblua explicitly
AC_ARG_WITH(liblua,
AC_HELP_STRING([--with-liblua=DIR], [Use an existing (compiled) lua lib from DIR/include and DIR/lib.])
AC_HELP_STRING([--with-liblua=included], [Use the liblua version included with Nmap])
AC_HELP_STRING([--without-liblua], [Compile without lua (this will exclude all of NSE from compilation)]),
[ case "$with_liblua" in
yes)
;;
included)
CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS"
LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
LUA_BUILD="lua_build"
LUA_CLEAN="lua_clean"
LUA_DIST_CLEAN="lua_dist_clean"
have_lua="yes"
;;
no)
no_lua="yes"
;;
*)
CPPFLAGS="-I$with_liblua/include $CPPFLAGS"
LDFLAGS="-L$with_liblua/lib $LDFLAGS"
;;
esac]
)
LUA_CFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN"
AC_SUBST(LUA_CFLAGS)
# OpenSSL and NSE C modules can require dlopen
AC_SEARCH_LIBS(dlopen, dl)
# They don't want lua
if test "$no_lua" = "yes"; then
CPPFLAGS="-DNOLUA $CPPFLAGS"
LIBLUA_LIBS=""
LUA_DEPENDS=""
LUA_BUILD=""
LUA_CLEAN=""
LUA_DIST_CLEAN=""
INSTALLNSE=""
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_LANG_PUSH(C++)
AC_MSG_CHECKING([for lua version >= 502])
AC_RUN_IFELSE([ AC_LANG_PROGRAM(
[[#include <lua.h>]],
[[if(LUA_VERSION_NUM < 502) return 1;]])],
have_lua=yes, have_lua=no, AC_MSG_RESULT(cross-compiling -- assuming yes); have_lua=yes)
AC_LANG_POP(C++)
LUA_DEPENDS=""
LUA_BUILD=""
LUA_CLEAN=""
LUA_DIST_CLEAN=""
fi
# if we didn't find we use our own
if test $have_lua != yes; then
AC_MSG_RESULT(no)
CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS"
LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a"
LUA_BUILD="lua_build"
LUA_CLEAN="lua_clean"
LUA_DIST_CLEAN="lua_dist_clean"
AC_DEFINE(LUA_INCLUDED)
else
AC_MSG_RESULT(yes)
fi
INSTALLNSE="install-nse"
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_CONFIG_FILES(Makefile) AC_CONFIG_FILES(Makefile)
AC_OUTPUT AC_OUTPUT
# NCAT ASCII ART # NCAT ASCII ART
if test -f docs/ncat-ascii-art.txt; then if test -f docs/ncat-ascii-art.txt; then
cat docs/ncat-ascii-art.txt cat docs/ncat-ascii-art.txt
fi fi
echo "Configuration complete." echo "Configuration complete."

View File

@@ -1,8 +0,0 @@
print("I'm in hello.lua.")
function on_connect()
sock_write("Hello")
end
--connect("localhost", 2233)
--connect("localhost", 2234)

View File

@@ -92,7 +92,6 @@
#include "base64.h" #include "base64.h"
#include "nsock.h" #include "nsock.h"
#include "ncat.h" #include "ncat.h"
#include "ncat_lua.h"
#include "util.h" #include "util.h"
#include "sys_wrap.h" #include "sys_wrap.h"
@@ -138,7 +137,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data);
static void post_connect(nsock_pool nsp, nsock_iod iod); static void post_connect(nsock_pool nsp, nsock_iod iod);
static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data); static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data);
static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data); static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data);
void write_socket_handler(nsock_pool nsp, nsock_event evt, void *data); static void write_socket_handler(nsock_pool nsp, nsock_event evt, void *data);
static void idle_timer_handler(nsock_pool nsp, nsock_event evt, void *data); static void idle_timer_handler(nsock_pool nsp, nsock_event evt, void *data);
static void refresh_idle_timer(nsock_pool nsp); static void refresh_idle_timer(nsock_pool nsp);
@@ -278,7 +277,7 @@ static const char *sock_to_url(const union sockaddr_u *su)
if (su->storage.ss_family == AF_INET) if (su->storage.ss_family == AF_INET)
Snprintf(buf, sizeof(buf), "%s:%hu", host_str, port); Snprintf(buf, sizeof(buf), "%s:%hu", host_str, port);
else if (su->storage.ss_family == AF_INET6) else if (su->storage.ss_family == AF_INET6)
Snprintf(buf, sizeof(buf), "[%s]:%hu]", host_str, port); Snprintf(buf, sizeof(buf), "[%s]:%hu", host_str, port);
else else
bye("Unknown address family in sock_to_url_host."); bye("Unknown address family in sock_to_url_host.");
@@ -774,13 +773,6 @@ static void post_connect(nsock_pool nsp, nsock_iod iod)
cs.idle_timer_event_id = cs.idle_timer_event_id =
nsock_timer_create(nsp, idle_timer_handler, o.idletimeout, NULL); nsock_timer_create(nsp, idle_timer_handler, o.idletimeout, NULL);
} }
#ifdef HAVE_LUA
if (o.lua)
{
lua_run_onconnect(nsp, iod);
}
#endif
} }
static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data) static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data)
@@ -874,7 +866,7 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
refresh_idle_timer(nsp); refresh_idle_timer(nsp);
} }
void write_socket_handler(nsock_pool nsp, nsock_event evt, void *data) static void write_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
{ {
enum nse_status status = nse_status(evt); enum nse_status status = nse_status(evt);
enum nse_type type = nse_type(evt); enum nse_type type = nse_type(evt);

View File

@@ -118,8 +118,8 @@ size_t srcaddrlen;
union sockaddr_u targetss; union sockaddr_u targetss;
size_t targetsslen; size_t targetsslen;
union sockaddr_u httpconnect; union sockaddr_u httpconnect, socksconnect;
union sockaddr_u socksconnect; size_t httpconnectlen, socksconnectlen;
/* Global options structure. */ /* Global options structure. */
struct options o; struct options o;
@@ -177,10 +177,6 @@ void options_init(void)
o.sslverify = 0; o.sslverify = 0;
o.ssltrustfile = NULL; o.ssltrustfile = NULL;
#endif #endif
//#ifdef HAVE_LUA
o.lua = 0;
o.luafile = NULL;
//#endif
} }
/* Internal helper for resolve and resolve_numeric. addl_flags is ored into /* Internal helper for resolve and resolve_numeric. addl_flags is ored into

View File

@@ -107,8 +107,8 @@ extern size_t srcaddrlen;
extern union sockaddr_u targetss; extern union sockaddr_u targetss;
extern size_t targetsslen; extern size_t targetsslen;
extern union sockaddr_u httpconnect; extern union sockaddr_u httpconnect, socksconnect;
extern union sockaddr_u socksconnect; extern size_t httpconnectlen, socksconnectlen;
struct options { struct options {
unsigned short portno; unsigned short portno;
@@ -162,9 +162,6 @@ struct options {
char *sslkey; char *sslkey;
int sslverify; int sslverify;
char *ssltrustfile; char *ssltrustfile;
int lua;
char *luafile;
}; };
extern struct options o; extern struct options o;

View File

@@ -114,10 +114,6 @@
#include <openssl/err.h> #include <openssl/err.h>
#endif #endif
#ifdef HAVE_LUA
#include "ncat_lua.h"
#endif
static int ncat_connect_mode(void); static int ncat_connect_mode(void);
static int ncat_listen_mode(void); static int ncat_listen_mode(void);
@@ -279,9 +275,6 @@ int main(int argc, char *argv[])
{"ssl-key", required_argument, NULL, 0}, {"ssl-key", required_argument, NULL, 0},
{"ssl-verify", no_argument, NULL, 0}, {"ssl-verify", no_argument, NULL, 0},
{"ssl-trustfile", required_argument, NULL, 0}, {"ssl-trustfile", required_argument, NULL, 0},
#endif
#ifdef HAVE_LUA
{"lua-file", required_argument, NULL, 0},
#endif #endif
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@@ -297,13 +290,8 @@ int main(int argc, char *argv[])
while (1) { while (1) {
/* handle command line arguments */ /* handle command line arguments */
int option_index; int option_index;
#ifdef HAVE_LUA
int c = getopt_long(argc, argv, "46UCc:e:g:G:i:km:hp:d:lo:x:ts:uvw:n:L",
long_options, &option_index);
#else
int c = getopt_long(argc, argv, "46UCc:e:g:G:i:km:hp:d:lo:x:ts:uvw:n", int c = getopt_long(argc, argv, "46UCc:e:g:G:i:km:hp:d:lo:x:ts:uvw:n",
long_options, &option_index); long_options, &option_index);
#endif
/* That's the end of the options. */ /* That's the end of the options. */
if (c == -1) if (c == -1)
@@ -418,12 +406,6 @@ int main(int argc, char *argv[])
case 't': case 't':
o.telnet = 1; o.telnet = 1;
break; break;
#ifdef HAVE_LUA
case 'L':
o.lua = 1;
break;
#endif
case 0: case 0:
if (strcmp(long_options[option_index].name, "version") == 0) { if (strcmp(long_options[option_index].name, "version") == 0) {
print_banner(); print_banner();
@@ -488,12 +470,6 @@ int main(int argc, char *argv[])
verification. */ verification. */
o.sslverify = 1; o.sslverify = 1;
} }
#endif
#ifdef HAVE_LUA
else if (strcmp(long_options[option_index].name, "lua-file") == 0) {
o.lua = 1;
o.luafile = Strdup(optarg);
}
#endif #endif
break; break;
case 'h': case 'h':
@@ -548,10 +524,6 @@ int main(int argc, char *argv[])
" --ssl-verify Verify trust and domain name of certificates\n" " --ssl-verify Verify trust and domain name of certificates\n"
" --ssl-trustfile PEM file containing trusted SSL certificates\n" " --ssl-trustfile PEM file containing trusted SSL certificates\n"
#endif #endif
#ifdef HAVE_LUA
" --lua-file A .lua ncat script\n"
" -L Run Ncat in Lua stdin mode\n"
#endif
" --version Display Ncat's version information and exit\n" " --version Display Ncat's version information and exit\n"
"\n" "\n"
"See the ncat(1) manpage for full options, descriptions and usage examples\n" "See the ncat(1) manpage for full options, descriptions and usage examples\n"
@@ -684,9 +656,6 @@ int main(int argc, char *argv[])
#endif #endif
/* Listen defaults to any address and DEFAULT_NCAT_PORT */ /* Listen defaults to any address and DEFAULT_NCAT_PORT */
if (!o.listen) if (!o.listen)
#ifdef HAVE_LUA
if (!(o.lua && o.luafile == NULL))
#endif
bye("You must specify a host to connect to."); bye("You must specify a host to connect to.");
} else { } else {
#if HAVE_SYS_UN_H #if HAVE_SYS_UN_H
@@ -710,9 +679,6 @@ int main(int argc, char *argv[])
bye("Could not resolve hostname \"%s\": %s.", o.target, gai_strerror(rc)); bye("Could not resolve hostname \"%s\": %s.", o.target, gai_strerror(rc));
optind++; optind++;
} else { } else {
#ifdef HAVE_LUA
if (!(o.lua && o.luafile == NULL))
#endif
if (!o.listen) if (!o.listen)
bye("You must specify a host to connect to."); bye("You must specify a host to connect to.");
} }
@@ -821,14 +787,6 @@ connection brokering should work.");
the console. A no-op on Unix. */ the console. A no-op on Unix. */
set_lf_mode(); set_lf_mode();
#ifdef HAVE_LUA
if(o.lua)
lua_setup();
if(o.lua && o.luafile == NULL)
return ncat_lua_mode();
#endif
if (o.listen) if (o.listen)
return ncat_listen_mode(); return ncat_listen_mode();
else else