forked from nmap/ncrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
366 lines (295 loc) · 9.3 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# Require autoconf 2.13 -*- mode: fundamental; -*-
AC_PREREQ(2.13)
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ncrack.cc)
CXXFLAGS="$CXXFLAGS -O2"
# This variable is needed so that PCAP support, which is by default defined
# for Nsock due to Nmap, is disabled in Ncrack's case.
ac_configure_args="$ac_configure_args --with-libpcap=no"
AC_ARG_WITH(localdirs,
AC_HELP_STRING([--with-localdirs], [Explicitly ask compiler to use /usr/local/{include,libs} if they exist ]),
[ case "$with_localdirs" in
yes)
user_localdirs=1
;;
no)
user_localdirs=0
;;
esac
],
[ user_localdirs=0 ] )
if test "$user_localdirs" = 1; then
if test -d /usr/local/lib; then
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi
if test -d /usr/local/include; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
fi
fi
dnl use ncrack_config.h instead of -D macros
AC_CONFIG_HEADER(ncrack_config.h)
AC_PATH_TOOL([STRIP], [strip], [/bin/true])
dnl Host specific hacks
AC_CANONICAL_HOST
AC_C_INLINE
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
if test -n "$GXX"; then
CXXFLAGS="$CXXFLAGS -Wall"
fi
AC_MSG_CHECKING([whether the compiler is gcc 4 or greater])
if test x"$GXX" = xno; then
AC_MSG_RESULT([no])
else
# On some distros, there are snapshots available as gcc4
if test -z "$ac_cv_prog_CC" || test x"$CC" = xgcc4; then
our_gcc="$CC"
else
our_gcc="$ac_cv_prog_CC"
fi
ncrack_gcc_major_version=0
case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
*4.)
ncrack_gcc_major_version=4
;;
esac
if test 4 -ge $ncrack_gcc_major_version; then
AC_MSG_RESULT([yes])
CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
else
AC_MSG_RESULT([no])
fi
fi
# Remember that all following tests will run with this CXXFLAGS by default
AC_MSG_CHECKING(for __func__)
AC_TRY_COMPILE([
#include <stdio.h>
],[printf ("%s", __func__);],
have_func=yes, have_func=no)
if test "x$have_func" = "xyes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for __FUNCTION__)
AC_TRY_COMPILE([
#include <stdio.h>
],[printf ("%s", __FUNCTION__);],
have_function=yes, have_function=no)
if test "x$have_function" = "xyes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(__func__, __FUNCTION__)
else
AC_MSG_RESULT(no)
AC_DEFINE(__func__, __FILE__)
fi
fi
AC_CHECK_HEADERS(pwd.h termios.h sys/sockio.h)
dnl If any socket libraries needed
AC_SEARCH_LIBS(setsockopt, socket)
AC_SEARCH_LIBS(gethostbyname, nsl)
dnl This test is from the configure.in of Unix Network Programming second
dnl edition example code by W. Richard Stevens
dnl ##################################################################
dnl Check if sockaddr{} has sa_len member.
dnl
AC_CACHE_CHECK(if sockaddr{} has sa_len member, ac_cv_sockaddr_has_sa_len,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>],
[unsigned int i = sizeof(((struct sockaddr *)0)->sa_len)],
ac_cv_sockaddr_has_sa_len=yes,
ac_cv_sockaddr_has_sa_len=no))
if test $ac_cv_sockaddr_has_sa_len = yes ; then
AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
fi
#dnl check endedness
AC_C_BIGENDIAN
AC_MSG_CHECKING([if struct in_addr is a wacky huge structure (some Sun boxes)])
AC_TRY_COMPILE([#include <netinet/in.h>], struct in_addr i; i._S_un._S_addr;, \
AC_DEFINE(IN_ADDR_DEEPSTRUCT) \
AC_MSG_RESULT(yes) , \
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>], struct in_addr i; i.S_un.S_addr;, \
AC_DEFINE(IN_ADDR_DEEPSTRUCT) \
AC_MSG_RESULT(yes) , \
AC_MSG_RESULT(no);))
dnl Checks for library functions.
AC_CHECK_FUNCS(strerror)
AC_CHECK_FUNCS(signal)
dnl Type of 6th argument to recvfrom(). Usually int or socklen_t.
AC_DEFUN([RECVFROM_ARG6_TYPE],
[
AC_LANG_PUSH(C++)
AC_MSG_CHECKING([for type of 6th argument to recvfrom()])
recvfrom6_t=
for t in socklen_t int; do
AC_TRY_COMPILE([
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>],[
$t arg;
recvfrom (0, NULL, 0, 0, NULL, &arg);],[
recvfrom6_t="$t"
break])
done
if test "x$recvfrom6_t" = x; then
AC_MSG_WARN([Cannot find type for 6th argument to recvfrom(). Using socklen_t ptr])
recvfrom6_t="socklen_t"
fi
AC_MSG_RESULT($recvfrom6_t)
AC_DEFINE_UNQUOTED(recvfrom6_t, $recvfrom6_t,
[Type of 6th argument to recvfrom()])
AC_LANG_POP(C++)
])
RECVFROM_ARG6_TYPE
# We test whether they specified openssl desires explicitly
use_openssl="yes"
specialssldir=""
AC_ARG_WITH(openssl,
AC_HELP_STRING([--with-openssl=DIR],[Use optional openssl libs and includes from [DIR]/lib/ and [DIR]/include/openssl/)]),
[ case "$with_openssl" in
yes)
;;
no)
use_openssl="no"
;;
*)
specialssldir="$with_openssl"
CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
LDFLAGS="$LDFLAGS -L$with_openssl/lib"
;;
esac]
)
# If they didn't specify it, we try to find it
if test "$use_openssl" = "yes" -a -z "$specialssldir"; then
AC_CHECK_HEADER(openssl/ssl.h,,
[ use_openssl="no"
if test "$with_openssl" = "yes"; then
AC_MSG_ERROR([OpenSSL was explicitly requested but openssl/ssl.h was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl.])
fi
AC_MSG_WARN([Failed to find openssl/ssl.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument])
])
# use_openssl="yes" given explicitly in next 2 rules to avoid adding lib to $LIBS
if test "$use_openssl" = "yes"; then
AC_CHECK_LIB(crypto, BIO_int_ctrl,
[ use_openssl="yes"],
[ use_openssl="no"
if test "$with_openssl" = "yes"; then
AC_MSG_ERROR([OpenSSL was explicitly requested but libcrypto was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl.])
fi
AC_MSG_WARN([Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument])
])
fi
if test "$use_openssl" = "yes"; then
AC_CHECK_LIB(ssl, SSL_new,
[ use_openssl="yes" ],
[ use_openssl="no"
if test "$with_openssl" = "yes"; then
AC_MSG_ERROR([OpenSSL was explicitly requested but libssl was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl.])
fi
AC_MSG_WARN([Failed to find libssl so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ],
[ -lcrypto ])
fi
fi
OPENSSL_LIBS=
if test "$use_openssl" = "yes"; then
AC_DEFINE(HAVE_OPENSSL)
OPENSSL_LIBS="-lssl -lcrypto"
fi
AC_SUBST(OPENSSL_LIBS)
# NBASE
AC_ARG_WITH(libnbase,
AC_HELP_STRING([--with-libnbase=DIR], [Look for nbase include/libs in DIR]),
[ case "$with_libnbase" in
yes)
;;
*)
NBASEDIR="$with_libnbase"
NBASE_BUILD=""
;;
esac],
NBASE_BUILD="nbase_build"
NBASEDIR="nbase"
)
LDFLAGS="$LDFLAGS -L$NBASEDIR"
CPPFLAGS="$CPPFLAGS -I$NBASEDIR"
LIBNBASE_LIBS="-lnbase"
AC_SUBST(NBASEDIR)
AC_SUBST(NBASE_BUILD)
AC_SUBST(LIBNBASE_LIBS)
AC_CONFIG_SUBDIRS(nbase)
# NSOCK
NSOCKDIR="nsock"
NSOCK_BUILD="nsock_build"
AC_ARG_WITH(libnsock,
AC_HELP_STRING([--with-libnsock=DIR], [Compile and link to libnsock in DIR]),
[ case "$with_libnsock" in
yes)
;;
*)
NSOCKDIR="$with_libnsock"
NSOCK_BUILD=""
;;
esac]
)
LDFLAGS="$LDFLAGS -L$NSOCKDIR/src"
CPPFLAGS="$CPPFLAGS -I$NSOCKDIR/include"
LIBNSOCK_LIBS="-lnsock"
AC_SUBST(NSOCKDIR)
AC_SUBST(NSOCK_BUILD)
AC_SUBST(LIBNSOCK_LIBS)
AC_CONFIG_SUBDIRS(nsock/src)
# Modules
MODULES_BUILD="modules_build"
AC_SUBST(MODULES_BUILD)
OPENSSHLIB_DIR=
OPENSSHLIB_BUILD=
OPENSSH_LIB=
if test "$use_openssl" = "yes"; then
# OPENSSHLIB
OPENSSHLIB_DIR="opensshlib"
OPENSSHLIB_BUILD="opensshlib_build"
AC_ARG_WITH(libopenssh,
AC_HELP_STRING([--with-libopenssh=DIR], [Compile and link to libopenssh in DIR]),
[ case "$with_libopenssh" in
yes)
;;
*)
OPENSSHLIB_DIR="$with_libopenssh"
OPENSSHLIB_BUILD=""
;;
esac]
)
LDFLAGS="$LDFLAGS -L$OPENSSHLIB_DIR"
CPPFLAGS="$CPPFLAGS -I$OPENSSHLIB_DIR"
OPENSSH_LIB="-lopenssh"
AC_CONFIG_SUBDIRS(opensshlib)
# SSH, SMB, RDP modules rely on crypto functions which rely on OpenSSL, so
# build them only in case the system has OpenSSL.
MODULES_SRCS="ncrack_ssh.cc ncrack_smb.cc ncrack_rdp.cc ncrack_sip.cc \
ncrack_psql.cc ncrack_mysql.cc"
MODULES_OBJS="ncrack_ssh.o ncrack_smb.o ncrack_rdp.o ncrack_sip.o \
ncrack_psql.o ncrack_mysql.o"
fi
MODULES_SRCS="$MODULES_SRCS ncrack_ftp.cc ncrack_telnet.cc ncrack_http.cc \
ncrack_pop3.cc ncrack_vnc.cc ncrack_redis.cc ncrack_winrm.cc ncrack_owa.cc \
ncrack_imap.cc ncrack_cassandra.cc"
MODULES_OBJS="$MODULES_OBJS ncrack_ftp.o ncrack_telnet.o ncrack_http.o \
ncrack_pop3.o ncrack_vnc.o ncrack_redis.o ncrack_winrm.o ncrack_owa.o \
ncrack_imap.o ncrack_cassandra.o"
AC_SUBST(MODULES_SRCS)
AC_SUBST(MODULES_OBJS)
AC_SUBST(OPENSSHLIB_DIR)
AC_SUBST(OPENSSHLIB_BUILD)
AC_SUBST(OPENSSH_LIB)
CPPFLAGS="$CPPFLAGS -Imodules"
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_OUTPUT(Makefile modules/Makefile)
if test -f docs/leet-ncrack-ascii-art.txt; then
cat docs/leet-ncrack-ascii-art.txt
fi
echo "Configuration complete. Type make (or gmake on some *BSD machines) to compile."