pax_global_header00006660000000000000000000000064126750527770014534gustar00rootroot0000000000000052 comment=734799d4a0a79714eae2dba8d33a130da351fc65 sslscan-1.11.5-rbsec/000077500000000000000000000000001267505277700143635ustar00rootroot00000000000000sslscan-1.11.5-rbsec/.gitignore000066400000000000000000000002661267505277700163570ustar00rootroot00000000000000# object files *.o *.obj # compiled binary sslscan sslscan.exe # debian build of openssl openssl-*/ openssl_* libcrypto* libssl* # custom openssl build openssl/ .openssl.is.fresh sslscan-1.11.5-rbsec/.travis.yml000066400000000000000000000005251267505277700164760ustar00rootroot00000000000000language: c compiler: - clang - gcc env: - TARGET=sslscan - TARGET=static script: - make $TARGET CC=$CC matrix: exclude: # OpenSSL can't be compiled out-of-the box with clang, see # http://wiki.openssl.org/index.php/Compilation_and_Installation#Modifying_Build_Settings - compiler: clang env: TARGET=static sslscan-1.11.5-rbsec/Changelog000066400000000000000000000277121267505277700162060ustar00rootroot00000000000000Changelog ========= Version: 1.11.5 Date : 24/03/2016 Author : rbsec Changes: The following are a list of changes > Fix bug in heartbleed check (credit nuxi) > Makefile improvements and fixes for OSX and FreeBSD > Optimize OpenSSL clone > Implement --show-times to display handshake times in milliseconds Version: 1.11.4 Date : 06/03/2016 Author : rbsec Changes: The following are a list of changes > Fix compression detection (credit nuxi) > Added support for PostgreSQL (credit nuxi) Version: 1.11.3 Date : 03/03/2016 Author : rbsec Changes: The following are a list of changes > Properly fix missing SSLv2 EXPORT ciphers by patching OpenSSL Version: 1.11.2 Date : 02/03/2016 Author : rbsec Changes: The following are a list of changes > Makefile improvements > Update OpenSSL from Git when statically building > Use enable-ssl2 and enable-weak-ciphers when building statically Version: 1.11.1 Date : 11/12/2015 Author : rbsec Changes: The following are a list of changes > Show cipher IDs with --show-cipher-ids (credit maurice2k) > Warn when building agsinst system OpenSSL rather than statically > Allow building statically on OSX (experimental) Version: 1.11.0 Date : 24/09/2015 Author : rbsec Changes: The following are a list of changes > Rewrote ciphersuite scanning engine to be much faster > Ciphers are now output in order of server preference > Most secure protocols are scanned first (TLSv1.2 -> SSLv2) > All protocols are tried when trying to obtain the certificate > Obselete --failed and --no-preferred-ciphers options removed > Flag TLSv1.0 ciphers in output > Flag 56 bit ciphers as red, not yellow > Fix building on OpenBSD (credit Stuart Henderson) > Fix incorrect output when server prefers NULL ciphers Version: 1.10.6 Date : 06/08/2015 Author : rbsec Changes: The following are a list of changes > Fix --sleep only working for whole seconds (credit dmke) > Fix compiling against OpenSSL 0.9.8 (credit aclemons) > Flag expired certificates (credit jacktrice) Version: 1.10.5 Date : 07/07/2015 Author : rbsec Changes: The following are a list of changes > Added IRC STARTTLS support (--starttls-irc, credit jkent) > Highlight weak RSA keys in output > Added option to show OCSP status (--ocsp, credit kelbyludwig) > Fix a segfault with certificate parsing Version: 1.10.4 Date : 21/06/2015 Author : rbsec Changes: The following are a list of changes > Display cipher details by default (hide with --no-cipher-details) > Fix scanning multiple targets if one fails (credit shellster) > Fix bug with --no-color and --failed (credit yasulib) > Minor bugfixes to output Version: 1.10.3 Date : 22/05/2015 Author : rbsec Changes: The following are a list of changes > Flag weak DHE keys in --cipher-details > Report DHE key bits in XML > Change ECDHE key bits to "ecdhebits" rather than "dhebits" in XML Version: 1.10.2 Date : 12/05/2015 Author : rbsec Changes: The following are a list of changes > Wrap TLS extensions in CDATA blocks in XML output. > Fix incorrect TLS versions in heartbleed checks Version: 1.10.1 Date : 06/04/2015 Author : rbsec Changes: The following are a list of changes > Fix XML output to use "TLSv1.0" in preferred ciphers, not "TLSv1" > Added --cipher-details option to display EC curves and EDH keys Note that this feature requires OpenSSL >= 1.0.2 > Update static build options to compile against OpenSSL 1.0.2 Version: 1.10.0 Date : 28/02/2015 Author : rbsec Changes: The following are a list of changes > Experimental build support (credit jtesta). > Support XMPP server-to-server connections (--xmpp-server). Version: 1.9.11 Date : 03/02/2015 Author : rbsec Changes: The following are a list of changes > Makefile updates to assist packaging in Kali. > Fix missing static build number when compiling from tarball. Version: 1.9.10 Date : 24/01/2015 Author : rbsec Changes: The following are a list of changes > Display certificate CN, Altnames and Issuer in default output. > Flag certificates where CN == issuer, or CN = * > Highlight GCM ciphersuites as good Version: 1.9.9 Date : 22/01/2015 Author : kyprizel Changes: The following are a list of changes > Added --show-client-cas option to determine trusted CAs for client authentication > Added --no-preferred option to disable any output except specified Version: 1.9.8 Date : 08/12/2014 Author : rbsec Changes: The following are a list of changes > Added --sleep option to pause between request > Only check for heartbleed against specified TLS version > Added --sleep option to pause between request > Fix issues compiling against OpenSSL 0.9.8 > Highlight CBC ciphersuites on SSLv3 (POODLE) > Experimental build support on OSX (credit MikeSchroll) Version: 1.9.7 Date : 26/10/2014 Author : rbsec Changes: The following are a list of changes > Added option for static compilation with OpenSSL (credit dmke) > Added "sslmethod" attribute to Heartbleed XML output (credit dmke) > Split headers into sslscan.h (credit dmke) Version: 1.9.6 Date : 10/10/2014 Author : rbsec Changes: The following are a list of changes > Highlight NULL ciphers in output. > Highlight SSLv3 ciphers. > Added --rdp option to support RDP servers (credit skettler). > Added --timeout option to set socket timeout (default 3s). Version: 1.9.5 Date : 13/09/2014 Author : rbsec Changes: The following are a list of changes > Renamed --get-certificate option to --show-certficate. > Display certificate signing algorithm highlighting weak algorithms. > Display certificate key strength highlighting weak keys. > Bumped XML version to 1.9.5 due to minor changes. Version: 1.9.4 Date : 22/05/2014 Author : rbsec Changes: The following are a list of changes > Check for SSLv2 and SSLv3 ciphers over STARTTLS. Version: 1.9.3 Date : 20/05/2014 Author : rbsec Changes: The following are a list of changes > Fixed broken STARTTLS SMTP check. Version: 1.9.2 Date : 09/04/2014 Author : rbsec Changes: The following are a list of changes > Added check for OpenSSL Heartbleed (CVE-2014-0160). Version: 1.9.1 Date : 06/03/2014 Author : rbsec Changes: The following are a list of changes > Added --tlsall option to only scan TLS ciphersuites. > Scan all TLS versions by default for STARTTLS services. > Added support for IPv6 addresses using square bracket notation [:1]. > Highlight anonymous (ADH and AECDH) ciphers in output. > Added option to disable colour in output (--no-colour). > Removed undocumented -p output option. > Removed old references to titania.co.uk domain. Version: 1.9 Date : 30/12/2013 Author : rbsec Changes: The following are a list of changes > Highlight SSLv2 ciphers > Highlight weak (n <= 40 bit) and medium (40 < n <= 56 bit) ciphers > Highlight RC4 ciphers > Highlight anonymous (ADH) ciphers > Hide certificate information by default > Hide rejected ciphers by default (display with --failed). > Added TLSv1.1 and TLSv1.2 support (merged from twwbond/sslscan). > Compiles if OpenSSL does not support SSLv2 ciphers (merged from digineo/sslscan). > Supports IPv6 hostnames (can be forced with --ipv6). > Check for TLS compression (CRIME, disable with --no-compression) Version: 1.8.4 Date : xx/xx/2010 Author : Jacob Appelbaum Changes: The following are a list of changes > Add demo targets in Makefile > Refactoring of code by Adam Langley > Add SNI patch from Tim Brown > Bug fixes from craSH and Cygwin build improvements Version: 1.8.3 Date : 11/08/2010 Author : Jacob Appelbaum Changes: The following are a list of changes > Improve new protocol setup support for STARTTLS: POP3, IMAP, FTP, and XMPP This modeled after the support found in OpenSSL's s_client > Add verbose option to print more info > Add default ports when a STARTTLS setup flag is called without any port at all Version: 1.8.2 Date : 19/06/2009 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Fixed output with HTML disabled > Fixed XML critical Version: 1.8.1 Date : 25/05/2009 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Fixed some compiler warnings. Version: 1.8.0 Date : 19/05/2009 Author : Ian Ventura-Whiting (Fizz) Thanks : John Nichols Changes: The following are a list of changes since the previous version: > Added SSL implementation workaround option. > Added HTTP connection testing. > Fixed Certification validation XML output. Version: 1.7.1 Date : 20/04/2008 Author : Ian Ventura-Whiting (Fizz) Thanks : Mark Lowe Changes: The following are a list of changes since the previous version: > Added HELO for SMTP checks > Increased read buffer size Version: 1.7 Date : 18/04/2008 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Added STARTTLS SMTP capability > Fixed XML output format bug Version: 1.6 Date : 30/12/2007 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Added man page. > Improved certificate checking > Added Makefile Version: 1.5 Date : 25/09/2007 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Update to the license to make it BINARY compatible with OpenSSL. Its then easier for the packagers. Version: 1.4 Date : 03/09/2007 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Added Server Certificate ouput. > Added support for client certs. > Added support for private keys and password. > Added support for PKCS#12. > Fixed xml output. Version: 1.3 Date : 06/08/2007 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Added XML file output option. > Improved help text. > Added program URL. Version: 1.2 Date : 16/07/2007 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Removed unused variable > Other minor changes. Version: 1.1 Date : 13/07/2007 Author : Ian Ventura-Whiting (Fizz) Changes: The following are a list of changes since the previous version: > Correction in banner text > Host:Port now directly from the command-line. Version: 1.0 Date : 13/07/2007 Author : Ian Ventura-Whiting (Fizz) Notes : Initial version of sslscan sslscan-1.11.5-rbsec/INSTALL000066400000000000000000000073641267505277700154260ustar00rootroot00000000000000Requirements: OpenSSL 0.9.8o or better Makefile build: make make install (as root) Manual Build: sslscan can be built manually using the following commands: gcc -lssl -o sslscan sslscan.c clang -lssl -o sslscan sslscan.c ---- There are three ways to build a Windows executable: 1.) By cross-compiling on a Linux build machine using MinGW or Mingw-w64. 2.) By compiling on a Windows build machine using MinGW or Mingw-w64. 3.) By compiling on a Windows build machine using Visual Studio 2013 (other versions may also work, but are untested). If you have a Debian-like Linux machine (such as Ubuntu or Kali), option #1 is BY FAR the easiest. Note that installing Visual Studio and additional tools requires downloading gigabytes of data! In any case, it is necessary to compile OpenSSL to ensure that all protocols and algorithms are enabled (note that some systems that package OpenSSL have some deprecated features such as SSLv2 turned off for safety reasons; we actually need those to test with). I. Cross-compiling from Linux A. Building a 64-bit Windows executable 0.) Install Mingw-w64. On Debian-like systems, this can be done with: apt-get install mingw-w64 1.) Download and compile OpenSSL with the following: git clone https://github.com/openssl/openssl git checkout OpenSSL_1_0_2-stable ./Configure --cross-compile-prefix=x86_64-w64-mingw32- \ -fstack-protector-all -D_FORTIFY_SOURCE=2 mingw64 shared make 2.) Compile sslscan with the path to the OpenSSL directory: make -f Makefile.mingw OPENSSL_PATH=../path/to/openssl B. Building a 32-bit Windows executable 0.) Install MinGW. On Debian-like systems, this can be done with: apt-get install mingw32 1.) Download and compile OpenSSL with the following: git clone https://github.com/openssl/openssl git checkout OpenSSL_1_0_2-stable ./Configure --cross-compile-prefix=i586-mingw32msvc- \ -fstack-protector-all -D_FORTIFY_SOURCE=2 mingw shared make 2.) Compile sslscan with the path to the OpenSSL directory: DEFINES="-DWONKY_LINUX_MINGW=1" make -f Makefile.mingw \ OPENSSL_PATH=../path/to/openssl II. Compiling on Windows using Mingw A. Building a 64-bit Windows executable 0.) Install Mingw-w64 from http://mingw-w64.sourceforge.net/. Install MSYS from http://www.mingw.org/. 1.) In an MSYS shell, compile OpenSSL with the following: ./Configure mingw64 -fstack-protector-all -D_FORTIFY_SOURCE=2 shared make 2.) In an MSYS shell, compile sslscan with the path to the OpenSSL directory: make -f Makefile.mingw OPENSSL_PATH=../path/to/openssl B. Building a 32-bit Windows executable 0.) Install MinGW and MSYS from http://www.mingw.org/. 1.) In an MSYS shell, compile OpenSSL with the following: ./Configure mingw -fstack-protector-all -D_FORTIFY_SOURCE=2 shared make 2.) In an MSYS shell, compile sslscan with the path to the OpenSSL directory: make -f Makefile.mingw OPENSSL_PATH=../path/to/openssl III. Compiling on Windows using Visual Studio 2013 Express for Windows Desktop A. Install Visual Studio 2013 Express for Windows Desktop: http://go.microsoft.com/?linkid=9832280 B. Install the Windows Driver Kit 8.1: http://go.microsoft.com/fwlink/p/?linkid=393659 C. Install ActivePerl Community Edition: http://www.activestate.com/activeperl/downloads D. In the VS2013 x64 Cross Tools Command Prompt, compile OpenSSL with: perl Configure VC-WIN64A ms\do_win64a nmake -f ms\nt.mak E. Inside the sslscan folder, compile sslscan with: nmake -f Makefile.vs OPENSSL_PATH=path/to/openssl sslscan-1.11.5-rbsec/LICENSE000066400000000000000000000773311267505277700154030ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS sslscan-1.11.5-rbsec/Makefile000066400000000000000000000063131267505277700160260ustar00rootroot00000000000000# set gcc as default if CC is not set ifndef CC CC=gcc endif GIT_VERSION = $(shell git describe --tags --always --dirty=-wip) # Ugly hack to get version if git isn't installed ifeq ($(GIT_VERSION),) GIT_VERSION = $(shell grep -E -o -m 1 "[0-9]+\.[0-9]+\.[0-9]+" Changelog) endif # Detect OS OS := $(shell uname) SRCS = sslscan.c PREFIX = /usr BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/share/man MAN1DIR = $(MANDIR)/man1 WARNINGS = -Wall -Wformat=2 DEFINES = -DVERSION=\"$(GIT_VERSION)\" # for dynamic linking LIBS = -lssl -lcrypto ifneq ($(OS), FreeBSD) LIBS += -ldl endif # for static linking ifeq ($(STATIC_BUILD), TRUE) PWD = $(shell pwd)/openssl LDFLAGS += -L${PWD}/ CFLAGS += -I${PWD}/include/ -I${PWD}/ LIBS = -lssl -lcrypto -lz ifneq ($(OS), FreeBSD) LIBS += -ldl endif GIT_VERSION := $(GIT_VERSION)-static else # for dynamic linking LDFLAGS += -L/usr/local/lib -L/usr/local/ssl/lib -L/usr/local/opt/openssl/lib -L/opt/local/lib CFLAGS += -I/usr/local/include -I/usr/local/ssl/include -I/usr/local/ssl/include/openssl -I/usr/local/opt/openssl/include -I/opt/local/include -I/opt/local/include/openssl endif .PHONY: all sslscan clean install uninstall static opensslpull all: sslscan @echo @echo "===========" @echo "| WARNING |" @echo "===========" @echo @echo "Building against system OpenSSL. Legacy protocol checks may not be possible." @echo "It is recommended that you statically build sslscan with \`make static\`." @echo sslscan: $(SRCS) $(CC) -o $@ ${WARNINGS} ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${DEFINES} ${SRCS} ${LIBS} install: @if [ ! -f sslscan ] ; then \ echo "\n=========\n| ERROR |\n========="; \ echo "Before installing you need to build sslscan with either \`make\` or \`make static\`\n"; \ exit 1; \ fi ifeq ($(OS), Darwin) install sslscan $(DESTDIR)$(BINDIR)/sslscan; install sslscan.1 $(DESTDIR)$(MAN1DIR)/sslscan.1; else install -D sslscan $(DESTDIR)$(BINDIR)/sslscan; install -D sslscan.1 $(DESTDIR)$(MAN1DIR)/sslscan.1; endif uninstall: rm -f $(DESTDIR)$(BINDIR)/sslscan rm -f $(DESTDIR)$(MAN1DIR)/sslscan.1 .openssl.is.fresh: opensslpull true opensslpull: if [ -d openssl -a -d openssl/.git ]; then \ 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 ; \ else \ git clone --depth 1 -b OpenSSL_1_0_2-stable https://github.com/openssl/openssl ./openssl && cd ./openssl && touch ../.openssl.is.fresh ; \ fi sed -i.bak 's/# if 0/# if 1/g' openssl/ssl/s2_lib.c rm openssl/ssl/s2_lib.c.bak # Need to build OpenSSL differently on OSX ifeq ($(OS), Darwin) openssl/Makefile: .openssl.is.fresh cd ./openssl; ./Configure enable-ssl2 enable-weak-ssl-ciphers zlib darwin64-x86_64-cc # Any other *NIX platform else openssl/Makefile: .openssl.is.fresh cd ./openssl; ./config no-shares enable-weak-ssl-ciphers enable-ssl2 zlib endif openssl/libcrypto.a: openssl/Makefile $(MAKE) -C openssl depend $(MAKE) -C openssl all $(MAKE) -C openssl test static: openssl/libcrypto.a $(MAKE) sslscan STATIC_BUILD=TRUE clean: if [ -d openssl -a -d openssl/.git ]; then ( cd ./openssl; git clean -fx ); fi; rm -f sslscan rm -f .openssl.is.fresh sslscan-1.11.5-rbsec/Makefile.mingw000066400000000000000000000023511267505277700171440ustar00rootroot00000000000000# If we're in Linux, lets see if we can find the path to Mingw automatically... ifeq ($(shell uname), Linux) MINGW32=$(shell which i586-mingw32msvc-gcc) ifneq ($(MINGW32),) CC=$(MINGW32) endif MINGW64=$(shell which x86_64-w64-mingw32-gcc) ifneq ($(MINGW64),) CC=$(MINGW64) endif endif ifndef CC CC=gcc endif .PHONY: clean # Enable security options like stack protectors and variable formatting checks. SECURITY_OPTIONS=-fstack-protector-all -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security # Turn on linker optimizations, and DEP support (--nxcompat) LINK_OPTIONS=-Wl,-O1 -Wl,--discard-all -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -static # Set ARCHITECTURE to either x86 or x86_64... ARCHITECTURE=32-bit ifeq ($(shell $(CC) -dumpmachine), x86_64-w64-mingw32) ARCHITECTURE=64-bit endif # Set the version string for the program. VERSION = "$(shell grep -E -o -m 1 "[0-9]+\.[0-9]+\.[0-9]+" Changelog) Windows $(ARCHITECTURE) (Mingw)" all: sslscan sslscan: sslscan.c $(CC) -I$(OPENSSL_PATH)/include -DVERSION=\"$(VERSION)\" $(DEFINES) $(SECURITY_OPTIONS) $(LINK_OPTIONS) -o sslscan.exe sslscan.c $(OPENSSL_PATH)/libssl.a $(OPENSSL_PATH)/libcrypto.a -lws2_32 -lgdi32 strip sslscan.exe clean: rm -f *.o sslscan.exe sslscan-1.11.5-rbsec/Makefile.vs000066400000000000000000000010041267505277700164450ustar00rootroot00000000000000LFLAGS=/nologo /dynamicbase /highentropyva /nxcompat /opt:ref /subsystem:console /ltcg CFLAGS=/nologo /GL /GS /Gs0 /Gw /MT /Ox -DVERSION="\"1.9.8 Windows 64-bit (VS)\"" all: sslscan.exe sslscan.obj: sslscan.c cl.exe $(CFLAGS) /I $(OPENSSL_PATH)/include /c sslscan.c sslscan.exe: sslscan.obj link.exe $(LFLAGS) /out:sslscan.exe sslscan.obj $(OPENSSL_PATH)/out32/libeay32.lib $(OPENSSL_PATH)/out32/ssleay32.lib advapi32.lib gdi32.lib user32.lib ws2_32.lib clean: del sslscan.obj sslscan.exe rebuild: clean all sslscan-1.11.5-rbsec/README.md000066400000000000000000000146001267505277700156430ustar00rootroot00000000000000# README [![Build Status](https://travis-ci.org/rbsec/sslscan.svg?branch=master)](https://travis-ci.org/rbsec/sslscan) This is a fork of ioerror's version of sslscan (the original readme of which is included below). Changes are as follows: * Highlight SSLv2 and SSLv3 ciphers in output. * Highlight CBC ciphers on SSLv3 (POODLE) * Highlight RC4 ciphers in output. * Highlight GCM ciphers as good in output. * Highlight NULL (0 bit), weak (<40 bit) and medium (40 < n <= 56) ciphers in output. * Highlight anonymous (ADH and AECDH) ciphers in output (purple). * Hide certificate information by default (display with --get-certificate). * Hide rejected ciphers by default (display with --failed). * Added TLSv1.1 and TLSv1.2 support (merged from twwbond/sslscan). * Compiles if OpenSSL does not support SSLv2 ciphers (merged from digineo/sslscan). * Supports IPv6 hostnames (can be forced with --ipv6). * Check for TLS compression (CRIME, disable with --no-compression). * Disable cipher suite checking (--no-ciphersuites). * Disable coloured output (--no-colour). * Removed undocumented -p output option. * Added check for OpenSSL HeartBleed (CVE-2014-0160, disable with --no-heartbleed). * Flag certificates signed with MD5 or SHA-1, or with short (<2048 bit) RSA keys. * Support scanning RDP servers with --rdp (credit skettler). * Added option to specify socket timeout. * Added option for static compilation (credit dmke). * Added --sleep option to pause between requests. * Disable output for anything than specified checks (--no-preferred). * Determine the list of CAs acceptable for client certificates (--show-client-cas). * Experimental build support on OSX (credit MikeSchroll) * Flag some self-signed SSL certificates. * Experimental Windows support (credit jtesta). * Display EC curve names and DHE key lengths with OpenSSL >= 1.0.2 (--no-cipher-details) * Flag weak DHE keys with OpenSSL >= 1.0.2 (--cipher-details) * Flag expired certificates * Flag TLSv1.0 ciphers in output as weak. * Experimental OSX support (static building only) * Support for scanning PostgreSQL servers (credit nuxi) ### Building on Windows Thanks to a patch by jtesta, sslscan can now be compiled on Windows. This can either be done natively or by cross-compiling from Linux. See INSTALL for instructions. Note that sslscan was originally written for Linux, and has not been extensively tested on Windows. As such, the Windows version should be considered experimental. Pre-build cross-compiled Windows binaries are available on the [GitHub Releases Page](https://github.com/rbsec/sslscan/releases). ### Building on OS X There is experimental support for statically building on OS X, however this should be considered unsupported. You may need to install any dependencies required to compile OpenSSL from source on OS X. Once you have, just run: make static ### OpenSSL issues #### Statically linking a custom OpenSSL build It is possible to ignore the OpenSSL system installation and ship your own version. Although this results in a more resource-heavy `sslscan` binary (file size, memory consumption, etc.), this allows to enable both SSLv2 and SSLv3 ciphers. In comparison to the method of repackaging the Debian build, this custom OpenSSL build won't affect other tools on the same system, as they would use the version packaged by the distro's maintainers. To compile your own OpenSSL version, you'll probably need to install the OpenSSL build dependencies: apt-get install build-essential git zlib1g-dev apt-get build-dep openssl then run make static which will clone the [OpenSSL repository](https://github.com/openssl/openssl), and configure/compile/test OpenSSL prior to compiling `sslscan`. **Please note:** Out of the box, OpenSSL cannot compiled with `clang` without further customization (which is not done by the provided `Makefile`). For more information on this, see [Modifying Build Settings](http://wiki.openssl.org/index.php/Compilation_and_Installation#Modifying_Build_Settings) in the OpenSSL wiki. You can verify whether you have a statically linked OpenSSL version, if ./sslscan --version looks a bit like 1.x.y-...-static OpenSSL 1.1.0-dev xx XXX xxxx (pay attention to the `-static` suffix and the `1.1.0-dev` OpenSSL version). #### Building on Kali Kali now ships with a statically built version of sslscan which supports SSLv2. The package can be found in the [Kali Git Repository](http://git.kali.org/gitweb/?p=packages/sslscan.git;a=summary). If for whatever reason you can't install this package, follow the instructions above for statically building against OpenSSL. #### Building on Debian It is recommended that you statically build sslscan using the instructions listed above. If this is not an option and you want to compile your system OpenSSL with support for legacy protocols such as SSLv2 and SSLv3 then follow the instructions below. Note that many modern distros (including Debian) ship with a version of OpenSSL that disables support for SSLv2 ciphers. If `sslscan` is compiled on one of these distros, it will not be able to detect SSLv2. This issue can be resolved by rebuilding OpenSSL from source after removing the patch that disables SSLv2 support. The `build_openssl_debian.sh` script automates this process for Debian systems. It has been tested on Debian Squeeze/Wheezy; it may work on other Debian based distros, but has not been tested. The built version of OpenSSL will be installed using `dpkg`. If it is not possible to rebuild OpenSSL, `sslscan` will still compile (thanks to a patch from [digineo/sslscan](https://github.com/digineo/sslscan), based on the debian patch). However, a warning will be displayed in the output to notify the user that SSLv2 ciphers will not be detected. # Original (ioerror) README This is a fork of sslscan.c to better support STARTTLS. The original home page of sslscan is: http://www.titania.co.uk sslscan was originally written by: Ian Ventura-Whiting The current home page of this fork (until upstream merges a finished patch) is: http://www.github.com/ioerror/sslscan Most of the pre-TLS protocol setup was inspired by the OpenSSL s_client.c program. The goal of this fork is to eventually merge with the original project after the STARTTLS setup is polished. Some of the OpenSSL setup code was borrowed from The Tor Project's Tor program. Thus it is likely proper to comply with the BSD license by saying: Copyright (c) 2007-2010, The Tor Project, Inc. sslscan-1.11.5-rbsec/TODO000066400000000000000000000016711267505277700150600ustar00rootroot00000000000000Fix session resumption test We have a false positive for session resumption IDs are assigned but not accepted for resumption Fix the certificate formatting (prefix it with whitespace) Add support for SOCKS5 proxy (or audit for 'usewithtor') It seems to work fine with 'usewithtor' It still seems prudent to add proper proxy support Add STARTTLS support for LDAP: http://www.rfc-editor.org/rfc/rfc2830.txt Fix XMPP scans that do not support StartTLS: "" Add HTML report generation Add diff between reported and actually supported ciphers Make a Debian package We should explicitly check for things that may be NULL; the original author was not very careful. Perhaps write a GUI for people who are console adverse? Compare with http://www.thesprawl.org/memdump/?entry=7 Finally, we should send a diff from 1.8.2 to the upstream developer sslscan-1.11.5-rbsec/build_openssl_debian.sh000077500000000000000000000021231267505277700210640ustar00rootroot00000000000000#!/bin/bash # # Script to build OpenSSL deb packages from source with SSLv2 support # Built packages are automatically installed with dpkg # Tested on Debian Squeeze and Kali 1.0.8 # The packages will probably get replaced next time you do a system upgrade # To prevent this, hold the packages using the following command # # $ echo "openssl hold" | sudo dpkg --set-selections # # Clean up previous build sudo rm -rf openssl mkdir openssl cd openssl # Exit if any command fails set -e # Install dependencies sudo apt-get update sudo apt-get -y --no-upgrade install build-essential devscripts quilt sudo apt-get -y build-dep openssl # Get the source apt-get source openssl cd openssl* # Revert the patches quilt pop -a # Remove the 'ssltest_no_sslv2.patch' line sed -i '/ssltest_no_sslv2.patch/d' debian/patches/series # Remove the 'no-ssl2' build argument sed -i 's/ no-ssl2//g' debian/rules # Re-apply patches quilt push -a # Packaging stuff dch -n 'Allow SSLv2' dpkg-source --commit # Build the packges (takes a while) sudo debuild -uc -us # Install the packages cd .. sudo dpkg -i *ssl*.deb sslscan-1.11.5-rbsec/sslscan.1000066400000000000000000000124561267505277700161230ustar00rootroot00000000000000.TH SSLSCAN 1 "December 30, 2013" .SH NAME sslscan \- Fast SSL/TLS scanner .SH SYNOPSIS .B sslscan .RI [ options ] " [host:port | host]" .SH DESCRIPTION This manual page documents briefly the .B sslscan command .PP \fBsslscan\fP queries SSL/TLS services, such as HTTPS, in order to determine the ciphers that are supported. SSLScan is designed to be easy, lean and fast. The output includes preferred ciphers of the SSL/TLS service, and text and XML output formats are supported. It is TLS SNI aware when used with a supported version of OpenSSL. Output is colour coded to indicate security issues. Colours are as follows: Red Background NULL cipher (no encryption) .br Red Broken cipher (<= 40 bit), broken protocol (SSLv2 or SSLv3) or broken certificate signing algorithm (MD5) .br Yellow Weak cipher (<= 56 bit or RC4) or weak certificate signing algorithm (SHA-1) .br Purple Anonymous cipher (ADH or AECDH) .SH OPTIONS .TP .B \-\-help .br Show summary of options .TP .B \-\-version Show version of program .TP .B \-\-targets= A file containing a list of hosts to check. Hosts can be supplied with ports (i.e. host:port). One target per line .TP .B \-\-ipv4 .br Force IPv4 DNS resolution. Default is to try IPv4, and if that fails then fall back to IPv6. .TP .B \-\-ipv6 .br Force IPv6 DNS resolution. Default is to try IPv4, and if that fails then fall back to IPv6. .TP .B \-\-show\-certificate Display certificate information. .TP .B \-\-no\-check\-certificate Don't flag certificates signed with weak algorithms (MD5 and SHA-1) or short (<2048 bit) RSA keys .TP .B \-\-show\-client\-cas Show a list of CAs that the server allows for client authentication. Will be blank for IIS/Schannel servers. .TP .B \-\-show\-ciphers Show a complete list of ciphers supported by sslscan .TP .B \-\-show\-cipher-ids Print the hexadecimal cipher IDs .TP .B \-\-show\-times Show the time taken for each handshake in milliseconds. Note that only a single request is made with each cipher, and that the size of the ClientHello is not constant, so this should not be used for proper benchmarking or performance testing. You might want to also use \-\-no\-cipher\-details to make the output a bit clearer. .TP .B \-\-ssl2 .br Only check SSLv2 ciphers .br Note that this option may not be available if system OpenSSL does not support SSLv2. Either build OpenSSL statically or rebuild your system OpenSSL with SSLv2 support. See the readme for further details. .TP .B \-\-ssl3 .br Only check SSLv3 ciphers .br Note that this option may not be available if system OpenSSL does not support SSLv3. Either build OpenSSL statically or rebuild your system OpenSSL with SSLv3 support. See the readme for further details. .TP .B \-\-tls10 .br Only check TLS 1.0 ciphers .TP .B \-\-tls11 .br Only check TLS 1.1 ciphers .TP .B \-\-tls12 .br Only check TLS 1.2 ciphers .TP .B \-\-tlsall .br Only check TLS ciphers (versions 1.0, 1.1 and 1.2) .TP .B \-\-ocsp .br Display OCSP status .TP .B \-\-pk= A file containing the private key or a PKCS#12 file containing a private key/certificate pair (as produced by MSIE and Netscape) .TP .B \-\-pkpass= The password for the private key or PKCS#12 file .TP .B \-\-certs= A file containing PEM/ASN1 formatted client certificates .TP .B \-\-no\-ciphersuites Do not scan for supported ciphersuites. .TP .B \-\-no\-renegotiation Do not check for secure TLS renegotiation .TP .B \-\-no\-compression Do not check for TLS compression (CRIME) .TP .B \-\-no\-heartbleed Do not check for OpenSSL Heartbleed (CVE-2014-0160) .TP .B \-\-starttls\-ftp STARTTLS setup for FTP .TP .B \-\-starttls\-irc STARTTLS setup for IRC .TP .B \-\-starttls\-imap STARTTLS setup for IMAP .TP .B \-\-starttls\-pop3 STARTTLS setup for POP3 .TP .B \-\-starttls\-smtp STARTTLS setup for SMTP .br Note that some servers hang when we try to use SSLv3 ciphers over STARTTLS. If you scan hangs, try using the --tlsall option. .TP .B \-\-starttls\-psql STARTTLS setup for PostgreSQL .TP .B \-\-starttls\-xmpp STARTTLS setup for XMPP .TP .B \-\-xmpp-server Perform a server-to-server XMPP connection. Try this if --starttls-xmpp is failing. .TP .B \-\-rdp .br Send RDP preamble before starting scan. .TP .B \-\-http .br Makes a HTTP request after a successful connection and returns the server response code .TP .B \-\-no\-cipher\-details .br Hide NIST EC curve name and EDH/RSA key length. Requires OpenSSL >= 1.0.2 (so if you distro doesn't ship this, you'll need to statically build sslscan). .TP .B \-\-bugs .br Enables workarounds for SSL bugs .TP .B \-\-timeout= .br Set socket timeout. Useful for hosts that fail to respond to ciphers they don't understand. Default is 3s. .TP .B \-\-sleep= .br Pause between connections. Useful on STARTTLS SMTP services, or anything else that's performing rate limiting. Default is disabled. .TP .B \-\-xml= .br Output results to an XML file .br .TP .B \-\-no-colour .br Disable coloured output. .SH EXAMPLES .LP Scan a local HTTPS server .RS .nf sslscan localhost sslscan 127.0.0.1 sslscan 127.0.0.1:443 sslscan [::1] sslscan [::1]:443 .SH AUTHOR sslscan was originally written by Ian Ventura-Whiting . .br sslscan was extended by Jacob Appelbaum . .br sslscan was extended by rbsec . .br This manual page was originally written by Marvin Stark . sslscan-1.11.5-rbsec/sslscan.c000066400000000000000000004416471267505277700162150ustar00rootroot00000000000000/*************************************************************************** * sslscan - A SSL cipher scanning tool * * Copyright 2007-2009 by Ian Ventura-Whiting (Fizz) * * fizz@titania.co.uk * * Copyright 2010 by Michael Boman (michael@michaelboman.org) * * Copyleft 2010 by Jacob Appelbaum * * Copyleft 2013 by rbsec * * Copyleft 2014 by Julian Kornberger * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * * In addition, as a special exception, the copyright holders give * * permission to link the code of portions of this program with the * * OpenSSL library under certain conditions as described in each * * individual source file, and distribute linked combinations * * including the two. * * You must obey the GNU General Public License in all respects * * for all of the code used other than OpenSSL. If you modify * * file(s) with this exception, you may extend this exception to your * * version of the file(s), but you are not obligated to do so. If you * * do not wish to do so, delete this exception statement from your * * version. If you delete this exception statement from all source * * files in the program, then also delete it here. * ***************************************************************************/ // Includes... #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN #define _WIN32_WINNT 0x0501 #include #include #include #include #ifdef _MSC_VER // For access(). #include // Flag for access() call. #define R_OK 4 // access() happens to be deprecated, so use the secure version instead. #define access _access_s // There is no snprintf(), but _snprintf() instead. #define snprintf _snprintf // Calling close() on a socket descriptor instead of closesocket() causes // a crash! #define close closesocket // Visual Studio doesn't have ssize_t... typedef int ssize_t; #endif #else #include #include #include #endif #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_COMP #include #endif // If we're not compiling with Visual Studio, include unistd.h. VS // doesn't have this header. #ifndef _MSC_VER #include #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) #include #endif #include "sslscan.h" /* Borrowed from tortls.c to dance with OpenSSL on many platforms, with * many versions and releases of OpenSSL. */ /** Does the run-time openssl version look like we need * SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION? */ static int use_unsafe_renegotiation_op = 0; /** Does the run-time openssl version look like we need * SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION? */ static int use_unsafe_renegotiation_flag = 0; // Adds Ciphers to the Cipher List structure int populateCipherList(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { int returnCode = true; struct sslCipher *sslCipherPointer; int tempInt; int loop; // STACK_OF is a sign that you should be using C++ :) STACK_OF(SSL_CIPHER) *cipherList; SSL *ssl = NULL; options->ctx = SSL_CTX_new(sslMethod); if (options->ctx == NULL) { printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); return false; } SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL"); ssl = SSL_new(options->ctx); if (ssl == NULL) { printf_error("%sERROR: Could not create SSL object.%s\n", COL_RED, RESET); SSL_CTX_free(options->ctx); return false; } cipherList = SSL_get_ciphers(ssl); // Create Cipher Struct Entries... for (loop = 0; loop < sk_SSL_CIPHER_num(cipherList); loop++) { if (options->ciphers == 0) { options->ciphers = malloc(sizeof(struct sslCipher)); sslCipherPointer = options->ciphers; } else { sslCipherPointer = options->ciphers; while (sslCipherPointer->next != 0) sslCipherPointer = sslCipherPointer->next; sslCipherPointer->next = malloc(sizeof(struct sslCipher)); sslCipherPointer = sslCipherPointer->next; } // Init memset(sslCipherPointer, 0, sizeof(struct sslCipher)); // Add cipher information... sslCipherPointer->sslMethod = sslMethod; sslCipherPointer->name = SSL_CIPHER_get_name(sk_SSL_CIPHER_value(cipherList, loop)); sslCipherPointer->version = SSL_CIPHER_get_version(sk_SSL_CIPHER_value(cipherList, loop)); SSL_CIPHER_description(sk_SSL_CIPHER_value(cipherList, loop), sslCipherPointer->description, sizeof(sslCipherPointer->description) - 1); sslCipherPointer->bits = SSL_CIPHER_get_bits(sk_SSL_CIPHER_value(cipherList, loop), &tempInt); } SSL_free(ssl); SSL_CTX_free(options->ctx); return returnCode; } // File Exists int fileExists(char *fileName) { return access(fileName, R_OK) == 0; } // Read a line from the input... void readLine(FILE *input, char *lineFromFile, int maxSize) { // Variables... int stripPointer; // Read line from file... fgets(lineFromFile, maxSize, input); // Clear the end-of-line stuff... stripPointer = strlen(lineFromFile) -1; while (stripPointer >= 0 && ((lineFromFile[stripPointer] == '\r') || (lineFromFile[stripPointer] == '\n') || (lineFromFile[stripPointer] == ' '))) { lineFromFile[stripPointer] = 0; stripPointer--; } } int readOrLogAndClose(int fd, void* buffer, size_t len, const struct sslCheckOptions *options) { ssize_t n; if (len < 2) return 1; n = recv(fd, buffer, len - 1, 0); if (n < 0 && errno != 11) { printf_error("%s ERROR: error reading from %s:%d: %s%s\n", COL_RED, options->host, options->port, strerror(errno), RESET); close(fd); return 0; } else if (n == 0) { printf_error("%s ERROR: unexpected EOF reading from %s:%d%s\n", COL_RED, options->host, options->port, RESET); close(fd); return 0; } else { ((unsigned char *)buffer)[n] = 0; } return 1; } // Write a null-terminated string to a socket ssize_t sendString(int sockfd, const char str[]) { return send(sockfd, str, strlen(str), 0); } // Create a TCP socket int tcpConnect(struct sslCheckOptions *options) { //Sleep if required if (options->sleep > 0) { SLEEPMS(options->sleep); } // Variables... int socketDescriptor; int tlsStarted = 0; char buffer[BUFFERSIZE]; int status; // Create Socket if (options->h_addrtype == AF_INET) { socketDescriptor = socket(AF_INET, SOCK_STREAM, 0); } else // IPv6 { socketDescriptor = socket(AF_INET6, SOCK_STREAM, 0); } if(socketDescriptor < 0) { printf_error("%s ERROR: Could not open a socket.%s\n", COL_RED, RESET); return 0; } // Set socket timeout #ifdef _WIN32 // Windows isn't looking for a timeval struct like in UNIX; it wants a timeout in a DWORD represented in milliseconds... DWORD timeout = (options->timeout.tv_sec * 1000) + (options->timeout.tv_usec / 1000); setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); #else setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVTIMEO, (char *)&options->timeout,sizeof(struct timeval)); #endif // Connect if (options->h_addrtype == AF_INET) { status = connect(socketDescriptor, (struct sockaddr *) &options->serverAddress, sizeof(options->serverAddress)); } else // IPv6 { status = connect(socketDescriptor, (struct sockaddr *) &options->serverAddress6, sizeof(options->serverAddress6)); } if(status < 0) { printf_error("%sERROR: Could not open a connection to host %s on port %d.%s\n", COL_RED, options->host, options->port, RESET); close(socketDescriptor); return 0; } // If STARTTLS is required... if (options->starttls_smtp == true && tlsStarted == false) { tlsStarted = 1; if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; if (strncmp(buffer, "220", 3) != 0) { close(socketDescriptor); printf("%s ERROR: The host %s on port %d did not appear to be an SMTP service.%s\n", COL_RED, options->host, options->port, RESET); return 0; } sendString(socketDescriptor, "EHLO example.org\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; if (strncmp(buffer, "250", 3) != 0) { close(socketDescriptor); printf("%s ERROR: The SMTP service on %s port %d did not respond with status 250 to our HELO.%s\n", COL_RED, options->host, options->port, RESET); return 0; } sendString(socketDescriptor, "STARTTLS\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; if (strncmp(buffer, "220", 3) != 0) { close(socketDescriptor); printf("%s ERROR: The SMTP service on %s port %d did not appear to support STARTTLS.%s\n", COL_RED, options->host, options->port, RESET); return 0; } } // We could use an XML parser but frankly it seems like a security disaster if (options->starttls_xmpp == true && tlsStarted == false) { /* This is so ghetto, you cannot release it! */ char xmpp_setup[1024]; // options->host is 512 bytes long /* XXX: TODO - options->host isn't always the host you want to test eg: talk.google.com actually expects gmail.com, not talk.google.com jabber.ccc.de expects jabber.ccc.de It may be useful to provide a commandline switch to provide the expected hostname. */ // Server to server handshake if (options->xmpp_server) { if (snprintf(xmpp_setup, sizeof(xmpp_setup), "\r\n" "\r\n", options->host) >= sizeof(xmpp_setup)) { printf("(internal error: xmpp_setup buffer too small)\n"); abort(); } } // Client to server handshake (default) else { if (snprintf(xmpp_setup, sizeof(xmpp_setup), "\r\n" "\r\n", options->host) >= sizeof(xmpp_setup)) { printf("(internal error: xmpp_setup buffer too small)\n"); abort(); } } tlsStarted = 1; sendString(socketDescriptor, xmpp_setup); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; printf_verbose("Server reported: %s\nAttempting to STARTTLS\n", buffer); sendString(socketDescriptor, "\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; /* We're looking for something like: verbose) printf("Server reported: %s\n", buffer); if (strstr(buffer, "starttls_pop3 == true && tlsStarted == false) { tlsStarted = 1; if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; printf_verbose("Server reported: %s\n", buffer); sendString(socketDescriptor, "STLS\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; // We probably want to confirm that we see something like: // '+OK Begin SSL/TLS negotiation now.' // Or // '+OK Begin TLS negotiation, mate' if (strstr(buffer, "+OK Begin")) { printf_verbose("It appears that the POP3 server is ready for TLS.\n"); } printf_verbose("Server reported: %s\n", buffer); } // Setup an IMAP STARTTLS socket if (options->starttls_imap == true && tlsStarted == false) { tlsStarted = 1; memset(buffer, 0, BUFFERSIZE); // Fetch the IMAP banner if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; printf_verbose("Server banner: %s\n", buffer); // Attempt to STARTTLS sendString(socketDescriptor, ". STARTTLS\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; if (strstr(buffer, ". OK") || strstr(buffer, " . OK")){ printf_verbose("STARTLS IMAP setup complete.\nServer reported: %s\n", buffer); } else{ printf_verbose("STARTLS IMAP setup not complete.\nServer reported: %s\n", buffer); } } if (options->starttls_irc == true && tlsStarted == false) { tlsStarted = 1; if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; printf_verbose("Server reported: %s\n", buffer); // Attempt to STARTTLS sendString(socketDescriptor, "STARTTLS\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; if (strstr(buffer, " 670 ") || strstr(buffer, ":STARTTLS successful")) { printf_verbose("STARTLS IRC setup complete.\nServer reported %s\n", buffer); } else { printf_verbose("STARTLS IRC setup not complete.\nServer reported %s\n", buffer); } } // Setup a FTP STARTTLS socket if (options->starttls_ftp == true && tlsStarted == false) { tlsStarted = 1; // Fetch the server banner if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; printf_verbose("Server banner: %s\n", buffer); // Send TLS request sendString(socketDescriptor, "AUTH TLS\r\n"); if (!readOrLogAndClose(socketDescriptor, buffer, BUFFERSIZE, options)) return 0; if (strstr(buffer, "234 AUTH TLS successful")) { printf_verbose("STARTLS FTP setup complete.\n"); } else { printf_verbose("STARTLS FTP setup possibly not complete.\n"); } printf_verbose("Server reported: %s\n", buffer); } if (options->starttls_psql == true && tlsStarted == false) { unsigned char buffer; tlsStarted = 1; // Send SSLRequest packet send(socketDescriptor, "\x00\x00\x00\x08\x04\xd2\x16\x2f", 8, 0); // Read reply byte if (1 != recv(socketDescriptor, &buffer, 1, 0)) { printf_error("%s ERROR: unexpected EOF reading from %s:%d%s\n", COL_RED, options->host, options->port, RESET); return 0; } if (buffer != 'S') { printf_error("%s ERROR: server at %s:%d%s rejected TLS startup\n", COL_RED, options->host, options->port, RESET); return 0; } } // Setup an RDP socket with preamble // Borrowed from https://labs.portcullis.co.uk/tools/ssl-cipher-suite-enum/ if (options->rdp == true && tlsStarted == false) { unsigned char buffer[32768]; size_t readlen; tlsStarted = 1; // Send RDP preamble send(socketDescriptor, "\x03\x00\x00\x13\x0e\xe0\x00\x00\x00\x00\x00\x01\x00\x08\x00\x03\x00\x00\x00", 19, 0); // Read reply header if (4 != recv(socketDescriptor, buffer, 4, 0)) { printf_error("%s ERROR: unexpected EOF reading from %s:%d%s\n", COL_RED, options->host, options->port, RESET); return 0; } // Calculate remaining bytes (and check for overflows) readlen = ((buffer[2] & 0x7f) << 8) + buffer[3] - 4; if (readlen > sizeof(buffer)) { printf_error("%s ERROR: unexpected data from %s:%d%s\n", COL_RED, options->host, options->port, RESET); return 0; } // Read reply data if (readlen != recv(socketDescriptor, buffer, readlen, 0)) { printf_error("%s ERROR: unexpected EOF reading from %s:%d%s\n", COL_RED, options->host, options->port, RESET); return 0; } } // Return return socketDescriptor; } // Private Key Password Callback... static int password_callback(char *buf, int size, int rwflag, void *userdata) { strncpy(buf, (char *)userdata, size); // I don't know the semantics of these arguments, but it looks like this // could go badly wrong if userdata is too long. buf[strlen(userdata)] = 0; return strlen(userdata); } // Load client certificates/private keys... int loadCerts(struct sslCheckOptions *options) { // Variables... int status = 1; PKCS12 *pk12 = NULL; FILE *pk12File = NULL; X509 *cert = NULL; EVP_PKEY *pkey = NULL; STACK_OF(X509) *ca = NULL; // Configure PKey password... if (options->privateKeyPassword != 0) { SSL_CTX_set_default_passwd_cb_userdata(options->ctx, (void *)options->privateKeyPassword); SSL_CTX_set_default_passwd_cb(options->ctx, password_callback); } // Separate Certs and PKey Files... if ((options->clientCertsFile != 0) && (options->privateKeyFile != 0)) { // Load Cert... if (!SSL_CTX_use_certificate_file(options->ctx, options->clientCertsFile, SSL_FILETYPE_PEM)) { if (!SSL_CTX_use_certificate_file(options->ctx, options->clientCertsFile, SSL_FILETYPE_ASN1)) { if (!SSL_CTX_use_certificate_chain_file(options->ctx, options->clientCertsFile)) { printf("%s Could not configure certificate(s).%s\n", COL_RED, RESET); status = 0; } } } // Load PKey... if (status != 0) { if (!SSL_CTX_use_PrivateKey_file(options->ctx, options->privateKeyFile, SSL_FILETYPE_PEM)) { if (!SSL_CTX_use_PrivateKey_file(options->ctx, options->privateKeyFile, SSL_FILETYPE_ASN1)) { // Why would the more specific functions succeed if the generic functions failed? // -- I'm guessing that the original author was hopeful? - io if (!SSL_CTX_use_RSAPrivateKey_file(options->ctx, options->privateKeyFile, SSL_FILETYPE_PEM)) { if (!SSL_CTX_use_RSAPrivateKey_file(options->ctx, options->privateKeyFile, SSL_FILETYPE_ASN1)) { printf("%s Could not configure private key.%s\n", COL_RED, RESET); status = 0; } } } } } } // PKCS Cert and PKey File... else if (options->privateKeyFile != 0) { pk12File = fopen(options->privateKeyFile, "rb"); if (pk12File != NULL) { pk12 = d2i_PKCS12_fp(pk12File, NULL); if (!pk12) { status = 0; printf("%s Could not read PKCS#12 file.%s\n", COL_RED, RESET); } else { if (!PKCS12_parse(pk12, options->privateKeyPassword, &pkey, &cert, &ca)) { status = 0; printf("%s Error parsing PKCS#12. Are you sure that password was correct?%s\n", COL_RED, RESET); } else { if (!SSL_CTX_use_certificate(options->ctx, cert)) { status = 0; printf("%s Could not configure certificate.%s\n", COL_RED, RESET); } if (!SSL_CTX_use_PrivateKey(options->ctx, pkey)) { status = 0; printf("%s Could not configure private key.%s\n", COL_RED, RESET); } } PKCS12_free(pk12); } fclose(pk12File); } else { printf("%s Could not open PKCS#12 file.%s\n", COL_RED, RESET); status = 0; } } // Check Cert/Key... if (status != 0) { if (!SSL_CTX_check_private_key(options->ctx)) { printf("%s Private key does not match certificate.%s\n", COL_RED, RESET); return false; } else return true; } else return false; } // Test renegotiation int outputRenegotiation( struct sslCheckOptions *options, struct renegotiationOutput *outputData) { printf_xml(" \n", outputData->supported, outputData->secure); if (outputData->secure) printf("%sSecure%s session renegotiation supported\n\n", COL_GREEN, RESET); else if (outputData->supported) printf("%sInsecure%s session renegotiation supported\n\n", COL_RED, RESET); else printf("Session renegotiation %snot supported%s\n\n", COL_GREEN, RESET); return true; } struct renegotiationOutput * newRenegotiationOutput( void ) { struct renegotiationOutput *myRenOut; myRenOut = calloc(1,sizeof(struct renegotiationOutput)); return( myRenOut ); } int freeRenegotiationOutput( struct renegotiationOutput *myRenOut ) { if ( myRenOut != NULL) { free(myRenOut); } return true; } void tls_reneg_init(struct sslCheckOptions *options) { /* Borrowed from tortls.c to dance with OpenSSL on many platforms, with * many versions and release of OpenSSL. */ SSL_library_init(); SSL_load_error_strings(); long version = SSLeay(); if (version >= 0x009080c0L && version < 0x009080d0L) { printf_verbose("OpenSSL %s looks like version 0.9.8l; I will try SSL3_FLAGS to enable renegotiation.\n", SSLeay_version(SSLEAY_VERSION)); use_unsafe_renegotiation_flag = 1; use_unsafe_renegotiation_op = 1; } else if (version >= 0x009080d0L) { printf_verbose("OpenSSL %s looks like version 0.9.8m or later; " "I will try SSL_OP to enable renegotiation\n", SSLeay_version(SSLEAY_VERSION)); use_unsafe_renegotiation_op = 1; } else if (version < 0x009080c0L) { printf_verbose("OpenSSL %s [%lx] looks like it's older than " "0.9.8l, but some vendors have backported 0.9.8l's " "renegotiation code to earlier versions, and some have " "backported the code from 0.9.8m or 0.9.8n. I'll set both " "SSL3_FLAGS and SSL_OP just to be safe.\n", SSLeay_version(SSLEAY_VERSION), version); use_unsafe_renegotiation_flag = 1; use_unsafe_renegotiation_op = 1; } else { printf_verbose("OpenSSL %s has version %lx\n", SSLeay_version(SSLEAY_VERSION), version); } #ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION SSL_CTX_set_options(options->ctx, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION); #endif } // Check if the server supports compression int testCompression(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { // Variables... int status = true; int socketDescriptor = 0; SSL *ssl = NULL; BIO *cipherConnectionBio; SSL_SESSION session; // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Setup Context Object... options->ctx = SSL_CTX_new(sslMethod); tls_reneg_init(options); if (options->ctx != NULL) { if (SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL") != 0) { // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); if (status == true) { // Create SSL object... ssl = SSL_new(options->ctx); #if ( OPENSSL_VERSION_NUMBER > 0x009080cfL ) // Make sure we can connect to insecure servers // OpenSSL is going to change the default at a later date SSL_set_options(ssl, SSL_OP_LEGACY_SERVER_CONNECT); #endif #ifdef SSL_OP_NO_COMPRESSION // Make sure to clear the no compression flag SSL_clear_options(ssl, SSL_OP_NO_COMPRESSION); #endif if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // This enables TLS SNI SSL_set_tlsext_host_name(ssl, options->host); #endif // Connect SSL over socket SSL_connect(ssl); session = *SSL_get_session(ssl); #ifndef OPENSSL_NO_COMP // Make sure zlib is actually present if (COMP_zlib()->type != NID_undef) { printf_xml(" \n", session.compress_meth); if (session.compress_meth == 0) { printf("Compression %sdisabled%s\n\n", COL_GREEN, RESET); } else { printf("Compression %senabled%s (CRIME)\n\n", COL_RED, RESET); } } else #endif { printf("%sOpenSSL version does not support compression%s\n", COL_RED, RESET); printf("%sRebuild with zlib1g-dev package for zlib support%s\n\n", COL_RED, RESET); } // Disconnect SSL over socket SSL_shutdown(ssl); // Free SSL object SSL_free(ssl); } else { status = false; printf_error("%s ERROR: Could create SSL object.%s\n", COL_RED, RESET); } } } else { status = false; printf_error("%s ERROR: Could set cipher.%s\n", COL_RED, RESET); } // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { status = false; printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); } // Disconnect from host close(socketDescriptor); } else { // Could not connect printf_error("%sERROR: Could not connect.%s\n", COL_RED, RESET); status = false; exit(status); } return status; } // Check if the server supports renegotiation int testRenegotiation(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { // Variables... int cipherStatus; int status = true; //int secure = false; int socketDescriptor = 0; int res; SSL *ssl = NULL; BIO *cipherConnectionBio; struct renegotiationOutput *renOut = newRenegotiationOutput(); // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Setup Context Object... options->ctx = SSL_CTX_new(sslMethod); tls_reneg_init(options); if (options->ctx != NULL) { if (SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL") != 0) { // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); if (status == true) { // Create SSL object... ssl = SSL_new(options->ctx); #if ( OPENSSL_VERSION_NUMBER > 0x009080cfL ) // Make sure we can connect to insecure servers // OpenSSL is going to change the default at a later date SSL_set_options(ssl, SSL_OP_LEGACY_SERVER_CONNECT); #endif if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // This enables TLS SNI // Based on http://does-not-exist.org/mail-archives/mutt-dev/msg13045.html // TLS Virtual-hosting requires that the server present the correct // certificate; to do this, the ServerNameIndication TLS extension is used. // If TLS is negotiated, and OpenSSL is recent enough that it might have // support, and support was enabled when OpenSSL was built, mutt supports // sending the hostname we think we're connecting to, so a server can send // back the correct certificate. // NB: finding a server which uses this for IMAP is problematic, so this is // untested. Please report success or failure! However, this code change // has worked fine in other projects to which the contributor has added it, // or HTTP usage. SSL_set_tlsext_host_name(ssl, options->host); #endif // Connect SSL over socket cipherStatus = SSL_connect(ssl); /* Yes, we know what we are doing here. No, we do not treat a renegotiation * as authenticating any earlier-received data. */ if (use_unsafe_renegotiation_flag) { printf_verbose("use_unsafe_renegotiation_flag\n"); ssl->s3->flags |= SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION; } if (use_unsafe_renegotiation_op) { printf_verbose("use_unsafe_renegotiation_op\n"); SSL_set_options(ssl, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION); } if (cipherStatus == 1) { #if ( OPENSSL_VERSION_NUMBER > 0x009080cfL ) // SSL_get_secure_renegotiation_support() appeared first in OpenSSL 0.9.8m printf_verbose("Attempting secure_renegotiation_support()"); renOut->secure = SSL_get_secure_renegotiation_support(ssl); if( renOut->secure ) { // If it supports secure renegotiations, // it should have renegotiation support in general renOut->supported = true; status = true; } else { #endif // We can't assume that just because the secure renegotiation // support failed the server doesn't support insecure renegotiations· // assume ssl is connected and error free up to here //setBlocking(ssl); // this is unnecessary if it is already blocking· printf_verbose("Attempting SSL_renegotiate(ssl)\n"); SSL_renegotiate(ssl); // Ask to renegotiate the connection // This hangs when an 'encrypted alert' is sent by the server printf_verbose("Attempting SSL_do_handshake(ssl)\n"); SSL_do_handshake(ssl); // Send renegotiation request to server //TODO :: XXX hanging here if (ssl->state == SSL_ST_OK) { res = SSL_do_handshake(ssl); // Send renegotiation request to server if( res != 1 ) { printf_error("\n\nSSL_do_handshake() call failed\n"); } if (ssl->state == SSL_ST_OK) { /* our renegotiation is complete */ renOut->supported = true; status = true; } else { renOut->supported = false; status = false; printf_error("\n\nFailed to complete renegotiation\n"); } } else { status = false; renOut->secure = false; } #if ( OPENSSL_VERSION_NUMBER > 0x009080cfL ) } #endif // Disconnect SSL over socket SSL_shutdown(ssl); } // Free SSL object SSL_free(ssl); } else { status = false; renOut->supported = false; printf_error("%s ERROR: Could create SSL object.%s\n", COL_RED, RESET); } } } else { status = false; renOut->supported = false; printf_error("%s ERROR: Could set cipher.%s\n", COL_RED, RESET); } // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { status = false; renOut->supported = false; printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); } // Disconnect from host close(socketDescriptor); } else { // Could not connect printf_error("%sERROR: Could not connect.%s\n", COL_RED, RESET); renOut->supported = false; status = false; freeRenegotiationOutput( renOut ); exit(status); } outputRenegotiation(options, renOut); freeRenegotiationOutput( renOut ); return status; } const char* printableSslMethod(const SSL_METHOD *sslMethod) { #ifndef OPENSSL_NO_SSL2 if (sslMethod == SSLv2_client_method()) return "SSLv2"; #endif #ifndef OPENSSL_NO_SSL3 if (sslMethod == SSLv3_client_method()) return "SSLv3"; #endif if (sslMethod == TLSv1_client_method()) return "TLSv1.0"; #if OPENSSL_VERSION_NUMBER >= 0x10001000L if (sslMethod == TLSv1_1_client_method()) return "TLSv1.1"; if (sslMethod == TLSv1_2_client_method()) return "TLSv1.2"; #endif return "unknown SSL_METHOD"; } // Test for Heartbleed int testHeartbleed(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { // Variables... int status = true; int socketDescriptor = 0; // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Credit to Jared Stafford (jspenguin@jspenguin.org) char hello[] = {0x16,0x03,0x01,0x00,0xdc,0x01,0x00,0x00,0xd8,0x03,0x00,0x53,0x43,0x5b,0x90,0x9d,0x9b,0x72,0x0b,0xbc,0x0c,0xbc,0x2b,0x92,0xa8,0x48,0x97,0xcf,0xbd,0x39,0x04,0xcc,0x16,0x0a,0x85,0x03,0x90,0x9f,0x77,0x04,0x33,0xd4,0xde,0x00,0x00,0x66,0xc0,0x14,0xc0,0x0a,0xc0,0x22,0xc0,0x21,0x00,0x39,0x00,0x38,0x00,0x88,0x00,0x87,0xc0,0x0f,0xc0,0x05,0x00,0x35,0x00,0x84,0xc0,0x12,0xc0,0x08,0xc0,0x1c,0xc0,0x1b,0x00,0x16,0x00,0x13,0xc0,0x0d,0xc0,0x03,0x00,0x0a,0xc0,0x13,0xc0,0x09,0xc0,0x1f,0xc0,0x1e,0x00,0x33,0x00,0x32,0x00,0x9a,0x00,0x99,0x00,0x45,0x00,0x44,0xc0,0x0e,0xc0,0x04,0x00,0x2f,0x00,0x96,0x00,0x41,0xc0,0x11,0xc0,0x07,0xc0,0x0c,0xc0,0x02,0x00,0x05,0x00,0x04,0x00,0x15,0x00,0x12,0x00,0x09,0x00,0x14,0x00,0x11,0x00,0x08,0x00,0x06,0x00,0x03,0x00,0xff,0x01,0x00,0x00,0x49,0x00,0x0b,0x00,0x04,0x03,0x00,0x01,0x02,0x00,0x0a,0x00,0x34,0x00,0x32,0x00,0x0e,0x00,0x0d,0x00,0x19,0x00,0x0b,0x00,0x0c,0x00,0x18,0x00,0x09,0x00,0x0a,0x00,0x16,0x00,0x17,0x00,0x08,0x00,0x06,0x00,0x07,0x00,0x14,0x00,0x15,0x00,0x04,0x00,0x05,0x00,0x12,0x00,0x13,0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x0f,0x00,0x10,0x00,0x11,0x00,0x23,0x00,0x00,0x00,0x0f,0x00,0x01,0x01}; if (sslMethod == TLSv1_client_method()) { hello[10] = 0x01; } #if OPENSSL_VERSION_NUMBER >= 0x10001000L else if (sslMethod == TLSv1_1_client_method()) { hello[10] = 0x02; } else if (sslMethod == TLSv1_2_client_method()) { hello[10] = 0x03; } #endif if (send(socketDescriptor, hello, sizeof(hello), 0) <= 0) { printf_error("send() failed: %s\n", strerror(errno)); exit(1); } // Send the heartbeat char hb[8] = {0x18,0x03,0x00,0x00,0x03,0x01,0x40,0x00}; if (sslMethod == TLSv1_client_method()) { hb[2] = 0x01; } #if OPENSSL_VERSION_NUMBER >= 0x10001000L else if (sslMethod == TLSv1_1_client_method()) { hb[2] = 0x02; } else if (sslMethod == TLSv1_2_client_method()) { hb[2] = 0x03; } #endif if (send(socketDescriptor, hb, sizeof(hb), 0) <= 0) { printf_error("send() failed: %s\n", strerror(errno)); exit(1); } char hbbuf[65536]; while(1) { memset(hbbuf, 0, sizeof(hbbuf)); // Read 5 byte header int readResult = recv(socketDescriptor, hbbuf, 5, 0); if (readResult <= 0) { break; } char typ = hbbuf[0]; // Combine 2 bytes to get payload length uint16_t ln = hbbuf[4] | hbbuf[3] << 8; // Debugging /* uint16_t ver = hbbuf[2] | hbbuf[1] << 8; printf("%hhX %hhX %hhX %hhX %hhX - %d %d %d\n", hbbuf[0], hbbuf[1], hbbuf[2], hbbuf[3], hbbuf[4], typ, ver, ln); */ memset(hbbuf, 0, sizeof(hbbuf)); // Read rest of record readResult = recv(socketDescriptor, hbbuf, ln, 0); if (readResult <= 0) { break; } // Server returned error if (typ == 21) { break; } // Successful response else if (typ == 24 && ln > 3) { printf("%svulnerable%s to heartbleed\n", COL_RED, RESET); printf_xml(" \n", printableSslMethod(sslMethod)); close(socketDescriptor); return status; } } printf("%snot vulnerable%s to heartbleed\n", COL_GREEN, RESET); printf_xml(" \n", printableSslMethod(sslMethod)); // Disconnect from host close(socketDescriptor); } else { // Could not connect printf_error("%sERROR: Could not connect.%s\n", COL_RED, RESET); status = false; printf("dying"); exit(status); } return status; } int ssl_print_tmp_key(struct sslCheckOptions *options, SSL *s) { #if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER) EVP_PKEY *key; if (!SSL_get_server_tmp_key(s, &key)) return 1; switch (EVP_PKEY_id(key)) { case EVP_PKEY_RSA: if (EVP_PKEY_bits(key) <= 768) { printf(" RSA %s%d%s bits", COL_RED, EVP_PKEY_bits(key), RESET); } else if (EVP_PKEY_bits(key) <= 1024) { printf(" RSA %s%d%s bits", COL_YELLOW, EVP_PKEY_bits(key), RESET); } else { printf(" RSA %d bits", EVP_PKEY_bits(key)); } break; case EVP_PKEY_DH: if (EVP_PKEY_bits(key) <= 768) { printf(" DHE %s%d%s bits", COL_RED, EVP_PKEY_bits(key), RESET); } else if (EVP_PKEY_bits(key) <= 1024) { printf(" DHE %s%d%s bits", COL_YELLOW, EVP_PKEY_bits(key), RESET); } else { printf(" DHE %d bits", EVP_PKEY_bits(key)); } printf_xml(" dhebits=\"%d\"", EVP_PKEY_bits(key)); break; #ifndef OPENSSL_NO_EC case EVP_PKEY_EC: { EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key); int nid; const char *cname; nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec)); EC_KEY_free(ec); cname = EC_curve_nid2nist(nid); if (!cname) cname = OBJ_nid2sn(nid); printf(" Curve %s DHE %d", cname, EVP_PKEY_bits(key)); printf_xml(" curve=\"%s\" ecdhebits=\"%d\"", cname, EVP_PKEY_bits(key)); } #endif } EVP_PKEY_free(key); return 1; #endif return 0; } // Test a cipher... int testCipher(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { // Variables... int cipherStatus; int status = true; int socketDescriptor = 0; SSL *ssl = NULL; BIO *cipherConnectionBio; BIO *stdoutBIO = NULL; int tempInt; char requestBuffer[200]; char buffer[50]; char hexCipherId[10]; int resultSize = 0; int cipherbits; uint32_t cipherid; const SSL_CIPHER *sslCipherPointer; const char *cleanSslMethod = printableSslMethod(sslMethod); struct timeval tval_start, tval_end, tval_elapsed; if (options->showTimes) { gettimeofday(&tval_start, NULL); } // Create request buffer... memset(requestBuffer, 0, 200); snprintf(requestBuffer, 199, "GET / HTTP/1.0\r\nUser-Agent: SSLScan\r\nHost: %s\r\n\r\n", options->host); // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { if (SSL_CTX_set_cipher_list(options->ctx, options->cipherstring) != 0) { // Create SSL object... ssl = SSL_new(options->ctx); if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // This enables TLS SNI SSL_set_tlsext_host_name (ssl, options->host); #endif // Connect SSL over socket cipherStatus = SSL_connect(ssl); sslCipherPointer = SSL_get_current_cipher(ssl); cipherbits = SSL_CIPHER_get_bits(sslCipherPointer, NULL); if (cipherStatus == 0) { return false; } else if (cipherStatus != 1) { printf_verbose("SSL_get_error(ssl, cipherStatus) said: %d\n", SSL_get_error(ssl, cipherStatus)); return false; } cipherid = SSL_CIPHER_get_id(sslCipherPointer); cipherid = cipherid & 0x00ffffff; // remove first byte which is the version (0x03 for TLSv1/SSLv3) // Show Cipher Status printf_xml(" cipherstring, "ALL:eNULL")) { printf_xml("accepted\""); printf("Accepted "); } else { printf_xml("preferred\""); printf("%sPreferred%s ", COL_GREEN, RESET); } if (options->http == true) { // Stdout BIO... stdoutBIO = BIO_new(BIO_s_file()); BIO_set_fp(stdoutBIO, stdout, BIO_NOCLOSE); // HTTP Get... SSL_write(ssl, requestBuffer, sizeof(requestBuffer)); memset(buffer ,0 , 50); resultSize = SSL_read(ssl, buffer, 49); if (resultSize > 9) { int loop = 0; for (loop = 9; (loop < 49) && (buffer[loop] != 0) && (buffer[loop] != '\r') && (buffer[loop] != '\n'); loop++) { } buffer[loop] = 0; // Output HTTP code... printf("%s", buffer + 9); loop = strlen(buffer + 9); while (loop < 17) { loop++; printf(" "); } printf_xml(" http=\"%s\"", buffer + 9); } else { // Output HTTP code... printf(" "); } } } printf_xml(" sslversion=\"%s\"", cleanSslMethod); #ifndef OPENSSL_NO_SSL2 if (strcmp(cleanSslMethod, "SSLv2") == 0) { printf("%sSSLv2%s ", COL_RED, RESET); } else #endif #ifndef OPENSSL_NO_SSL3 if (strcmp(cleanSslMethod, "SSLv3") == 0) { printf("%sSSLv3%s ", COL_RED, RESET); } else #endif if (strcmp(cleanSslMethod, "TLSv1.0") == 0) { printf("%sTLSv1.0%s ", COL_YELLOW, RESET); } #if OPENSSL_VERSION_NUMBER >= 0x10001000L else { printf("%s ", cleanSslMethod); } #endif if (cipherbits < 10) tempInt = 2; else if (cipherbits < 100) tempInt = 1; else tempInt = 0; if (cipherbits == 0) { printf("%s%d%s bits ", COL_RED_BG, cipherbits, RESET); } else if (cipherbits >= 112) { printf("%s%d%s bits ", COL_GREEN, cipherbits, RESET); } else if (cipherbits > 56) { printf("%s%d%s bits ", COL_YELLOW, cipherbits, RESET); } else { printf("%s%d%s bits ", COL_RED, cipherbits, RESET); } while (tempInt != 0) { tempInt--; printf(" "); } sprintf(hexCipherId, "0x%X", cipherid); if (options->showCipherIds == true) { printf("%8s ", hexCipherId); } printf_xml(" bits=\"%d\" cipher=\"%s\" id=\"%s\"", cipherbits, sslCipherPointer->name, hexCipherId); if (strstr(sslCipherPointer->name, "NULL")) { printf("%s%-29s%s", COL_RED_BG, sslCipherPointer->name, RESET); } else if (strstr(sslCipherPointer->name, "ADH") || strstr(sslCipherPointer->name, "AECDH")) { printf("%s%-29s%s", COL_PURPLE, sslCipherPointer->name, RESET); } else if (strstr(sslCipherPointer->name, "EXP") #ifndef OPENSSL_NO_SSL3 || (strcmp(cleanSslMethod, "SSLv3") == 0 && !strstr(sslCipherPointer->name, "RC4")) #endif ) { printf("%s%-29s%s", COL_RED, sslCipherPointer->name, RESET); } else if (strstr(sslCipherPointer->name, "RC4")) { printf("%s%-29s%s", COL_YELLOW, sslCipherPointer->name, RESET); } else if (strstr(sslCipherPointer->name, "GCM")) { printf("%s%-29s%s", COL_GREEN, sslCipherPointer->name, RESET); } else { printf("%-29s", sslCipherPointer->name); } if (options->cipher_details == true) { ssl_print_tmp_key(options, ssl); } // Timing if (options->showTimes) { int msec; gettimeofday(&tval_end, NULL); timersub(&tval_end, &tval_start, &tval_elapsed); msec = tval_elapsed.tv_sec * 1000 + (int)tval_elapsed.tv_usec/1000; printf("%s %dms%s", COL_GREY, msec, RESET); printf_xml(" time=\"%d\"", msec); } printf("\n"); printf_xml(" />\n"); // Disconnect SSL over socket if (cipherStatus == 1) { strncat(options->cipherstring, ":!", 2); strncat(options->cipherstring, SSL_get_cipher_name(ssl), strlen(SSL_get_cipher_name(ssl))); SSL_shutdown(ssl); } // Free SSL object SSL_free(ssl); } else { status = false; printf("%s ERROR: Could create SSL object.%s\n", COL_RED, RESET); } } else { status = false; } // Disconnect from host close(socketDescriptor); } // Could not connect else status = false; return status; } int checkCertificateProtocol(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { int status = true; // Setup Context Object... options->ctx = SSL_CTX_new(sslMethod); if (options->ctx != NULL) { // SSL implementation bugs/workaround if (options->sslbugs) SSL_CTX_set_options(options->ctx, SSL_OP_ALL | 0); else SSL_CTX_set_options(options->ctx, 0); // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); // Check the certificate status = checkCertificate(options, sslMethod); } // Error Creating Context Object else { printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); status = false; } return status; } // Report certificate weaknesses (key length and signing algorithm) int checkCertificate(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { int cipherStatus = 0; int status = true; int socketDescriptor = 0; int keyBits; SSL *ssl = NULL; BIO *cipherConnectionBio = NULL; BIO *stdoutBIO = NULL; BIO *fileBIO = NULL; X509 *x509Cert = NULL; EVP_PKEY *publicKey = NULL; char certAlgorithm[80]; X509_EXTENSION *extension = NULL; // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Setup Context Object... options->ctx = SSL_CTX_new(sslMethod); if (options->ctx != NULL) { if (SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL") != 0) { // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); if (status == true) { // Create SSL object... ssl = SSL_new(options->ctx); if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // Based on http://does-not-exist.org/mail-archives/mutt-dev/msg13045.html // TLS Virtual-hosting requires that the server present the correct // certificate; to do this, the ServerNameIndication TLS extension is used. // If TLS is negotiated, and OpenSSL is recent enough that it might have // support, and support was enabled when OpenSSL was built, mutt supports // sending the hostname we think we're connecting to, so a server can send // back the correct certificate. // NB: finding a server which uses this for IMAP is problematic, so this is // untested. Please report success or failure! However, this code change // has worked fine in other projects to which the contributor has added it, // or HTTP usage. SSL_set_tlsext_host_name (ssl, options->host); #endif // Connect SSL over socket cipherStatus = SSL_connect(ssl); if (cipherStatus == 1) { // Setup BIO's stdoutBIO = BIO_new(BIO_s_file()); BIO_set_fp(stdoutBIO, stdout, BIO_NOCLOSE); if (options->xmlOutput) { fileBIO = BIO_new(BIO_s_file()); BIO_set_fp(fileBIO, options->xmlOutput, BIO_NOCLOSE); } // Get Certificate... printf("\n %sSSL Certificate:%s\n", COL_BLUE, RESET); printf_xml(" \n"); x509Cert = SSL_get_peer_certificate(ssl); if (x509Cert != NULL) { // Cert Serial No. - Code adapted from OpenSSL's crypto/asn1/t_x509.c if (!(X509_FLAG_COMPAT & X509_FLAG_NO_SERIAL)) { BIO *bp; bp = BIO_new_fp(stdout, BIO_NOCLOSE); if (options->xmlOutput) if(NULL != bp) BIO_free(bp); // We don't free the xml_bp because it will be used in the future } // Signature Algo... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_SIGNAME)) { printf("Signature Algorithm: "); i2t_ASN1_OBJECT(certAlgorithm, sizeof(certAlgorithm), x509Cert->cert_info->signature->algorithm); strtok(certAlgorithm, "\n"); if (strstr(certAlgorithm, "md5")) { printf("%s%s%s\n", COL_RED, certAlgorithm, RESET); } else if (strstr(certAlgorithm, "sha1")) { printf("%s%s%s\n", COL_YELLOW, certAlgorithm, RESET); } else if (strstr(certAlgorithm, "sha512") || strstr(certAlgorithm, "sha256")) { printf("%s%s%s\n", COL_GREEN, certAlgorithm, RESET); } else { printf("%s\n", certAlgorithm); } if (options->xmlOutput) { printf_xml(" "); i2a_ASN1_OBJECT(fileBIO, x509Cert->cert_info->signature->algorithm); printf_xml("\n"); } } // Public Key... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_PUBKEY)) { publicKey = X509_get_pubkey(x509Cert); if (publicKey == NULL) { printf("Public Key: Could not load\n"); printf_xml(" \n"); } else { switch (publicKey->type) { case EVP_PKEY_RSA: if (publicKey->pkey.rsa) { keyBits = BN_num_bits(publicKey->pkey.rsa->n); if (keyBits < 2048 ) { printf("RSA Key Strength: %s%d%s\n", COL_RED, keyBits, RESET); } else if (keyBits >= 4096 ) { printf("RSA Key Strength: %s%d%s\n", COL_GREEN, keyBits, RESET); } else { printf("RSA Key Strength: %d\n", keyBits); } printf_xml(" \n", BN_num_bits(publicKey->pkey.rsa->n)); } else { printf(" RSA Public Key: NULL\n"); } printf("\n"); break; case EVP_PKEY_DSA: if (publicKey->pkey.dsa) { // TODO - display key strength printf_xml(" \n"); /* DSA_print(stdoutBIO, publicKey->pkey.dsa, 6); */ } else { printf(" DSA Public Key: NULL\n"); } break; case EVP_PKEY_EC: if (publicKey->pkey.ec) { // TODO - display key strength printf_xml(" \n"); /* EC_KEY_print(stdoutBIO, publicKey->pkey.ec, 6); */ } else { printf(" EC Public Key: NULL\n"); } break; default: printf(" Public Key: Unknown\n"); printf_xml(" \n"); break; } EVP_PKEY_free(publicKey); } } // SSL Certificate Issuer... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_ISSUER)) { int cnindex; X509_NAME *subj; X509_NAME_ENTRY *e; ASN1_STRING *d; const char *subject; const char *issuer; // Get SSL cert CN cnindex = -1; subj = X509_get_subject_name(x509Cert); cnindex = X509_NAME_get_index_by_NID(subj, NID_commonName, cnindex); // SSL cert doesn't have a CN, so just print whole thing if (cnindex == -1) { subject = (char *) X509_NAME_oneline(X509_get_subject_name(x509Cert), NULL, 0); printf("Subject: %s\n", subject); printf_xml(" \n", subject); } else { e = X509_NAME_get_entry(subj, cnindex); d = X509_NAME_ENTRY_get_data(e); subject = (char *) ASN1_STRING_data(d); printf("Subject: %s\n", subject); printf_xml(" \n", subject); } // Get certificate altnames if supported if (!(X509_FLAG_COMPAT & X509_FLAG_NO_EXTENSIONS)) { if (sk_X509_EXTENSION_num(x509Cert->cert_info->extensions) > 0) { cnindex = X509_get_ext_by_NID (x509Cert, NID_subject_alt_name, -1); if (cnindex != -1) { extension = X509v3_get_ext(x509Cert->cert_info->extensions,cnindex); printf("Altnames: "); if (!X509V3_EXT_print(stdoutBIO, extension, X509_FLAG_COMPAT, 0)) { M_ASN1_OCTET_STRING_print(stdoutBIO, extension->value); } if (options->xmlOutput) { printf_xml(" value); } printf_xml("]]>\n"); printf("\n"); } } } // Get SSL cert issuer cnindex = -1; subj = X509_get_issuer_name(x509Cert); cnindex = X509_NAME_get_index_by_NID(subj, NID_commonName, cnindex); // Issuer cert doesn't have a CN, so just print whole thing if (cnindex == -1) { char *issuer = X509_NAME_oneline(X509_get_issuer_name(x509Cert), NULL, 0); printf("Issuer: %s", issuer); printf_xml(" \n", issuer); } else { e = X509_NAME_get_entry(subj, cnindex); d = X509_NAME_ENTRY_get_data(e); issuer = (char *) ASN1_STRING_data(d); // If issuer is same as hostname we scanned or is *, flag as self-signed if ( strcmp(issuer, options->host) == 0 || strcmp(issuer, subject) == 0 || strcmp(issuer, "*") == 0 ) { printf("Issuer: %s%s%s\n", COL_RED, issuer, RESET); printf_xml(" \n", issuer); printf_xml(" true\n"); } else { printf("Issuer: %s\n", issuer); printf_xml(" \n", issuer); printf_xml(" false\n"); } } } // Check for certificate expiration time_t *ptime; int timediff; ptime = NULL; printf("\nNot valid before: "); timediff = X509_cmp_time(X509_get_notBefore(x509Cert), ptime); // Certificate isn't valid yet if (timediff > 0) { printf("%s", COL_RED); } else { printf("%s", COL_GREEN); } ASN1_TIME_print(stdoutBIO, X509_get_notBefore(x509Cert)); printf("%s", RESET); if (options->xmlOutput) { printf_xml(" "); ASN1_TIME_print(fileBIO, X509_get_notBefore(x509Cert)); printf_xml("\n"); } printf("\nNot valid after: "); timediff = X509_cmp_time(X509_get_notAfter(x509Cert), ptime); // Certificate has expired if (timediff < 0) { printf("%s", COL_RED); } else { printf("%s", COL_GREEN); } ASN1_TIME_print(stdoutBIO, X509_get_notAfter(x509Cert)); printf("%s", RESET); if (options->xmlOutput) { printf_xml(" "); ASN1_TIME_print(fileBIO, X509_get_notAfter(x509Cert)); printf_xml("\n"); if (timediff < 0) { printf_xml(" true\n"); } else { printf_xml(" false\n"); } } printf("\n"); // Free X509 Certificate... X509_free(x509Cert); // This is abusing status a bit, but means that we'll only get the cert once status = false; } else { printf(" Unable to parse certificate\n"); } printf_xml(" \n"); // Free BIO BIO_free(stdoutBIO); if (options->xmlOutput) BIO_free(fileBIO); // Disconnect SSL over socket SSL_shutdown(ssl); } // Free SSL object SSL_free(ssl); } else { status = false; printf("%s ERROR: Could not create SSL object.%s\n", COL_RED, RESET); } } } else { status = false; printf("%s ERROR: Could not set cipher.%s\n", COL_RED, RESET); } // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { status = false; printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); } // Disconnect from host close(socketDescriptor); } // Could not connect else status = false; return status; } // Request a stapled OCSP request from the server. int ocspRequest(struct sslCheckOptions *options) { int cipherStatus = 0; int status = true; int socketDescriptor = 0; SSL *ssl = NULL; BIO *cipherConnectionBio = NULL; BIO *stdoutBIO = NULL; BIO *fileBIO = NULL; const SSL_METHOD *sslMethod = NULL; // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Setup Context Object... if( options->sslVersion == ssl_v2 || options->sslVersion == ssl_v3) { printf_verbose("sslMethod = SSLv23_method()"); sslMethod = SSLv23_method(); } #if OPENSSL_VERSION_NUMBER >= 0x10001000L else if( options->sslVersion == tls_v11) { printf_verbose("sslMethod = TLSv1_1_method()"); sslMethod = TLSv1_1_method(); } else if( options->sslVersion == tls_v12) { printf_verbose("sslMethod = TLSv1_2_method()"); sslMethod = TLSv1_2_method(); } #endif else { printf_verbose("sslMethod = TLSv1_method()\n"); printf_verbose("If server doesn't support TLSv1.0, manually specify TLS version\n"); sslMethod = TLSv1_method(); } options->ctx = SSL_CTX_new(sslMethod); if (options->ctx != NULL) { if (SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL") != 0) { // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); if (status == true) { // Create SSL object... ssl = SSL_new(options->ctx); if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // Based on http://does-not-exist.org/mail-archives/mutt-dev/msg13045.html // TLS Virtual-hosting requires that the server present the correct // certificate; to do this, the ServerNameIndication TLS extension is used. // If TLS is negotiated, and OpenSSL is recent enough that it might have // support, and support was enabled when OpenSSL was built, mutt supports // sending the hostname we think we're connecting to, so a server can send // back the correct certificate. // NB: finding a server which uses this for IMAP is problematic, so this is // untested. Please report success or failure! However, this code change // has worked fine in other projects to which the contributor has added it, // or HTTP usage. SSL_set_tlsext_host_name (ssl, options->host); #endif SSL_set_tlsext_status_type(ssl, TLSEXT_STATUSTYPE_ocsp); SSL_CTX_set_tlsext_status_cb(options->ctx, ocsp_resp_cb); // Connect SSL over socket cipherStatus = SSL_connect(ssl); if (cipherStatus == 1) { // Setup BIO's stdoutBIO = BIO_new(BIO_s_file()); BIO_set_fp(stdoutBIO, stdout, BIO_NOCLOSE); if (options->xmlOutput) { fileBIO = BIO_new(BIO_s_file()); BIO_set_fp(fileBIO, options->xmlOutput, BIO_NOCLOSE); } // Free BIO BIO_free(stdoutBIO); if (options->xmlOutput) BIO_free(fileBIO); // Disconnect SSL over socket SSL_shutdown(ssl); } else { printf("\n%sFailed to connect to get OCSP status.%s\n", COL_RED, RESET); printf("Most likely cause is server not supporting %s, try manually specifying version\n", printableSslMethod(sslMethod)); } // Free SSL object SSL_free(ssl); } else { status = false; printf("%s ERROR: Could not create SSL object.%s\n", COL_RED, RESET); } } } else { status = false; printf("%s ERROR: Could not set cipher.%s\n", COL_RED, RESET); } // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { status = false; printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); } // Disconnect from host close(socketDescriptor); } // Could not connect else status = false; return status; } static int ocsp_resp_cb(SSL *s, void *arg) { const unsigned char *p; int len; OCSP_RESPONSE *rsp; len = SSL_get_tlsext_status_ocsp_resp(s, &p); if (!p) { printf("No OCSP response sent\n\n"); return 1; } rsp = d2i_OCSP_RESPONSE(NULL, &p, len); if (!rsp){ printf("OCSP response parse error\n"); return 0; } BIO *bio_out; bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); int i = 0; long l; OCSP_CERTID *cid = NULL; OCSP_BASICRESP *br = NULL; OCSP_RESPID *rid = NULL; OCSP_RESPDATA *rd = NULL; OCSP_CERTSTATUS *cst = NULL; OCSP_REVOKEDINFO *rev = NULL; OCSP_SINGLERESP *single = NULL; OCSP_RESPBYTES *rb = rsp->responseBytes; //Pretty print response status l = ASN1_ENUMERATED_get(rsp->responseStatus); if (BIO_printf(bio_out, "OCSP Response Status: %s (0x%lx)\n", OCSP_response_status_str(l), l) <= 0) goto err; //Check for null response bytes if (rb == NULL) return 1; i = ASN1_STRING_length(rb->response); if ((br = OCSP_response_get1_basic(rsp)) == NULL) goto err; rd = br->tbsResponseData; l = ASN1_INTEGER_get(rd->version); //Pretty print responder id if(BIO_puts(bio_out, "Responder Id: ") <= 0) goto err; rid = rd->responderId; switch (rid->type){ case V_OCSP_RESPID_NAME: X509_NAME_print_ex(bio_out, rid->value.byName, 0, XN_FLAG_ONELINE); break; case V_OCSP_RESPID_KEY: i2a_ASN1_STRING(bio_out, rid->value.byKey, V_ASN1_OCTET_STRING); break; } if(BIO_printf(bio_out, "\nProduced At: ") <= 0) goto err; if (!ASN1_GENERALIZEDTIME_print(bio_out, rd->producedAt)) goto err; if (BIO_printf(bio_out, "\nResponses:\n") <= 0) goto err; for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++) { if (!sk_OCSP_SINGLERESP_value(rd->responses, i)) continue; single = sk_OCSP_SINGLERESP_value(rd->responses, i); cid = single->certId; if (ocsp_certid_print(bio_out, cid, 4) <= 0) goto err; cst = single->certStatus; if (cst->type == V_OCSP_CERTSTATUS_GOOD) { if (BIO_printf(bio_out, "Cert Status: %s%s%s\n\n", COL_GREEN, OCSP_cert_status_str(cst->type), RESET) <= 0) goto err; } else if (cst->type == V_OCSP_CERTSTATUS_UNKNOWN) { if (BIO_printf(bio_out, "Cert Status: %s%s%s\n\n", COL_YELLOW, OCSP_cert_status_str(cst->type), RESET) <= 0) goto err; } else { rev = cst->value.revoked; if (BIO_printf(bio_out, "\nRevocation Time: \n\n") <= 0) goto err; if (!ASN1_GENERALIZEDTIME_print(bio_out, rev->revocationTime)) goto err; if (rev->revocationReason) { l = ASN1_ENUMERATED_get(rev->revocationReason); if (BIO_printf(bio_out, "\nRevocation Reason: %s (0x%lx)\n\n", OCSP_crl_reason_str(l), l) <= 0) goto err; } } } err: OCSP_RESPONSE_free(rsp); return 1; } int ocsp_certid_print(BIO *bp, OCSP_CERTID *a, int indent) { BIO_printf(bp, "%*sHash Algorithm: ", indent, ""); i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm); BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, ""); i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING); BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, ""); i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING); BIO_printf(bp, "\n%*sSerial Number: ", indent, ""); i2a_ASN1_INTEGER(bp, a->serialNumber); BIO_printf(bp, "\n"); return 1; } // Print out the full certificate int showCertificate(struct sslCheckOptions *options) { // Variables... int cipherStatus = 0; int status = true; int socketDescriptor = 0; SSL *ssl = NULL; BIO *cipherConnectionBio = NULL; BIO *stdoutBIO = NULL; BIO *fileBIO = NULL; X509 *x509Cert = NULL; EVP_PKEY *publicKey = NULL; const SSL_METHOD *sslMethod = NULL; ASN1_OBJECT *asn1Object = NULL; X509_EXTENSION *extension = NULL; char buffer[1024]; long tempLong = 0; int tempInt = 0; int tempInt2 = 0; long verifyError = 0; // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Setup Context Object... if( options->sslVersion == ssl_v2 || options->sslVersion == ssl_v3) { printf_verbose("sslMethod = SSLv23_method()"); sslMethod = SSLv23_method(); } #if OPENSSL_VERSION_NUMBER >= 0x10001000L else if( options->sslVersion == tls_v11) { printf_verbose("sslMethod = TLSv1_1_method()"); sslMethod = TLSv1_1_method(); } else if( options->sslVersion == tls_v12) { printf_verbose("sslMethod = TLSv1_2_method()"); sslMethod = TLSv1_2_method(); } #endif else { printf_verbose("sslMethod = TLSv1_method()\n"); printf_verbose("If server doesn't support TLSv1.0, manually specificy TLS version\n"); sslMethod = TLSv1_method(); } options->ctx = SSL_CTX_new(sslMethod); if (options->ctx != NULL) { if (SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL") != 0) { // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); if (status == true) { // Create SSL object... ssl = SSL_new(options->ctx); if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // Based on http://does-not-exist.org/mail-archives/mutt-dev/msg13045.html // TLS Virtual-hosting requires that the server present the correct // certificate; to do this, the ServerNameIndication TLS extension is used. // If TLS is negotiated, and OpenSSL is recent enough that it might have // support, and support was enabled when OpenSSL was built, mutt supports // sending the hostname we think we're connecting to, so a server can send // back the correct certificate. // NB: finding a server which uses this for IMAP is problematic, so this is // untested. Please report success or failure! However, this code change // has worked fine in other projects to which the contributor has added it, // or HTTP usage. SSL_set_tlsext_host_name (ssl, options->host); #endif // Connect SSL over socket cipherStatus = SSL_connect(ssl); if (cipherStatus == 1) { // Setup BIO's stdoutBIO = BIO_new(BIO_s_file()); BIO_set_fp(stdoutBIO, stdout, BIO_NOCLOSE); if (options->xmlOutput) { fileBIO = BIO_new(BIO_s_file()); BIO_set_fp(fileBIO, options->xmlOutput, BIO_NOCLOSE); } // Get Certificate... printf("\n %sSSL Certificate:%s\n", COL_BLUE, RESET); printf_xml(" \n"); x509Cert = SSL_get_peer_certificate(ssl); if (x509Cert != NULL) { // Print a base64 blob version of the cert printf(" Certificate blob:\n"); PEM_write_bio_X509(stdoutBIO,x509Cert); if (options->xmlOutput) { printf_xml(" \n"); PEM_write_bio_X509(fileBIO,x509Cert); printf_xml(" \n"); } //SSL_set_verify(ssl, SSL_VERIFY_NONE|SSL_VERIFY_CLIENT_ONCE, NULL); // Cert Version if (!(X509_FLAG_COMPAT & X509_FLAG_NO_VERSION)) { tempLong = X509_get_version(x509Cert); printf(" Version: %lu\n", tempLong); printf_xml(" %lu\n", tempLong); } // Cert Serial No. - Code adapted from OpenSSL's crypto/asn1/t_x509.c if (!(X509_FLAG_COMPAT & X509_FLAG_NO_SERIAL)) { ASN1_INTEGER *bs; BIO *bp; BIO *xml_bp; bp = BIO_new_fp(stdout, BIO_NOCLOSE); if (options->xmlOutput) xml_bp = BIO_new_fp(options->xmlOutput, BIO_NOCLOSE); long l; int i; const char *neg; bs=X509_get_serialNumber(x509Cert); if (BIO_write(bp," Serial Number:",18) <= 0) return(1); if (bs->length <= 4) { l=ASN1_INTEGER_get(bs); if (l < 0) { l= -l; neg="-"; } else neg=""; if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0) return(1); if (options->xmlOutput) if (BIO_printf(xml_bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0) return(1); } else { neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":""; if (BIO_printf(bp,"%1s%s","",neg) <= 0) return(1); if (options->xmlOutput) if (BIO_printf(xml_bp," ") <= 0) return(1); for (i=0; ilength; i++) { if (BIO_printf(bp,"%02x%c",bs->data[i], ((i+1 == bs->length)?'\n':':')) <= 0) return(1); if (options->xmlOutput) { if (i+1 == bs->length) { if (BIO_printf(xml_bp,"%02x",bs->data[i]) <= 0) return(1); } else { if (BIO_printf(xml_bp,"%02x%c",bs->data[i], ':') <= 0) return(1); } } } if (options->xmlOutput) if (BIO_printf(xml_bp,"\n") <= 0) return(1); } if(NULL != bp) BIO_free(bp); // We don't free the xml_bp because it will be used in the future } // Signature Algo... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_SIGNAME)) { printf(" Signature Algorithm: "); i2a_ASN1_OBJECT(stdoutBIO, x509Cert->cert_info->signature->algorithm); printf("\n"); if (options->xmlOutput) { printf_xml(" "); i2a_ASN1_OBJECT(fileBIO, x509Cert->cert_info->signature->algorithm); printf_xml("\n"); } } // SSL Certificate Issuer... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_ISSUER)) { X509_NAME_oneline(X509_get_issuer_name(x509Cert), buffer, sizeof(buffer) - 1); printf(" Issuer: %s\n", buffer); printf_xml(" \n", buffer); } // Validity... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_VALIDITY)) { printf(" Not valid before: "); ASN1_TIME_print(stdoutBIO, X509_get_notBefore(x509Cert)); if (options->xmlOutput) { printf_xml(" "); ASN1_TIME_print(fileBIO, X509_get_notBefore(x509Cert)); printf_xml("\n"); } printf("\n Not valid after: "); ASN1_TIME_print(stdoutBIO, X509_get_notAfter(x509Cert)); printf("\n"); if (options->xmlOutput) { printf_xml(" "); ASN1_TIME_print(fileBIO, X509_get_notAfter(x509Cert)); printf_xml("\n"); } } // SSL Certificate Subject... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_SUBJECT)) { X509_NAME_oneline(X509_get_subject_name(x509Cert), buffer, sizeof(buffer) - 1); printf(" Subject: %s\n", buffer); printf_xml(" \n", buffer); } // Public Key Algo... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_PUBKEY)) { printf(" Public Key Algorithm: "); i2a_ASN1_OBJECT(stdoutBIO, x509Cert->cert_info->key->algor->algorithm); printf("\n"); if (options->xmlOutput) { printf_xml(" "); i2a_ASN1_OBJECT(fileBIO, x509Cert->cert_info->key->algor->algorithm); printf_xml("\n"); } // Public Key... publicKey = X509_get_pubkey(x509Cert); if (publicKey == NULL) { printf(" Public Key: Could not load\n"); printf_xml(" \n"); } else { switch (publicKey->type) { case EVP_PKEY_RSA: if (publicKey->pkey.rsa) { printf(" RSA Public Key: (%d bit)\n", BN_num_bits(publicKey->pkey.rsa->n)); printf_xml(" \n", BN_num_bits(publicKey->pkey.rsa->n)); RSA_print(stdoutBIO, publicKey->pkey.rsa, 6); if (options->xmlOutput) { RSA_print(fileBIO, publicKey->pkey.rsa, 4); printf_xml(" \n"); } } else { printf(" RSA Public Key: NULL\n"); } break; case EVP_PKEY_DSA: if (publicKey->pkey.dsa) { printf(" DSA Public Key:\n"); printf_xml(" \n"); DSA_print(stdoutBIO, publicKey->pkey.dsa, 6); if (options->xmlOutput) { DSA_print(fileBIO, publicKey->pkey.dsa, 4); printf_xml(" \n"); } } else { printf(" DSA Public Key: NULL\n"); } break; case EVP_PKEY_EC: if (publicKey->pkey.ec) { printf(" EC Public Key:\n"); printf_xml(" \n"); EC_KEY_print(stdoutBIO, publicKey->pkey.ec, 6); if (options->xmlOutput) { EC_KEY_print(fileBIO, publicKey->pkey.ec, 4); printf_xml(" \n"); } } else { printf(" EC Public Key: NULL\n"); } break; default: printf(" Public Key: Unknown\n"); printf_xml(" \n"); break; } EVP_PKEY_free(publicKey); } } // X509 v3... if (!(X509_FLAG_COMPAT & X509_FLAG_NO_EXTENSIONS)) { if (sk_X509_EXTENSION_num(x509Cert->cert_info->extensions) > 0) { printf(" X509v3 Extensions:\n"); printf_xml(" \n"); for (tempInt = 0; tempInt < sk_X509_EXTENSION_num(x509Cert->cert_info->extensions); tempInt++) { // Get Extension... extension = sk_X509_EXTENSION_value(x509Cert->cert_info->extensions, tempInt); // Print Extension name... printf(" "); asn1Object = X509_EXTENSION_get_object(extension); i2a_ASN1_OBJECT(stdoutBIO, asn1Object); tempInt2 = X509_EXTENSION_get_critical(extension); BIO_printf(stdoutBIO, ": %s\n", tempInt2 ? "critical" : ""); if (options->xmlOutput) { printf_xml(" value); } if (options->xmlOutput) { if (!X509V3_EXT_print(fileBIO, extension, X509_FLAG_COMPAT, 0)) M_ASN1_OCTET_STRING_print(fileBIO, extension->value); printf_xml("]]>\n"); } printf("\n"); } printf_xml(" \n"); } } // Verify Certificate... printf(" Verify Certificate:\n"); verifyError = SSL_get_verify_result(ssl); if (verifyError == X509_V_OK) printf(" Certificate passed verification\n"); else printf(" %s\n", X509_verify_cert_error_string(verifyError)); // Free X509 Certificate... X509_free(x509Cert); } else { printf(" Unable to parse certificate\n"); } printf_xml(" \n"); // Free BIO BIO_free(stdoutBIO); if (options->xmlOutput) BIO_free(fileBIO); // Disconnect SSL over socket SSL_shutdown(ssl); } // Free SSL object SSL_free(ssl); } else { status = false; printf("%s ERROR: Could create SSL object.%s\n", COL_RED, RESET); } } } else { status = false; printf("%s ERROR: Could set cipher.%s\n", COL_RED, RESET); } // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { status = false; printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); } // Disconnect from host close(socketDescriptor); } // Could not connect else status = false; return status; } // Print out the list of trusted CAs int showTrustedCAs(struct sslCheckOptions *options) { // Variables... int cipherStatus = 0; int status = true; int socketDescriptor = 0; SSL *ssl = NULL; BIO *cipherConnectionBio = NULL; BIO *stdoutBIO = NULL; BIO *fileBIO = NULL; const SSL_METHOD *sslMethod = NULL; char buffer[1024]; int tempInt = 0; STACK_OF(X509_NAME) *sk2; X509_NAME *xn; // Connect to host socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { // Setup Context Object... if( options->sslVersion == ssl_v2 || options->sslVersion == ssl_v3) { printf_verbose("sslMethod = SSLv23_method()"); sslMethod = SSLv23_method(); } #if OPENSSL_VERSION_NUMBER >= 0x10001000L else if( options->sslVersion == tls_v11) { printf_verbose("sslMethod = TLSv1_1_method()"); sslMethod = TLSv1_1_method(); } else if( options->sslVersion == tls_v12) { printf_verbose("sslMethod = TLSv1_2_method()"); sslMethod = TLSv1_2_method(); } #endif else { printf_verbose("sslMethod = TLSv1_method()\n"); printf_verbose("If server doesn't support TLSv1.0, manually specificy TLS version\n"); sslMethod = TLSv1_method(); } options->ctx = SSL_CTX_new(sslMethod); if (options->ctx != NULL) { if (SSL_CTX_set_cipher_list(options->ctx, "ALL:COMPLEMENTOFALL") != 0) { // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); if (status == true) { // Create SSL object... ssl = SSL_new(options->ctx); if (ssl != NULL) { // Connect socket and BIO cipherConnectionBio = BIO_new_socket(socketDescriptor, BIO_NOCLOSE); // Connect SSL and BIO SSL_set_bio(ssl, cipherConnectionBio, cipherConnectionBio); #if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT) // Based on http://does-not-exist.org/mail-archives/mutt-dev/msg13045.html // TLS Virtual-hosting requires that the server present the correct // certificate; to do this, the ServerNameIndication TLS extension is used. // If TLS is negotiated, and OpenSSL is recent enough that it might have // support, and support was enabled when OpenSSL was built, mutt supports // sending the hostname we think we're connecting to, so a server can send // back the correct certificate. // NB: finding a server which uses this for IMAP is problematic, so this is // untested. Please report success or failure! However, this code change // has worked fine in other projects to which the contributor has added it, // or HTTP usage. SSL_set_tlsext_host_name (ssl, options->host); #endif // Connect SSL over socket cipherStatus = SSL_connect(ssl); if (cipherStatus >= 0) { // Setup BIO's stdoutBIO = BIO_new(BIO_s_file()); BIO_set_fp(stdoutBIO, stdout, BIO_NOCLOSE); if (options->xmlOutput) { fileBIO = BIO_new(BIO_s_file()); BIO_set_fp(fileBIO, options->xmlOutput, BIO_NOCLOSE); } sk2=SSL_get_client_CA_list(ssl); if ((sk2 != NULL) && (sk_X509_NAME_num(sk2) > 0)) { printf("\n %sAcceptable client certificate CA names:%s\n", COL_BLUE, RESET); for (tempInt=0; tempIntxmlOutput) { printf_xml(" \n"); BIO_printf(fileBIO, "%s", buffer); BIO_printf(fileBIO, "\n"); printf_xml(" \n"); } printf("%s", buffer); printf("\n"); } } // Free BIO BIO_free(stdoutBIO); if (options->xmlOutput) BIO_free(fileBIO); // Disconnect SSL over socket SSL_shutdown(ssl); } // Free SSL object SSL_free(ssl); } else { status = false; printf("%s ERROR: Could create SSL object.%s\n", COL_RED, RESET); } } } else { status = false; printf("%s ERROR: Could set cipher.%s\n", COL_RED, RESET); } // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { status = false; printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); } // Disconnect from host close(socketDescriptor); } // Could not connect else status = false; return status; } int testConnection(struct sslCheckOptions *options) { // Variables... int socketDescriptor = 0; struct addrinfo *addrinfoResult = NULL; struct addrinfo hints; memset(&hints, 0, sizeof(struct addrinfo)); // Resolve Host Name options->h_addrtype = 0; if (options->ipv4 && options->ipv6) { // If both IPv4 and IPv6 are enabled, we restrict nothing in the // results (i.e.: we'll accept either type of address). } else if (options->ipv4) // Only IPv4 is acceptable... { hints.ai_family = AF_INET; } else if (options->ipv6) // Only IPv6 is acceptable... { hints.ai_family = AF_INET6; printf("Trying %sIPv6%s lookup\n\n", COL_GREEN, RESET); } // Perform the actual lookup. if (getaddrinfo(options->host, NULL, &hints, &addrinfoResult) != 0) { printf("%sERROR: Could not resolve hostname %s.%s\n", COL_RED, options->host, RESET); return false; } // Configure Server Address and Port if (addrinfoResult->ai_family == AF_INET6) { options->serverAddress6.sin6_family = addrinfoResult->ai_family; memcpy((char *) &options->serverAddress6, addrinfoResult->ai_addr, addrinfoResult->ai_addrlen); options->serverAddress6.sin6_port = htons(options->port); } else { options->serverAddress.sin_family = addrinfoResult->ai_family; memcpy((char *) &options->serverAddress, addrinfoResult->ai_addr, addrinfoResult->ai_addrlen); options->serverAddress.sin_port = htons(options->port); } options->h_addrtype = addrinfoResult->ai_family; freeaddrinfo(addrinfoResult); addrinfoResult = NULL; socketDescriptor = tcpConnect(options); if (socketDescriptor != 0) { close(socketDescriptor); return true; } else { return false; } } int testProtocolCiphers(struct sslCheckOptions *options, const SSL_METHOD *sslMethod) { int status; status = true; strncpy(options->cipherstring, "ALL:eNULL", 10); // Loop until the server won't accept any more ciphers while (status == true) { // Setup Context Object... options->ctx = SSL_CTX_new(sslMethod); if (options->ctx != NULL) { // SSL implementation bugs/workaround if (options->sslbugs) SSL_CTX_set_options(options->ctx, SSL_OP_ALL | 0); else SSL_CTX_set_options(options->ctx, 0); // Load Certs if required... if ((options->clientCertsFile != 0) || (options->privateKeyFile != 0)) status = loadCerts(options); // Test the cipher if (status == true) status = testCipher(options, sslMethod); // Free CTX Object SSL_CTX_free(options->ctx); } // Error Creating Context Object else { printf_error("%sERROR: Could not create CTX object.%s\n", COL_RED, RESET); return false; } } return true; } // Test a single host and port for ciphers... int testHost(struct sslCheckOptions *options) { // Variables... struct sslCipher *sslCipherPointer = NULL; int status = true; // XML Output... printf_xml(" \n", options->host, options->port); // Verbose warning about STARTTLS and SSLv3 if (options->sslVersion == ssl_v3 || options->sslVersion == ssl_all) { printf_verbose("Some servers will fail to response to SSLv3 ciphers over STARTTLS\nIf your scan hangs, try using the --tlsall option\n\n"); } // Test renegotiation printf("Testing SSL server %s%s%s on port %s%d%s\n\n", COL_GREEN, options->host, RESET, COL_GREEN, options->port, RESET); if (options->showClientCiphers == true) { // Build a list of ciphers... switch (options->sslVersion) { case ssl_all: #if OPENSSL_VERSION_NUMBER >= 0x10001000L populateCipherList(options, TLSv1_2_client_method()); populateCipherList(options, TLSv1_1_client_method()); #endif populateCipherList(options, TLSv1_client_method()); #ifndef OPENSSL_NO_SSL3 populateCipherList(options, SSLv3_client_method()); #endif #ifndef OPENSSL_NO_SSL2 populateCipherList(options, SSLv2_client_method()); #endif break; case tls_all: #if OPENSSL_VERSION_NUMBER >= 0x10001000L populateCipherList(options, TLSv1_2_client_method()); populateCipherList(options, TLSv1_1_client_method()); #endif populateCipherList(options, TLSv1_client_method()); break; #if OPENSSL_VERSION_NUMBER >= 0x10001000L case tls_v12: populateCipherList(options, TLSv1_2_client_method()); break; case tls_v11: populateCipherList(options, TLSv1_1_client_method()); break; #endif case tls_v10: populateCipherList(options, TLSv1_client_method()); break; #ifndef OPENSSL_NO_SSL3 case ssl_v3: populateCipherList(options, SSLv3_client_method()); break; #endif #ifndef OPENSSL_NO_SSL2 case ssl_v2: populateCipherList(options, SSLv2_client_method()); break; #endif } printf("\n %sSupported Client Cipher(s):%s\n", COL_BLUE, RESET); sslCipherPointer = options->ciphers; while ((sslCipherPointer != 0) && (status == true)) { printf(" %s\n",sslCipherPointer->name); printf_xml(" \n", sslCipherPointer->name); sslCipherPointer = sslCipherPointer->next; } printf("\n"); } if (status == true && options->reneg ) { printf(" %sTLS renegotiation:%s\n", COL_BLUE, RESET); testRenegotiation(options, TLSv1_client_method()); } if (status == true && options->compression ) { printf(" %sTLS Compression:%s\n", COL_BLUE, RESET); testCompression(options, TLSv1_client_method()); } if (status == true && options->heartbleed ) { printf(" %sHeartbleed:%s\n", COL_BLUE, RESET); #if OPENSSL_VERSION_NUMBER >= 0x10001000L if( options->sslVersion == ssl_all || options->sslVersion == tls_all || options->sslVersion == tls_v12) { printf("TLS 1.2 "); status = testHeartbleed(options, TLSv1_2_client_method()); } if( options->sslVersion == ssl_all || options->sslVersion == tls_all || options->sslVersion == tls_v11) { printf("TLS 1.1 "); status = testHeartbleed(options, TLSv1_1_client_method()); } #endif if( options->sslVersion == ssl_all || options->sslVersion == tls_all || options->sslVersion == tls_v10) { printf("TLS 1.0 "); status = testHeartbleed(options, TLSv1_client_method()); } if( options->sslVersion == ssl_v2 || options->sslVersion == ssl_v3) { printf("%sAll TLS protocols disabled, cannot check for heartbleed.\n%s", COL_RED, RESET); } printf("\n"); } // Print OCSP response if (status == true && options->ocspStatus == true) { printf(" %sOCSP Stapling Request:%s\n", COL_BLUE, RESET); #if OPENSSL_VERSION_NUMBER > 0x00908000L && !defined(OPENSSL_NO_TLSEXT) status = ocspRequest(options); #endif } if (options->ciphersuites) { // Test supported ciphers... printf(" %sSupported Server Cipher(s):%s\n", COL_BLUE, RESET); switch (options->sslVersion) { case ssl_all: #if OPENSSL_VERSION_NUMBER >= 0x10001000L if (status != false) status = testProtocolCiphers(options, TLSv1_2_client_method()); if (status != false) status = testProtocolCiphers(options, TLSv1_1_client_method()); #endif if (status != false) status = testProtocolCiphers(options, TLSv1_client_method()); #ifndef OPENSSL_NO_SSL3 if (status != false) status = testProtocolCiphers(options, SSLv3_client_method()); #endif #ifndef OPENSSL_NO_SSL2 if (status != false) status = testProtocolCiphers(options, SSLv2_client_method()); #endif break; #ifndef OPENSSL_NO_SSL2 case ssl_v2: status = testProtocolCiphers(options, SSLv2_client_method()); break; #endif #ifndef OPENSSL_NO_SSL3 case ssl_v3: status = testProtocolCiphers(options, SSLv3_client_method()); break; #endif case tls_all: #if OPENSSL_VERSION_NUMBER >= 0x10001000L if (status != false) status = testProtocolCiphers(options, TLSv1_2_client_method()); if (status != false) status = testProtocolCiphers(options, TLSv1_1_client_method()); #endif if (status != false) status = testProtocolCiphers(options, TLSv1_client_method()); break; case tls_v10: status = testProtocolCiphers(options, TLSv1_client_method()); break; #if OPENSSL_VERSION_NUMBER >= 0x10001000L case tls_v11: status = testProtocolCiphers(options, TLSv1_1_client_method()); break; case tls_v12: status = testProtocolCiphers(options, TLSv1_2_client_method()); break; #endif } } // Print certificate if (status == true && options->showCertificate == true) { status = showCertificate(options); } // Show weak certificate signing algorithm or key strength if (status == true && options->checkCertificate == true) { #if OPENSSL_VERSION_NUMBER >= 0x10001000L if (status != false) { status = checkCertificateProtocol(options, TLSv1_2_client_method()); } if (status != false) status = checkCertificateProtocol(options, TLSv1_1_client_method()); #endif if (status != false) status = checkCertificateProtocol(options, TLSv1_client_method()); #ifndef OPENSSL_NO_SSL3 if (status != false) status = checkCertificateProtocol(options, SSLv3_client_method()); #endif #ifndef OPENSSL_NO_SSL2 if (status != false) status = checkCertificateProtocol(options, SSLv2_client_method()); #endif } // Print client auth trusted CAs if (status == true && options->showTrustedCAs == true) { status = showTrustedCAs(options); } // XML Output... printf_xml(" \n"); // Return status... return status; } int main(int argc, char *argv[]) { // Variables... struct sslCheckOptions options; struct sslCipher *sslCipherPointer; int argLoop; int tempInt; int maxSize; int xmlArg; int mode = mode_help; int msec; FILE *targetsFile; char line[1024]; #ifdef _WIN32 WORD wVersionRequested; WSADATA wsaData; int err; #endif // Init... memset(&options, 0, sizeof(struct sslCheckOptions)); options.port = 0; xmlArg = 0; strncpy(options.host, "127.0.0.1", 10); options.showCertificate = false; options.showTrustedCAs = false; options.checkCertificate = true; options.showClientCiphers = false; options.showCipherIds = false; options.showTimes = false; options.ciphersuites = true; options.reneg = true; options.compression = true; options.heartbleed = true; options.starttls_ftp = false; options.starttls_imap = false; options.starttls_irc = false; options.starttls_pop3 = false; options.starttls_smtp = false; options.starttls_xmpp = false; options.starttls_psql = false; options.xmpp_server = false; options.verbose = false; options.cipher_details = true; options.ipv4 = true; options.ipv6 = true; options.ocspStatus = false; // Default socket timeout 3s options.timeout.tv_sec = 3; options.timeout.tv_usec = 0; options.sleep = 0; options.sslVersion = ssl_all; #ifdef _WIN32 wVersionRequested = MAKEWORD(2, 2); err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { printf_error("WSAStartup failed: %d\n", err); return -1; } #endif SSL_library_init(); // Get program parameters for (argLoop = 1; argLoop < argc; argLoop++) { // Help if ((strcmp("--help", argv[argLoop]) == 0) || (strcmp("-h", argv[argLoop]) == 0)) mode = mode_help; // targets else if ((strncmp("--targets=", argv[argLoop], 10) == 0) && (strlen(argv[argLoop]) > 10)) { mode = mode_multiple; options.targets = argLoop; } // Show certificate else if (strcmp("--show-certificate", argv[argLoop]) == 0) options.showCertificate = true; // Don't check certificate strength else if (strcmp("--no-check-certificate", argv[argLoop]) == 0) options.checkCertificate = false; // Show supported client ciphers else if (strcmp("--show-ciphers", argv[argLoop]) == 0) options.showClientCiphers = true; // Show ciphers ids else if (strcmp("--show-cipher-ids", argv[argLoop]) == 0) { options.showCipherIds = true; } // Show handshake times else if (strcmp("--show-times", argv[argLoop]) == 0) { options.showTimes = true; } // Show client auth trusted CAs else if (strcmp("--show-client-cas", argv[argLoop]) == 0) options.showTrustedCAs = true; // Version else if (strcmp("--version", argv[argLoop]) == 0) mode = mode_version; // XML Output else if (strncmp("--xml=", argv[argLoop], 6) == 0) xmlArg = argLoop; // Verbose else if (strcmp("--verbose", argv[argLoop]) == 0) options.verbose = true; #if OPENSSL_VERSION_NUMBER >= 0x10002000L // Cipher details (curve names and EDH key lengths) else if (strcmp("--no-cipher-details", argv[argLoop]) == 0) options.cipher_details = false; #endif // Disable coloured output else if ((strcmp("--no-colour", argv[argLoop]) == 0) || (strcmp("--no-color", argv[argLoop]) == 0)) { RESET = ""; COL_RED = ""; COL_YELLOW = ""; COL_BLUE = ""; COL_GREEN = ""; COL_PURPLE = ""; COL_RED_BG = ""; } // Client Certificates else if (strncmp("--certs=", argv[argLoop], 8) == 0) options.clientCertsFile = argv[argLoop] +8; // Private Key File else if (strncmp("--pk=", argv[argLoop], 5) == 0) options.privateKeyFile = argv[argLoop] +5; // Private Key Password else if (strncmp("--pkpass=", argv[argLoop], 9) == 0) options.privateKeyPassword = argv[argLoop] +9; // Should we check for supported cipher suites else if (strcmp("--no-ciphersuites", argv[argLoop]) == 0) options.ciphersuites = false; // Should we check for TLS renegotiation? else if (strcmp("--no-renegotiation", argv[argLoop]) == 0) options.reneg = false; // Should we check for TLS Compression else if (strcmp("--no-compression", argv[argLoop]) == 0) options.compression = false; // Should we check for Heartbleed (CVE-2014-0160) else if (strcmp("--no-heartbleed", argv[argLoop]) == 0) options.heartbleed = false; // StartTLS... FTP else if (strcmp("--starttls-ftp", argv[argLoop]) == 0) options.starttls_ftp = true; // StartTLS... IMAP else if (strcmp("--starttls-imap", argv[argLoop]) == 0) options.starttls_imap = true; else if (strcmp("--starttls-irc", argv[argLoop]) == 0) options.starttls_irc = true; // StartTLS... POP3 else if (strcmp("--starttls-pop3", argv[argLoop]) == 0) options.starttls_pop3 = true; // StartTLS... SMTP else if (strcmp("--starttls-smtp", argv[argLoop]) == 0) options.starttls_smtp = true; // StartTLS... XMPP else if (strcmp("--starttls-xmpp", argv[argLoop]) == 0) options.starttls_xmpp = true; // StartTLS... PostgreSQL else if (strcmp("--starttls-psql", argv[argLoop]) == 0) options.starttls_psql = true; #ifndef OPENSSL_NO_SSL2 // SSL v2 only... else if (strcmp("--ssl2", argv[argLoop]) == 0) options.sslVersion = ssl_v2; #endif #ifndef OPENSSL_NO_SSL3 // SSL v3 only... else if (strcmp("--ssl3", argv[argLoop]) == 0) options.sslVersion = ssl_v3; #endif // TLS v1 only... else if (strcmp("--tls10", argv[argLoop]) == 0) options.sslVersion = tls_v10; #if OPENSSL_VERSION_NUMBER >= 0x10001000L // TLS v11 only... else if (strcmp("--tls11", argv[argLoop]) == 0) options.sslVersion = tls_v11; // TLS v12 only... else if (strcmp("--tls12", argv[argLoop]) == 0) options.sslVersion = tls_v12; #endif // TLS (all versions)... else if (strcmp("--tlsall", argv[argLoop]) == 0) options.sslVersion = tls_all; // Use a server-to-server XMPP handshake else if (strcmp("--xmpp-server", argv[argLoop]) == 0) options.xmpp_server = true; // SSL Bugs... else if (strcmp("--bugs", argv[argLoop]) == 0) options.sslbugs = 1; // Socket Timeout else if (strncmp("--timeout=", argv[argLoop], 10) == 0) options.timeout.tv_sec = atoi(argv[argLoop] + 10); // Sleep between requests (ms) else if (strncmp("--sleep=", argv[argLoop], 8) == 0) { msec = atoi(argv[argLoop] + 8); if (msec >= 0) { options.sleep = msec; } } // SSL HTTP Get... else if (strcmp("--http", argv[argLoop]) == 0) options.http = 1; // RDP Preamble... else if (strcmp("--rdp", argv[argLoop]) == 0) options.rdp = 1; // IPv4 only else if (strcmp("--ipv4", argv[argLoop]) == 0) options.ipv6 = false; // IPv6 only else if (strcmp("--ipv6", argv[argLoop]) == 0) options.ipv4 = false; else if (strcmp("--ocsp", argv[argLoop]) == 0) options.ocspStatus = true; // Host (maybe port too)... else if (argLoop + 1 == argc) { mode = mode_single; // Get host... // IPv6 [] address parsing by DinoTools/phibos tempInt = 0; char *hostString = argv[argLoop]; maxSize = strlen(hostString); if (strncmp((char*)hostString, "https://", 8) == 0) { // Strip https:// from the start of the hostname memmove(hostString, hostString + 8, (maxSize - 8)); memset(hostString + (maxSize - 8), 0, 8); maxSize = strlen(hostString); } int squareBrackets = false; if (hostString[0] == '[') { squareBrackets = true; // skip the square bracket hostString++; } while ((hostString[tempInt] != 0) && ((squareBrackets == true && hostString[tempInt] != ']') || (squareBrackets == false && hostString[tempInt] != ':'))) tempInt++; if (squareBrackets == true && hostString[tempInt] == ']') { hostString[tempInt] = 0; if (tempInt < maxSize && hostString[tempInt + 1] == ':') { tempInt++; hostString[tempInt] = 0; } } else hostString[tempInt] = 0; strncpy(options.host, hostString, sizeof(options.host) -1); // Get port (if it exists)... tempInt++; if (tempInt < maxSize - 1) options.port = atoi(hostString + tempInt); else if (options.port == 0) { if (options.starttls_ftp) options.port = 21; else if (options.starttls_imap) options.port = 143; else if (options.starttls_irc) options.port = 6667; else if (options.starttls_pop3) options.port = 110; else if (options.starttls_smtp) options.port = 25; else if (options.starttls_xmpp) options.port = 5222; else if (options.starttls_psql) options.port = 5432; else if (options.rdp) options.port = 3389; else options.port = 443; } } // Not too sure what the user is doing... else mode = mode_help; } // Open XML file output... if ((xmlArg > 0) && (mode != mode_help)) { options.xmlOutput = fopen(argv[xmlArg] + 6, "w"); if (options.xmlOutput == NULL) { printf_error("%sERROR: Could not open XML output file %s.%s\n", COL_RED, argv[xmlArg] + 6, RESET); exit(0); } // Output file header... fprintf(options.xmlOutput, "\n\n", VERSION); } switch (mode) { case mode_version: printf("%s\t\t%s\n\t\t%s\n%s", COL_BLUE, VERSION, SSLeay_version(SSLEAY_VERSION), RESET); #ifdef OPENSSL_NO_SSL2 printf("\t\t%sOpenSSL version does not support SSLv2%s\n", COL_RED, RESET); printf("\t\t%sSSLv2 ciphers will not be detected%s\n", COL_RED, RESET); #endif #ifdef OPENSSL_NO_SSL3 printf("\t\t%sOpenSSL version does not support SSLv3%s\n", COL_RED, RESET); printf("\t\t%sSSLv3 ciphers will not be detected%s\n", COL_RED, RESET); #endif #if OPENSSL_VERSION_NUMBER < 0x10001000L printf("\t\t%sOpenSSL version does not support TLSv1.1%s\n", COL_RED, RESET); printf("\t\t%sTLSv1.1 ciphers will not be detected%s\n", COL_RED, RESET); printf("\t\t%sOpenSSL version does not support TLSv1.2%s\n", COL_RED, RESET); printf("\t\t%sTLSv1.2 ciphers will not be detected%s\n", COL_RED, RESET); #endif break; case mode_help: // Program version banner... printf("%s%s%s\n", COL_BLUE, program_banner, RESET); printf("%s\t\t%s\n\t\t%s\n%s", COL_BLUE, VERSION, SSLeay_version(SSLEAY_VERSION), RESET); #ifdef OPENSSL_NO_SSL2 printf("%sOpenSSL version does not support SSLv2%s\n", COL_RED, RESET); printf("%sSSLv2 ciphers will not be detected%s\n\n", COL_RED, RESET); #endif #ifdef OPENSSL_NO_SSL3 printf("%sOpenSSL version does not support SSLv3%s\n", COL_RED, RESET); printf("%sSSLv3 ciphers will not be detected%s\n", COL_RED, RESET); #endif printf("%sCommand:%s\n", COL_BLUE, RESET); printf(" %s%s [Options] [host:port | host]%s\n\n", COL_GREEN, argv[0], RESET); printf("%sOptions:%s\n", COL_BLUE, RESET); printf(" %s--targets=%s A file containing a list of hosts to check.\n", COL_GREEN, RESET); printf(" Hosts can be supplied with ports (host:port)\n"); printf(" %s--ipv4%s Only use IPv4\n", COL_GREEN, RESET); printf(" %s--ipv6%s Only use IPv6\n", COL_GREEN, RESET); printf(" %s--show-certificate%s Show full certificate information\n", COL_GREEN, RESET); printf(" %s--no-check-certificate%s Don't warn about weak certificate algorithm or keys\n", COL_GREEN, RESET); printf(" %s--show-client-cas%s Show trusted CAs for TLS client auth\n", COL_GREEN, RESET); printf(" %s--show-ciphers%s Show supported client ciphers\n", COL_GREEN, RESET); printf(" %s--show-cipher-ids%s Show cipher ids\n", COL_GREEN, RESET); printf(" %s--show-times%s Show handhake times in milliseconds\n", COL_GREEN, RESET); #ifndef OPENSSL_NO_SSL2 printf(" %s--ssl2%s Only check SSLv2 ciphers\n", COL_GREEN, RESET); #endif #ifndef OPENSSL_NO_SSL3 printf(" %s--ssl3%s Only check SSLv3 ciphers\n", COL_GREEN, RESET); #endif printf(" %s--tls10%s Only check TLSv1.0 ciphers\n", COL_GREEN, RESET); #if OPENSSL_VERSION_NUMBER >= 0x10001000L printf(" %s--tls11%s Only check TLSv1.1 ciphers\n", COL_GREEN, RESET); printf(" %s--tls12%s Only check TLSv1.2 ciphers\n", COL_GREEN, RESET); #endif printf(" %s--tlsall%s Only check TLS ciphers (all versions)\n", COL_GREEN, RESET); printf(" %s--ocsp%s Request OCSP response from server\n", COL_GREEN, RESET); printf(" %s--pk=%s A file containing the private key or a PKCS#12 file\n", COL_GREEN, RESET); printf(" containing a private key/certificate pair\n"); printf(" %s--pkpass=%s The password for the private key or PKCS#12 file\n", COL_GREEN, RESET); printf(" %s--certs=%s A file containing PEM/ASN1 formatted client certificates\n", COL_GREEN, RESET); printf(" %s--no-ciphersuites%s Do not check for supported ciphersuites\n", COL_GREEN, RESET); printf(" %s--no-renegotiation%s Do not check for TLS renegotiation\n", COL_GREEN, RESET); printf(" %s--no-compression%s Do not check for TLS compression (CRIME)\n", COL_GREEN, RESET); printf(" %s--no-heartbleed%s Do not check for OpenSSL Heartbleed (CVE-2014-0160)\n", COL_GREEN, RESET); printf(" %s--starttls-ftp%s STARTTLS setup for FTP\n", COL_GREEN, RESET); printf(" %s--starttls-imap%s STARTTLS setup for IMAP\n", COL_GREEN, RESET); printf(" %s--starttls-irc%s STARTTLS setup for IRC\n", COL_GREEN, RESET); printf(" %s--starttls-pop3%s STARTTLS setup for POP3\n", COL_GREEN, RESET); printf(" %s--starttls-smtp%s STARTTLS setup for SMTP\n", COL_GREEN, RESET); printf(" %s--starttls-xmpp%s STARTTLS setup for XMPP\n", COL_GREEN, RESET); printf(" %s--starttls-psql%s STARTTLS setup for PostgreSQL\n", COL_GREEN, RESET); printf(" %s--xmpp-server%s Use a server-to-server XMPP handshake\n", COL_GREEN, RESET); printf(" %s--http%s Test a HTTP connection\n", COL_GREEN, RESET); printf(" %s--rdp%s Send RDP preamble before starting scan\n", COL_GREEN, RESET); printf(" %s--bugs%s Enable SSL implementation bug work-arounds\n", COL_GREEN, RESET); printf(" %s--timeout=%s Set socket timeout. Default is 3s\n", COL_GREEN, RESET); printf(" %s--sleep=%s Pause between connection request. Default is disabled\n", COL_GREEN, RESET); printf(" %s--xml=%s Output results to an XML file\n", COL_GREEN, RESET); printf(" %s--version%s Display the program version\n", COL_GREEN, RESET); printf(" %s--verbose%s Display verbose output\n", COL_GREEN, RESET); #if OPENSSL_VERSION_NUMBER >= 0x10002000L printf(" %s--no-cipher-details%s Disable EC curve names and EDH/RSA key lengths output\n", COL_GREEN, RESET); #endif printf(" %s--no-colour%s Disable coloured output\n", COL_GREEN, RESET); printf(" %s--help%s Display the help text you are now reading\n\n", COL_GREEN, RESET); printf("%sExample:%s\n", COL_BLUE, RESET); printf(" %s%s 127.0.0.1%s\n", COL_GREEN, argv[0], RESET); printf(" %s%s [::1]%s\n\n", COL_GREEN, argv[0], RESET); break; // Check a single host/port ciphers... case mode_single: case mode_multiple: printf("Version: %s%s%s\n%s\n%s\n", COL_GREEN, VERSION, RESET, SSLeay_version(SSLEAY_VERSION), RESET); #ifdef OPENSSL_NO_SSL2 printf("%sOpenSSL version does not support SSLv2%s\n", COL_RED, RESET); printf("%sSSLv2 ciphers will not be detected%s\n\n", COL_RED, RESET); #endif #ifdef OPENSSL_NO_SSL3 printf("%sOpenSSL version does not support SSLv3%s\n", COL_RED, RESET); printf("%sSSLv3 ciphers will not be detected%s\n", COL_RED, RESET); #endif #if OPENSSL_VERSION_NUMBER < 0x10001000L printf("\t\t%sOpenSSL version does not support TLSv1.1%s\n", COL_RED, RESET); printf("\t\t%sTLSv1.1 ciphers will not be detected%s\n", COL_RED, RESET); printf("\t\t%sOpenSSL version does not support TLSv1.2%s\n", COL_RED, RESET); printf("\t\t%sTLSv1.2 ciphers will not be detected%s\n", COL_RED, RESET); #endif SSLeay_add_all_algorithms(); ERR_load_crypto_strings(); // Do the testing... if (mode == mode_single) { if (testConnection(&options)) { testHost(&options); } } else { if (fileExists(argv[options.targets] + 10) == true) { // Open targets file... targetsFile = fopen(argv[options.targets] + 10, "r"); if (targetsFile == NULL) printf_error("%sERROR: Could not open targets file %s.%s\n", COL_RED, argv[options.targets] + 10, RESET); else { readLine(targetsFile, line, sizeof(line)); while (feof(targetsFile) == 0) { if (strlen(line) != 0) { // Get host... tempInt = 0; while ((line[tempInt] != 0) && (line[tempInt] != ':')) tempInt++; line[tempInt] = 0; strncpy(options.host, line, sizeof(options.host) -1); // Get port (if it exists)... tempInt++; if (strlen(line + tempInt) > 0) { options.port = atoi(line + tempInt); } // Otherwise assume 443 else { options.port = 443; } // Test the host... if (testConnection(&options)) { testHost(&options); } printf("\n\n"); } readLine(targetsFile, line, sizeof(line)); } } } else printf_error("%sERROR: Targets file %s does not exist.%s\n", COL_RED, argv[options.targets] + 10, RESET); } // Free Structures while (options.ciphers != 0) { sslCipherPointer = options.ciphers->next; free(options.ciphers); options.ciphers = sslCipherPointer; } break; } // Close XML file, if required... if ((xmlArg > 0) && (mode != mode_help)) { fprintf(options.xmlOutput, "\n"); fclose(options.xmlOutput); } return 0; } /* vim :set ts=4 sw=4 sts=4 et : */ sslscan-1.11.5-rbsec/sslscan.h000066400000000000000000000172321267505277700162070ustar00rootroot00000000000000/*************************************************************************** * sslscan - A SSL cipher scanning tool * * Copyright 2007-2009 by Ian Ventura-Whiting (Fizz) * * fizz@titania.co.uk * * Copyright 2010 by Michael Boman (michael@michaelboman.org) * * Copyleft 2010 by Jacob Appelbaum * * Copyleft 2013 by rbsec * * Copyleft 2014 by Julian Kornberger * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * * In addition, as a special exception, the copyright holders give * * permission to link the code of portions of this program with the * * OpenSSL library under certain conditions as described in each * * individual source file, and distribute linked combinations * * including the two. * * You must obey the GNU General Public License in all respects * * for all of the code used other than OpenSSL. If you modify * * file(s) with this exception, you may extend this exception to your * * version of the file(s), but you are not obligated to do so. If you * * do not wish to do so, delete this exception statement from your * * version. If you delete this exception statement from all source * * files in the program, then also delete it here. * ***************************************************************************/ #ifndef HAVE_SSLSCAN_H_ #define HAVE_SSLSCAN_H_ // Defines... #define false 0 #define true 1 #define mode_help 0 #define mode_version 1 #define mode_single 2 #define mode_multiple 3 #define BUFFERSIZE 1024 #define ssl_all 0 #define ssl_v2 1 #define ssl_v3 2 #define tls_all 3 #define tls_v10 4 #define tls_v11 5 #define tls_v12 6 // Macros for various outputs #define printf_error(format, ...) fprintf(stderr, format, ##__VA_ARGS__) #define printf_xml(format, ...) if (options->xmlOutput) fprintf(options->xmlOutput, format, ##__VA_ARGS__) #define printf_verbose(format, ...) if (options->verbose) printf(format, ##__VA_ARGS__) // Colour Console Output... #if !defined(_WIN32) // Always better to do "const char RESET[] = " because it saves relocation records. const char *RESET = ""; // DEFAULT const char *COL_RED = ""; const char *COL_YELLOW = ""; const char *COL_BLUE = ""; const char *COL_GREEN = ""; const char *COL_PURPLE = ""; const char *COL_GREY = ""; const char *COL_RED_BG = ""; #else const char *RESET = ""; const char *COL_RED = ""; const char *COL_YELLOW = ""; const char *COL_BLUE = ""; const char *COL_GREEN = ""; const char *COL_PURPLE = ""; const char *COL_GREY = ""; const char *COL_RED_BG = ""; #endif #ifdef _WIN32 #define SLEEPMS(ms) Sleep(ms); #else #define SLEEPMS(ms) do { \ struct timeval wait = { 0, ms*1000 }; \ select(0, NULL, NULL, NULL, &wait); \ } while(0) #endif const char *program_banner = " _\n" " ___ ___| |___ ___ __ _ _ __\n" " / __/ __| / __|/ __/ _` | '_ \\\n" " \\__ \\__ \\ \\__ \\ (_| (_| | | | |\n" " |___/___/_|___/\\___\\__,_|_| |_|\n\n"; struct sslCipher { // Cipher Properties... const char *name; char *version; int bits; char description[512]; const SSL_METHOD *sslMethod; struct sslCipher *next; }; struct sslCheckOptions { // Program Options... char host[512]; int port; int showCertificate; int checkCertificate; int showTrustedCAs; int showClientCiphers; int showCipherIds; int showTimes; int ciphersuites; int reneg; int compression; int heartbleed; int starttls_ftp; int starttls_imap; int starttls_irc; int starttls_pop3; int starttls_smtp; int starttls_xmpp; int starttls_psql; int xmpp_server; int sslVersion; int targets; int sslbugs; int http; int rdp; int verbose; int cipher_details; int ipv4; int ipv6; int ocspStatus; char cipherstring[65536]; // File Handles... FILE *xmlOutput; // TCP Connection Variables... short h_addrtype; struct sockaddr_in serverAddress; struct sockaddr_in6 serverAddress6; struct timeval timeout; unsigned int sleep; // SSL Variables... SSL_CTX *ctx; struct sslCipher *ciphers; char *clientCertsFile; char *privateKeyFile; char *privateKeyPassword; }; // store renegotiation test data struct renegotiationOutput { int supported; int secure; }; /* We redefine these so that we can run correctly even if the vendor gives us * a version of OpenSSL that does not match its header files. (Apple: I am * looking at you.) */ #ifndef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION # define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000L #endif #ifndef SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION # define SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x0010 #endif // Utilities int fileExists(char *); void readLine(FILE *, char *, int); ssize_t sendString(int, const char[]); int readOrLogAndClose(int, void *, size_t, const struct sslCheckOptions *); const char *printableSslMethod(const SSL_METHOD *); static int password_callback(char *, int, int, void *); int ssl_print_tmp_key(struct sslCheckOptions *, SSL *s); static int ocsp_resp_cb(SSL *s, void *arg); int ocsp_certid_print(BIO *bp, OCSP_CERTID *a, int indent); int tcpConnect(struct sslCheckOptions *); // Tests void tls_reneg_init(struct sslCheckOptions *); int outputRenegotiation(struct sslCheckOptions *, struct renegotiationOutput *); struct renegotiationOutput *newRenegotiationOutput(void); int freeRenegotiationOutput(struct renegotiationOutput *); int testCompression(struct sslCheckOptions *, const SSL_METHOD *); int testRenegotiation(struct sslCheckOptions *, const SSL_METHOD *); int testHeartbleed(struct sslCheckOptions *, const SSL_METHOD *); int testCipher(struct sslCheckOptions *, const SSL_METHOD *); int testProtocolCiphers(struct sslCheckOptions *, const SSL_METHOD *); int testConnection(struct sslCheckOptions *); int testHost(struct sslCheckOptions *); int loadCerts(struct sslCheckOptions *); int checkCertificateProtocols(struct sslCheckOptions *, const SSL_METHOD *); int checkCertificate(struct sslCheckOptions *, const SSL_METHOD *); int showCertificate(struct sslCheckOptions *); #endif /* vim :set ts=4 sw=4 sts=4 et : */ sslscan-1.11.5-rbsec/tags000066400000000000000000000157461267505277700152610ustar00rootroot00000000000000!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ !_TAG_PROGRAM_VERSION 5.8 // BUFFERSIZE sslscan.c 61;" d file: COL_BLUE sslscan.c /^const char *COL_BLUE = "";$/;" v COL_BLUE sslscan.c /^const char *COL_BLUE = "";$/;" v COL_GREEN sslscan.c /^const char *COL_GREEN = "";$/;" v COL_GREEN sslscan.c /^const char *COL_GREEN = "";$/;" v COL_PURPLE sslscan.c /^const char *COL_PURPLE = "";$/;" v COL_PURPLE sslscan.c /^const char *COL_PURPLE = "";$/;" v COL_RED sslscan.c /^const char *COL_RED = "";$/;" v COL_RED sslscan.c /^const char *COL_RED = "";$/;" v COL_YELLOW sslscan.c /^const char *COL_YELLOW = "";$/;" v COL_YELLOW sslscan.c /^const char *COL_YELLOW = "";$/;" v RESET sslscan.c /^const char *RESET = ""; \/\/ DEFAULT$/;" v RESET sslscan.c /^const char *RESET = "";$/;" v SSL3_FLAGS_ALLOW_UNSAFE_LEGACY_RENEGOTIATION sslscan.c 674;" d file: SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION sslscan.c 671;" d file: bits sslscan.c /^ int bits;$/;" m struct:sslCipher file: ciphers sslscan.c /^ struct sslCipher *ciphers;$/;" m struct:sslCheckOptions typeref:struct:sslCheckOptions::sslCipher file: ciphersuites sslscan.c /^ int ciphersuites;$/;" m struct:sslCheckOptions file: clientCertsFile sslscan.c /^ char *clientCertsFile;$/;" m struct:sslCheckOptions file: compression sslscan.c /^ int compression;$/;" m struct:sslCheckOptions file: ctx sslscan.c /^ SSL_CTX *ctx;$/;" m struct:sslCheckOptions file: defaultCipher sslscan.c /^int defaultCipher(struct sslCheckOptions *options, const SSL_METHOD *sslMethod)$/;" f description sslscan.c /^ char description[512];$/;" m struct:sslCipher file: false sslscan.c 53;" d file: fileExists sslscan.c /^int fileExists(char *fileName)$/;" f freeRenegotiationOutput sslscan.c /^int freeRenegotiationOutput( struct renegotiationOutput *myRenOut )$/;" f getCertificate sslscan.c /^ int getCertificate;$/;" m struct:sslCheckOptions file: getCertificate sslscan.c /^int getCertificate(struct sslCheckOptions *options)$/;" f host sslscan.c /^ char host[512];$/;" m struct:sslCheckOptions file: hostStruct sslscan.c /^ struct hostent *hostStruct;$/;" m struct:sslCheckOptions typeref:struct:sslCheckOptions::hostent file: http sslscan.c /^ int http;$/;" m struct:sslCheckOptions file: ipv4 sslscan.c /^ int ipv4;$/;" m struct:sslCheckOptions file: ipv6 sslscan.c /^ int ipv6;$/;" m struct:sslCheckOptions file: loadCerts sslscan.c /^int loadCerts(struct sslCheckOptions *options)$/;" f main sslscan.c /^int main(int argc, char *argv[])$/;" f mode_help sslscan.c 56;" d file: mode_multiple sslscan.c 59;" d file: mode_single sslscan.c 58;" d file: mode_version sslscan.c 57;" d file: name sslscan.c /^ const char *name;$/;" m struct:sslCipher file: newRenegotiationOutput sslscan.c /^struct renegotiationOutput * newRenegotiationOutput( void )$/;" f next sslscan.c /^ struct sslCipher *next;$/;" m struct:sslCipher typeref:struct:sslCipher::sslCipher file: noFailed sslscan.c /^ int noFailed;$/;" m struct:sslCheckOptions file: outputRenegotiation sslscan.c /^int outputRenegotiation( struct sslCheckOptions *options, struct renegotiationOutput *outputData)$/;" f password_callback sslscan.c /^static int password_callback(char *buf, int size, int rwflag, void *userdata)$/;" f file: populateCipherList sslscan.c /^int populateCipherList(struct sslCheckOptions *options, const SSL_METHOD *sslMethod)$/;" f port sslscan.c /^ int port;$/;" m struct:sslCheckOptions file: privateKeyFile sslscan.c /^ char *privateKeyFile;$/;" m struct:sslCheckOptions file: privateKeyPassword sslscan.c /^ char *privateKeyPassword;$/;" m struct:sslCheckOptions file: program_banner sslscan.c /^const char *program_banner = " _\\n"$/;" v program_version sslscan.c /^const char *program_version = "1.9.1-rbsec";$/;" v readLine sslscan.c /^void readLine(FILE *input, char *lineFromFile, int maxSize)$/;" f readOrLogAndClose sslscan.c /^int readOrLogAndClose(int fd, void* buffer, size_t len, const struct sslCheckOptions *options)$/;" f reneg sslscan.c /^ int reneg;$/;" m struct:sslCheckOptions file: renegotiationOutput sslscan.c /^struct renegotiationOutput$/;" s file: secure sslscan.c /^ int secure;$/;" m struct:renegotiationOutput file: serverAddress sslscan.c /^ struct sockaddr_in serverAddress;$/;" m struct:sslCheckOptions typeref:struct:sslCheckOptions::sockaddr_in file: serverAddress6 sslscan.c /^ struct sockaddr_in6 serverAddress6;$/;" m struct:sslCheckOptions typeref:struct:sslCheckOptions::sockaddr_in6 file: showClientCiphers sslscan.c /^ int showClientCiphers;$/;" m struct:sslCheckOptions file: sslCheckOptions sslscan.c /^struct sslCheckOptions$/;" s file: sslCipher sslscan.c /^struct sslCipher$/;" s file: sslMethod sslscan.c /^ const SSL_METHOD *sslMethod;$/;" m struct:sslCipher file: sslVersion sslscan.c /^ int sslVersion;$/;" m struct:sslCheckOptions file: ssl_all sslscan.c 63;" d file: ssl_v2 sslscan.c 64;" d file: ssl_v3 sslscan.c 65;" d file: sslbugs sslscan.c /^ int sslbugs;$/;" m struct:sslCheckOptions file: starttls_ftp sslscan.c /^ int starttls_ftp;$/;" m struct:sslCheckOptions file: starttls_imap sslscan.c /^ int starttls_imap;$/;" m struct:sslCheckOptions file: starttls_pop3 sslscan.c /^ int starttls_pop3;$/;" m struct:sslCheckOptions file: starttls_smtp sslscan.c /^ int starttls_smtp;$/;" m struct:sslCheckOptions file: starttls_xmpp sslscan.c /^ int starttls_xmpp;$/;" m struct:sslCheckOptions file: supported sslscan.c /^ int supported;$/;" m struct:renegotiationOutput file: targets sslscan.c /^ int targets;$/;" m struct:sslCheckOptions file: tcpConnect sslscan.c /^int tcpConnect(struct sslCheckOptions *options)$/;" f testCipher sslscan.c /^int testCipher(struct sslCheckOptions *options, struct sslCipher *sslCipherPointer)$/;" f testCompression sslscan.c /^int testCompression(struct sslCheckOptions *options, const SSL_METHOD *sslMethod)$/;" f testHost sslscan.c /^int testHost(struct sslCheckOptions *options)$/;" f testRenegotiation sslscan.c /^int testRenegotiation(struct sslCheckOptions *options, const SSL_METHOD *sslMethod)$/;" f tls_all sslscan.c 66;" d file: tls_reneg_init sslscan.c /^void tls_reneg_init(struct sslCheckOptions *options)$/;" f tls_v10 sslscan.c 67;" d file: tls_v11 sslscan.c 68;" d file: tls_v12 sslscan.c 69;" d file: true sslscan.c 54;" d file: use_unsafe_renegotiation_flag sslscan.c /^static int use_unsafe_renegotiation_flag = 0;$/;" v file: use_unsafe_renegotiation_op sslscan.c /^static int use_unsafe_renegotiation_op = 0;$/;" v file: verbose sslscan.c /^ int verbose;$/;" m struct:sslCheckOptions file: version sslscan.c /^ char *version;$/;" m struct:sslCipher file: xmlOutput sslscan.c /^ FILE *xmlOutput;$/;" m struct:sslCheckOptions file: xml_version sslscan.c /^const char *xml_version = "1.9.1-rbsec";$/;" v