From 6a7da53a5f4fc7acb67c956384b6bf49602b2fd7 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Wed, 4 Aug 2021 11:42:25 +0200 Subject: [PATCH 01/16] Adapt script to use the penterep mail template Src folder containts all the source files for the script. Moved the ssltest script to a separte package src so so that relative imports work correctly inside the package src and all the subpacakges. Main script file is now the template file SSLTester.py which runs start_scan.py file from main package. This is a temporay state just to merge the two projects together. --- .gitignore | 4 +- LICENSE | 674 ++++++++++++++++++ README.MD | 54 ++ README.md | 34 - SSLTester/SSLTest.py | 78 ++ .../src}/__init__.py | 0 .../src/fix_openssl_config.py | 2 +- .../src/scan_parameters}/__init__.py | 0 .../scan_parameters/connection}/__init__.py | 0 .../connection/connection_utils.py | 11 +- .../exceptions/ConnectionTimeoutError.py | 0 .../scan_parameters}/exceptions/DNSError.py | 0 .../exceptions/NoIanaPairFound.py | 0 .../exceptions/UnknownConnectionError.py | 0 .../scan_parameters/exceptions}/__init__.py | 0 .../non_ratable/ProtocolSupport.py | 2 +- .../non_ratable/WebServerSoft.py | 0 .../scan_parameters/non_ratable}/__init__.py | 0 .../non_ratable/port_discovery.py | 0 .../scan_parameters}/ratable/Certificate.py | 0 .../scan_parameters}/ratable/CipherSuite.py | 2 +- .../src/scan_parameters}/ratable/PType.py | 0 .../scan_parameters}/ratable/Parameters.py | 0 .../src/scan_parameters/ratable}/__init__.py | 0 .../src/scan_parameters}/utils.py | 15 +- .../src/scan_vulnerabilities}/__init__.py | 0 .../scan_vulnerabilities}/multitheard_scan.py | 0 .../scan_vulnerabilities/tests}/__init__.py | 0 .../tests/ccs_injection.py | 0 .../src/scan_vulnerabilities}/tests/crime.py | 0 .../scan_vulnerabilities}/tests/heartbleed.py | 0 .../tests/insec_renegotiation.py | 0 .../src/scan_vulnerabilities}/tests/poodle.py | 0 .../tests/rc4_support.py | 0 .../tests/session_ticket.py | 0 .../src/scan_vulnerabilities}/utils.py | 0 {ssl_scan => SSLTester/src/ssl_scan}/SSLv3.py | 5 +- SSLTester/src/ssl_scan/__init__.py | 2 + {ssl_scan => SSLTester/src/ssl_scan}/utils.py | 0 ssltest.py => SSLTester/src/start_script.py | 65 +- .../src/text_output}/TextOutput.py | 2 +- SSLTester/src/text_output/__init__.py | 0 SSLTester/src/utils.py | 15 + libs/ptlibs/ptlibs/__init__.py | 0 libs/ptlibs/ptlibs/ptdefs.py | 31 + libs/ptlibs/ptlibs/ptjsonlib.py | 65 ++ libs/ptlibs/ptlibs/ptmisclib.py | 282 ++++++++ libs/ptlibs/ptlibs/ptthreads.py | 80 +++ libs/ptlibs/setup.py | 18 + setup.py | 21 + ssl_scan/__init__.py | 1 - 51 files changed, 1364 insertions(+), 99 deletions(-) create mode 100644 LICENSE create mode 100644 README.MD delete mode 100644 README.md create mode 100755 SSLTester/SSLTest.py rename {scan_parameters => SSLTester/src}/__init__.py (100%) rename fix_openssl_config.py => SSLTester/src/fix_openssl_config.py (95%) rename {scan_parameters/connection => SSLTester/src/scan_parameters}/__init__.py (100%) rename {scan_parameters/exceptions => SSLTester/src/scan_parameters/connection}/__init__.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/connection/connection_utils.py (99%) rename {scan_parameters => SSLTester/src/scan_parameters}/exceptions/ConnectionTimeoutError.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/exceptions/DNSError.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/exceptions/NoIanaPairFound.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/exceptions/UnknownConnectionError.py (100%) rename {scan_parameters/non_ratable => SSLTester/src/scan_parameters/exceptions}/__init__.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/non_ratable/ProtocolSupport.py (98%) rename {scan_parameters => SSLTester/src/scan_parameters}/non_ratable/WebServerSoft.py (100%) rename {scan_parameters/ratable => SSLTester/src/scan_parameters/non_ratable}/__init__.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/non_ratable/port_discovery.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/ratable/Certificate.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/ratable/CipherSuite.py (98%) rename {scan_parameters => SSLTester/src/scan_parameters}/ratable/PType.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/ratable/Parameters.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_parameters/ratable}/__init__.py (100%) rename {scan_parameters => SSLTester/src/scan_parameters}/utils.py (92%) rename {scan_vulnerabilities/tests => SSLTester/src/scan_vulnerabilities}/__init__.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/multitheard_scan.py (100%) rename {text_output => SSLTester/src/scan_vulnerabilities/tests}/__init__.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/ccs_injection.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/crime.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/heartbleed.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/insec_renegotiation.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/poodle.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/rc4_support.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/tests/session_ticket.py (100%) rename {scan_vulnerabilities => SSLTester/src/scan_vulnerabilities}/utils.py (100%) rename {ssl_scan => SSLTester/src/ssl_scan}/SSLv3.py (97%) create mode 100644 SSLTester/src/ssl_scan/__init__.py rename {ssl_scan => SSLTester/src/ssl_scan}/utils.py (100%) rename ssltest.py => SSLTester/src/start_script.py (85%) rename {text_output => SSLTester/src/text_output}/TextOutput.py (99%) create mode 100644 SSLTester/src/text_output/__init__.py create mode 100644 SSLTester/src/utils.py create mode 100644 libs/ptlibs/ptlibs/__init__.py create mode 100644 libs/ptlibs/ptlibs/ptdefs.py create mode 100644 libs/ptlibs/ptlibs/ptjsonlib.py create mode 100644 libs/ptlibs/ptlibs/ptmisclib.py create mode 100644 libs/ptlibs/ptlibs/ptthreads.py create mode 100644 libs/ptlibs/setup.py create mode 100644 setup.py delete mode 100644 ssl_scan/__init__.py diff --git a/.gitignore b/.gitignore index bcc748b..e94c761 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ share/python-wheels/ MANIFEST # PyInstaller -# Usually these files are written by a python script from a template +# Usually these files are written by a python script from a SSLTester # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec @@ -131,5 +131,5 @@ dmypy.json # Pycharm .idea/ -output.json +SSLTester/output.json logs/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3877ae0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + 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 + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..e474e63 --- /dev/null +++ b/README.MD @@ -0,0 +1,54 @@ +``` + ____ _ _____ _ +| _ \ ___ _ __ | |_ ___ _ __ ___ _ __ |_ _|__ ___ | |___ +| |_) / _ \ '_ \| __/ _ \ '__/ _ \ '_ \ | |/ _ \ / _ \| / __| +| __/ __/ | | | || __/ | | __/ |_) | | | (_) | (_) | \__ \ +|_| \___|_| |_|\__\___|_| \___| .__/ |_|\___/ \___/|_|___/ + |_| +``` + +# scriptname + +## Installation + +``` +$ git clone SSLTester +$ cd SSLTester && sudo pip install . +``` + +## Installation (ptmanager) + +``` +$ sudo ptmanager -ut SSLTester +``` + +## Options +``` +TODO +``` + +## Usage examples +``` +TODO +``` + +## Version History + +* 0.0.1 + +## Licence + +Copyright (c) 2020 HACKER Consulting s.r.o. + +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 . \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index fb66b09..0000000 --- a/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Overview - -- A standalone script that can be run in a console -- File `resources/security_levels.json` can be edited to change the parameter rating values - -# Run the script - -- Run the main file `ssltest.py` with option `-u` to enter the url. -- Use `-h` or `--help` for more help. -- Example: `./ssltest.py -u vutbr.cz` - -## Prepare hosting OS environment - -- If you are going to run the script these dependencies are required -- To install required python packages use `pip3 install -r requirements.txt` command which installs: - - [cryptography](https://pypi.org/project/cryptography/) - - [pyopenssl](https://pypi.org/project/pyOpenSSL/) - - [python3-nmap](https://pypi.org/project/python3-nmap/) - - [requests](https://pypi.org/project/requests/) - - [urllib3](https://pypi.org/project/urllib3/) - - [Flask](https://pypi.org/project/Flask/) - - [flask-restful](https://pypi.org/project/Flask-RESTful/) -- Nmap is required to for some functions, install with `apt install -y nmap` -- To run the tool script refer to the section at the start - -## Supported vulnerability tests - -- Heartbleed -- CCS Injection -- Insecure renegotiation -- ZombiePOODLE/GOLDENDOODLE -- Session ticker support -- CRIME -- RC4 Support \ No newline at end of file diff --git a/SSLTester/SSLTest.py b/SSLTester/SSLTest.py new file mode 100755 index 0000000..66471ea --- /dev/null +++ b/SSLTester/SSLTest.py @@ -0,0 +1,78 @@ +#!/usr/bin/python3 + +__version__ = "0.0.1" + +from ptlibs import ptjsonlib, ptmisclib +import argparse +import sys + +from src.start_script import start + + +class SSLTester: + def __init__(self, args): + self.args = args + self.ptjsonlib = ptjsonlib.ptjsonlib(self.args.json) + self.json_no = self.ptjsonlib.add_json("SSLTester") + self.use_json = self.args.json + + def run(self): + start(self.args) + ptmisclib.ptprint(ptmisclib.out_if(self.ptjsonlib.get_all_json(), "", self.use_json)) + + +def get_help(): + return [ + {"description": ["Script that scans a webservers cryptographic parameters and vulnerabilities"]}, + {"usage": [ + "SSLTester.py -u url <-h> <-ns> <-nd> <-p port > <-j > <-t test_num >" + " <-fc> <-i> <-v>" + ]}, + {"usage_example": [ + "SSLTester.py -u github.com -t 1 2", + ]}, + {"options": [ + ["-u", "--url", "", "Url to scan, required option"], + ["-p", "--proxy", "", "Set proxy (e.g. http://127.0.0.1:8080)"], + ["-c", "--cookie", "", "Set cookie(s)"], + ["-H", "--headers", "", "Set custom headers"], + ["-ua", "--user-agent", "", "Set user agent"], + ["-j", "--json", "", "Output in JSON format"], + ["-v", "--version", "", "Show script version and exit"], + ["-h", "--help", "", "Show this help message and exit"] + ] + }] + + +def parse_args(): + parser = argparse.ArgumentParser(add_help=False, usage=f"{SCRIPTNAME} ") + required = parser.add_argument_group('required arguments') + required.add_argument('-u', '--url', required=True, metavar='url') + parser.add_argument('-ns', '--nmap-scan', action='store_true', default=False) + parser.add_argument('-nd', '--nmap-discover', action='store_true', default=False) + parser.add_argument('-p', '--port', default=[443], type=int, nargs='+', metavar='port') + parser.add_argument('-j', '--json', action='store', metavar='output_file', required=False, nargs='?', default=False) + parser.add_argument('-t', '--test', type=int, metavar='test_num', nargs='+') + parser.add_argument('-fc', '--fix-conf', action='store_true', default=False) + parser.add_argument('-d', '--debug', action='store_true', default=False) + parser.add_argument('-i', '--info', action='store_true', default=False) + parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {__version__}") + + if len(sys.argv) == 1 or "-h" in sys.argv or "--help" in sys.argv: + ptmisclib.help_print(get_help(), SCRIPTNAME, __version__) + sys.exit(0) + args = parser.parse_args() + ptmisclib.print_banner(SCRIPTNAME, __version__, args.json) + return args + + +def main(): + global SCRIPTNAME + SCRIPTNAME = "SSLTester" + args = parse_args() + script = SSLTester(args) + script.run() + + +if __name__ == "__main__": + main() diff --git a/scan_parameters/__init__.py b/SSLTester/src/__init__.py similarity index 100% rename from scan_parameters/__init__.py rename to SSLTester/src/__init__.py diff --git a/fix_openssl_config.py b/SSLTester/src/fix_openssl_config.py similarity index 95% rename from fix_openssl_config.py rename to SSLTester/src/fix_openssl_config.py index 8ffd5d1..7a3ca81 100755 --- a/fix_openssl_config.py +++ b/SSLTester/src/fix_openssl_config.py @@ -22,7 +22,7 @@ def fix_openssl_config(): append[1] = True if append[0] or append[1]: - correct_config_file = open('resources/correct_openssl_conf.txt', 'r') + correct_config_file = open('../../resources/correct_openssl_conf.txt', 'r') correct_config = correct_config_file.read() with open(config_file_name, 'w') as f: f.seek(0, 0) diff --git a/scan_parameters/connection/__init__.py b/SSLTester/src/scan_parameters/__init__.py similarity index 100% rename from scan_parameters/connection/__init__.py rename to SSLTester/src/scan_parameters/__init__.py diff --git a/scan_parameters/exceptions/__init__.py b/SSLTester/src/scan_parameters/connection/__init__.py similarity index 100% rename from scan_parameters/exceptions/__init__.py rename to SSLTester/src/scan_parameters/connection/__init__.py diff --git a/scan_parameters/connection/connection_utils.py b/SSLTester/src/scan_parameters/connection/connection_utils.py similarity index 99% rename from scan_parameters/connection/connection_utils.py rename to SSLTester/src/scan_parameters/connection/connection_utils.py index 3f3f586..7d981e3 100644 --- a/scan_parameters/connection/connection_utils.py +++ b/SSLTester/src/scan_parameters/connection/connection_utils.py @@ -1,15 +1,16 @@ -import ssl -import socket import logging +import socket +import ssl from OpenSSL import SSL from cryptography import x509 from cryptography.hazmat.backends import default_backend -from ..utils import convert_openssh_to_iana, incremental_sleep -from ..exceptions.UnknownConnectionError import UnknownConnectionError + from ..exceptions.ConnectionTimeoutError import ConnectionTimeoutError from ..exceptions.DNSError import DNSError -from ssl_scan.SSLv3 import SSLv3 +from ..exceptions.UnknownConnectionError import UnknownConnectionError +from ..utils import convert_openssh_to_iana, incremental_sleep +from ...ssl_scan.SSLv3 import SSLv3 def get_website_info(url: str, port: int): diff --git a/scan_parameters/exceptions/ConnectionTimeoutError.py b/SSLTester/src/scan_parameters/exceptions/ConnectionTimeoutError.py similarity index 100% rename from scan_parameters/exceptions/ConnectionTimeoutError.py rename to SSLTester/src/scan_parameters/exceptions/ConnectionTimeoutError.py diff --git a/scan_parameters/exceptions/DNSError.py b/SSLTester/src/scan_parameters/exceptions/DNSError.py similarity index 100% rename from scan_parameters/exceptions/DNSError.py rename to SSLTester/src/scan_parameters/exceptions/DNSError.py diff --git a/scan_parameters/exceptions/NoIanaPairFound.py b/SSLTester/src/scan_parameters/exceptions/NoIanaPairFound.py similarity index 100% rename from scan_parameters/exceptions/NoIanaPairFound.py rename to SSLTester/src/scan_parameters/exceptions/NoIanaPairFound.py diff --git a/scan_parameters/exceptions/UnknownConnectionError.py b/SSLTester/src/scan_parameters/exceptions/UnknownConnectionError.py similarity index 100% rename from scan_parameters/exceptions/UnknownConnectionError.py rename to SSLTester/src/scan_parameters/exceptions/UnknownConnectionError.py diff --git a/scan_parameters/non_ratable/__init__.py b/SSLTester/src/scan_parameters/exceptions/__init__.py similarity index 100% rename from scan_parameters/non_ratable/__init__.py rename to SSLTester/src/scan_parameters/exceptions/__init__.py diff --git a/scan_parameters/non_ratable/ProtocolSupport.py b/SSLTester/src/scan_parameters/non_ratable/ProtocolSupport.py similarity index 98% rename from scan_parameters/non_ratable/ProtocolSupport.py rename to SSLTester/src/scan_parameters/non_ratable/ProtocolSupport.py index 5935fff..bb8ffd2 100644 --- a/scan_parameters/non_ratable/ProtocolSupport.py +++ b/SSLTester/src/scan_parameters/non_ratable/ProtocolSupport.py @@ -4,7 +4,7 @@ from ..utils import rate_parameter from ..ratable.PType import PType from ..connection.connection_utils import create_session_pyopenssl -from ssl_scan.SSLv3 import SSLv3 +from ...ssl_scan.SSLv3 import SSLv3 class ProtocolSupport: diff --git a/scan_parameters/non_ratable/WebServerSoft.py b/SSLTester/src/scan_parameters/non_ratable/WebServerSoft.py similarity index 100% rename from scan_parameters/non_ratable/WebServerSoft.py rename to SSLTester/src/scan_parameters/non_ratable/WebServerSoft.py diff --git a/scan_parameters/ratable/__init__.py b/SSLTester/src/scan_parameters/non_ratable/__init__.py similarity index 100% rename from scan_parameters/ratable/__init__.py rename to SSLTester/src/scan_parameters/non_ratable/__init__.py diff --git a/scan_parameters/non_ratable/port_discovery.py b/SSLTester/src/scan_parameters/non_ratable/port_discovery.py similarity index 100% rename from scan_parameters/non_ratable/port_discovery.py rename to SSLTester/src/scan_parameters/non_ratable/port_discovery.py diff --git a/scan_parameters/ratable/Certificate.py b/SSLTester/src/scan_parameters/ratable/Certificate.py similarity index 100% rename from scan_parameters/ratable/Certificate.py rename to SSLTester/src/scan_parameters/ratable/Certificate.py diff --git a/scan_parameters/ratable/CipherSuite.py b/SSLTester/src/scan_parameters/ratable/CipherSuite.py similarity index 98% rename from scan_parameters/ratable/CipherSuite.py rename to SSLTester/src/scan_parameters/ratable/CipherSuite.py index f8ed081..0baf862 100644 --- a/scan_parameters/ratable/CipherSuite.py +++ b/SSLTester/src/scan_parameters/ratable/CipherSuite.py @@ -1,4 +1,4 @@ -from ..utils import read_json +from ...utils import read_json from .Parameters import Parameters from .PType import PType diff --git a/scan_parameters/ratable/PType.py b/SSLTester/src/scan_parameters/ratable/PType.py similarity index 100% rename from scan_parameters/ratable/PType.py rename to SSLTester/src/scan_parameters/ratable/PType.py diff --git a/scan_parameters/ratable/Parameters.py b/SSLTester/src/scan_parameters/ratable/Parameters.py similarity index 100% rename from scan_parameters/ratable/Parameters.py rename to SSLTester/src/scan_parameters/ratable/Parameters.py diff --git a/scan_vulnerabilities/__init__.py b/SSLTester/src/scan_parameters/ratable/__init__.py similarity index 100% rename from scan_vulnerabilities/__init__.py rename to SSLTester/src/scan_parameters/ratable/__init__.py diff --git a/scan_parameters/utils.py b/SSLTester/src/scan_parameters/utils.py similarity index 92% rename from scan_parameters/utils.py rename to SSLTester/src/scan_parameters/utils.py index 3e83d03..162880d 100644 --- a/scan_parameters/utils.py +++ b/SSLTester/src/scan_parameters/utils.py @@ -8,6 +8,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa, dsa, ec, ed25519, ed448 from .exceptions.NoIanaPairFound import NoIanaPairFound from .ratable.PType import PType +from ..utils import read_json def convert_openssh_to_iana(search_term: str): @@ -25,20 +26,6 @@ def convert_openssh_to_iana(search_term: str): raise NoIanaPairFound() -def read_json(file_name: str): - """ - Read a json file and return its content. - - :param file_name: json file name - :return: json data in python objects - """ - root_dir = os.path.dirname(os.path.abspath(__file__)) - file = open(f'{root_dir}/../resources/{file_name}', 'r') - json_data = json.loads(file.read()) - file.close() - return json_data - - def rate_key_length_parameter(algorithm_type: PType, key_len: str, key_len_type: PType): """ Get the rating of an algorithm key length. diff --git a/scan_vulnerabilities/tests/__init__.py b/SSLTester/src/scan_vulnerabilities/__init__.py similarity index 100% rename from scan_vulnerabilities/tests/__init__.py rename to SSLTester/src/scan_vulnerabilities/__init__.py diff --git a/scan_vulnerabilities/multitheard_scan.py b/SSLTester/src/scan_vulnerabilities/multitheard_scan.py similarity index 100% rename from scan_vulnerabilities/multitheard_scan.py rename to SSLTester/src/scan_vulnerabilities/multitheard_scan.py diff --git a/text_output/__init__.py b/SSLTester/src/scan_vulnerabilities/tests/__init__.py similarity index 100% rename from text_output/__init__.py rename to SSLTester/src/scan_vulnerabilities/tests/__init__.py diff --git a/scan_vulnerabilities/tests/ccs_injection.py b/SSLTester/src/scan_vulnerabilities/tests/ccs_injection.py similarity index 100% rename from scan_vulnerabilities/tests/ccs_injection.py rename to SSLTester/src/scan_vulnerabilities/tests/ccs_injection.py diff --git a/scan_vulnerabilities/tests/crime.py b/SSLTester/src/scan_vulnerabilities/tests/crime.py similarity index 100% rename from scan_vulnerabilities/tests/crime.py rename to SSLTester/src/scan_vulnerabilities/tests/crime.py diff --git a/scan_vulnerabilities/tests/heartbleed.py b/SSLTester/src/scan_vulnerabilities/tests/heartbleed.py similarity index 100% rename from scan_vulnerabilities/tests/heartbleed.py rename to SSLTester/src/scan_vulnerabilities/tests/heartbleed.py diff --git a/scan_vulnerabilities/tests/insec_renegotiation.py b/SSLTester/src/scan_vulnerabilities/tests/insec_renegotiation.py similarity index 100% rename from scan_vulnerabilities/tests/insec_renegotiation.py rename to SSLTester/src/scan_vulnerabilities/tests/insec_renegotiation.py diff --git a/scan_vulnerabilities/tests/poodle.py b/SSLTester/src/scan_vulnerabilities/tests/poodle.py similarity index 100% rename from scan_vulnerabilities/tests/poodle.py rename to SSLTester/src/scan_vulnerabilities/tests/poodle.py diff --git a/scan_vulnerabilities/tests/rc4_support.py b/SSLTester/src/scan_vulnerabilities/tests/rc4_support.py similarity index 100% rename from scan_vulnerabilities/tests/rc4_support.py rename to SSLTester/src/scan_vulnerabilities/tests/rc4_support.py diff --git a/scan_vulnerabilities/tests/session_ticket.py b/SSLTester/src/scan_vulnerabilities/tests/session_ticket.py similarity index 100% rename from scan_vulnerabilities/tests/session_ticket.py rename to SSLTester/src/scan_vulnerabilities/tests/session_ticket.py diff --git a/scan_vulnerabilities/utils.py b/SSLTester/src/scan_vulnerabilities/utils.py similarity index 100% rename from scan_vulnerabilities/utils.py rename to SSLTester/src/scan_vulnerabilities/utils.py diff --git a/ssl_scan/SSLv3.py b/SSLTester/src/ssl_scan/SSLv3.py similarity index 97% rename from ssl_scan/SSLv3.py rename to SSLTester/src/ssl_scan/SSLv3.py index 6fb9c92..359bab3 100644 --- a/ssl_scan/SSLv3.py +++ b/SSLTester/src/ssl_scan/SSLv3.py @@ -1,8 +1,5 @@ from .utils import read_json, hex_to_int - -from OpenSSL.crypto import X509 -from OpenSSL.crypto import verify -from scan_vulnerabilities.utils import * +from ..scan_vulnerabilities.utils import send_client_hello from cryptography.x509 import load_der_x509_certificate diff --git a/SSLTester/src/ssl_scan/__init__.py b/SSLTester/src/ssl_scan/__init__.py new file mode 100644 index 0000000..4b681b1 --- /dev/null +++ b/SSLTester/src/ssl_scan/__init__.py @@ -0,0 +1,2 @@ +# http://ssllib.sourceforge.net/SSLv2.spec.html +# https://forum.nginx.org/read.php?2,104032,104152 diff --git a/ssl_scan/utils.py b/SSLTester/src/ssl_scan/utils.py similarity index 100% rename from ssl_scan/utils.py rename to SSLTester/src/ssl_scan/utils.py diff --git a/ssltest.py b/SSLTester/src/start_script.py similarity index 85% rename from ssltest.py rename to SSLTester/src/start_script.py index 2be4847..a84238d 100755 --- a/ssltest.py +++ b/SSLTester/src/start_script.py @@ -1,26 +1,23 @@ -#!/usr/bin/python3 - import argparse, sys, logging, json, textwrap, traceback, os -from scan_vulnerabilities.tests import heartbleed -from scan_vulnerabilities.tests import ccs_injection -from scan_vulnerabilities.tests import insec_renegotiation as rene -from scan_vulnerabilities.tests import poodle -from scan_vulnerabilities.tests import session_ticket -from scan_vulnerabilities.tests import crime -from scan_vulnerabilities.tests import rc4_support -from ssl_scan.SSLv3 import SSLv3 -from scan_parameters.ratable.CipherSuite import CipherSuite -from scan_parameters.ratable.Certificate import Certificate -from scan_parameters.non_ratable.ProtocolSupport import ProtocolSupport -from scan_parameters.non_ratable.WebServerSoft import WebServerSoft -from scan_parameters.connection.connection_utils import get_website_info -from scan_parameters.non_ratable.port_discovery import discover_ports -from scan_parameters.ratable.PType import PType -from scan_parameters.utils import fix_url -from text_output.TextOutput import TextOutput -from scan_vulnerabilities.multitheard_scan import scan_vulnerabilities -from fix_openssl_config import fix_openssl_config +from .scan_vulnerabilities.tests import heartbleed +from .scan_vulnerabilities.tests import ccs_injection +from .scan_vulnerabilities.tests import insec_renegotiation as rene +from .scan_vulnerabilities.tests import poodle +from .scan_vulnerabilities.tests import session_ticket +from .scan_vulnerabilities.tests import crime +from .scan_vulnerabilities.tests import rc4_support +from .scan_parameters.ratable.CipherSuite import CipherSuite +from .scan_parameters.ratable.Certificate import Certificate +from .scan_parameters.non_ratable.ProtocolSupport import ProtocolSupport +from .scan_parameters.non_ratable.WebServerSoft import WebServerSoft +from .scan_parameters.connection.connection_utils import get_website_info +from .scan_parameters.non_ratable.port_discovery import discover_ports +from .scan_parameters.ratable.PType import PType +from .scan_parameters.utils import fix_url +from .text_output.TextOutput import TextOutput +from .scan_vulnerabilities.multitheard_scan import scan_vulnerabilities +from .fix_openssl_config import fix_openssl_config tests_switcher = { 1: (heartbleed.scan, 'Heartbleed'), @@ -33,8 +30,8 @@ } -def tls_test(program_args): - args = parse_options(program_args) +def tls_test(args): + # args = parse_options(program_args) fix_conf_option(args) if '/' in args.url: args.url = fix_url(args.url) @@ -142,16 +139,15 @@ def info_report_option(args): :param args: input options """ - if args.verbose: + if args.debug: logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) - elif args.information: + elif args.info: logging.basicConfig(stream=sys.stderr, level=logging.INFO) def parse_options(program_args): """ Parse input options. - :return: object of parsed arguments """ tests_help = 'test the server for a specified vulnerability\n' \ @@ -196,30 +192,28 @@ def parse_options(program_args): parser.add_argument('-v', '--verbose', action='store_true', default=False, help='output more information') args = parser.parse_args(program_args) - check_test_numbers(args.test, parser.usage) return args -def check_test_numbers(tests, usage): +def check_test_numbers(tests): """ Check if the tests numbers are actually tests - + :param tests: test argument - :param usage: usage string - :return: + :param print_usage: usage string + :return: """ if not tests or 0 in tests: return test_numbers = [test for test in tests_switcher.keys()] unknown_tests = list(filter(lambda test: test not in test_numbers, tests)) if unknown_tests: - print(f'usage: {usage}') if len(unknown_tests) > 1: unknown_tests = list(map(str, unknown_tests)) print(f'Numbers {", ".join(unknown_tests)} are not test numbers.', file=sys.stderr) else: print(f'Number {unknown_tests[0]} is not a test number.', file=sys.stderr) - exit(1) + sys.exit(1) def scan(args, port: int): @@ -262,6 +256,7 @@ def scan(args, port: int): port, args.url) -if __name__ == "__main__": - out = tls_test(sys.argv[1:]) +def start(args): + check_test_numbers(args.test) + out = tls_test(args) if out: print(out) diff --git a/text_output/TextOutput.py b/SSLTester/src/text_output/TextOutput.py similarity index 99% rename from text_output/TextOutput.py rename to SSLTester/src/text_output/TextOutput.py index 0260362..33e5dcf 100644 --- a/text_output/TextOutput.py +++ b/SSLTester/src/text_output/TextOutput.py @@ -1,6 +1,6 @@ import json +from ..utils import read_json -from scan_parameters.utils import read_json class TextOutput: diff --git a/SSLTester/src/text_output/__init__.py b/SSLTester/src/text_output/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/SSLTester/src/utils.py b/SSLTester/src/utils.py new file mode 100644 index 0000000..136e3f2 --- /dev/null +++ b/SSLTester/src/utils.py @@ -0,0 +1,15 @@ +import os, json + + +def read_json(file_name: str): + """ + Read a json file and return its content. + + :param file_name: json file name + :return: json data in python objects + """ + root_dir = os.path.dirname(os.path.abspath(__file__)) + file = open(f'{root_dir}/../../resources/{file_name}', 'r') + json_data = json.loads(file.read()) + file.close() + return json_data diff --git a/libs/ptlibs/ptlibs/__init__.py b/libs/ptlibs/ptlibs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/libs/ptlibs/ptlibs/ptdefs.py b/libs/ptlibs/ptlibs/ptdefs.py new file mode 100644 index 0000000..feebb53 --- /dev/null +++ b/libs/ptlibs/ptlibs/ptdefs.py @@ -0,0 +1,31 @@ +from __future__ import unicode_literals + +# Colors definitions +colors = { + "OK": "\033[92m", + "INFO": "\033[93m", + "ERROR": "\033[31m", + "TITLE": "\033[93m", + "TEXT": "\033[0m", + "VULN": "\033[31m", + "NOTVULN": "\033[92m", + "REDIR": "\033[0m", + "PARSED": "\033[0m", + "TITNOBULL": "\033[93m", + "ADDITIONS": "\033[90m" +} + +# Chars definitions +chars = { + "OK": "\u2713", + "INFO": "\u2139", + "ERROR": "\u2717", + "TITLE": "\u2BA1", + "TEXT": "", + "VULN": "\u2717", + "NOTVULN": "\u2713", + "REDIR": "\u2794", + "PARSED": "\u26AD", + "TITNOBULL": "", + "ADDITIONS": "" +} \ No newline at end of file diff --git a/libs/ptlibs/ptlibs/ptjsonlib.py b/libs/ptlibs/ptlibs/ptjsonlib.py new file mode 100644 index 0000000..50be4bb --- /dev/null +++ b/libs/ptlibs/ptlibs/ptjsonlib.py @@ -0,0 +1,65 @@ +import json + + +class ptjsonlib: + def __init__(self, json): + self.json = json + self.json_list = [] + + def add_json(self, name): + if self.json: + json_template = {"test_code": name, "status": "null", "vulnerable": "null", "data": {}} + self.json_list.append(json_template) + return len(self.json_list) - 1 + else: + pass + + def del_json(self, position): + if self.json: + self.json_list.pop(position) + else: + pass + + def add_data(self, position, data): + if self.json: + self.json_list[position]['data'].update(data) + else: + pass + + def set_testcode(self, position, testcode): + if self.json: + self.json_list[position].update({"testcode": testcode}) + else: + pass + + def set_status(self, position, status, errormessage=""): + if self.json: + self.json_list[position].update({"status": status}) + if status == "error": + self.json_list[position].update({"message": errormessage}) + else: + pass + + def set_vulnerable(self, position, vulnerable): + if self.json: + self.json_list[position].update({"vulnerable": vulnerable}) + else: + pass + + def get_json(self, position): + if self.json: + return json.dumps(self.json_list[position]) + else: + pass + + def get_all_json(self): + if self.json: + return json.dumps(self.json_list) + else: + pass + + def get_status(self, position): + if self.json: + return self.json_list[position]["status"] + else: + pass diff --git a/libs/ptlibs/ptlibs/ptmisclib.py b/libs/ptlibs/ptlibs/ptmisclib.py new file mode 100644 index 0000000..b9592b7 --- /dev/null +++ b/libs/ptlibs/ptlibs/ptmisclib.py @@ -0,0 +1,282 @@ +import itertools +import datetime +import socket +import signal +import sys +import string +import requests +import re + +import ptlibs.ptdefs as ptdefs + +try: + import fcntl, termios, struct +except: + pass + + +strip_ANSI_escape_sequences_sub = re.compile(r""" + \x1b # literal ESC + \[ # literal [ + [;\d]* # zero or more digits or semicolons + [A-Za-z] # a letter + """, re.VERBOSE).sub + +def print_banner(scriptname, version, condition=None, space=1): + if not condition: + print(rf""" + ____ _ _____ _ +| _ \ ___ _ __ | |_ ___ _ __ ___ _ __ |_ _|__ ___ | |___ +| |_) / _ \ '_ \| __/ _ \ '__/ _ \ '_ \ | |/ _ \ / _ \| / __| +| __/ __/ | | | || __/ | | __/ |_) | | | (_) | (_) | \__ \ +|_| \___|_| |_|\__\___|_| \___| .__/ |_|\___/ \___/|_|___/ + |_|{" "*(26-len(scriptname+version)-1)}{scriptname} v{version} + https://www.penterep.com""") + print("\n"*space) + + +def help_calc_column_width(lines): + if isinstance(lines[0], list): + max_cols_len = [0 for x in range(10)] + for row in lines: + for index, column in enumerate(row): + x = len(column) + if (x > max_cols_len[index]) and not index+1 == len(row): + max_cols_len[index] = x + return max_cols_len + + +def help_print(help_object, scriptname, version): + """construct & print help message""" + print_banner(scriptname, version) + for help_item in help_object: + print( out_title(f"{list(help_item.keys())[0].capitalize().replace('_', ' ')}:", show_bullet=False)) + lines = list(help_item.values())[0] + cols_width = help_calc_column_width(lines) + for line in lines: + if isinstance(line, list): + for index, column in enumerate(line): + if not index: + print(" ", end="") + print(column, end=(cols_width[index]-len(column)+2)*' ') + print("") + else: + print(f" {line}") + print("") + + +def check_argv(argv, help_object): + if len(argv) == 1: + print_help(help_object) + sys.exit(1) + for arg in argv[1:]: + if arg == "-h" or arg == "--help": + print_help(help_object) + subproces.kill() + sys.exit(0) + + +def signal_handler(sig, frame): + ptprint(f"\r", clear_to_eol=True) + ptprint( out_if(f"{ptdefs.colors['ERROR']}Script terminated{ptdefs.colors['TEXT']}", "ERROR"), clear_to_eol=True) + sys.exit(0) +signal.signal(signal.SIGINT, signal_handler) + + +def check_connectivity(proxies=[]): + try: + requests.request("GET", "https://www.google.com", proxies=proxies, verify=False, allow_redirects=False) + except: + print() + ptprint( out_if(f"{ptdefs.colors['ERROR']}Missing net connectivity{ptdefs.colors['TEXT']}", "ERROR")) + sys.exit(0) + +def check_url_availability(url, proxies=[]): + try: + requests.request("GET", url, proxies=proxies, verify=False, allow_redirects=False) + except Exception as e: + print() + ptprint( out_if(f"{ptdefs.colors['ERROR']}URL is not available: {e}{ptdefs.colors['TEXT']}", "ERROR")) + sys.exit(0) + +def bullet(bullet_type=None): + if bullet_type and ptdefs.chars[bullet_type]: + return f"{ptdefs.colors[bullet_type]}[{ptdefs.chars[bullet_type]}]{ptdefs.colors['TEXT']} " + else: + return "" + + +def out_if(string="", bullet_type=None, condition=True, colortext=False): + if condition: + if colortext: + return f"{bullet(bullet_type)}{ptdefs.colors[bullet_type]}{string}{ptdefs.colors['TEXT']}" + else: + return f"{bullet(bullet_type)}{string}" + + +def out_ifnot(string="", bullet_type=None, condition=False, colortext=False): + if not condition: + if colortext: + return f"{bullet(bullet_type)}{ptdefs.colors[bullet_type]}{string}{ptdefs.colors['TEXT']}" + else: + return f"{bullet(bullet_type)}{string}" + else: + return "" + + +def out_title(string, show_bullet=True): + if show_bullet: + return f"{bullet('TITLE')}{ptdefs.colors['TITLE']}{string}{ptdefs.colors['TEXT']}" + else: + return f"{ptdefs.colors['TITLE']}{string}{ptdefs.colors['TEXT']}" + + +def out_title_if(string="", condition=True, show_bullet=True): + if condition: + return out_title(string, show_bullet) + else: + return "" + + +def out_title_ifnot(string="", condition=False, show_bullet=True): + if not condition: + return out_title(string, show_bullet) + else: + return "" + +def ptprint(string, end="\n", flush=False, clear_to_eol=False): + if string: + if clear_to_eol: + string = string + (' ' * (terminal_width() - len_string_without_colors(string))) + print(string, end=end, flush=flush) + +def get_colored_text(string, color): + return f"{ptdefs.colors[color]}{string}{ptdefs.colors['TEXT']}" + + +def clear_line(end="\n"): + print(' '*terminal_width(), end=end) + + +def clear_line_ifnot(end="\n", condition=True): + if condition: + clear_line(end) + + +def clear_line_ifnot(end="\n", condition=False): + if not condition: + clear_line(end) + +def len_string_without_colors(string): + return len(strip_ANSI_escape_sequences_sub("", string)) + +def add_spaces_to_eon(string, minus=0): + return string + (' ' * (terminal_width() - len_string_without_colors(string) - minus)) + + +def end_error(message, json_no, json_object, condition): + ptprint( out_ifnot(f"Error: {message}", "ERROR", condition) ) + json_object.set_status(json_no, "error", message) + ptprint( out_if(json_object.get_all_json(), None, condition) ) + sys.exit(1) + + +def read_file(file): + with open(file, "r") as f: + domain_list = [line.strip("\n") for line in f] + return domain_list + + +def get_request_headers(args): + request_headers = {} + if args.user_agent: + request_headers.update({"User-Agent": args.user_agent}) + if args.cookie: + request_headers.update({"Cookie": '; '.join(args.cookie)}) + if args.headers: + for header in args.headers: + request_headers.update({header.split(":")[0]: header.split(":")[1]}) + return request_headers + + +def pairs(pair): + if len(pair.split(":")) == 2: + return pair + else: + raise ValueError() + + +def get_combinations(charset, min, max): + pool = tuple(charset) + n = len(pool) + for len_str in range (min, max+1): + for indices in itertools.product(range(n), repeat=len_str): + yield "".join(tuple(pool[i] for i in indices)) + + +def get_keyspace(charset, len_min, len_max, multiple=1): + c = len(charset) + keyspace = 0 + for l in range(len_min, len_max + 1): + keyspace += c ** l + return keyspace * multiple + + +def get_wordlist(file_handler, begin_with=""): + while True: + data = file_handler.readline().strip() + if not data: + break + if data.startswith(begin_with): + yield data + +def get_charset(charsets): + result = [] + for i in charsets: + if i == "lowercase": + result += [char for char in string.ascii_lowercase] + elif i == "uppercase": + result += [char for char in string.ascii_uppercase] + elif i == "numbers": + result += [char for char in string.digits] + elif i == "specials": + result += [char for char in "!#$%&'()@^`{}"] + else: + result += [char for char in i if char not in result] + return result + +def add_slash_to_end_url(url): + if url.find("*") == -1 and not url.endswith("/"): + return url+"/" + else: + return url + +def remove_slash_from_end_url(url): + if url.find("*") == -1 and url.endswith("/"): + return url[:-1] + else: + return url + +def terminal_size(): + #import fcntl, termios, struct + th, tw, hp, wp = struct.unpack('HHHH', + fcntl.ioctl(0, termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) + return tw, th + +def terminal_width(): + #import fcntl, termios, struct + th, tw, hp, wp = struct.unpack('HHHH', + fcntl.ioctl(0, termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) + return tw + +def terminal_height(): + #import fcntl, termios, struct + th, tw, hp, wp = struct.unpack('HHHH', + fcntl.ioctl(0, termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) + return th + +def time2str(time): + return str(str(datetime.timedelta(seconds=time))).split(".")[0] \ No newline at end of file diff --git a/libs/ptlibs/ptlibs/ptthreads.py b/libs/ptlibs/ptlibs/ptthreads.py new file mode 100644 index 0000000..336a66b --- /dev/null +++ b/libs/ptlibs/ptlibs/ptthreads.py @@ -0,0 +1,80 @@ +import threading +import time + +import ptlibs.ptmisclib as ptmisclib + +class ptthreads: + def __init__(self): + self.threads_list = [] + self.free_threads = [] + self.returns = [] + self.lock = threading.Lock() + + def threads(self, items, function, threads): + self.free_threads.clear() + self.threads_list.clear() + self.returns.clear() + for i in range(threads): + self.free_threads.append(i) + self.threads_list.append("") + while items: + if not type(items) == list: + try: + item = next(items).strip() + except: + break + else: + item = items[0] + items.remove(item) + thread_no = self.free_threads.pop() + self.threads_list[thread_no] = threading.Thread( + target = self.wrapper_worker, + args = (item, function, thread_no), + daemon=False + ) + result = self.threads_list[thread_no].start() + while not self.free_threads: + time.sleep(0.01) + while not items: + time.sleep(0.01) + if len(self.free_threads) == threads and not items: + return self.returns + for thread in self.threads_list: + if thread: + thread.join() + + def wrapper_worker(self, item, function, thread_no): + self.returns.append(function(item)) + self.free_threads.append(thread_no) + + +class printlock: + def __init__(self): + self.output_string = "" + self.lock = threading.Lock() + + def add_string_to_output(self, string="", condition=True, end="\n", silent=False, trim=False): + if condition and not silent: + if trim: + string = string.strip() + if string: + self.output_string += string + end + + def get_output_string(self): + return self.output_string + + def print_output(self, condition=True, end="\n", flush=True): + if condition and not silent: + print(self.output_string, end=end, flush=flush) + + def lock_print_output(self, condition=True, end="\n", flush=True): + if condition: + self.lock.acquire() + ptmisclib.ptprint(self.output_string, end=end, flush=flush) + self.lock.release() + + def lock_print(self, string, condition=True, end="\n", flush=True, clear_to_eol=False): + if condition: + self.lock.acquire() + ptmisclib.ptprint(string, end=end, flush=flush, clear_to_eol=clear_to_eol) + self.lock.release() \ No newline at end of file diff --git a/libs/ptlibs/setup.py b/libs/ptlibs/setup.py new file mode 100644 index 0000000..d9b1a4f --- /dev/null +++ b/libs/ptlibs/setup.py @@ -0,0 +1,18 @@ +import setuptools + +setuptools.setup( + name="ptlibs", + description="ptlibs", + version="0.0.1", + author="Penterep", + author_email="d.kummel@penterep.com", + url="https://www.penterep.com/", + licence="GPLv3", + packages=setuptools.find_packages(), + classifiers=[ + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python :: 3.6", + "Environment :: Console" + ], + python_requires = '>=3.6', +) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bb97a29 --- /dev/null +++ b/setup.py @@ -0,0 +1,21 @@ +import setuptools + +setuptools.setup( + name="SSLTester", + description="", + version="0.0.1", + author="Penterep", + author_email="", + url="https://www.penterep.com/", + licence="GPLv3", + packages=setuptools.find_packages(), + classifiers=[ + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python :: 3.6", + "Environment :: Console" + ], + python_requires='>=3.6', + install_requires=["ptlibs", ""], + entry_points={'console_scripts': ['scriptname = SSLTester.SSLTester:main']}, + include_package_data=True +) diff --git a/ssl_scan/__init__.py b/ssl_scan/__init__.py deleted file mode 100644 index 21db5e1..0000000 --- a/ssl_scan/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# http://ssllib.sourceforge.net/SSLv2.spec.html From f39304851f57aace2ef45ae19529ca02d52b1226 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Wed, 4 Aug 2021 12:21:29 +0200 Subject: [PATCH 02/16] Change name to SSLTest --- .gitignore | 4 ++-- README.MD | 6 +++--- SSLTester/SSLTest.py | 12 ++++++------ setup.py | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index e94c761..bae96f4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ share/python-wheels/ MANIFEST # PyInstaller -# Usually these files are written by a python script from a SSLTester +# Usually these files are written by a python script from a SSLTest # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec @@ -131,5 +131,5 @@ dmypy.json # Pycharm .idea/ -SSLTester/output.json +SSLTest/output.json logs/ \ No newline at end of file diff --git a/README.MD b/README.MD index e474e63..612ec0c 100644 --- a/README.MD +++ b/README.MD @@ -12,14 +12,14 @@ ## Installation ``` -$ git clone SSLTester -$ cd SSLTester && sudo pip install . +$ git clone SSLTest +$ cd SSLTest && sudo pip install . ``` ## Installation (ptmanager) ``` -$ sudo ptmanager -ut SSLTester +$ sudo ptmanager -ut SSLTest ``` ## Options diff --git a/SSLTester/SSLTest.py b/SSLTester/SSLTest.py index 66471ea..d78d438 100755 --- a/SSLTester/SSLTest.py +++ b/SSLTester/SSLTest.py @@ -9,11 +9,11 @@ from src.start_script import start -class SSLTester: +class SSLTest: def __init__(self, args): self.args = args self.ptjsonlib = ptjsonlib.ptjsonlib(self.args.json) - self.json_no = self.ptjsonlib.add_json("SSLTester") + self.json_no = self.ptjsonlib.add_json("SSLTest") self.use_json = self.args.json def run(self): @@ -25,11 +25,11 @@ def get_help(): return [ {"description": ["Script that scans a webservers cryptographic parameters and vulnerabilities"]}, {"usage": [ - "SSLTester.py -u url <-h> <-ns> <-nd> <-p port > <-j > <-t test_num >" + "SSLTest.py -u url <-h> <-ns> <-nd> <-p port > <-j > <-t test_num >" " <-fc> <-i> <-v>" ]}, {"usage_example": [ - "SSLTester.py -u github.com -t 1 2", + "SSLTest.py -u github.com -t 1 2", ]}, {"options": [ ["-u", "--url", "", "Url to scan, required option"], @@ -68,9 +68,9 @@ def parse_args(): def main(): global SCRIPTNAME - SCRIPTNAME = "SSLTester" + SCRIPTNAME = "SSLTest" args = parse_args() - script = SSLTester(args) + script = SSLTest(args) script.run() diff --git a/setup.py b/setup.py index bb97a29..0e6e82f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ import setuptools setuptools.setup( - name="SSLTester", + name="SSLTest", description="", version="0.0.1", author="Penterep", @@ -16,6 +16,6 @@ ], python_requires='>=3.6', install_requires=["ptlibs", ""], - entry_points={'console_scripts': ['scriptname = SSLTester.SSLTester:main']}, + entry_points={'console_scripts': ['scriptname = SSLTest.SSLTest:main']}, include_package_data=True ) From 3333c2eb2ca1fae484322814ff2794bfe2b2a86c Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Wed, 4 Aug 2021 12:22:47 +0200 Subject: [PATCH 03/16] Rename folder --- {SSLTester => SSLTest}/SSLTest.py | 0 {SSLTester => SSLTest}/src/__init__.py | 0 {SSLTester => SSLTest}/src/fix_openssl_config.py | 0 {SSLTester => SSLTest}/src/scan_parameters/__init__.py | 0 {SSLTester => SSLTest}/src/scan_parameters/connection/__init__.py | 0 .../src/scan_parameters/connection/connection_utils.py | 0 .../src/scan_parameters/exceptions/ConnectionTimeoutError.py | 0 {SSLTester => SSLTest}/src/scan_parameters/exceptions/DNSError.py | 0 .../src/scan_parameters/exceptions/NoIanaPairFound.py | 0 .../src/scan_parameters/exceptions/UnknownConnectionError.py | 0 {SSLTester => SSLTest}/src/scan_parameters/exceptions/__init__.py | 0 .../src/scan_parameters/non_ratable/ProtocolSupport.py | 0 .../src/scan_parameters/non_ratable/WebServerSoft.py | 0 .../src/scan_parameters/non_ratable/__init__.py | 0 .../src/scan_parameters/non_ratable/port_discovery.py | 0 {SSLTester => SSLTest}/src/scan_parameters/ratable/Certificate.py | 0 {SSLTester => SSLTest}/src/scan_parameters/ratable/CipherSuite.py | 0 {SSLTester => SSLTest}/src/scan_parameters/ratable/PType.py | 0 {SSLTester => SSLTest}/src/scan_parameters/ratable/Parameters.py | 0 {SSLTester => SSLTest}/src/scan_parameters/ratable/__init__.py | 0 {SSLTester => SSLTest}/src/scan_parameters/utils.py | 0 {SSLTester => SSLTest}/src/scan_vulnerabilities/__init__.py | 0 .../src/scan_vulnerabilities/multitheard_scan.py | 0 {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/__init__.py | 0 .../src/scan_vulnerabilities/tests/ccs_injection.py | 0 {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/crime.py | 0 .../src/scan_vulnerabilities/tests/heartbleed.py | 0 .../src/scan_vulnerabilities/tests/insec_renegotiation.py | 0 {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/poodle.py | 0 .../src/scan_vulnerabilities/tests/rc4_support.py | 0 .../src/scan_vulnerabilities/tests/session_ticket.py | 0 {SSLTester => SSLTest}/src/scan_vulnerabilities/utils.py | 0 {SSLTester => SSLTest}/src/ssl_scan/SSLv3.py | 0 {SSLTester => SSLTest}/src/ssl_scan/__init__.py | 0 {SSLTester => SSLTest}/src/ssl_scan/utils.py | 0 {SSLTester => SSLTest}/src/start_script.py | 0 {SSLTester => SSLTest}/src/text_output/TextOutput.py | 0 {SSLTester => SSLTest}/src/text_output/__init__.py | 0 {SSLTester => SSLTest}/src/utils.py | 0 39 files changed, 0 insertions(+), 0 deletions(-) rename {SSLTester => SSLTest}/SSLTest.py (100%) rename {SSLTester => SSLTest}/src/__init__.py (100%) rename {SSLTester => SSLTest}/src/fix_openssl_config.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/connection/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/connection/connection_utils.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/exceptions/ConnectionTimeoutError.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/exceptions/DNSError.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/exceptions/NoIanaPairFound.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/exceptions/UnknownConnectionError.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/exceptions/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/non_ratable/ProtocolSupport.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/non_ratable/WebServerSoft.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/non_ratable/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/non_ratable/port_discovery.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/ratable/Certificate.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/ratable/CipherSuite.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/ratable/PType.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/ratable/Parameters.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/ratable/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_parameters/utils.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/multitheard_scan.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/__init__.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/ccs_injection.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/crime.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/heartbleed.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/insec_renegotiation.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/poodle.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/rc4_support.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/tests/session_ticket.py (100%) rename {SSLTester => SSLTest}/src/scan_vulnerabilities/utils.py (100%) rename {SSLTester => SSLTest}/src/ssl_scan/SSLv3.py (100%) rename {SSLTester => SSLTest}/src/ssl_scan/__init__.py (100%) rename {SSLTester => SSLTest}/src/ssl_scan/utils.py (100%) rename {SSLTester => SSLTest}/src/start_script.py (100%) rename {SSLTester => SSLTest}/src/text_output/TextOutput.py (100%) rename {SSLTester => SSLTest}/src/text_output/__init__.py (100%) rename {SSLTester => SSLTest}/src/utils.py (100%) diff --git a/SSLTester/SSLTest.py b/SSLTest/SSLTest.py similarity index 100% rename from SSLTester/SSLTest.py rename to SSLTest/SSLTest.py diff --git a/SSLTester/src/__init__.py b/SSLTest/src/__init__.py similarity index 100% rename from SSLTester/src/__init__.py rename to SSLTest/src/__init__.py diff --git a/SSLTester/src/fix_openssl_config.py b/SSLTest/src/fix_openssl_config.py similarity index 100% rename from SSLTester/src/fix_openssl_config.py rename to SSLTest/src/fix_openssl_config.py diff --git a/SSLTester/src/scan_parameters/__init__.py b/SSLTest/src/scan_parameters/__init__.py similarity index 100% rename from SSLTester/src/scan_parameters/__init__.py rename to SSLTest/src/scan_parameters/__init__.py diff --git a/SSLTester/src/scan_parameters/connection/__init__.py b/SSLTest/src/scan_parameters/connection/__init__.py similarity index 100% rename from SSLTester/src/scan_parameters/connection/__init__.py rename to SSLTest/src/scan_parameters/connection/__init__.py diff --git a/SSLTester/src/scan_parameters/connection/connection_utils.py b/SSLTest/src/scan_parameters/connection/connection_utils.py similarity index 100% rename from SSLTester/src/scan_parameters/connection/connection_utils.py rename to SSLTest/src/scan_parameters/connection/connection_utils.py diff --git a/SSLTester/src/scan_parameters/exceptions/ConnectionTimeoutError.py b/SSLTest/src/scan_parameters/exceptions/ConnectionTimeoutError.py similarity index 100% rename from SSLTester/src/scan_parameters/exceptions/ConnectionTimeoutError.py rename to SSLTest/src/scan_parameters/exceptions/ConnectionTimeoutError.py diff --git a/SSLTester/src/scan_parameters/exceptions/DNSError.py b/SSLTest/src/scan_parameters/exceptions/DNSError.py similarity index 100% rename from SSLTester/src/scan_parameters/exceptions/DNSError.py rename to SSLTest/src/scan_parameters/exceptions/DNSError.py diff --git a/SSLTester/src/scan_parameters/exceptions/NoIanaPairFound.py b/SSLTest/src/scan_parameters/exceptions/NoIanaPairFound.py similarity index 100% rename from SSLTester/src/scan_parameters/exceptions/NoIanaPairFound.py rename to SSLTest/src/scan_parameters/exceptions/NoIanaPairFound.py diff --git a/SSLTester/src/scan_parameters/exceptions/UnknownConnectionError.py b/SSLTest/src/scan_parameters/exceptions/UnknownConnectionError.py similarity index 100% rename from SSLTester/src/scan_parameters/exceptions/UnknownConnectionError.py rename to SSLTest/src/scan_parameters/exceptions/UnknownConnectionError.py diff --git a/SSLTester/src/scan_parameters/exceptions/__init__.py b/SSLTest/src/scan_parameters/exceptions/__init__.py similarity index 100% rename from SSLTester/src/scan_parameters/exceptions/__init__.py rename to SSLTest/src/scan_parameters/exceptions/__init__.py diff --git a/SSLTester/src/scan_parameters/non_ratable/ProtocolSupport.py b/SSLTest/src/scan_parameters/non_ratable/ProtocolSupport.py similarity index 100% rename from SSLTester/src/scan_parameters/non_ratable/ProtocolSupport.py rename to SSLTest/src/scan_parameters/non_ratable/ProtocolSupport.py diff --git a/SSLTester/src/scan_parameters/non_ratable/WebServerSoft.py b/SSLTest/src/scan_parameters/non_ratable/WebServerSoft.py similarity index 100% rename from SSLTester/src/scan_parameters/non_ratable/WebServerSoft.py rename to SSLTest/src/scan_parameters/non_ratable/WebServerSoft.py diff --git a/SSLTester/src/scan_parameters/non_ratable/__init__.py b/SSLTest/src/scan_parameters/non_ratable/__init__.py similarity index 100% rename from SSLTester/src/scan_parameters/non_ratable/__init__.py rename to SSLTest/src/scan_parameters/non_ratable/__init__.py diff --git a/SSLTester/src/scan_parameters/non_ratable/port_discovery.py b/SSLTest/src/scan_parameters/non_ratable/port_discovery.py similarity index 100% rename from SSLTester/src/scan_parameters/non_ratable/port_discovery.py rename to SSLTest/src/scan_parameters/non_ratable/port_discovery.py diff --git a/SSLTester/src/scan_parameters/ratable/Certificate.py b/SSLTest/src/scan_parameters/ratable/Certificate.py similarity index 100% rename from SSLTester/src/scan_parameters/ratable/Certificate.py rename to SSLTest/src/scan_parameters/ratable/Certificate.py diff --git a/SSLTester/src/scan_parameters/ratable/CipherSuite.py b/SSLTest/src/scan_parameters/ratable/CipherSuite.py similarity index 100% rename from SSLTester/src/scan_parameters/ratable/CipherSuite.py rename to SSLTest/src/scan_parameters/ratable/CipherSuite.py diff --git a/SSLTester/src/scan_parameters/ratable/PType.py b/SSLTest/src/scan_parameters/ratable/PType.py similarity index 100% rename from SSLTester/src/scan_parameters/ratable/PType.py rename to SSLTest/src/scan_parameters/ratable/PType.py diff --git a/SSLTester/src/scan_parameters/ratable/Parameters.py b/SSLTest/src/scan_parameters/ratable/Parameters.py similarity index 100% rename from SSLTester/src/scan_parameters/ratable/Parameters.py rename to SSLTest/src/scan_parameters/ratable/Parameters.py diff --git a/SSLTester/src/scan_parameters/ratable/__init__.py b/SSLTest/src/scan_parameters/ratable/__init__.py similarity index 100% rename from SSLTester/src/scan_parameters/ratable/__init__.py rename to SSLTest/src/scan_parameters/ratable/__init__.py diff --git a/SSLTester/src/scan_parameters/utils.py b/SSLTest/src/scan_parameters/utils.py similarity index 100% rename from SSLTester/src/scan_parameters/utils.py rename to SSLTest/src/scan_parameters/utils.py diff --git a/SSLTester/src/scan_vulnerabilities/__init__.py b/SSLTest/src/scan_vulnerabilities/__init__.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/__init__.py rename to SSLTest/src/scan_vulnerabilities/__init__.py diff --git a/SSLTester/src/scan_vulnerabilities/multitheard_scan.py b/SSLTest/src/scan_vulnerabilities/multitheard_scan.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/multitheard_scan.py rename to SSLTest/src/scan_vulnerabilities/multitheard_scan.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/__init__.py b/SSLTest/src/scan_vulnerabilities/tests/__init__.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/__init__.py rename to SSLTest/src/scan_vulnerabilities/tests/__init__.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/ccs_injection.py b/SSLTest/src/scan_vulnerabilities/tests/ccs_injection.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/ccs_injection.py rename to SSLTest/src/scan_vulnerabilities/tests/ccs_injection.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/crime.py b/SSLTest/src/scan_vulnerabilities/tests/crime.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/crime.py rename to SSLTest/src/scan_vulnerabilities/tests/crime.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/heartbleed.py b/SSLTest/src/scan_vulnerabilities/tests/heartbleed.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/heartbleed.py rename to SSLTest/src/scan_vulnerabilities/tests/heartbleed.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/insec_renegotiation.py b/SSLTest/src/scan_vulnerabilities/tests/insec_renegotiation.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/insec_renegotiation.py rename to SSLTest/src/scan_vulnerabilities/tests/insec_renegotiation.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/poodle.py b/SSLTest/src/scan_vulnerabilities/tests/poodle.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/poodle.py rename to SSLTest/src/scan_vulnerabilities/tests/poodle.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/rc4_support.py b/SSLTest/src/scan_vulnerabilities/tests/rc4_support.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/rc4_support.py rename to SSLTest/src/scan_vulnerabilities/tests/rc4_support.py diff --git a/SSLTester/src/scan_vulnerabilities/tests/session_ticket.py b/SSLTest/src/scan_vulnerabilities/tests/session_ticket.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/tests/session_ticket.py rename to SSLTest/src/scan_vulnerabilities/tests/session_ticket.py diff --git a/SSLTester/src/scan_vulnerabilities/utils.py b/SSLTest/src/scan_vulnerabilities/utils.py similarity index 100% rename from SSLTester/src/scan_vulnerabilities/utils.py rename to SSLTest/src/scan_vulnerabilities/utils.py diff --git a/SSLTester/src/ssl_scan/SSLv3.py b/SSLTest/src/ssl_scan/SSLv3.py similarity index 100% rename from SSLTester/src/ssl_scan/SSLv3.py rename to SSLTest/src/ssl_scan/SSLv3.py diff --git a/SSLTester/src/ssl_scan/__init__.py b/SSLTest/src/ssl_scan/__init__.py similarity index 100% rename from SSLTester/src/ssl_scan/__init__.py rename to SSLTest/src/ssl_scan/__init__.py diff --git a/SSLTester/src/ssl_scan/utils.py b/SSLTest/src/ssl_scan/utils.py similarity index 100% rename from SSLTester/src/ssl_scan/utils.py rename to SSLTest/src/ssl_scan/utils.py diff --git a/SSLTester/src/start_script.py b/SSLTest/src/start_script.py similarity index 100% rename from SSLTester/src/start_script.py rename to SSLTest/src/start_script.py diff --git a/SSLTester/src/text_output/TextOutput.py b/SSLTest/src/text_output/TextOutput.py similarity index 100% rename from SSLTester/src/text_output/TextOutput.py rename to SSLTest/src/text_output/TextOutput.py diff --git a/SSLTester/src/text_output/__init__.py b/SSLTest/src/text_output/__init__.py similarity index 100% rename from SSLTester/src/text_output/__init__.py rename to SSLTest/src/text_output/__init__.py diff --git a/SSLTester/src/utils.py b/SSLTest/src/utils.py similarity index 100% rename from SSLTester/src/utils.py rename to SSLTest/src/utils.py From e4efa2ccc722ea8530c85062145cbec437b64cff Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Wed, 4 Aug 2021 13:15:59 +0200 Subject: [PATCH 04/16] Add descriptions for options to help message and move test options checking Move the test checking function to the main script file so that checking can be done before actuall scaning Copied over the old option descriptions to the new format --- SSLTest/SSLTest.py | 101 ++++++++++++----- SSLTest/src/{start_script.py => run.py} | 142 ++++++------------------ 2 files changed, 110 insertions(+), 133 deletions(-) rename SSLTest/src/{start_script.py => run.py} (58%) diff --git a/SSLTest/SSLTest.py b/SSLTest/SSLTest.py index d78d438..1b10bb3 100755 --- a/SSLTest/SSLTest.py +++ b/SSLTest/SSLTest.py @@ -2,11 +2,13 @@ __version__ = "0.0.1" -from ptlibs import ptjsonlib, ptmisclib import argparse import sys +import textwrap + +from ptlibs import ptjsonlib, ptmisclib -from src.start_script import start +from src.run import run, get_tests_switcher class SSLTest: @@ -17,55 +19,100 @@ def __init__(self, args): self.use_json = self.args.json def run(self): - start(self.args) + run(self.args, ) ptmisclib.ptprint(ptmisclib.out_if(self.ptjsonlib.get_all_json(), "", self.use_json)) +def get_usage(): + return f"{SCRIPTNAME}.py -u url <-h> <-ns> <-nd> <-p port > <-j > " \ + f"<-t test_num > <-fc> <-i> <-v>" + + +def get_tests_help(): + tests_help = 'test the server for a specified vulnerability\n' \ + 'possible vulnerabilities (separate with spaces):\n' + for key, value in get_tests_switcher().items(): + test_number = key + test_desc = value[1] + tests_help += f'{" " * 4}{test_number}: {test_desc}\n' + tests_help += 'if this argument isn\'t specified all tests will be ran\n' \ + 'if 0 is given as a test number no tests will be ran' + return tests_help + + def get_help(): return [ {"description": ["Script that scans a webservers cryptographic parameters and vulnerabilities"]}, - {"usage": [ - "SSLTest.py -u url <-h> <-ns> <-nd> <-p port > <-j > <-t test_num >" - " <-fc> <-i> <-v>" - ]}, - {"usage_example": [ - "SSLTest.py -u github.com -t 1 2", - ]}, + {"usage": [get_usage()]}, + {"usage_example": [f"{SCRIPTNAME}.py -u github.com -t 1 2"]}, {"options": [ ["-u", "--url", "", "Url to scan, required option"], - ["-p", "--proxy", "", "Set proxy (e.g. http://127.0.0.1:8080)"], - ["-c", "--cookie", "", "Set cookie(s)"], - ["-H", "--headers", "", "Set custom headers"], - ["-ua", "--user-agent", "", "Set user agent"], - ["-j", "--json", "", "Output in JSON format"], + ["-p", "--port", "", "Port or ports (separate with spaces) to scan on (default: [443])"], + ["-j", "--json", "", "change output to json format, if a file name is specified output is written to the " + "given file"], + ["-t", "--test", "", get_tests_help()], + ["-fc", "--fix-conf", "", "Allow the use of older versions of TLS protocol (TLSv1 and TLSv1.1) in order to" + " scan a server which still run on these versions. !WARNING!: this may rewrite" + " the contents of a configuration file located at /etc/ssl/openssl.cnf"], + ["-ns", "--nmap-scan", "", "Use nmap to scan the server version"], + ["-nd", "--nmap-discover", "", "Use nmap to discover web server ports"], + ["-i", "--info", "", "Output some internal information about the script functions"], + ["-d", "--debug", "", "Output debug information"], ["-v", "--version", "", "Show script version and exit"], ["-h", "--help", "", "Show this help message and exit"] ] }] +def print_help(): + ptmisclib.help_print(get_help(), SCRIPTNAME, __version__) + + def parse_args(): - parser = argparse.ArgumentParser(add_help=False, usage=f"{SCRIPTNAME} ") - required = parser.add_argument_group('required arguments') - required.add_argument('-u', '--url', required=True, metavar='url') - parser.add_argument('-ns', '--nmap-scan', action='store_true', default=False) - parser.add_argument('-nd', '--nmap-discover', action='store_true', default=False) - parser.add_argument('-p', '--port', default=[443], type=int, nargs='+', metavar='port') - parser.add_argument('-j', '--json', action='store', metavar='output_file', required=False, nargs='?', default=False) - parser.add_argument('-t', '--test', type=int, metavar='test_num', nargs='+') - parser.add_argument('-fc', '--fix-conf', action='store_true', default=False) - parser.add_argument('-d', '--debug', action='store_true', default=False) - parser.add_argument('-i', '--info', action='store_true', default=False) + parser = argparse.ArgumentParser(add_help=False, usage=get_usage()) + required = parser.add_argument_group("required arguments") + required.add_argument("-u", "--url", required=True, metavar="url") + parser.add_argument("-p", "--port", default=[443], type=int, nargs="+", metavar="port") + parser.add_argument("-j", "--json", action="store", metavar="output_file", required=False, nargs="?", default=False) + parser.add_argument("-t", "--test", type=int, metavar="test_num", nargs="+") + parser.add_argument("-fc", "--fix-conf", action="store_true", default=False) + parser.add_argument("-ns", "--nmap-scan", action="store_true", default=False) + parser.add_argument("-nd", "--nmap-discover", action="store_true", default=False) + parser.add_argument("-i", "--info", action="store_true", default=False) + parser.add_argument("-d", "--debug", action="store_true", default=False) parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {__version__}") if len(sys.argv) == 1 or "-h" in sys.argv or "--help" in sys.argv: - ptmisclib.help_print(get_help(), SCRIPTNAME, __version__) + print_help() sys.exit(0) args = parser.parse_args() + check_test_option(args.test) ptmisclib.print_banner(SCRIPTNAME, __version__, args.json) return args +def check_test_option(tests): + """ + Check if the tests numbers are actually tests + + :param tests: test argument + :return: + """ + tests_switcher = get_tests_switcher() + if not tests or 0 in tests: + return + test_numbers = [test for test in tests_switcher.keys()] + unknown_tests = list(filter(lambda test: test not in test_numbers, tests)) + if unknown_tests: + print_help() + if len(unknown_tests) > 1: + unknown_tests = list(map(str, unknown_tests)) + print(f"Numbers {','.join(unknown_tests)} are not test numbers.", file=sys.stderr) + else: + print(f"Number {unknown_tests[0]} is not a test number.", file=sys.stderr) + sys.exit(1) + + def main(): global SCRIPTNAME SCRIPTNAME = "SSLTest" diff --git a/SSLTest/src/start_script.py b/SSLTest/src/run.py similarity index 58% rename from SSLTest/src/start_script.py rename to SSLTest/src/run.py index a84238d..c19cbda 100755 --- a/SSLTest/src/start_script.py +++ b/SSLTest/src/run.py @@ -1,44 +1,39 @@ -import argparse, sys, logging, json, textwrap, traceback, os +import json +import logging +import os +import sys +import traceback -from .scan_vulnerabilities.tests import heartbleed -from .scan_vulnerabilities.tests import ccs_injection -from .scan_vulnerabilities.tests import insec_renegotiation as rene -from .scan_vulnerabilities.tests import poodle -from .scan_vulnerabilities.tests import session_ticket -from .scan_vulnerabilities.tests import crime -from .scan_vulnerabilities.tests import rc4_support -from .scan_parameters.ratable.CipherSuite import CipherSuite -from .scan_parameters.ratable.Certificate import Certificate +from .fix_openssl_config import fix_openssl_config +from .scan_parameters.connection.connection_utils import get_website_info from .scan_parameters.non_ratable.ProtocolSupport import ProtocolSupport from .scan_parameters.non_ratable.WebServerSoft import WebServerSoft -from .scan_parameters.connection.connection_utils import get_website_info from .scan_parameters.non_ratable.port_discovery import discover_ports +from .scan_parameters.ratable.Certificate import Certificate +from .scan_parameters.ratable.CipherSuite import CipherSuite from .scan_parameters.ratable.PType import PType from .scan_parameters.utils import fix_url -from .text_output.TextOutput import TextOutput from .scan_vulnerabilities.multitheard_scan import scan_vulnerabilities -from .fix_openssl_config import fix_openssl_config - -tests_switcher = { - 1: (heartbleed.scan, 'Heartbleed'), - 2: (ccs_injection.scan, 'CCS injection'), - 3: (rene.scan, 'Insecure renegotiation'), - 4: (poodle.scan, 'ZombiePOODLE/GOLDENDOOLDE'), - 5: (session_ticket.scan, 'Session ticket support'), - 6: (crime.scan, 'CRIME'), - 7: (rc4_support.scan, 'RC4 support') -} +from .scan_vulnerabilities.tests import ccs_injection +from .scan_vulnerabilities.tests import crime +from .scan_vulnerabilities.tests import heartbleed +from .scan_vulnerabilities.tests import insec_renegotiation as rene +from .scan_vulnerabilities.tests import poodle +from .scan_vulnerabilities.tests import rc4_support +from .scan_vulnerabilities.tests import session_ticket +from .text_output.TextOutput import TextOutput -def tls_test(args): - # args = parse_options(program_args) - fix_conf_option(args) - if '/' in args.url: - args.url = fix_url(args.url) - info_report_option(args) - nmap_discover_option(args) - output_data = scan_all_ports(args) - return json_option(args, output_data) +def get_tests_switcher(): + return { + 1: (heartbleed.scan, 'Heartbleed'), + 2: (ccs_injection.scan, 'CCS injection'), + 3: (rene.scan, 'Insecure renegotiation'), + 4: (poodle.scan, 'ZombiePOODLE/GOLDENDOOLDE'), + 5: (session_ticket.scan, 'Session ticket support'), + 6: (crime.scan, 'CRIME'), + 7: (rc4_support.scan, 'RC4 support') + } def fix_conf_option(args): @@ -67,6 +62,7 @@ def vulnerability_scan(address, tests, version): :param tests: input option for tests :return: dictionary of scanned results """ + tests_switcher = get_tests_switcher() # if no -t argument is present if not tests: scans = [value for value in tests_switcher.values()] @@ -145,77 +141,6 @@ def info_report_option(args): logging.basicConfig(stream=sys.stderr, level=logging.INFO) -def parse_options(program_args): - """ - Parse input options. - :return: object of parsed arguments - """ - tests_help = 'test the server for a specified vulnerability\n' \ - 'possible vulnerabilities (separate with spaces):\n' - for key, value in tests_switcher.items(): - test_number = key - test_desc = value[1] - tests_help += f'{" " * 4}{test_number}: {test_desc}\n' - tests_help += 'if this argument isn\'t specified all tests will be ran\n' \ - 'if 0 is given as a test number no tests will be ran' - - parser = argparse.ArgumentParser( - usage='use -h or --help for more information', - description='Script that scans a webservers cryptographic parameters and vulnerabilities', - formatter_class=argparse.RawTextHelpFormatter) - required = parser.add_argument_group('required arguments') - required.add_argument('-u', '--url', required=True, metavar='url', help='url to scan') - parser.add_argument('-ns', '--nmap-scan', action='store_true', default=False, - help='use nmap to scan the server version') - parser.add_argument('-nd', '--nmap-discover', action='store_true', default=False, - help='use nmap to discover web server ports') - parser.add_argument('-p', '--port', default=[443], type=int, nargs='+', metavar='port', - help='port or ports (separate with spaces) to scan on (default: %(default)s)') - parser.add_argument('-j', '--json', action='store', metavar='output_file', required=False, - nargs='?', default=False, - help=textwrap.dedent('''\ - change output to json format, if a file name is specified - output is written to the given file - ''')) - parser.add_argument('-t', '--test', type=int, metavar='test_num', nargs='+', - help=textwrap.dedent(tests_help)) - parser.add_argument('-fc', '--fix-conf', action='store_true', default=False, - help=textwrap.dedent('''\ - allow the use of older versions of TLS protocol - (TLSv1 and TLSv1.1) in order to scan a server which - still run on these versions. - !WARNING!: this may rewrite the contents of a - configuration file located at /etc/ssl/openssl.cnf - backup is recommended, root permission required - ''')) - parser.add_argument('-i', '--information', action='store_true', default=False, help='output some information') - parser.add_argument('-v', '--verbose', action='store_true', default=False, help='output more information') - - args = parser.parse_args(program_args) - return args - - -def check_test_numbers(tests): - """ - Check if the tests numbers are actually tests - - :param tests: test argument - :param print_usage: usage string - :return: - """ - if not tests or 0 in tests: - return - test_numbers = [test for test in tests_switcher.keys()] - unknown_tests = list(filter(lambda test: test not in test_numbers, tests)) - if unknown_tests: - if len(unknown_tests) > 1: - unknown_tests = list(map(str, unknown_tests)) - print(f'Numbers {", ".join(unknown_tests)} are not test numbers.', file=sys.stderr) - else: - print(f'Number {unknown_tests[0]} is not a test number.', file=sys.stderr) - sys.exit(1) - - def scan(args, port: int): """ Call other scanning functions for a specific url and port @@ -256,7 +181,12 @@ def scan(args, port: int): port, args.url) -def start(args): - check_test_numbers(args.test) - out = tls_test(args) +def run(args): + fix_conf_option(args) + if '/' in args.url: + args.url = fix_url(args.url) + info_report_option(args) + nmap_discover_option(args) + output_data = scan_all_ports(args) + out = json_option(args, output_data) if out: print(out) From 6d713bb2a2e1c3f74820489885090fcae8dcfdb0 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Wed, 4 Aug 2021 13:35:57 +0200 Subject: [PATCH 05/16] Fixed code duplication in utils for vuln scans and sslv3 scanning Create a new main utils file for functions that are required in more then one package --- .../tests/ccs_injection.py | 7 ++- .../src/scan_vulnerabilities/tests/crime.py | 9 ++- .../scan_vulnerabilities/tests/heartbleed.py | 7 ++- .../tests/insec_renegotiation.py | 7 ++- .../src/scan_vulnerabilities/tests/poodle.py | 9 ++- .../scan_vulnerabilities/tests/rc4_support.py | 9 ++- .../tests/session_ticket.py | 7 ++- SSLTest/src/scan_vulnerabilities/utils.py | 60 ------------------ SSLTest/src/ssl_scan/SSLv2.py | 0 SSLTest/src/ssl_scan/SSLv3.py | 17 ++++- SSLTest/src/ssl_scan/utils.py | 27 -------- SSLTest/src/utils.py | 63 ++++++++++++++++++- 12 files changed, 115 insertions(+), 107 deletions(-) create mode 100644 SSLTest/src/ssl_scan/SSLv2.py delete mode 100644 SSLTest/src/ssl_scan/utils.py diff --git a/SSLTest/src/scan_vulnerabilities/tests/ccs_injection.py b/SSLTest/src/scan_vulnerabilities/tests/ccs_injection.py index e5f3dd7..723de5c 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/ccs_injection.py +++ b/SSLTest/src/scan_vulnerabilities/tests/ccs_injection.py @@ -1,4 +1,7 @@ -from ..utils import * +import logging + +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock, receive_data def construct_client_hello(version): @@ -69,7 +72,7 @@ def scan(address, version): client_hello = construct_client_hello(version) logging.info('Scanning CCS injection vulnerability...') timeout = 2 - server_hello, sock = send_client_hello(address, client_hello, timeout) + server_hello, sock = communicate_data_return_sock(address, client_hello, timeout) if not is_server_hello(server_hello): logging.info('CCS injection scan done.') sock.close() diff --git a/SSLTest/src/scan_vulnerabilities/tests/crime.py b/SSLTest/src/scan_vulnerabilities/tests/crime.py index d3ae115..0a2d18b 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/crime.py +++ b/SSLTest/src/scan_vulnerabilities/tests/crime.py @@ -1,4 +1,7 @@ -from ..utils import * +import logging + +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock def construct_client_hello(version): @@ -60,9 +63,9 @@ def scan(address, version): client_hello = construct_client_hello(version) logging.info("Scanning CRIME vulnerability...") timeout = 2 - server_hello, sock = send_client_hello(address, client_hello, timeout) + server_hello, sock = communicate_data_return_sock(address, client_hello, timeout) sock.close() - logging.info("Session CRIME vulnerability scan done.") + logging.info("CRIME vulnerability scan done.") if not is_server_hello(server_hello): return False # 0x02 stands for fatal error diff --git a/SSLTest/src/scan_vulnerabilities/tests/heartbleed.py b/SSLTest/src/scan_vulnerabilities/tests/heartbleed.py index 0a6541a..20e8ed5 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/heartbleed.py +++ b/SSLTest/src/scan_vulnerabilities/tests/heartbleed.py @@ -1,4 +1,7 @@ -from ..utils import * +import logging + +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock, receive_data def construct_client_hello(version): @@ -75,7 +78,7 @@ def scan(address, version): client_hello = construct_client_hello(version) logging.info('Scanning Heartbleed vulnerability...') timeout = 2 - server_hello, sock = send_client_hello(address, client_hello, timeout) + server_hello, sock = communicate_data_return_sock(address, client_hello, timeout) if not is_server_hello(server_hello): sock.close() logging.info('Heartbeat scan done.') diff --git a/SSLTest/src/scan_vulnerabilities/tests/insec_renegotiation.py b/SSLTest/src/scan_vulnerabilities/tests/insec_renegotiation.py index 4380986..49b0cb8 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/insec_renegotiation.py +++ b/SSLTest/src/scan_vulnerabilities/tests/insec_renegotiation.py @@ -1,4 +1,7 @@ -from ..utils import * +import logging + +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock renegotiation_extension = bytes([ 0xff, 0x01, 0x00, 0x01, 0x00 @@ -68,7 +71,7 @@ def scan(address, version): client_hello = construct_client_hello(version) logging.info("Scanning Renegotiation vulnerability...") timeout = 2 - server_hello, sock = send_client_hello(address, client_hello, timeout) + server_hello, sock = communicate_data_return_sock(address, client_hello, timeout) sock.close() logging.info("Renegotiation vulnerability scan done.") if not is_server_hello(server_hello): diff --git a/SSLTest/src/scan_vulnerabilities/tests/poodle.py b/SSLTest/src/scan_vulnerabilities/tests/poodle.py index a5539b6..84761fc 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/poodle.py +++ b/SSLTest/src/scan_vulnerabilities/tests/poodle.py @@ -1,6 +1,11 @@ -from ..utils import * +import logging +import socket + from OpenSSL import SSL +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock + def construct_client_hello(version): client_hello = bytes([ @@ -80,7 +85,7 @@ def scan(address, version): """ client_hello = construct_client_hello(version) logging.info("Scanning Poodle vulnerability...") - server_hello, sock = send_client_hello(address, client_hello, 2) + server_hello, sock = communicate_data_return_sock(address, client_hello, 2) # If no server hello is sent the server doesn't support # CBC ciphers if not is_server_hello(server_hello): diff --git a/SSLTest/src/scan_vulnerabilities/tests/rc4_support.py b/SSLTest/src/scan_vulnerabilities/tests/rc4_support.py index ed8350d..9014d45 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/rc4_support.py +++ b/SSLTest/src/scan_vulnerabilities/tests/rc4_support.py @@ -1,4 +1,7 @@ -from ..utils import * +import logging + +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock def construct_client_hello(version): @@ -57,9 +60,9 @@ def scan(address, version): client_hello = construct_client_hello(version) logging.info("Scanning rc4 support vulnerability...") timeout = 2 - server_hello, sock = send_client_hello(address, client_hello, timeout) + server_hello, sock = communicate_data_return_sock(address, client_hello, timeout) sock.close() - logging.info("Session rc4 support vulnerability scan done.") + logging.info("RC4 support vulnerability scan done.") if not is_server_hello(server_hello): return False # 0x02 means fatal error and 0x28 means handshake failure diff --git a/SSLTest/src/scan_vulnerabilities/tests/session_ticket.py b/SSLTest/src/scan_vulnerabilities/tests/session_ticket.py index c83dba3..02ff4cb 100644 --- a/SSLTest/src/scan_vulnerabilities/tests/session_ticket.py +++ b/SSLTest/src/scan_vulnerabilities/tests/session_ticket.py @@ -1,4 +1,7 @@ -from ..utils import * +import logging + +from ..utils import is_server_hello +from ...utils import communicate_data_return_sock def construct_client_hello(version): @@ -69,7 +72,7 @@ def scan(address, version): client_hello = construct_client_hello(version) logging.info("Scanning session ticket vulnerability...") timeout = 2 - server_hello, sock = send_client_hello(address, client_hello, timeout) + server_hello, sock = communicate_data_return_sock(address, client_hello, timeout) sock.close() logging.info("Session ticket vulnerability scan done.") if not is_server_hello(server_hello): diff --git a/SSLTest/src/scan_vulnerabilities/utils.py b/SSLTest/src/scan_vulnerabilities/utils.py index 2667f15..ec48f37 100644 --- a/SSLTest/src/scan_vulnerabilities/utils.py +++ b/SSLTest/src/scan_vulnerabilities/utils.py @@ -1,63 +1,3 @@ -import inspect -import logging -import os -import socket - -from time import sleep, time - - -def receive_data(sock, timeout): - """ - Receive data in chunks - - :param sock: socket to receive from - :param timeout: timeout in seconds - :return: array of bytes of received data - """ - stack = inspect.stack() - full_test_name = stack[len(stack) - 6].filename - # Get current test name for debugging purposes - test_name = full_test_name.split(os.path.sep)[-1] - all_data = [] - begin = time() - while 1: - if all_data and time() - begin > timeout: - logging.debug(f"({test_name}) timed out with received data") - break - elif time() - begin > timeout * 2: - logging.debug(f"({test_name}) timed out with no received data") - break - try: - data = sock.recv(2048) - if data: - logging.debug(f"({test_name}) receiving data") - all_data.extend(data) - begin = time() - else: - sleep(0.1) - except socket.timeout: - pass - return bytes(all_data) - - -def send_client_hello(address, client_hello, timeout): - """ - Send client client_hello to the server and catch the - response - - :param address: tuple of an url and port - :param client_hello: client_hello data in bytes - :param timeout: timeout in seconds - :return: created socket and received response - """ - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.settimeout(timeout) - sock.connect(address) - sock.send(client_hello) - response = receive_data(sock, timeout) - return response, sock - - def is_server_hello(server_hello): # Server hello content type in record protocol try: diff --git a/SSLTest/src/ssl_scan/SSLv2.py b/SSLTest/src/ssl_scan/SSLv2.py new file mode 100644 index 0000000..e69de29 diff --git a/SSLTest/src/ssl_scan/SSLv3.py b/SSLTest/src/ssl_scan/SSLv3.py index 359bab3..8daa96c 100644 --- a/SSLTest/src/ssl_scan/SSLv3.py +++ b/SSLTest/src/ssl_scan/SSLv3.py @@ -1,8 +1,19 @@ -from .utils import read_json, hex_to_int -from ..scan_vulnerabilities.utils import send_client_hello +from ..utils import read_json, communicate_data_return_sock from cryptography.x509 import load_der_x509_certificate +def hex_to_int(hex_num: list): + result = '0x' + # {}:02x: + # {}: -- value + # 0 -- padding with zeros + # 2 -- number digits + # x -- hex format + for num in hex_num: + result += f'{num:02x}' + return int(result, 16) + + class SSLv3: def __init__(self, url, port): self.address = (url, port) @@ -44,7 +55,7 @@ def __init__(self, url, port): 0x01, # Compression methods length 0x00 # Compression methods ]) - self.response, _ = send_client_hello(self.address, self.client_hello, self.timeout) + self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, "SSLv3 scan") def scan_sslv3_version(self): # Test if the response is Content type Alert (0x15) diff --git a/SSLTest/src/ssl_scan/utils.py b/SSLTest/src/ssl_scan/utils.py deleted file mode 100644 index a0db21f..0000000 --- a/SSLTest/src/ssl_scan/utils.py +++ /dev/null @@ -1,27 +0,0 @@ -import os, json - - -def read_json(file_name: str): - """ - Read a json file and return its content. - - :param file_name: json file name - :return: json data in python objects - """ - root_dir = os.path.dirname(os.path.abspath(__file__)) - file = open(f'{root_dir}/../resources/{file_name}', 'r') - json_data = json.loads(file.read()) - file.close() - return json_data - - -def hex_to_int(hex_num: list): - result = '0x' - # {}:02x: - # {}: -- value - # 0 -- padding with zeros - # 2 -- number digits - # x -- hex format - for num in hex_num: - result += f'{num:02x}' - return int(result, 16) diff --git a/SSLTest/src/utils.py b/SSLTest/src/utils.py index 136e3f2..5339a33 100644 --- a/SSLTest/src/utils.py +++ b/SSLTest/src/utils.py @@ -1,4 +1,10 @@ -import os, json +import inspect +import json +import logging +import os +import socket + +from time import sleep, time def read_json(file_name: str): @@ -13,3 +19,58 @@ def read_json(file_name: str): json_data = json.loads(file.read()) file.close() return json_data + + +def receive_data(sock, timeout, debug_source=None): + """ + Receive data in chunks + + :param debug_source: + :param sock: socket to receive from + :param timeout: timeout in seconds + :return: array of bytes of received data + """ + if debug_source is None: + stack = inspect.stack() + full_test_name = stack[len(stack) - 6].filename + # Get current test name for debugging purposes + debug_source = full_test_name.split(os.path.sep)[-1] + all_data = [] + begin = time() + while 1: + if all_data and time() - begin > timeout: + logging.debug(f"({debug_source}) timed out with received data") + break + elif time() - begin > timeout * 2: + logging.debug(f"({debug_source}) timed out with no received data") + break + try: + data = sock.recv(2048) + if data: + logging.debug(f"({debug_source}) receiving data") + all_data.extend(data) + begin = time() + else: + sleep(0.1) + except socket.timeout: + pass + return bytes(all_data) + + +def communicate_data_return_sock(address, client_hello, timeout, debug_source=None): + """ + Send client client_hello to the server and catch the + response + + :param debug_source: + :param address: tuple of an url and port + :param client_hello: client_hello data in bytes + :param timeout: timeout in seconds + :return: created socket and received response + """ + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(timeout) + sock.connect(address) + sock.send(client_hello) + response = receive_data(sock, timeout, debug_source) + return response, sock From b6d4218b592c0ee99b52eda4adf1853b92cf2077 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Wed, 4 Aug 2021 13:56:19 +0200 Subject: [PATCH 06/16] Fix readme and remove license so it can be fixed --- LICENSE | 674 ----------------------------------------- README.MD => README.md | 2 +- 2 files changed, 1 insertion(+), 675 deletions(-) delete mode 100644 LICENSE rename README.MD => README.md (98%) diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 3877ae0..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - 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 - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/README.MD b/README.md similarity index 98% rename from README.MD rename to README.md index 612ec0c..6399fa8 100644 --- a/README.MD +++ b/README.md @@ -7,7 +7,7 @@ |_| ``` -# scriptname +# SSLTest ## Installation From cf27db46593ac302c7ede98480f0f4457cd4795e Mon Sep 17 00:00:00 2001 From: SamoKopecky <44006847+SamoKopecky@users.noreply.github.com> Date: Wed, 4 Aug 2021 13:57:39 +0200 Subject: [PATCH 07/16] Create LICENSE.md --- LICENSE.md | 674 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,674 @@ + 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 + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 12278eb52586c61a07497dc3a0da3c2d03481c75 Mon Sep 17 00:00:00 2001 From: SamoKopecky <44006847+SamoKopecky@users.noreply.github.com> Date: Wed, 4 Aug 2021 16:57:25 +0200 Subject: [PATCH 08/16] Rename LICENSE.md to LICENSE --- LICENSE.md => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE.md => LICENSE (100%) diff --git a/LICENSE.md b/LICENSE similarity index 100% rename from LICENSE.md rename to LICENSE From 8cf4b0d9fd1a3777277a0100f717cf309040663e Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Thu, 5 Aug 2021 10:46:30 +0200 Subject: [PATCH 09/16] Refractoring --- SSLTest/SSLTest.py | 3 +- SSLTest/src/run.py | 58 ++++++++++++++++--- .../connections}/SSLv2.py | 0 .../connections}/SSLv3.py | 3 +- .../{connection => connections}/__init__.py | 0 .../connection_utils.py | 2 +- .../scan_parameters/ratable/Certificate.py | 3 +- .../scan_parameters/ratable/CipherSuite.py | 2 +- .../src/scan_parameters/ratable/Parameters.py | 3 +- .../ProtocolSupport.py | 7 ++- SSLTest/src/scan_parameters/utils.py | 3 +- SSLTest/src/ssl_scan/__init__.py | 2 - SSLTest/src/text_output/TextOutput.py | 44 +------------- 13 files changed, 64 insertions(+), 66 deletions(-) rename SSLTest/src/{ssl_scan => scan_parameters/connections}/SSLv2.py (100%) rename SSLTest/src/{ssl_scan => scan_parameters/connections}/SSLv3.py (98%) rename SSLTest/src/scan_parameters/{connection => connections}/__init__.py (100%) rename SSLTest/src/scan_parameters/{connection => connections}/connection_utils.py (99%) rename SSLTest/src/scan_parameters/{non_ratable => ratable}/ProtocolSupport.py (95%) delete mode 100644 SSLTest/src/ssl_scan/__init__.py diff --git a/SSLTest/SSLTest.py b/SSLTest/SSLTest.py index 1b10bb3..8901e70 100755 --- a/SSLTest/SSLTest.py +++ b/SSLTest/SSLTest.py @@ -4,7 +4,6 @@ import argparse import sys -import textwrap from ptlibs import ptjsonlib, ptmisclib @@ -19,7 +18,7 @@ def __init__(self, args): self.use_json = self.args.json def run(self): - run(self.args, ) + run(self.args) ptmisclib.ptprint(ptmisclib.out_if(self.ptjsonlib.get_all_json(), "", self.use_json)) diff --git a/SSLTest/src/run.py b/SSLTest/src/run.py index c19cbda..b7eeaeb 100755 --- a/SSLTest/src/run.py +++ b/SSLTest/src/run.py @@ -5,8 +5,8 @@ import traceback from .fix_openssl_config import fix_openssl_config -from .scan_parameters.connection.connection_utils import get_website_info -from .scan_parameters.non_ratable.ProtocolSupport import ProtocolSupport +from .scan_parameters.connections.connection_utils import get_website_info +from .scan_parameters.ratable.ProtocolSupport import ProtocolSupport from .scan_parameters.non_ratable.WebServerSoft import WebServerSoft from .scan_parameters.non_ratable.port_discovery import discover_ports from .scan_parameters.ratable.Certificate import Certificate @@ -83,7 +83,7 @@ def json_option(args, output_data): json_output_data = json.dumps(output_data, indent=2) if args.json is False: text_output = TextOutput(json_output_data) - text_output.text_output() + text_output.get_formatted_text() return text_output.output elif args.json is None: return json_output_data @@ -141,6 +141,47 @@ def info_report_option(args): logging.basicConfig(stream=sys.stderr, level=logging.INFO) +def dump_to_dict(cipher_suite, certificate_parameters, protocol_support, + certificate_non_parameters, software, vulnerabilities, port, url): + """ + Dump web server parameters to a single dict. + + :param cipher_suite: tuple containing parameters and the worst rating + :param certificate_parameters: tuple containing parameters and the worst rating + :param certificate_non_parameters: certificate parameters such as subject/issuer + :param protocol_support: dictionary of supported tls protocols + :param software: web server software + :param port: scanned port + :param url: scanned url + :param vulnerabilities: scanned vulnerabilities + :return: dictionary + """ + dump = {} + + # Parameters + worst_rating = max([cipher_suite[1], certificate_parameters[1]]) + parameters = {key.name: value for key, value in cipher_suite[0].items()} + parameters.update({key.name: value for key, value in certificate_parameters[0].items()}) + parameters.update({'rating': worst_rating}) + + # Non ratable cert info + certificate_info = {key.name: value for key, value in certificate_non_parameters.items()} + + # Protocol support + protocols = {} + keys = {key.name: value for key, value in protocol_support[0].items()} + for key, value in list(keys.items()): + protocols[key] = value + protocols.update({'rating': protocol_support[1]}) + + dump.update({'parameters': parameters}) + dump.update({'certificate_info': certificate_info}) + dump.update({'protocol_support': protocols}) + dump.update({'web_server_software': software}) + dump.update({'vulnerabilities': vulnerabilities}) + return {f'{url}:{port}': dump} + + def scan(args, port: int): """ Call other scanning functions for a specific url and port @@ -173,12 +214,11 @@ def scan(args, port: int): vulnerabilities = vulnerability_scan((args.url, port), args.test, main_version) logging.info('Scanning done.') - return TextOutput.dump_to_dict((cipher_suite.parameters, cipher_suite.rating), - (certificate.parameters, certificate.rating), - (protocol_support.versions, protocol_support.rating), - certificate.non_parameters, - versions.versions, vulnerabilities, - port, args.url) + return dump_to_dict((cipher_suite.parameters, cipher_suite.rating), + (certificate.parameters, certificate.rating), + (protocol_support.versions, protocol_support.rating), + certificate.non_parameters, versions.versions, vulnerabilities, + port, args.url) def run(args): diff --git a/SSLTest/src/ssl_scan/SSLv2.py b/SSLTest/src/scan_parameters/connections/SSLv2.py similarity index 100% rename from SSLTest/src/ssl_scan/SSLv2.py rename to SSLTest/src/scan_parameters/connections/SSLv2.py diff --git a/SSLTest/src/ssl_scan/SSLv3.py b/SSLTest/src/scan_parameters/connections/SSLv3.py similarity index 98% rename from SSLTest/src/ssl_scan/SSLv3.py rename to SSLTest/src/scan_parameters/connections/SSLv3.py index 8daa96c..fdf1356 100644 --- a/SSLTest/src/ssl_scan/SSLv3.py +++ b/SSLTest/src/scan_parameters/connections/SSLv3.py @@ -1,6 +1,7 @@ -from ..utils import read_json, communicate_data_return_sock from cryptography.x509 import load_der_x509_certificate +from ...utils import read_json, communicate_data_return_sock + def hex_to_int(hex_num: list): result = '0x' diff --git a/SSLTest/src/scan_parameters/connection/__init__.py b/SSLTest/src/scan_parameters/connections/__init__.py similarity index 100% rename from SSLTest/src/scan_parameters/connection/__init__.py rename to SSLTest/src/scan_parameters/connections/__init__.py diff --git a/SSLTest/src/scan_parameters/connection/connection_utils.py b/SSLTest/src/scan_parameters/connections/connection_utils.py similarity index 99% rename from SSLTest/src/scan_parameters/connection/connection_utils.py rename to SSLTest/src/scan_parameters/connections/connection_utils.py index 7d981e3..0f596ed 100644 --- a/SSLTest/src/scan_parameters/connection/connection_utils.py +++ b/SSLTest/src/scan_parameters/connections/connection_utils.py @@ -6,11 +6,11 @@ from cryptography import x509 from cryptography.hazmat.backends import default_backend +from .SSLv3 import SSLv3 from ..exceptions.ConnectionTimeoutError import ConnectionTimeoutError from ..exceptions.DNSError import DNSError from ..exceptions.UnknownConnectionError import UnknownConnectionError from ..utils import convert_openssh_to_iana, incremental_sleep -from ...ssl_scan.SSLv3 import SSLv3 def get_website_info(url: str, port: int): diff --git a/SSLTest/src/scan_parameters/ratable/Certificate.py b/SSLTest/src/scan_parameters/ratable/Certificate.py index 0ce3b82..e86ed9a 100644 --- a/SSLTest/src/scan_parameters/ratable/Certificate.py +++ b/SSLTest/src/scan_parameters/ratable/Certificate.py @@ -1,7 +1,8 @@ from cryptography import x509 -from ..utils import pub_key_alg_from_cert, get_sig_alg_from_oid + from .Parameters import Parameters from .PType import PType +from ..utils import pub_key_alg_from_cert, get_sig_alg_from_oid class Certificate(Parameters): diff --git a/SSLTest/src/scan_parameters/ratable/CipherSuite.py b/SSLTest/src/scan_parameters/ratable/CipherSuite.py index 0baf862..59f0c94 100644 --- a/SSLTest/src/scan_parameters/ratable/CipherSuite.py +++ b/SSLTest/src/scan_parameters/ratable/CipherSuite.py @@ -1,6 +1,6 @@ -from ...utils import read_json from .Parameters import Parameters from .PType import PType +from ...utils import read_json class CipherSuite(Parameters): diff --git a/SSLTest/src/scan_parameters/ratable/Parameters.py b/SSLTest/src/scan_parameters/ratable/Parameters.py index b7b066b..e5a632a 100644 --- a/SSLTest/src/scan_parameters/ratable/Parameters.py +++ b/SSLTest/src/scan_parameters/ratable/Parameters.py @@ -1,6 +1,7 @@ -from ..utils import rate_key_length_parameter, rate_parameter from abc import ABC +from ..utils import rate_key_length_parameter, rate_parameter + class Parameters(ABC): def __init__(self): diff --git a/SSLTest/src/scan_parameters/non_ratable/ProtocolSupport.py b/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py similarity index 95% rename from SSLTest/src/scan_parameters/non_ratable/ProtocolSupport.py rename to SSLTest/src/scan_parameters/ratable/ProtocolSupport.py index bb8ffd2..6ebe64d 100644 --- a/SSLTest/src/scan_parameters/non_ratable/ProtocolSupport.py +++ b/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py @@ -1,10 +1,11 @@ import logging from OpenSSL import SSL + +from .PType import PType +from ..connections.connection_utils import create_session_pyopenssl from ..utils import rate_parameter -from ..ratable.PType import PType -from ..connection.connection_utils import create_session_pyopenssl -from ...ssl_scan.SSLv3 import SSLv3 +from ..connections.SSLv3 import SSLv3 class ProtocolSupport: diff --git a/SSLTest/src/scan_parameters/utils.py b/SSLTest/src/scan_parameters/utils.py index 162880d..85eeb67 100644 --- a/SSLTest/src/scan_parameters/utils.py +++ b/SSLTest/src/scan_parameters/utils.py @@ -1,11 +1,10 @@ -import json import logging import re -import os import time from cryptography import x509 from cryptography.hazmat.primitives.asymmetric import rsa, dsa, ec, ed25519, ed448 + from .exceptions.NoIanaPairFound import NoIanaPairFound from .ratable.PType import PType from ..utils import read_json diff --git a/SSLTest/src/ssl_scan/__init__.py b/SSLTest/src/ssl_scan/__init__.py deleted file mode 100644 index 4b681b1..0000000 --- a/SSLTest/src/ssl_scan/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# http://ssllib.sourceforge.net/SSLv2.spec.html -# https://forum.nginx.org/read.php?2,104032,104152 diff --git a/SSLTest/src/text_output/TextOutput.py b/SSLTest/src/text_output/TextOutput.py index 33e5dcf..f7c5fd9 100644 --- a/SSLTest/src/text_output/TextOutput.py +++ b/SSLTest/src/text_output/TextOutput.py @@ -2,7 +2,6 @@ from ..utils import read_json - class TextOutput: def __init__(self, data: str): self.output = '' @@ -19,7 +18,7 @@ def rating_name(self, rating: int): """ return self.ratings[str(rating)] - def text_output(self): + def get_formatted_text(self): """ Call all other text output functions for each port and url. """ @@ -118,44 +117,3 @@ def output_vulnerabilities(self, data: dict): self.output += 'Scanned vulnerabilities:\n' for key, value in list(data.items()): self.output += f'\t{key}->{string_map.get(value)}\n' - - @staticmethod - def dump_to_dict(cipher_suite, certificate_parameters, protocol_support, - certificate_non_parameters, software, vulnerabilities, port, url): - """ - Dump web server parameters to a single dict. - - :param cipher_suite: tuple containing parameters and the worst rating - :param certificate_parameters: tuple containing parameters and the worst rating - :param certificate_non_parameters: certificate parameters such as subject/issuer - :param protocol_support: dictionary of supported tls protocols - :param software: web server software - :param port: scanned port - :param url: scanned url - :param vulnerabilities: scanned vulnerabilities - :return: dictionary - """ - dump = {} - - # Parameters - worst_rating = max([cipher_suite[1], certificate_parameters[1]]) - parameters = {key.name: value for key, value in cipher_suite[0].items()} - parameters.update({key.name: value for key, value in certificate_parameters[0].items()}) - parameters.update({'rating': worst_rating}) - - # Non ratable cert info - certificate_info = {key.name: value for key, value in certificate_non_parameters.items()} - - # Protocol support - protocols = {} - keys = {key.name: value for key, value in protocol_support[0].items()} - for key, value in list(keys.items()): - protocols[key] = value - protocols.update({'rating': protocol_support[1]}) - - dump.update({'parameters': parameters}) - dump.update({'certificate_info': certificate_info}) - dump.update({'protocol_support': protocols}) - dump.update({'web_server_software': software}) - dump.update({'vulnerabilities': vulnerabilities}) - return {f'{url}:{port}': dump} From 7abcdb60b620502e4e5f939be0af16f2be85926e Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Thu, 5 Aug 2021 13:20:44 +0200 Subject: [PATCH 10/16] Add SSLv2 protocol scanning Also create an abstract class SSLvX for classes SSLv2 and SSLv3 to reduce code duplication in the ProtocolSupport class scaning method. --- SSLTest/SSLTest.py | 6 +-- SSLTest/src/run.py | 1 + .../src/scan_parameters/connections/SSLv2.py | 38 ++++++++++++++ .../src/scan_parameters/connections/SSLv3.py | 11 ++--- .../src/scan_parameters/connections/SSLvX.py | 16 ++++++ .../connections/connection_utils.py | 1 + .../ratable/ProtocolSupport.py | 49 ++++++++++++------- 7 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 SSLTest/src/scan_parameters/connections/SSLvX.py diff --git a/SSLTest/SSLTest.py b/SSLTest/SSLTest.py index 8901e70..023de35 100755 --- a/SSLTest/SSLTest.py +++ b/SSLTest/SSLTest.py @@ -43,7 +43,7 @@ def get_help(): return [ {"description": ["Script that scans a webservers cryptographic parameters and vulnerabilities"]}, {"usage": [get_usage()]}, - {"usage_example": [f"{SCRIPTNAME}.py -u github.com -t 1 2"]}, + {"usage_example": [f"{SCRIPTNAME}.py -u https://example.com -t 1 2"]}, {"options": [ ["-u", "--url", "", "Url to scan, required option"], ["-p", "--port", "", "Port or ports (separate with spaces) to scan on (default: [443])"], @@ -51,8 +51,8 @@ def get_help(): "given file"], ["-t", "--test", "", get_tests_help()], ["-fc", "--fix-conf", "", "Allow the use of older versions of TLS protocol (TLSv1 and TLSv1.1) in order to" - " scan a server which still run on these versions. !WARNING!: this may rewrite" - " the contents of a configuration file located at /etc/ssl/openssl.cnf"], + "\n scan a server which still run on these versions. !WARNING!: this may rewrite" + "\n the contents of a configuration file located at /etc/ssl/openssl.cnf"], ["-ns", "--nmap-scan", "", "Use nmap to scan the server version"], ["-nd", "--nmap-discover", "", "Use nmap to discover web server ports"], ["-i", "--info", "", "Output some internal information about the script functions"], diff --git a/SSLTest/src/run.py b/SSLTest/src/run.py index b7eeaeb..878d9fb 100755 --- a/SSLTest/src/run.py +++ b/SSLTest/src/run.py @@ -91,6 +91,7 @@ def json_option(args, output_data): file = open(args.json, 'w') file.write(json_output_data) file.close() + print(f"Output writen to {args.json}", file=sys.stderr) def scan_all_ports(args): diff --git a/SSLTest/src/scan_parameters/connections/SSLv2.py b/SSLTest/src/scan_parameters/connections/SSLv2.py index e69de29..78ba9a2 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv2.py +++ b/SSLTest/src/scan_parameters/connections/SSLv2.py @@ -0,0 +1,38 @@ +from .SSLvX import SSLvX +from ...utils import communicate_data_return_sock + + +class SSLv2(SSLvX): + def __init__(self, url, port): + super().__init__(url, port) + self.protocol = 'SSLv2' + self.client_hello = bytes([ + 0x80, # No padding + 0x2e, # Length + 0x01, # Handshake Message Type + 0x00, 0x02, # Version (SSLv2) + 0x00, 0x15, # Cipher spec length + 0x00, 0x00, # Session ID Length + 0x00, 0x10, # Challenge Length + # Cipher specs (each 3 bytes unlike SSLv3 and up) + 0x01, 0x00, 0x80, 0x02, 0x00, 0x80, 0x03, 0x00, + 0x80, 0x04, 0x00, 0x80, 0x05, 0x00, 0x80, 0x06, + 0x00, 0x40, 0x07, 0x00, 0xc0, + # Challenge + 0xdc, 0x83, 0x85, 0x49, 0x87, 0xdf, 0x42, 0xad, + 0x84, 0x90, 0x51, 0x90, 0x00, 0x14, 0x33, 0xf6 + ]) + self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, "SSLv2 scan") + + def scan_version_support(self): + # No response to SSLv2 client hello + if len(self.response) == 0: + return False + # Test if the response is Content type Alert (0x15) + # and test if alert message is protocol version (0x46) + elif self.response[0] == 0x15 and self.response[6] == 0x46: + return False + # Test if the handshake message type is server hello + elif self.response[2] == 0x04: + return True + return False diff --git a/SSLTest/src/scan_parameters/connections/SSLv3.py b/SSLTest/src/scan_parameters/connections/SSLv3.py index fdf1356..e726598 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv3.py +++ b/SSLTest/src/scan_parameters/connections/SSLv3.py @@ -1,5 +1,6 @@ from cryptography.x509 import load_der_x509_certificate +from .SSLvX import SSLvX from ...utils import read_json, communicate_data_return_sock @@ -15,14 +16,10 @@ def hex_to_int(hex_num: list): return int(result, 16) -class SSLv3: +class SSLv3(SSLvX): def __init__(self, url, port): - self.address = (url, port) + super().__init__(url, port) self.protocol = 'SSLv3' - self.cipher_suite = None - self.certificate = None - self.cert_verified = None - self.timeout = 2 self.client_hello = bytes([ # Record protocol 0x16, # Content type (Handshake) @@ -58,7 +55,7 @@ def __init__(self, url, port): ]) self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, "SSLv3 scan") - def scan_sslv3_version(self): + def scan_version_support(self): # Test if the response is Content type Alert (0x15) # and test if the alert message is handshake failure (0x28) if self.response[0] == 0x15 and self.response[6] == 0x28: diff --git a/SSLTest/src/scan_parameters/connections/SSLvX.py b/SSLTest/src/scan_parameters/connections/SSLvX.py new file mode 100644 index 0000000..0d293ca --- /dev/null +++ b/SSLTest/src/scan_parameters/connections/SSLvX.py @@ -0,0 +1,16 @@ +from abc import ABC, abstractmethod + + +class SSLvX(ABC): + def __init__(self, url, port): + self.address = (url, port) + self.protocol = '' + self.cipher_suite = None + self.certificate = None + self.cert_verified = None + self.timeout = 2 + self.client_hello = bytes([]) + + @abstractmethod + def scan_version_support(self): + pass diff --git a/SSLTest/src/scan_parameters/connections/connection_utils.py b/SSLTest/src/scan_parameters/connections/connection_utils.py index 0f596ed..242ace3 100644 --- a/SSLTest/src/scan_parameters/connections/connection_utils.py +++ b/SSLTest/src/scan_parameters/connections/connection_utils.py @@ -7,6 +7,7 @@ from cryptography.hazmat.backends import default_backend from .SSLv3 import SSLv3 +from .SSLv2 import SSLv2 from ..exceptions.ConnectionTimeoutError import ConnectionTimeoutError from ..exceptions.DNSError import DNSError from ..exceptions.UnknownConnectionError import UnknownConnectionError diff --git a/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py b/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py index 6ebe64d..9e11f55 100644 --- a/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py +++ b/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py @@ -6,12 +6,15 @@ from ..connections.connection_utils import create_session_pyopenssl from ..utils import rate_parameter from ..connections.SSLv3 import SSLv3 +from ..connections.SSLv2 import SSLv2 class ProtocolSupport: def __init__(self, url: str, port: int): self.versions = {PType.protocols: {}, PType.no_protocol: {}} + self.supported_protocols = [] + self.unsupported_protocols = [] self.url = url self.port = port self.rating = 0 @@ -22,15 +25,34 @@ def scan_protocols(self): :return: list of the supported protocols. """ - logging.info('Scanning TLS versions...') + + logging.info('Scanning SSL/TLS versions...') + self.scan_tls_protocols() + self.scan_ssl_protocols() + for protocol in self.supported_protocols: + self.versions[PType.protocols][protocol] = 'N/A' + for no_protocol in self.unsupported_protocols: + self.versions[PType.no_protocol][no_protocol] = 'N/A' + + def scan_ssl_protocols(self): + ssl_versions = [ + SSLv3(self.url, self.port), + SSLv2(self.url, self.port) + ] + for ssl_version in ssl_versions: + result = ssl_version.scan_version_support() + if result: + self.supported_protocols.append(ssl_version.protocol) + else: + self.unsupported_protocols.append(ssl_version.protocol) + + def scan_tls_protocols(self): ssl_versions = { SSL.TLSv1_METHOD: 'TLSv1.0', SSL.TLSv1_1_METHOD: 'TLSv1.1', SSL.TLSv1_2_METHOD: 'TLSv1.2', SSL.SSLv23_METHOD: 'unknown' } - supported_protocols = [] - unsupported_protocols = [] for num_version in list(ssl_versions.keys()): context = SSL.Context(num_version) version = ssl_versions[num_version] @@ -41,26 +63,15 @@ def scan_protocols(self): if version == 'TLSv1': version += '.0' ssl_socket.close() - if version not in supported_protocols: - supported_protocols.append(version) + if version not in self.supported_protocols: + self.supported_protocols.append(version) except SSL.Error as e: if version == 'unknown': continue - unsupported_protocols.append(version) + self.unsupported_protocols.append(version) # Need to do this since there is no explicit option for TLSv1.3 - if 'TLSv1.3' not in supported_protocols: - unsupported_protocols.append('TLSv1.3') - # SSLv3 scanning - sslv3 = SSLv3(self.url, self.port) - result = sslv3.scan_sslv3_version() - if result: - supported_protocols.append("SSLv3") - else: - unsupported_protocols.append("SSLv3") - for protocol in supported_protocols: - self.versions[PType.protocols][protocol] = 'N/A' - for no_protocol in unsupported_protocols: - self.versions[PType.no_protocol][no_protocol] = 'N/A' + if 'TLSv1.3' not in self.supported_protocols: + self.unsupported_protocols.append('TLSv1.3') def rate_protocols(self): """ From dfbdc5f1e1110af5fe4cc55c08109f509cd6f430 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Thu, 5 Aug 2021 13:52:51 +0200 Subject: [PATCH 11/16] Fix bug in SSLv2 and SSLv3 protocol scanning --- SSLTest/src/fix_openssl_config.py | 6 +++++- SSLTest/src/scan_parameters/connections/SSLv2.py | 2 +- SSLTest/src/scan_parameters/connections/SSLv3.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SSLTest/src/fix_openssl_config.py b/SSLTest/src/fix_openssl_config.py index 7a3ca81..27ee117 100755 --- a/SSLTest/src/fix_openssl_config.py +++ b/SSLTest/src/fix_openssl_config.py @@ -1,5 +1,8 @@ #!/usr/bin/python3 +import os + + def fix_openssl_config(): config_file_name = '/etc/ssl/openssl.cnf' config_file = open(config_file_name, 'r') @@ -22,7 +25,8 @@ def fix_openssl_config(): append[1] = True if append[0] or append[1]: - correct_config_file = open('../../resources/correct_openssl_conf.txt', 'r') + root_dir = os.path.dirname(os.path.abspath(__file__)) + correct_config_file = open(f'{root_dir}/../../resources/correct_openssl_conf.txt', 'r') correct_config = correct_config_file.read() with open(config_file_name, 'w') as f: f.seek(0, 0) diff --git a/SSLTest/src/scan_parameters/connections/SSLv2.py b/SSLTest/src/scan_parameters/connections/SSLv2.py index 78ba9a2..1192c81 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv2.py +++ b/SSLTest/src/scan_parameters/connections/SSLv2.py @@ -30,7 +30,7 @@ def scan_version_support(self): return False # Test if the response is Content type Alert (0x15) # and test if alert message is protocol version (0x46) - elif self.response[0] == 0x15 and self.response[6] == 0x46: + elif self.response[0] == 0x15 and (self.response[6] == 0x28 or self.response[6] == 0x46): return False # Test if the handshake message type is server hello elif self.response[2] == 0x04: diff --git a/SSLTest/src/scan_parameters/connections/SSLv3.py b/SSLTest/src/scan_parameters/connections/SSLv3.py index e726598..3e60b62 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv3.py +++ b/SSLTest/src/scan_parameters/connections/SSLv3.py @@ -58,7 +58,8 @@ def __init__(self, url, port): def scan_version_support(self): # Test if the response is Content type Alert (0x15) # and test if the alert message is handshake failure (0x28) - if self.response[0] == 0x15 and self.response[6] == 0x28: + # or protocol version alert (0x46) + if self.response[0] == 0x15 and (self.response[6] == 0x28 or self.response[6] == 0x46): return False return True From cdefe21a1ec428db450c6f70d83ce554d9f7a3b1 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Fri, 6 Aug 2021 11:00:28 +0200 Subject: [PATCH 12/16] Fix bug in test option and improve SSL version scanning Bug with the newly added test case for 0 with None as its function --- SSLTest/SSLTest.py | 19 +++++++------------ SSLTest/src/run.py | 16 ++++++++++------ .../src/scan_parameters/connections/SSLv3.py | 8 ++++++-- .../connections/connection_utils.py | 8 +++----- .../exceptions/UnknownConnectionError.py | 4 ---- SSLTest/src/scan_vulnerabilities/utils.py | 6 +++--- 6 files changed, 29 insertions(+), 32 deletions(-) delete mode 100644 SSLTest/src/scan_parameters/exceptions/UnknownConnectionError.py diff --git a/SSLTest/SSLTest.py b/SSLTest/SSLTest.py index 023de35..0a553b5 100755 --- a/SSLTest/SSLTest.py +++ b/SSLTest/SSLTest.py @@ -22,11 +22,6 @@ def run(self): ptmisclib.ptprint(ptmisclib.out_if(self.ptjsonlib.get_all_json(), "", self.use_json)) -def get_usage(): - return f"{SCRIPTNAME}.py -u url <-h> <-ns> <-nd> <-p port > <-j > " \ - f"<-t test_num > <-fc> <-i> <-v>" - - def get_tests_help(): tests_help = 'test the server for a specified vulnerability\n' \ 'possible vulnerabilities (separate with spaces):\n' @@ -34,15 +29,14 @@ def get_tests_help(): test_number = key test_desc = value[1] tests_help += f'{" " * 4}{test_number}: {test_desc}\n' - tests_help += 'if this argument isn\'t specified all tests will be ran\n' \ - 'if 0 is given as a test number no tests will be ran' + tests_help += 'if this argument isn\'t specified all tests will be ran' return tests_help def get_help(): return [ {"description": ["Script that scans a webservers cryptographic parameters and vulnerabilities"]}, - {"usage": [get_usage()]}, + {"usage": [f"{SCRIPTNAME}.py "]}, {"usage_example": [f"{SCRIPTNAME}.py -u https://example.com -t 1 2"]}, {"options": [ ["-u", "--url", "", "Url to scan, required option"], @@ -60,7 +54,8 @@ def get_help(): ["-v", "--version", "", "Show script version and exit"], ["-h", "--help", "", "Show this help message and exit"] ] - }] + } + ] def print_help(): @@ -68,7 +63,7 @@ def print_help(): def parse_args(): - parser = argparse.ArgumentParser(add_help=False, usage=get_usage()) + parser = argparse.ArgumentParser(add_help=False, usage=f"{SCRIPTNAME}.py ") required = parser.add_argument_group("required arguments") required.add_argument("-u", "--url", required=True, metavar="url") parser.add_argument("-p", "--port", default=[443], type=int, nargs="+", metavar="port") @@ -97,9 +92,9 @@ def check_test_option(tests): :param tests: test argument :return: """ - tests_switcher = get_tests_switcher() - if not tests or 0 in tests: + if not tests: return + tests_switcher = get_tests_switcher() test_numbers = [test for test in tests_switcher.keys()] unknown_tests = list(filter(lambda test: test not in test_numbers, tests)) if unknown_tests: diff --git a/SSLTest/src/run.py b/SSLTest/src/run.py index 878d9fb..e6daab0 100755 --- a/SSLTest/src/run.py +++ b/SSLTest/src/run.py @@ -26,6 +26,7 @@ def get_tests_switcher(): return { + 0: (None, 'No test'), 1: (heartbleed.scan, 'Heartbleed'), 2: (ccs_injection.scan, 'CCS injection'), 3: (rene.scan, 'Insecure renegotiation'), @@ -65,7 +66,8 @@ def vulnerability_scan(address, tests, version): tests_switcher = get_tests_switcher() # if no -t argument is present if not tests: - scans = [value for value in tests_switcher.values()] + # Remove test at 0th index + scans = [value for value in list(tests_switcher.values())[1:]] elif 0 in tests: return {} else: @@ -192,7 +194,13 @@ def scan(args, port: int): :return: a single dictionary containing scanned data """ logging.info(f'Scanning for {args.url}:{port}') - certificate, cert_verified, cipher_suite, protocol = get_website_info(args.url, port) + + protocol_support = ProtocolSupport(args.url, port) + protocol_support.scan_protocols() + protocol_support.rate_protocols() + + certificate, cert_verified, cipher_suite, protocol = get_website_info(args.url, port, + protocol_support.supported_protocols) cipher_suite = CipherSuite(cipher_suite, protocol) cipher_suite.parse_cipher_suite() @@ -203,10 +211,6 @@ def scan(args, port: int): certificate.parse_certificate() certificate.rate_certificate() - protocol_support = ProtocolSupport(args.url, port) - protocol_support.scan_protocols() - protocol_support.rate_protocols() - versions = WebServerSoft(args.url, port, args.nmap_scan) versions.scan_server_software() diff --git a/SSLTest/src/scan_parameters/connections/SSLv3.py b/SSLTest/src/scan_parameters/connections/SSLv3.py index 3e60b62..fc21902 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv3.py +++ b/SSLTest/src/scan_parameters/connections/SSLv3.py @@ -56,12 +56,16 @@ def __init__(self, url, port): self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, "SSLv3 scan") def scan_version_support(self): + if len(self.response) == 0: + return False # Test if the response is Content type Alert (0x15) # and test if the alert message is handshake failure (0x28) # or protocol version alert (0x46) - if self.response[0] == 0x15 and (self.response[6] == 0x28 or self.response[6] == 0x46): + elif self.response[0] == 0x15 and (self.response[6] == 0x28 or self.response[6] == 0x46): return False - return True + elif self.response[0] == 0x16 and self.response[5] == 0x02: + return True + return False def parse_cipher_suite(self): cipher_suites = read_json('iana_cipher_suites.json') diff --git a/SSLTest/src/scan_parameters/connections/connection_utils.py b/SSLTest/src/scan_parameters/connections/connection_utils.py index 242ace3..82aaaba 100644 --- a/SSLTest/src/scan_parameters/connections/connection_utils.py +++ b/SSLTest/src/scan_parameters/connections/connection_utils.py @@ -10,16 +10,16 @@ from .SSLv2 import SSLv2 from ..exceptions.ConnectionTimeoutError import ConnectionTimeoutError from ..exceptions.DNSError import DNSError -from ..exceptions.UnknownConnectionError import UnknownConnectionError from ..utils import convert_openssh_to_iana, incremental_sleep -def get_website_info(url: str, port: int): +def get_website_info(url: str, port: int, supported_protocols): """ Gather objects to be used in rating a web server. Uses functions in this module to create a connection and get the servers certificate, cipher suite and protocol used in the connection. + :param supported_protocols: :param port: port to scan on :param url: url of the webserver :return: @@ -33,7 +33,7 @@ def get_website_info(url: str, port: int): cipher_suite, protocol = get_cipher_suite_and_protocol(ssl_socket) certificate = get_certificate(ssl_socket) ssl_socket.close() - except ssl.SSLError: + except (ssl.SSLError, ConnectionResetError) as e: sslv3 = SSLv3(url, port) sslv3.parse_cipher_suite() sslv3.parse_certificate() @@ -129,8 +129,6 @@ def create_session(url: str, port: int, context: ssl.SSLContext = ssl.create_def raise ConnectionTimeoutError() except socket.gaierror: raise DNSError() - except ConnectionResetError as e: - raise UnknownConnectionError(e) except socket.error as e: ssl_socket.close() sleep = incremental_sleep(sleep, e, 1) diff --git a/SSLTest/src/scan_parameters/exceptions/UnknownConnectionError.py b/SSLTest/src/scan_parameters/exceptions/UnknownConnectionError.py deleted file mode 100644 index 76ec014..0000000 --- a/SSLTest/src/scan_parameters/exceptions/UnknownConnectionError.py +++ /dev/null @@ -1,4 +0,0 @@ -class UnknownConnectionError(Exception): - - def __init__(self, exception): - super().__init__(exception) diff --git a/SSLTest/src/scan_vulnerabilities/utils.py b/SSLTest/src/scan_vulnerabilities/utils.py index ec48f37..fdd4ddb 100644 --- a/SSLTest/src/scan_vulnerabilities/utils.py +++ b/SSLTest/src/scan_vulnerabilities/utils.py @@ -1,8 +1,8 @@ def is_server_hello(server_hello): # Server hello content type in record protocol try: - if server_hello[5] != 0x02: - return False + if server_hello[5] == 0x02 and server_hello[0] == 0x16: + return True except IndexError: return False - return True + return False From 5877f4ff98be0c4a04c3c866daacce15e8673750 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Fri, 6 Aug 2021 12:31:46 +0200 Subject: [PATCH 13/16] Add all SSLv3 cipher suites --- .../src/scan_parameters/connections/SSLv3.py | 22 +++++++++++++++---- SSLTest/src/utils.py | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/SSLTest/src/scan_parameters/connections/SSLv3.py b/SSLTest/src/scan_parameters/connections/SSLv3.py index fc21902..349ef5d 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv3.py +++ b/SSLTest/src/scan_parameters/connections/SSLv3.py @@ -1,3 +1,5 @@ +import ssl + from cryptography.x509 import load_der_x509_certificate from .SSLvX import SSLvX @@ -24,10 +26,10 @@ def __init__(self, url, port): # Record protocol 0x16, # Content type (Handshake) 0x03, 0x00, # Version (SSLv3) - 0x00, 0x8f, # Length + 0x00, 0xcd, # Length # Handshake protocol 0x01, # Handshake type - 0x00, 0x00, 0x8b, # Length + 0x00, 0x00, 0xc9, # Length 0x03, 0x00, # Version # Random bytes 0xa9, 0x09, 0x3f, 0x70, 0xad, 0xdc, 0xde, 0x4f, @@ -35,7 +37,7 @@ def __init__(self, url, port): 0x1b, 0x3b, 0x34, 0x37, 0x23, 0xd8, 0xd4, 0x5d, 0x92, 0x40, 0x4b, 0x01, 0x9e, 0x55, 0xf7, 0x2f, 0x00, # Session id length - 0x00, 0x64, # Cipher suites length + 0x00, 0xa2, # Cipher suites length # Cipher suites 0xc0, 0x14, 0xc0, 0x0a, 0x00, 0x39, 0x00, 0x38, 0x00, 0x37, 0x00, 0x36, 0x00, 0x88, 0x00, 0x87, @@ -49,7 +51,15 @@ def __init__(self, url, port): 0xc0, 0x0c, 0xc0, 0x02, 0x00, 0x05, 0x00, 0x04, 0xc0, 0x12, 0xc0, 0x08, 0x00, 0x16, 0x00, 0x13, 0x00, 0x10, 0x00, 0x0d, 0xc0, 0x0d, 0xc0, 0x03, - 0x00, 0x0a, 0x00, 0xff, + 0x00, 0x0a, 0x00, 0xff, 0xc0, 0x22, 0xc0, 0x21, + 0xc0, 0x20, 0xc0, 0x19, 0x00, 0x3a, 0x00, 0x89, + 0x00, 0x8d, 0xc0, 0x1f, 0xc0, 0x1e, 0xc0, 0x1d, + 0xc0, 0x18, 0x00, 0x34, 0x00, 0x9b, 0x00, 0x46, + 0x00, 0x8c, 0xc0, 0x16, 0x00, 0x18, 0x00, 0x8a, + 0xc0, 0x1c, 0xc0, 0x1b, 0xc0, 0x1a, 0xc0, 0x17, + 0x00, 0x1b, 0x00, 0x8b, 0xc0, 0x10, 0xc0, 0x06, + 0xc0, 0x15, 0xc0, 0x0b, 0xc0, 0x01, 0x00, 0x02, + 0x00, 0x01, 0x01, # Compression methods length 0x00 # Compression methods ]) @@ -68,6 +78,8 @@ def scan_version_support(self): return False def parse_cipher_suite(self): + if len(self.response) == 0: + return cipher_suites = read_json('iana_cipher_suites.json') sess_id_len_idx = 43 # Always fixed cipher_suite_idx = self.response[sess_id_len_idx] + sess_id_len_idx + 1 @@ -76,6 +88,8 @@ def parse_cipher_suite(self): self.cipher_suite = cipher_suites[cipher_suites_bytes] def parse_certificate(self): + if len(self.response) == 0: + return # Length is always at the same place in server_hello (idx 3, 4) server_hello_len = hex_to_int([self.response[3], self.response[4]]) # +4 -- Length index in server_hello diff --git a/SSLTest/src/utils.py b/SSLTest/src/utils.py index 5339a33..90a8bbb 100644 --- a/SSLTest/src/utils.py +++ b/SSLTest/src/utils.py @@ -52,7 +52,7 @@ def receive_data(sock, timeout, debug_source=None): begin = time() else: sleep(0.1) - except socket.timeout: + except (socket.timeout, ConnectionResetError): pass return bytes(all_data) From 5e282a9c1115c324a6cc02ca97ec1a3766bb9837 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Fri, 6 Aug 2021 12:43:03 +0200 Subject: [PATCH 14/16] Add all cipher suites for scanning --- SSLTest/src/scan_parameters/connections/connection_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SSLTest/src/scan_parameters/connections/connection_utils.py b/SSLTest/src/scan_parameters/connections/connection_utils.py index 82aaaba..f3e3ce7 100644 --- a/SSLTest/src/scan_parameters/connections/connection_utils.py +++ b/SSLTest/src/scan_parameters/connections/connection_utils.py @@ -83,6 +83,7 @@ def create_session_pyopenssl(url: str, port: int, context: SSL.Context): :return: created secure socket """ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + context.set_cipher_list(b'ALL') ssl_socket = SSL.Connection(context, sock) sleep = 0 # Loop until there is a valid response or after 15 seconds @@ -110,6 +111,7 @@ def create_session(url: str, port: int, context: ssl.SSLContext = ssl.create_def cert_verified = True context.check_hostname = True context.verify_mode = ssl.VerifyMode.CERT_REQUIRED + context.set_ciphers('ALL') sleep = 0 # Loop until there is a valid response or after 15 seconds # because of rate limiting on some servers From 7140c464696112cefb63862961f82adee043ca38 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Sat, 7 Aug 2021 11:35:47 +0200 Subject: [PATCH 15/16] Add SSLv2 main connection parameters and fix TLSv1.0 bug Since the cipher suite is choosen by the client and not the server a cipher suite is hardcoded into the `parse_cipher_suite` function since there are only 7 cipher suites in SSLv2 and all of them are using MD5 hashing which is insecure for now it doesn't matter which one is choosen. If multiple cipher suite scanning is implemented the hardcoded cipher suite can be changed. Also fix the main connection displaying TLSv1 instead of TLSv1.0 --- .../src/scan_parameters/connections/SSLv2.py | 21 +++++++++++-- .../src/scan_parameters/connections/SSLv3.py | 19 ++---------- .../src/scan_parameters/connections/SSLvX.py | 31 +++++++++++++++++++ .../connections/connection_utils.py | 24 +++++++++----- .../scan_parameters/ratable/CipherSuite.py | 5 ++- .../ratable/ProtocolSupport.py | 1 + resources/cipher_parameters.json | 2 +- resources/security_levels.json | 4 +-- 8 files changed, 77 insertions(+), 30 deletions(-) diff --git a/SSLTest/src/scan_parameters/connections/SSLv2.py b/SSLTest/src/scan_parameters/connections/SSLv2.py index 1192c81..94a91c7 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv2.py +++ b/SSLTest/src/scan_parameters/connections/SSLv2.py @@ -1,5 +1,6 @@ +from cryptography.x509 import load_der_x509_certificate + from .SSLvX import SSLvX -from ...utils import communicate_data_return_sock class SSLv2(SSLvX): @@ -22,7 +23,6 @@ def __init__(self, url, port): 0xdc, 0x83, 0x85, 0x49, 0x87, 0xdf, 0x42, 0xad, 0x84, 0x90, 0x51, 0x90, 0x00, 0x14, 0x33, 0xf6 ]) - self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, "SSLv2 scan") def scan_version_support(self): # No response to SSLv2 client hello @@ -36,3 +36,20 @@ def scan_version_support(self): elif self.response[2] == 0x04: return True return False + + def parse_cipher_suite(self): + # TODO: temporary, change if multiple cipher suites rating is implemented + # One of the SSLv2 Cipher suites since the client is choosing the cipher suite + self.cipher_suite = 'DES_64_CBC_WITH_MD5' + + def parse_certificate(self): + print(self.response[13]) + certificate_length = SSLvX.hex_to_int([ + self.response[7], + self.response[8] + ]) + certificate_in_bytes = self.response[13:certificate_length + 13] + self.certificate = load_der_x509_certificate(certificate_in_bytes) + + def verify_cert(self): + self.cert_verified = False diff --git a/SSLTest/src/scan_parameters/connections/SSLv3.py b/SSLTest/src/scan_parameters/connections/SSLv3.py index 349ef5d..632cc3b 100644 --- a/SSLTest/src/scan_parameters/connections/SSLv3.py +++ b/SSLTest/src/scan_parameters/connections/SSLv3.py @@ -3,19 +3,7 @@ from cryptography.x509 import load_der_x509_certificate from .SSLvX import SSLvX -from ...utils import read_json, communicate_data_return_sock - - -def hex_to_int(hex_num: list): - result = '0x' - # {}:02x: - # {}: -- value - # 0 -- padding with zeros - # 2 -- number digits - # x -- hex format - for num in hex_num: - result += f'{num:02x}' - return int(result, 16) +from ...utils import read_json class SSLv3(SSLvX): @@ -63,7 +51,6 @@ def __init__(self, url, port): 0x01, # Compression methods length 0x00 # Compression methods ]) - self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, "SSLv3 scan") def scan_version_support(self): if len(self.response) == 0: @@ -91,14 +78,14 @@ def parse_certificate(self): if len(self.response) == 0: return # Length is always at the same place in server_hello (idx 3, 4) - server_hello_len = hex_to_int([self.response[3], self.response[4]]) + server_hello_len = SSLvX.hex_to_int([self.response[3], self.response[4]]) # +4 -- Length index in server_hello record_protocol_certificate_begin_idx = server_hello_len + 4 + 1 # +5 -- Certificate index in record layer handshake_certificate_idx = record_protocol_certificate_begin_idx + 5 # +7 -- Certificate length index in handshake protocol: certificate certificate_len_idx = handshake_certificate_idx + 7 - certificate_len = hex_to_int([ + certificate_len = SSLvX.hex_to_int([ self.response[certificate_len_idx], self.response[certificate_len_idx + 1], self.response[certificate_len_idx + 2] diff --git a/SSLTest/src/scan_parameters/connections/SSLvX.py b/SSLTest/src/scan_parameters/connections/SSLvX.py index 0d293ca..4f868ea 100644 --- a/SSLTest/src/scan_parameters/connections/SSLvX.py +++ b/SSLTest/src/scan_parameters/connections/SSLvX.py @@ -1,3 +1,5 @@ +from ...utils import communicate_data_return_sock + from abc import ABC, abstractmethod @@ -9,8 +11,37 @@ def __init__(self, url, port): self.certificate = None self.cert_verified = None self.timeout = 2 + self.response = b'' self.client_hello = bytes([]) + def send_client_hello(self): + self.response, _ = communicate_data_return_sock(self.address, self.client_hello, self.timeout, + self.__class__.__name__) + @abstractmethod def scan_version_support(self): pass + + @abstractmethod + def parse_cipher_suite(self): + pass + + @abstractmethod + def parse_certificate(self): + pass + + @abstractmethod + def verify_cert(self): + pass + + @staticmethod + def hex_to_int(hex_num: list): + result = '0x' + # {}:02x: + # {}: -- value + # 0 -- padding with zeros + # 2 -- number digits + # x -- hex format + for num in hex_num: + result += f'{num:02x}' + return int(result, 16) diff --git a/SSLTest/src/scan_parameters/connections/connection_utils.py b/SSLTest/src/scan_parameters/connections/connection_utils.py index f3e3ce7..ceebd24 100644 --- a/SSLTest/src/scan_parameters/connections/connection_utils.py +++ b/SSLTest/src/scan_parameters/connections/connection_utils.py @@ -34,14 +34,21 @@ def get_website_info(url: str, port: int, supported_protocols): certificate = get_certificate(ssl_socket) ssl_socket.close() except (ssl.SSLError, ConnectionResetError) as e: - sslv3 = SSLv3(url, port) - sslv3.parse_cipher_suite() - sslv3.parse_certificate() - sslv3.verify_cert() - cipher_suite = sslv3.cipher_suite - certificate = sslv3.certificate - cert_verified = sslv3.cert_verified - protocol = sslv3.protocol + ssl_protocols = [ + SSLv3(url, port), + SSLv2(url, port) + ] + chosen_protocol = ssl_protocols[0] + if ['SSLv2'] == supported_protocols: + chosen_protocol = ssl_protocols[1] + chosen_protocol.send_client_hello() + chosen_protocol.parse_cipher_suite() + chosen_protocol.parse_certificate() + chosen_protocol.verify_cert() + cipher_suite = chosen_protocol.cipher_suite + certificate = chosen_protocol.certificate + cert_verified = chosen_protocol.cert_verified + protocol = chosen_protocol.protocol return certificate, cert_verified, cipher_suite, protocol @@ -83,6 +90,7 @@ def create_session_pyopenssl(url: str, port: int, context: SSL.Context): :return: created secure socket """ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + # sock.settimeout(5) context.set_cipher_list(b'ALL') ssl_socket = SSL.Connection(context, sock) sleep = 0 diff --git a/SSLTest/src/scan_parameters/ratable/CipherSuite.py b/SSLTest/src/scan_parameters/ratable/CipherSuite.py index 59f0c94..97b692b 100644 --- a/SSLTest/src/scan_parameters/ratable/CipherSuite.py +++ b/SSLTest/src/scan_parameters/ratable/CipherSuite.py @@ -22,7 +22,8 @@ def parse_cipher_suite(self): """ json_data = read_json('cipher_parameters.json') raw_parameters = self.cipher_suite.split('_') - raw_parameters.remove('TLS') + if 'TLS' in raw_parameters: + raw_parameters.remove('TLS') parameter_types = list(self.parameters.keys()) # For each parameter iterate through each enum value until a match is found for p_raw in raw_parameters: @@ -53,3 +54,5 @@ def parse_protocol_version(self): self.parameters[PType.protocol] = {self.protocol: 0} if self.protocol == 'TLSv1.3': self.parameters[PType.kex_algorithm] = {'ECDHE': 0} + if self.protocol == 'TLSv1': + self.parameters[PType.protocol] = {'TLSv1.0': self.parameters[PType.protocol]['TLSv1']} diff --git a/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py b/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py index 9e11f55..a01d642 100644 --- a/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py +++ b/SSLTest/src/scan_parameters/ratable/ProtocolSupport.py @@ -40,6 +40,7 @@ def scan_ssl_protocols(self): SSLv2(self.url, self.port) ] for ssl_version in ssl_versions: + ssl_version.send_client_hello() result = ssl_version.scan_version_support() if result: self.supported_protocols.append(ssl_version.protocol) diff --git a/resources/cipher_parameters.json b/resources/cipher_parameters.json index a9a4972..fdd01ad 100644 --- a/resources/cipher_parameters.json +++ b/resources/cipher_parameters.json @@ -2,7 +2,7 @@ "kex_algorithm": "DH,DHE,ECDH,ECDHE,SRP,ECCPWD,GOSTR341112,RSA", "cert_pub_key_algorithm": "anon,KRB5,PSK,DSS", "sym_enc_algorithm": "RC4,RC2,IDEA,DES40,DES,3DES,AES,CAMELLIA,SEED,SM4,SM3,ARIA,KUZNYECHIK,MAGMA,CHACHA20", - "sym_enc_algorithm_key_length": "40,128,256", + "sym_enc_algorithm_key_length": "40,64,128,256", "sym_enc_algorithm_block_mode": "CBC,EDE,GCM,CCM,CTR", "sym_ecn_algorithm_block_mode_number": "8", "hash_function": "MD5,SHA,SHA256,SHA384", diff --git a/resources/security_levels.json b/resources/security_levels.json index d2c1985..702ca00 100644 --- a/resources/security_levels.json +++ b/resources/security_levels.json @@ -15,13 +15,13 @@ "1": "AES", "2": "", "3": "TDEA,2DES,3DES", - "4": "SKIPJACK, RC4" + "4": "SKIPJACK,RC4,DES" }, "sym_enc_algorithm_key_length": { "1": "AES,>=128", "2": "", "3": "3DES,>=168,2DES,>=112,TDEA,>=168", - "4": "AES,<<128,3DES,<<168,2DES,<<112,TDEA,<<168,RC4,>=0" + "4": "AES,<<128,3DES,<<168,2DES,<<112,TDEA,<<168,RC4,>=0,DES,>=0" }, "sym_enc_algorithm_block_mode": { "1": "GCM,CCM", From 6636560e935c96f3b8fbf2d46fa6a23fa3603f93 Mon Sep 17 00:00:00 2001 From: SamoKopecky Date: Mon, 9 Aug 2021 12:56:51 +0200 Subject: [PATCH 16/16] Update README.md --- README.md | 29 +++++++++++++++++-- SSLTest/SSLTest.py | 2 +- .../non_ratable/WebServerSoft.py | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6399fa8..3717adc 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ ``` # SSLTest +Script that scans web servers cryptographic parameters and vulnerabilities ## Installation @@ -24,12 +25,36 @@ $ sudo ptmanager -ut SSLTest ## Options ``` -TODO +-u --url Url to scan, required option +-p --port Port or ports (separate with spaces) to scan on (default: [443]) +-j --json change output to json format, if a file name is specified output is + written to the given file +-t --test test the server for a specified vulnerability + possible vulnerabilities (separate with spaces): + 0: No test + 1: Heartbleed + 2: CCS injection + 3: Insecure renegotiation + 4: ZombiePOODLE/GOLDENDOOLDE + 5: Session ticket support + 6: CRIME + 7: RC4 support + if this argument isn't specified all tests will be ran +-fc --fix-conf Allow the use of older versions of TLS protocol (TLSv1 and TLSv1.1) + in order to scan a server which still run on these versions. + !WARNING!: this may rewrite the contents of a configuration file + located at /etc/ssl/openssl.cnf +-ns --nmap-scan Use nmap to scan the server version +-nd --nmap-discover Use nmap to discover web server ports +-i --info Output some internal information about the script functions +-d --debug Output debug information +-v --version Show script version and exit +-h --help Show this help message and exit ``` ## Usage examples ``` -TODO +$ SSLTest.py -u https://example.com -t 1 2 ``` ## Version History diff --git a/SSLTest/SSLTest.py b/SSLTest/SSLTest.py index 0a553b5..da5e722 100755 --- a/SSLTest/SSLTest.py +++ b/SSLTest/SSLTest.py @@ -35,7 +35,7 @@ def get_tests_help(): def get_help(): return [ - {"description": ["Script that scans a webservers cryptographic parameters and vulnerabilities"]}, + {"description": ["Script that scans web servers cryptographic parameters and vulnerabilities "]}, {"usage": [f"{SCRIPTNAME}.py "]}, {"usage_example": [f"{SCRIPTNAME}.py -u https://example.com -t 1 2"]}, {"options": [ diff --git a/SSLTest/src/scan_parameters/non_ratable/WebServerSoft.py b/SSLTest/src/scan_parameters/non_ratable/WebServerSoft.py index 1b8c1cb..3972cf0 100644 --- a/SSLTest/src/scan_parameters/non_ratable/WebServerSoft.py +++ b/SSLTest/src/scan_parameters/non_ratable/WebServerSoft.py @@ -52,7 +52,7 @@ def scan_software_http(self): requests.exceptions.ConnectionError, requests.exceptions.Timeout, requests.exceptions.ReadTimeout): - value = 'unable to connect' + value = 'unable to connect (try scanning with nmap)' self.versions["http_header"] = value def scan_server_software(self):