Codebase list sslscan / upstream/1.11.4
Imported Upstream version 1.11.4 Sophie Brun 8 years ago
7 changed file(s) with 121 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
1313
1414 # custom openssl build
1515 openssl/
16 .openssl.is.fresh
00 Changelog
11 =========
2
3 Version: 1.11.4
4 Date : 06/03/2016
5 Author : rbsec <[email protected]>
6 Changes: The following are a list of changes
7 > Fix compression detection (credit nuxi)
8 > Added support for PostgreSQL (credit nuxi)
9
10 Version: 1.11.3
11 Date : 03/03/2016
12 Author : rbsec <[email protected]>
13 Changes: The following are a list of changes
14 > Properly fix missing SSLv2 EXPORT ciphers by patching OpenSSL
15
16 Version: 1.11.2
17 Date : 02/03/2016
18 Author : rbsec <[email protected]>
19 Changes: The following are a list of changes
20 > Makefile improvements
21 > Update OpenSSL from Git when statically building
22 > Use enable-ssl2 and enable-weak-ciphers when building statically
223
324 Version: 1.11.1
425 Date : 11/12/2015
1313 OS := $(shell uname)
1414
1515 SRCS = sslscan.c
16 BINPATH = $(DESTDIR)/usr/bin/
17 MANPATH = $(DESTDIR)/usr/share/man/
16 PREFIX = /usr
17 BINDIR = $(PREFIX)/bin
18 MANDIR = $(PREFIX)/share/man
19 MAN1DIR = $(MANDIR)/man1
1820
1921 WARNINGS = -Wall -Wformat=2
2022 DEFINES = -DVERSION=\"$(GIT_VERSION)\"
2729 PWD = $(shell pwd)/openssl
2830 LDFLAGS += -L${PWD}/
2931 CFLAGS += -I${PWD}/include/ -I${PWD}/
30 LIBS = -lssl -lcrypto -ldl
32 LIBS = -lssl -lcrypto -ldl -lz
3133 GIT_VERSION := $(GIT_VERSION)-static
3234 else
3335 # for dynamic linking
3537 CFLAGS += -I/usr/local/ssl/include/ -I/usr/local/ssl/include/openssl/ -I/usr/local/opt/openssl/include
3638 endif
3739
38 .PHONY: sslscan clean
40 .PHONY: all sslscan clean install uninstall static opensslpull
3941
4042 all: sslscan
4143 @echo
5052 sslscan: $(SRCS)
5153 $(CC) -o $@ ${WARNINGS} ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${DEFINES} ${SRCS} ${LIBS}
5254
53 install:
54 mkdir -p $(BINPATH)
55 mkdir -p $(MANPATH)man1/
56 cp sslscan $(BINPATH)
57 cp sslscan.1 $(MANPATH)man1/
55 install: sslscan
56 mkdir -p $(DESTDIR)$(BINDIR)
57 mkdir -p $(DESTDIR)$(MAN1DIR)
58 cp sslscan $(DESTDIR)$(BINDIR)
59 cp sslscan.1 $(DESTDIR)$(MAN1DIR)
5860
5961 uninstall:
60 rm -f $(BINPATH)sslscan
61 rm -f $(MANPATH)man1/sslscan.1
62 rm -f $(DESTDIR)$(BINDIR)/sslscan
63 rm -f $(DESTDIR)$(MAN1DIR)/sslscan.1
6264
63 openssl/Makefile:
64 [ -d openssl -a -d openssl/.git ] && true || git clone https://github.com/openssl/openssl ./openssl && cd ./openssl && git checkout OpenSSL_1_0_2-stable
65 .openssl.is.fresh: opensslpull
66 true
67 opensslpull:
68 if [ -d openssl -a -d openssl/.git ]; then \
69 cd ./openssl && git checkout OpenSSL_1_0_2-stable && git pull | grep -q "Already up-to-date." && [ -e ../.openssl.is.fresh ] || touch ../.openssl.is.fresh ; \
70 else \
71 git clone https://github.com/openssl/openssl ./openssl && cd ./openssl && git checkout OpenSSL_1_0_2-stable && touch ../.openssl.is.fresh ; \
72 fi
73 sed -i 's/# if 0/# if 1/g' openssl/ssl/s2_lib.c
6574
6675 # Need to build OpenSSL differently on OSX
6776 ifeq ($(OS), Darwin)
77 openssl/Makefile: .openssl.is.fresh
78 cd ./openssl; ./Configure darwin64-x86_64-cc
79 # Any other *NIX platform
80 else
81 openssl/Makefile: .openssl.is.fresh
82 cd ./openssl; ./config no-shares enable-weak-ssl-ciphers enable-ssl2 zlib
83 endif
84
6885 openssl/libcrypto.a: openssl/Makefile
69 cd ./openssl; ./Configure darwin64-x86_64-cc
7086 $(MAKE) -C openssl depend
7187 $(MAKE) -C openssl all
7288 $(MAKE) -C openssl test
73
74 # Any other *NIX platform
75 else
76 openssl/libcrypto.a: openssl/Makefile
77 cd ./openssl; ./config no-shares
78 $(MAKE) -C openssl depend
79 $(MAKE) -C openssl all
80 $(MAKE) -C openssl test
81 endif
8289
8390 static: openssl/libcrypto.a
8491 $(MAKE) sslscan STATIC_BUILD=TRUE
8693 clean:
8794 if [ -d openssl -a -d openssl/.git ]; then ( cd ./openssl; git clean -fx ); fi;
8895 rm -f sslscan
96 rm -f .openssl.is.fresh
3434 * Flag expired certificates
3535 * Flag TLSv1.0 ciphers in output as weak.
3636 * Experimental OSX support (static building only)
37 * Support for scanning PostgreSQL servers (credit nuxi)
3738
3839 ### Building on Windows
3940 Thanks to a patch by jtesta, sslscan can now be compiled on Windows. This can
6768 To compile your own OpenSSL version, you'll probably need to install the
6869 OpenSSL build dependencies:
6970
70 apt-get install build-essential git
71 apt-get install build-essential git zlib1g-dev
7172 apt-get build-dep openssl
7273
7374 then run
135135 .br
136136 Note that some servers hang when we try to use SSLv3 ciphers over STARTTLS. If you scan hangs, try using the --tlsall option.
137137 .TP
138 .B \-\-starttls\-psql
139 STARTTLS setup for PostgreSQL
140 .TP
138141 .B \-\-starttls\-xmpp
139142 STARTTLS setup for XMPP
140143 .TP
7575 #include <openssl/x509.h>
7676 #include <openssl/x509v3.h>
7777 #include <openssl/ocsp.h>
78 #ifndef OPENSSL_NO_COMP
79 #include <openssl/comp.h>
80 #endif
7881
7982 // If we're not compiling with Visual Studio, include unistd.h. VS
8083 // doesn't have this header.
451454 printf_verbose("Server reported: %s\n", buffer);
452455 }
453456
457 if (options->starttls_psql == true && tlsStarted == false)
458 {
459 unsigned char buffer;
460
461 tlsStarted = 1;
462
463 // Send SSLRequest packet
464 send(socketDescriptor, "\x00\x00\x00\x08\x04\xd2\x16\x2f", 8, 0);
465
466 // Read reply byte
467 if (1 != recv(socketDescriptor, &buffer, 1, 0)) {
468 printf_error("%s ERROR: unexpected EOF reading from %s:%d%s\n", COL_RED, options->host, options->port, RESET);
469 return 0;
470 }
471
472 if (buffer != 'S') {
473 printf_error("%s ERROR: server at %s:%d%s rejected TLS startup\n", COL_RED, options->host, options->port, RESET);
474 return 0;
475 }
476 }
477
454478 // Setup an RDP socket with preamble
455479 // Borrowed from https://labs.portcullis.co.uk/tools/ssl-cipher-suite-enum/
456480 if (options->rdp == true && tlsStarted == false)
483507 return 0;
484508 }
485509 }
510
486511 // Return
487512 return socketDescriptor;
488513 }
719744 SSL_set_options(ssl, SSL_OP_LEGACY_SERVER_CONNECT);
720745 #endif
721746
747 #ifdef SSL_OP_NO_COMPRESSION
748 // Make sure to clear the no compression flag
749 SSL_clear_options(ssl, SSL_OP_NO_COMPRESSION);
750 #endif
751
722752 if (ssl != NULL)
723753 {
724754 // Connect socket and BIO
738768 session = *SSL_get_session(ssl);
739769
740770 #ifndef OPENSSL_NO_COMP
741 printf_xml(" <compression supported=\"%d\" />\n",
742 session.compress_meth);
743
744 if (session.compress_meth == 0)
771 // Make sure zlib is actually present
772 if (COMP_zlib()->type != NID_undef)
745773 {
746 printf("Compression %sdisabled%s\n\n", COL_GREEN, RESET);
774 printf_xml(" <compression supported=\"%d\" />\n",
775 session.compress_meth);
776
777 if (session.compress_meth == 0)
778 {
779 printf("Compression %sdisabled%s\n\n", COL_GREEN, RESET);
780 }
781 else
782 {
783 printf("Compression %senabled%s (CRIME)\n\n", COL_RED, RESET);
784 }
747785 }
748786 else
787 #endif
749788 {
750 printf("Compression %senabled%s (CRIME)\n\n", COL_RED, RESET);
789 printf("%sOpenSSL version does not support compression%s\n", COL_RED, RESET);
790 printf("%sRebuild with zlib1g-dev package for zlib support%s\n\n", COL_RED, RESET);
751791 }
752 #endif
753792
754793 // Disconnect SSL over socket
755794 SSL_shutdown(ssl);
30873126 options.starttls_pop3 = false;
30883127 options.starttls_smtp = false;
30893128 options.starttls_xmpp = false;
3129 options.starttls_psql = false;
30903130 options.xmpp_server = false;
30913131 options.verbose = false;
30923132 options.cipher_details = true;
32293269 // StartTLS... XMPP
32303270 else if (strcmp("--starttls-xmpp", argv[argLoop]) == 0)
32313271 options.starttls_xmpp = true;
3272
3273 // StartTLS... PostgreSQL
3274 else if (strcmp("--starttls-psql", argv[argLoop]) == 0)
3275 options.starttls_psql = true;
3276
32323277 #ifndef OPENSSL_NO_SSL2
32333278 // SSL v2 only...
32343279 else if (strcmp("--ssl2", argv[argLoop]) == 0)
33483393 else if (options.port == 0) {
33493394 if (options.starttls_ftp)
33503395 options.port = 21;
3351 if (options.starttls_imap)
3396 else if (options.starttls_imap)
33523397 options.port = 143;
3353 if (options.starttls_irc)
3398 else if (options.starttls_irc)
33543399 options.port = 6667;
3355 if (options.starttls_pop3)
3400 else if (options.starttls_pop3)
33563401 options.port = 110;
3357 if (options.starttls_smtp)
3402 else if (options.starttls_smtp)
33583403 options.port = 25;
3359 if (options.starttls_xmpp)
3404 else if (options.starttls_xmpp)
33603405 options.port = 5222;
3361 if (options.rdp)
3406 else if (options.starttls_psql)
3407 options.port = 5432;
3408 else if (options.rdp)
33623409 options.port = 3389;
3363 if (options.port == 0)
3410 else
33643411 options.port = 443;
33653412 }
33663413 }
34573504 printf(" %s--starttls-pop3%s STARTTLS setup for POP3\n", COL_GREEN, RESET);
34583505 printf(" %s--starttls-smtp%s STARTTLS setup for SMTP\n", COL_GREEN, RESET);
34593506 printf(" %s--starttls-xmpp%s STARTTLS setup for XMPP\n", COL_GREEN, RESET);
3507 printf(" %s--starttls-psql%s STARTTLS setup for PostgreSQL\n", COL_GREEN, RESET);
34603508 printf(" %s--xmpp-server%s Use a server-to-server XMPP handshake\n", COL_GREEN, RESET);
34613509 printf(" %s--http%s Test a HTTP connection\n", COL_GREEN, RESET);
34623510 printf(" %s--rdp%s Send RDP preamble before starting scan\n", COL_GREEN, RESET);
126126 int starttls_pop3;
127127 int starttls_smtp;
128128 int starttls_xmpp;
129 int starttls_psql;
129130 int xmpp_server;
130131 int sslVersion;
131132 int targets;