mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
gh-pages
This commit is contained in:
parent
ef02e32ec7
commit
0009b1a22f
28 changed files with 74 additions and 2405 deletions
1
CNAME
Normal file
1
CNAME
Normal file
|
@ -0,0 +1 @@
|
||||||
|
www.opensnitch.io
|
225
LICENSE
225
LICENSE
|
@ -1,225 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
|
@ -1,7 +0,0 @@
|
||||||
exclude *.pyc .DS_Store .gitignore MANIFEST.in
|
|
||||||
include setup.py
|
|
||||||
include distribute_setup.py
|
|
||||||
include README.md
|
|
||||||
include LICENSE
|
|
||||||
recursive-include bin *
|
|
||||||
recursive-include opensnitch *.py
|
|
85
README.md
85
README.md
|
@ -1,85 +0,0 @@
|
||||||
# OpenSnitch
|
|
||||||
|
|
||||||
OpenSnitch is a GNU/Linux port of the Little Snitch application firewall.
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://raw.githubusercontent.com/evilsocket/opensnitch/master/screenshot.png" alt="OpenSnitch"/>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
**Warning: This is still alpha quality software, don't rely on it (yet) for your computer security.**
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
You'll need a GNU/Linux distribution with `iptables`, `NFQUEUE` and `ftrace` kernel support. In addition, you'll need the following package dependencies:
|
|
||||||
|
|
||||||
### Debian/Ubuntu:
|
|
||||||
|
|
||||||
sudo apt install build-essential \
|
|
||||||
libcap-dev \
|
|
||||||
libnetfilter-queue-dev \
|
|
||||||
python3-dbus \
|
|
||||||
python3-dev \
|
|
||||||
python3-gi \
|
|
||||||
python3-pyinotify \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-setuptools
|
|
||||||
|
|
||||||
### Fedora:
|
|
||||||
|
|
||||||
sudo dnf install @C-development \
|
|
||||||
libcap-devel \
|
|
||||||
libnetfilter_queue-devel \
|
|
||||||
python3-dbus \
|
|
||||||
python3-devel \
|
|
||||||
python3-inotify \
|
|
||||||
python3-qt5 \
|
|
||||||
python3-setuptools
|
|
||||||
|
|
||||||
### Arch:
|
|
||||||
|
|
||||||
There is an AUR package available at https://aur.archlinux.org/packages/opensnitch-git/
|
|
||||||
|
|
||||||
## Build and Install
|
|
||||||
|
|
||||||
cd opensnitch
|
|
||||||
sudo python3 setup.py install
|
|
||||||
|
|
||||||
## Run
|
|
||||||
|
|
||||||
sudo -HE opensnitchd
|
|
||||||
opensnitch-qt
|
|
||||||
|
|
||||||
## Known Issues / Future Improvements
|
|
||||||
|
|
||||||
Before opening an issue, keep in mind that the current implementation is just an experiment to see the doability of the project, future improvements of OpenSnitch will include:
|
|
||||||
|
|
||||||
Split the project into `opensnitchd`, `opensnitch-ui` and `opensnitch-ruleman`:
|
|
||||||
|
|
||||||
* `opensnitchd` will be a (C++ ? TBD) daemon, running as root with the main logic. It'll fix [this](https://github.com/evilsocket/opensnitch/issues/28).
|
|
||||||
* `opensnitch-ui` python (?) UI running as normal user, getting the daemon messages. Will fix [this](https://github.com/evilsocket/opensnitch/issues/20).
|
|
||||||
* `opensnitch-ruleman` python (?) UI for rule editing.
|
|
||||||
|
|
||||||
## How Does It Work
|
|
||||||
|
|
||||||
OpenSnitch is an application level firewall, meaning then while running, it will detect and alert the user for every outgoing connection applications he's running are creating. This can be extremely **effective to detect and block unwanted connections** on your system that might be caused by a security breach, **causing data exfiltration to be much harder for an attacker**.
|
|
||||||
In order to do that, OpenSnitch relies on `NFQUEUE`, an `iptables` target/extension which allows an userland software to intercept IP packets and either `ALLOW` or `DROP` them, once started it'll install the following iptables rules:
|
|
||||||
|
|
||||||
OUTPUT -t mangle -m conntrack --ctstate NEW -j NFQUEUE --queue-num 0 --queue-bypass
|
|
||||||
|
|
||||||
This will use `conntrack` iptables extension to pass all newly created connection packets to NFQUEUE number 0 (the one OpenSnitch is listening on), and then:
|
|
||||||
|
|
||||||
INPUT --protocol udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
|
|
||||||
|
|
||||||
This will also redirect DNS queries to OpenSnitch, allowing the software to perform and IP -> hostname resolution without performing active DNS queries itself.
|
|
||||||
|
|
||||||
Once a new connection is detected, the software relies on the `ftrace` kernel extension in order to track which PID (therefore which process) is creating the connection.
|
|
||||||
|
|
||||||
If `ftrace` is not available for your kernel, OpenSnitch will fallback using the `/proc` filesystem, even if this method will also work, it's vulnerable to application path manipulation as [described in this issue](https://github.com/evilsocket/opensnitch/issues/12), therefore **it's highly suggested to run OpenSnitch on a ftrace enabled kernel**.
|
|
||||||
|
|
||||||
## TODOs
|
|
||||||
|
|
||||||
grep -r TODO opensnitch | cut -d '#' -f 2 | sort -u
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is copyleft of [Simone Margaritelli](http://www.evilsocket.net/) and released under the GPL 3 license.
|
|
|
@ -1,44 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from argparse import ArgumentParser
|
|
||||||
from opensnitch.ui import QtApp
|
|
||||||
import logging
|
|
||||||
import signal
|
|
||||||
|
|
||||||
|
|
||||||
parser = ArgumentParser()
|
|
||||||
parser.add_argument("--debug", dest="debug",
|
|
||||||
action="store_true", default=False,
|
|
||||||
help="Enable debug logs")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
logging.basicConfig(
|
|
||||||
format='[%(asctime)s] (%(levelname)s) %(message)s',
|
|
||||||
level=logging.INFO if args.debug is False else logging.DEBUG)
|
|
||||||
|
|
||||||
# Handle ctrl-c
|
|
||||||
# note that this will cause any finally blocks and similar cleanups
|
|
||||||
# to not get executed
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
||||||
app = QtApp()
|
|
||||||
app.run()
|
|
105
bin/opensnitchd
105
bin/opensnitchd
|
@ -1,105 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from argparse import ArgumentParser
|
|
||||||
from os.path import expanduser
|
|
||||||
import warnings
|
|
||||||
import logging
|
|
||||||
import prctl
|
|
||||||
import pwd
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
# Ensure Qt4 wont be loaded by matplotlib
|
|
||||||
try:
|
|
||||||
import matplotlib as mpl
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
mpl.rcParams['backend'] = 'Qt5Agg'
|
|
||||||
|
|
||||||
from opensnitch.version import VERSION
|
|
||||||
from opensnitch.snitch import Snitch
|
|
||||||
|
|
||||||
|
|
||||||
REQUIRED_CAPS = ((prctl.CAP_NET_RAW, prctl.ALL_FLAGS, True),
|
|
||||||
(prctl.CAP_DAC_OVERRIDE, prctl.ALL_FLAGS, True),
|
|
||||||
(prctl.CAP_NET_ADMIN, prctl.ALL_FLAGS, True))
|
|
||||||
|
|
||||||
|
|
||||||
parser = ArgumentParser()
|
|
||||||
parser.add_argument("--log-file", dest="logfile", default=None,
|
|
||||||
help="Log to file", metavar="FILE")
|
|
||||||
parser.add_argument("--debug", dest="debug",
|
|
||||||
action="store_true", default=False,
|
|
||||||
help="Enable debug logs")
|
|
||||||
parser.add_argument("--database", dest="database", default=None,
|
|
||||||
help="Database path", metavar="FILE")
|
|
||||||
parser.add_argument("--user", dest="user",
|
|
||||||
default=os.environ.get('SUDO_USER', 'root'),
|
|
||||||
help="Run as user")
|
|
||||||
|
|
||||||
|
|
||||||
# At some point Scapy devs will realize how bothering their fucking warnings
|
|
||||||
# are while importing scapy.all ...
|
|
||||||
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
|
|
||||||
warnings.filterwarnings("ignore", category=RuntimeWarning, module="gtk")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
logging.basicConfig(
|
|
||||||
format='[%(asctime)s] (%(levelname)s) %(message)s',
|
|
||||||
level=logging.INFO if args.debug is False else logging.DEBUG,
|
|
||||||
filename=args.logfile)
|
|
||||||
|
|
||||||
if not os.geteuid() == 0:
|
|
||||||
sys.exit('OpenSnitch must be run as root.')
|
|
||||||
|
|
||||||
if 'DBUS_SESSION_BUS_ADDRESS' not in os.environ:
|
|
||||||
raise RuntimeError('DBUS_SESSION_BUS_ADDRESS not set')
|
|
||||||
|
|
||||||
# set_keepcaps allows us to keep caps across setuid call
|
|
||||||
prctl.set_keepcaps(True)
|
|
||||||
prctl.set_caps(*REQUIRED_CAPS)
|
|
||||||
|
|
||||||
user = pwd.getpwnam(args.user)
|
|
||||||
os.setgid(user.pw_gid)
|
|
||||||
os.setuid(user.pw_uid)
|
|
||||||
# The effective capability set is cleared on setuid
|
|
||||||
# Re-set the effective set
|
|
||||||
prctl.set_caps(*REQUIRED_CAPS)
|
|
||||||
|
|
||||||
dbfile = args.database or os.path.join(
|
|
||||||
expanduser("~%s" % args.user), "opensnitch.db")
|
|
||||||
|
|
||||||
snitch = Snitch(dbfile)
|
|
||||||
try:
|
|
||||||
logging.info("OpenSnitch v%s running with pid %d.",
|
|
||||||
VERSION, os.getpid())
|
|
||||||
snitch.start()
|
|
||||||
except KeyboardInterrupt as e:
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
logging.info("Quitting ...")
|
|
||||||
snitch.stop()
|
|
||||||
|
|
||||||
# Temporary hack to handle Ctrl-C
|
|
||||||
os.kill(os.getpid(), 15)
|
|
73
index.html
Normal file
73
index.html
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>OpenSnitch</title>
|
||||||
|
<meta name="description" content="OpenSnitch is a GNU/Linux port of the Little Snitch application firewall.">
|
||||||
|
|
||||||
|
<link rel="icon" href="https://www.evilsocket.net/images/favicon.ico">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="https://getbootstrap.com/examples/cover/cover.css">
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="site-wrapper">
|
||||||
|
<div class="site-wrapper-inner">
|
||||||
|
<div class="cover-container">
|
||||||
|
<div class="masthead clearfix">
|
||||||
|
<div class="inner">
|
||||||
|
<nav>
|
||||||
|
<ul class="nav masthead-nav">
|
||||||
|
<li><a href="https://github.com/evilsocket/opensnitch">Download</a></li>
|
||||||
|
<li><a href="https://github.com/evilsocket/opensnitch/issues">Bug Tracker</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="inner cover">
|
||||||
|
<h1 class="cover-heading">OpenSnitch</h1>
|
||||||
|
<p class="lead">OpenSnitch is a GNU/Linux port of the Little Snitch application firewall.</p>
|
||||||
|
<p class="lead" align="center">
|
||||||
|
<img src="https://raw.githubusercontent.com/evilsocket/opensnitch/master/screenshot.png" alt="OpenSnitch"/>
|
||||||
|
</p>
|
||||||
|
<p class="lead" align="center">
|
||||||
|
<iframe src="https://ghbtns.com/github-btn.html?user=evilsocket&repo=opensnitch&type=star&count=true&size=large" frameborder="0" scrolling="0" width="150px" height="30px"></iframe>
|
||||||
|
</p>
|
||||||
|
<p class="lead">
|
||||||
|
<a href="https://github.com/evilsocket/opensnitch" class="btn btn-lg btn-default">Learn more</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mastfoot">
|
||||||
|
<div class="inner">
|
||||||
|
<p>OpenSnitch was made <span style="color:red">♥</span> by <a href="https://twitter.com/evilsocket" target="_blank" >Simone 'evilsocket' Margaritelli</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
|
ga('create', 'UA-98436807-1', 'auto');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,85 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from collections import namedtuple
|
|
||||||
from socket import inet_ntoa
|
|
||||||
from opensnitch import proc
|
|
||||||
from dpkt import ip
|
|
||||||
|
|
||||||
|
|
||||||
Application = namedtuple('Application', ('pid', 'path', 'cmdline'))
|
|
||||||
_Connection = namedtuple('Connection', (
|
|
||||||
'id',
|
|
||||||
'data',
|
|
||||||
'pkt',
|
|
||||||
'src_addr',
|
|
||||||
'dst_addr',
|
|
||||||
'hostname',
|
|
||||||
'src_port',
|
|
||||||
'dst_port',
|
|
||||||
'proto',
|
|
||||||
'app'))
|
|
||||||
|
|
||||||
|
|
||||||
def Connection(procmon, dns, packet_id, payload):
|
|
||||||
data = payload
|
|
||||||
pkt = ip.IP(data)
|
|
||||||
src_addr = inet_ntoa(pkt.src)
|
|
||||||
dst_addr = inet_ntoa(pkt.dst)
|
|
||||||
hostname = dns.get_hostname(dst_addr)
|
|
||||||
src_port = None
|
|
||||||
dst_port = None
|
|
||||||
proto = None
|
|
||||||
app = None
|
|
||||||
|
|
||||||
if pkt.p == ip.IP_PROTO_TCP:
|
|
||||||
proto = 'tcp'
|
|
||||||
src_port = pkt.tcp.sport
|
|
||||||
dst_port = pkt.tcp.dport
|
|
||||||
elif pkt.p == ip.IP_PROTO_UDP:
|
|
||||||
proto = 'udp'
|
|
||||||
src_port = pkt.udp.sport
|
|
||||||
dst_port = pkt.udp.dport
|
|
||||||
elif pkt.p == ip.IP_PROTO_ICMP:
|
|
||||||
proto = 'icmp'
|
|
||||||
src_port = None
|
|
||||||
dst_port = None
|
|
||||||
|
|
||||||
if proto == 'icmp':
|
|
||||||
app = Application(None, None, None)
|
|
||||||
|
|
||||||
elif None not in (proto, src_addr, dst_addr):
|
|
||||||
pid = proc.get_pid_by_connection(src_addr,
|
|
||||||
src_port,
|
|
||||||
dst_addr,
|
|
||||||
dst_port,
|
|
||||||
proto)
|
|
||||||
app = Application(
|
|
||||||
pid, *proc._get_app_path_and_cmdline(procmon, pid))
|
|
||||||
|
|
||||||
return _Connection(
|
|
||||||
packet_id,
|
|
||||||
data,
|
|
||||||
pkt,
|
|
||||||
src_addr,
|
|
||||||
dst_addr,
|
|
||||||
hostname,
|
|
||||||
src_port,
|
|
||||||
dst_port,
|
|
||||||
proto,
|
|
||||||
app)
|
|
|
@ -1,89 +0,0 @@
|
||||||
from gi.repository import GLib
|
|
||||||
|
|
||||||
import dbus.mainloop.glib
|
|
||||||
import dbus.mainloop
|
|
||||||
import dbus.service
|
|
||||||
import dbus
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from opensnitch.rule import RuleSaveOption, RuleVerdict
|
|
||||||
|
|
||||||
|
|
||||||
BUS_NAME = 'io.opensnitch.service'
|
|
||||||
OBJECT_PATH = '/'
|
|
||||||
|
|
||||||
|
|
||||||
class OpensnitchService(dbus.service.Object):
|
|
||||||
|
|
||||||
def __init__(self, handlers, rules):
|
|
||||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
||||||
|
|
||||||
bus = dbus.SessionBus()
|
|
||||||
bus_name = dbus.service.BusName(BUS_NAME, bus=bus)
|
|
||||||
|
|
||||||
self.handlers = handlers
|
|
||||||
self._rules = rules
|
|
||||||
|
|
||||||
super().__init__(bus_name, OBJECT_PATH)
|
|
||||||
|
|
||||||
@dbus.service.signal(BUS_NAME, signature='usqssuss')
|
|
||||||
def prompt(self, connection_id,
|
|
||||||
hostname,
|
|
||||||
dst_port,
|
|
||||||
dst_addr,
|
|
||||||
proto,
|
|
||||||
app_pid,
|
|
||||||
app_path,
|
|
||||||
app_cmdline):
|
|
||||||
# Signal is emitted by calling decorated function
|
|
||||||
logging.debug('Prompting connection id %s', connection_id)
|
|
||||||
|
|
||||||
@dbus.service.method(BUS_NAME, in_signature='iiib', out_signature='b')
|
|
||||||
def connection_set_result(self, connection_id, save_option,
|
|
||||||
verdict, apply_to_all):
|
|
||||||
save_option = int(save_option)
|
|
||||||
verdict = int(verdict)
|
|
||||||
apply_to_all = bool(apply_to_all)
|
|
||||||
|
|
||||||
try:
|
|
||||||
handler = self.handlers[int(connection_id)]
|
|
||||||
except KeyError:
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
handler.future.set_result((save_option,
|
|
||||||
verdict,
|
|
||||||
apply_to_all))
|
|
||||||
except Exception as e:
|
|
||||||
logging.debug('Could not set result %s', e)
|
|
||||||
|
|
||||||
if RuleSaveOption(save_option) != RuleSaveOption.ONCE:
|
|
||||||
self._rules.add_rule(handler.conn, RuleVerdict(verdict),
|
|
||||||
apply_to_all, save_option)
|
|
||||||
|
|
||||||
@dbus.service.method(BUS_NAME,
|
|
||||||
in_signature='i', out_signature='b')
|
|
||||||
def connection_recheck_verdict(self, connection_id):
|
|
||||||
try:
|
|
||||||
handler = self.handlers[int(connection_id)]
|
|
||||||
except KeyError:
|
|
||||||
# If connection is not found or verdict is set connection is
|
|
||||||
# considered to be handled
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
conn = handler.conn
|
|
||||||
|
|
||||||
verd = self._rules.get_verdict(conn)
|
|
||||||
if verd is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
handler.future.set_result((RuleSaveOption.ONCE,
|
|
||||||
verd,
|
|
||||||
False)) # Apply to all
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
loop = GLib.MainLoop()
|
|
||||||
loop.run()
|
|
|
@ -1,64 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from scapy.all import DNSRR, DNS
|
|
||||||
from threading import Lock
|
|
||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
class DNSCollector:
|
|
||||||
def __init__(self):
|
|
||||||
self.lock = Lock()
|
|
||||||
self.hosts = {'127.0.0.1': 'localhost'}
|
|
||||||
|
|
||||||
def add_response(self, packet):
|
|
||||||
if packet.haslayer(DNS) and packet.haslayer(DNSRR):
|
|
||||||
with self.lock:
|
|
||||||
try:
|
|
||||||
a_count = packet[DNS].ancount
|
|
||||||
i = a_count + 4
|
|
||||||
while i > 4:
|
|
||||||
hostname = packet[0][i].rrname
|
|
||||||
address = packet[0][i].rdata
|
|
||||||
i -= 1
|
|
||||||
|
|
||||||
if hostname == b'.':
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif hostname.endswith(b'.'):
|
|
||||||
hostname = hostname[:-1]
|
|
||||||
|
|
||||||
# for CNAME records
|
|
||||||
if address.endswith('.'):
|
|
||||||
address = address[:-1]
|
|
||||||
|
|
||||||
logging.debug("Adding DNS response: %s => %s", address, hostname) # noqa
|
|
||||||
self.hosts[address] = hostname.decode()
|
|
||||||
except Exception as e:
|
|
||||||
logging.debug("Error while parsing DNS response: %s" % e)
|
|
||||||
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_hostname(self, address):
|
|
||||||
try:
|
|
||||||
return self.hosts[address]
|
|
||||||
except KeyError:
|
|
||||||
logging.debug("No hostname found for address %s" % address)
|
|
||||||
return address
|
|
|
@ -1,85 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Adam Hose
|
|
||||||
# adis@blad.is
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
import iptc
|
|
||||||
|
|
||||||
|
|
||||||
class IPTCRules:
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.insert_dns_rule()
|
|
||||||
self.insert_connection_packet_rules()
|
|
||||||
self.insert_reject_rule()
|
|
||||||
|
|
||||||
def remove(self):
|
|
||||||
table = iptc.Table(iptc.Table.FILTER)
|
|
||||||
chain = iptc.Chain(table, 'INPUT')
|
|
||||||
for r in chain.rules:
|
|
||||||
chain.delete_rule(r)
|
|
||||||
|
|
||||||
table = iptc.Table(iptc.Table.FILTER)
|
|
||||||
chain = iptc.Chain(table, 'OUTPUT')
|
|
||||||
for r in chain.rules:
|
|
||||||
chain.delete_rule(r)
|
|
||||||
|
|
||||||
table = iptc.Table(iptc.Table.FILTER)
|
|
||||||
chain = iptc.Chain(table, 'MANGLE')
|
|
||||||
for r in chain.rules:
|
|
||||||
chain.delete_rule(r)
|
|
||||||
|
|
||||||
def insert_dns_rule(self):
|
|
||||||
"""Get DNS responses"""
|
|
||||||
table = iptc.Table(iptc.Table.FILTER)
|
|
||||||
chain = iptc.Chain(table, 'INPUT')
|
|
||||||
rule = iptc.Rule()
|
|
||||||
rule.protocol = 'udp'
|
|
||||||
m = rule.create_match('udp')
|
|
||||||
m.sport = '53'
|
|
||||||
|
|
||||||
t = rule.create_target('NFQUEUE')
|
|
||||||
t.set_parameter('queue-num', str(0))
|
|
||||||
t.set_parameter('queue-bypass')
|
|
||||||
|
|
||||||
chain.insert_rule(rule)
|
|
||||||
|
|
||||||
def insert_connection_packet_rules(self):
|
|
||||||
table = iptc.Table(iptc.Table.MANGLE)
|
|
||||||
chain = iptc.Chain(table, 'OUTPUT')
|
|
||||||
rule = iptc.Rule()
|
|
||||||
|
|
||||||
t = rule.create_target('NFQUEUE')
|
|
||||||
t.set_parameter('queue-num', str(0))
|
|
||||||
t.set_parameter('queue-bypass')
|
|
||||||
|
|
||||||
m = rule.create_match('conntrack')
|
|
||||||
m.set_parameter('ctstate', 'NEW')
|
|
||||||
|
|
||||||
chain.insert_rule(rule)
|
|
||||||
|
|
||||||
def insert_reject_rule(self):
|
|
||||||
table = iptc.Table(iptc.Table.MANGLE)
|
|
||||||
chain = iptc.Chain(table, 'OUTPUT')
|
|
||||||
rule = iptc.Rule()
|
|
||||||
rule.protol = 'tcp'
|
|
||||||
|
|
||||||
rule.create_target('REJECT')
|
|
||||||
|
|
||||||
m = rule.create_match('mark')
|
|
||||||
m.mark = '0x18ba5'
|
|
||||||
|
|
||||||
chain.insert_rule(rule)
|
|
|
@ -1,79 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# https://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
import logging
|
|
||||||
import psutil
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def get_pid_by_connection(src_addr, src_p, dst_addr, dst_p, proto='tcp'):
|
|
||||||
# We always take the first element as we assume it contains only one
|
|
||||||
# It should not be possible to keep two connections which are the same.
|
|
||||||
for conn in psutil.net_connections(kind=proto):
|
|
||||||
if proto == 'tcp':
|
|
||||||
if conn.laddr != (src_addr, int(src_p)):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if conn.raddr != (dst_addr, int(dst_p)):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# UDP gives us a very limited dataset to work with
|
|
||||||
elif proto == 'udp':
|
|
||||||
if conn.laddr[1] != int(src_p):
|
|
||||||
continue
|
|
||||||
|
|
||||||
return conn.pid
|
|
||||||
|
|
||||||
logging.warning("Could not find process for %s connection %s:%s -> %s:%s",
|
|
||||||
proto,
|
|
||||||
src_addr,
|
|
||||||
src_p,
|
|
||||||
dst_addr,
|
|
||||||
dst_p)
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _get_app_path_and_cmdline(procmon, pid):
|
|
||||||
path, args = None, None
|
|
||||||
if pid is None:
|
|
||||||
return (path, args)
|
|
||||||
|
|
||||||
pmr = procmon.get_app(pid)
|
|
||||||
if pmr:
|
|
||||||
path = pmr.get('filename')
|
|
||||||
args = pmr.get('args')
|
|
||||||
|
|
||||||
if not path:
|
|
||||||
logging.debug("Could not find pid %s with ProcMon, falling back to /proc/%s/exe -> %s", pid, pid, path or '?') # noqa
|
|
||||||
try:
|
|
||||||
path = os.readlink("/proc/{}/exe".format(pid))
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(e)
|
|
||||||
|
|
||||||
if not args:
|
|
||||||
logging.debug(
|
|
||||||
"Could not find pid %s command line with ProcMon", pid) # noqa
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open("/proc/{}/cmdline".format(pid)) as cmd_fd:
|
|
||||||
cmd_fd.read().replace('\0', ' ').strip()
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(e)
|
|
||||||
|
|
||||||
return (path, args)
|
|
|
@ -1,161 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from collections import defaultdict
|
|
||||||
import threading
|
|
||||||
import logging
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
def writefile(path, value, mode="w"):
|
|
||||||
with open(path, mode) as f:
|
|
||||||
return f.write(value)
|
|
||||||
|
|
||||||
|
|
||||||
class ProcMon(threading.Thread):
|
|
||||||
PROBE_NAME = "opensnitch_sys_execve"
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.pids = defaultdict(dict)
|
|
||||||
self.lock = threading.Lock()
|
|
||||||
self.running = False
|
|
||||||
self.daemon = True
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def enable():
|
|
||||||
ProcMon.disable(False)
|
|
||||||
logging.info("Enabling ProcMon ...")
|
|
||||||
|
|
||||||
for d in ('sched_process_fork',
|
|
||||||
'sched_process_exec',
|
|
||||||
'sched_process_exit'):
|
|
||||||
f = "/sys/kernel/debug/tracing/events/sched/%s/enable" % d
|
|
||||||
writefile(f, "1")
|
|
||||||
|
|
||||||
# Create the custom execve kprobe consumer
|
|
||||||
# Command line args will be in %si, we're asking ftrace for them
|
|
||||||
with open("/sys/kernel/debug/tracing/kprobe_events", "w") as f:
|
|
||||||
f.write("p:kprobes/%s sys_execve" % (ProcMon.PROBE_NAME,))
|
|
||||||
for i in range(1, 16):
|
|
||||||
f.write(" arg%d=+0(+%d(%%si)):string" % (i, i*8))
|
|
||||||
|
|
||||||
writefile("/sys/kernel/debug/tracing/events/kprobes/%s/enable" % ProcMon.PROBE_NAME, "1") # noqa
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def disable(verbose=True):
|
|
||||||
if verbose:
|
|
||||||
logging.info("Disabling ProcMon ...")
|
|
||||||
|
|
||||||
try:
|
|
||||||
for d in ('sched_process_fork',
|
|
||||||
'sched_process_exec',
|
|
||||||
'sched_process_exit'):
|
|
||||||
f = "/sys/kernel/debug/tracing/events/sched/%s/enable" % d
|
|
||||||
writefile(f, "0")
|
|
||||||
|
|
||||||
writefile("/sys/kernel/debug/tracing/events/kprobes/%s/enable" % ProcMon.PROBE_NAME, "0") # noqa
|
|
||||||
writefile("/sys/kernel/debug/tracing/kprobe_events", "-:%s" % ProcMon.PROBE_NAME, mode="a+") # noqa
|
|
||||||
writefile("/sys/kernel/debug/tracing/trace", "")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def is_ftrace_available():
|
|
||||||
try:
|
|
||||||
with open("/proc/sys/kernel/ftrace_enabled", "rt") as fp:
|
|
||||||
return fp.read().strip() == '1'
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_app(self, pid):
|
|
||||||
return self.pids[pid] or None
|
|
||||||
|
|
||||||
def _on_exec(self, pid, filename):
|
|
||||||
with self.lock:
|
|
||||||
p = self.pids[pid]
|
|
||||||
p['filename'] = filename
|
|
||||||
|
|
||||||
logging.debug("(pid=%d) %s %s",
|
|
||||||
pid,
|
|
||||||
filename,
|
|
||||||
p.get('args', ''))
|
|
||||||
|
|
||||||
def _on_args(self, pid, args):
|
|
||||||
with self.lock:
|
|
||||||
self.pids[pid]['args'] = args
|
|
||||||
|
|
||||||
def _on_exit(self, pid):
|
|
||||||
try:
|
|
||||||
del self.pids[pid]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
logging.info("ProcMon running ...")
|
|
||||||
self.running = True
|
|
||||||
|
|
||||||
with open("/sys/kernel/debug/tracing/trace_pipe", 'rb') as pipe:
|
|
||||||
PROBE_NAME = ProcMon.PROBE_NAME.encode()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
line = pipe.readline()
|
|
||||||
|
|
||||||
if PROBE_NAME in line:
|
|
||||||
m = re.search(b'^.*?\-(\d+)\s*\[', line)
|
|
||||||
if m is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
pid = int(m.group(1))
|
|
||||||
# "walk" over every argument field, 'fault' is our terminator. # noqa
|
|
||||||
# If we see it it means that there are more cmdline args. # noqa
|
|
||||||
if b'(fault)' in line:
|
|
||||||
line = line[:line.find(b'(fault)')]
|
|
||||||
|
|
||||||
args = b' '.join(
|
|
||||||
re.findall(b'arg\d+="(.*?)"', line))
|
|
||||||
|
|
||||||
self._on_args(pid, args.decode())
|
|
||||||
|
|
||||||
else:
|
|
||||||
m = re.search(b'sched_process_(.*?):', line)
|
|
||||||
if m is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
event = m.group(1)
|
|
||||||
if event == b'exec':
|
|
||||||
filename = re.search(
|
|
||||||
b'filename=(.*?)\s+pid=', line).group(1)
|
|
||||||
pid = int(
|
|
||||||
re.search(b'\spid=(\d+)', line).group(1))
|
|
||||||
|
|
||||||
self._on_exec(pid, filename.decode())
|
|
||||||
|
|
||||||
elif event == b'exit':
|
|
||||||
mm = re.search(
|
|
||||||
b'\scomm=(.*?)\s+pid=(\d+)', line)
|
|
||||||
# command = mm.group(1)
|
|
||||||
pid = int(mm.group(2))
|
|
||||||
|
|
||||||
self._on_exit(pid)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.warning(e)
|
|
|
@ -1,157 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from collections import namedtuple
|
|
||||||
from threading import Lock
|
|
||||||
from enum import Enum
|
|
||||||
import logging
|
|
||||||
import sqlite3
|
|
||||||
|
|
||||||
|
|
||||||
Rule = namedtuple('Rule', ('app_path',
|
|
||||||
'verdict',
|
|
||||||
'address',
|
|
||||||
'port',
|
|
||||||
'proto'))
|
|
||||||
|
|
||||||
|
|
||||||
class RuleVerdict(Enum):
|
|
||||||
|
|
||||||
ACCEPT = 0
|
|
||||||
DROP = 1
|
|
||||||
|
|
||||||
|
|
||||||
class RuleSaveOption(Enum):
|
|
||||||
|
|
||||||
ONCE = 0
|
|
||||||
UNTIL_QUIT = 1
|
|
||||||
FOREVER = 2
|
|
||||||
|
|
||||||
|
|
||||||
def matches(rule, conn):
|
|
||||||
if rule.app_path != conn.app.path:
|
|
||||||
return False
|
|
||||||
|
|
||||||
elif rule.address is not None and rule.address != conn.dst_addr:
|
|
||||||
return False
|
|
||||||
|
|
||||||
elif rule.port is not None and rule.port != conn.dst_port:
|
|
||||||
return False
|
|
||||||
|
|
||||||
elif rule.proto is not None and rule.proto != conn.proto:
|
|
||||||
return False
|
|
||||||
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class Rules:
|
|
||||||
def __init__(self, database):
|
|
||||||
self.mutex = Lock()
|
|
||||||
db = self.db = RulesDB(database)
|
|
||||||
self.rules = {}
|
|
||||||
|
|
||||||
with db._lock:
|
|
||||||
for r in db._load_rules():
|
|
||||||
self._add_rule(r)
|
|
||||||
|
|
||||||
def get_verdict(self, connection):
|
|
||||||
with self.mutex:
|
|
||||||
for r in self.rules.get(connection.app.path, []):
|
|
||||||
if matches(r, connection):
|
|
||||||
return r.verdict
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _remove_rules_for_path(self, path, remove_from_db=False):
|
|
||||||
try:
|
|
||||||
del self.rules[path]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if remove_from_db is True:
|
|
||||||
self.db.remove_all_app_rules(path)
|
|
||||||
|
|
||||||
def _add_rule(self, rule):
|
|
||||||
self.rules.setdefault(rule.app_path, set()).add(rule)
|
|
||||||
|
|
||||||
def add_rule(self, connection, verdict, apply_to_all=False,
|
|
||||||
save_option=RuleSaveOption.UNTIL_QUIT.value):
|
|
||||||
|
|
||||||
with self.mutex:
|
|
||||||
logging.debug("Adding %s rule for '%s' (all=%s)",
|
|
||||||
"ALLOW" if RuleVerdict(verdict) == RuleVerdict.ACCEPT else "DENY", # noqa
|
|
||||||
connection,
|
|
||||||
"true" if apply_to_all is True else "false")
|
|
||||||
|
|
||||||
if apply_to_all is True:
|
|
||||||
self._remove_rules_for_path(
|
|
||||||
connection.app.path,
|
|
||||||
(RuleSaveOption(save_option) == RuleSaveOption.FOREVER))
|
|
||||||
|
|
||||||
r = Rule(
|
|
||||||
connection.app.path,
|
|
||||||
verdict,
|
|
||||||
connection.dst_addr if not apply_to_all else None,
|
|
||||||
connection.dst_port if not apply_to_all else None,
|
|
||||||
connection.proto if not apply_to_all else None)
|
|
||||||
|
|
||||||
self._add_rule(r)
|
|
||||||
|
|
||||||
if RuleSaveOption(save_option) == RuleSaveOption.FOREVER:
|
|
||||||
self.db.save_rule(r)
|
|
||||||
|
|
||||||
|
|
||||||
class RulesDB:
|
|
||||||
|
|
||||||
def __init__(self, filename):
|
|
||||||
self._filename = filename
|
|
||||||
self._lock = Lock()
|
|
||||||
logging.info("Using rules database from %s" % filename)
|
|
||||||
self._create_table()
|
|
||||||
|
|
||||||
# Only call with lock!
|
|
||||||
def _get_conn(self):
|
|
||||||
return sqlite3.connect(self._filename)
|
|
||||||
|
|
||||||
def _create_table(self):
|
|
||||||
with self._lock:
|
|
||||||
conn = self._get_conn()
|
|
||||||
c = conn.cursor()
|
|
||||||
c.execute("CREATE TABLE IF NOT EXISTS rules (app_path TEXT, verdict INTEGER, address TEXT, port INTEGER, proto TEXT, UNIQUE (app_path, verdict, address, port, proto))") # noqa
|
|
||||||
|
|
||||||
def _load_rules(self):
|
|
||||||
conn = self._get_conn()
|
|
||||||
c = conn.cursor()
|
|
||||||
c.execute("SELECT * FROM rules")
|
|
||||||
for item in c.fetchall():
|
|
||||||
yield Rule(*item)
|
|
||||||
|
|
||||||
def save_rule(self, rule):
|
|
||||||
with self._lock:
|
|
||||||
conn = self._get_conn()
|
|
||||||
c = conn.cursor()
|
|
||||||
c.execute("INSERT INTO rules VALUES (?, ?, ?, ?, ?)", (rule.app_path, rule.verdict.value, rule.address, rule.port, rule.proto,)) # noqa
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
def remove_all_app_rules(self, app_path):
|
|
||||||
with self._lock:
|
|
||||||
conn = self._get_conn()
|
|
||||||
c = conn.cursor()
|
|
||||||
c.execute("DELETE FROM rules WHERE app_path=?", (app_path,))
|
|
||||||
conn.commit()
|
|
|
@ -1,182 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from concurrent.futures import Future, TimeoutError
|
|
||||||
from netfilterqueue import NetfilterQueue
|
|
||||||
from threading import Lock
|
|
||||||
from scapy.all import IP
|
|
||||||
import threading
|
|
||||||
import logging
|
|
||||||
import weakref
|
|
||||||
|
|
||||||
from opensnitch.connection import Connection
|
|
||||||
from opensnitch.dns import DNSCollector
|
|
||||||
from opensnitch.rule import RuleVerdict, Rules
|
|
||||||
from opensnitch.procmon import ProcMon
|
|
||||||
from opensnitch.iptables import IPTCRules
|
|
||||||
from opensnitch.dbus_service import OpensnitchService
|
|
||||||
|
|
||||||
|
|
||||||
MARK_PACKET_DROP = 101285
|
|
||||||
PACKET_TIMEOUT = 30 # 30 seconds is a good value?
|
|
||||||
IPTABLES_RULES = (
|
|
||||||
# Get DNS responses
|
|
||||||
"INPUT --protocol udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass",
|
|
||||||
# Get connection packets
|
|
||||||
"OUTPUT -t mangle -m conntrack --ctstate NEW -j NFQUEUE --queue-num 0 --queue-bypass", # noqa
|
|
||||||
# Reject packets marked by OpenSnitch
|
|
||||||
"OUTPUT --protocol tcp -m mark --mark 101285 -j REJECT")
|
|
||||||
|
|
||||||
|
|
||||||
def drop_packet(pkt, conn):
|
|
||||||
logging.info('Dropping %s from "%s %s"',
|
|
||||||
conn, conn.app.path, conn.app.cmdline)
|
|
||||||
pkt.set_mark(MARK_PACKET_DROP)
|
|
||||||
pkt.drop()
|
|
||||||
|
|
||||||
|
|
||||||
class NetfilterQueueWrapper(threading.Thread):
|
|
||||||
|
|
||||||
def __init__(self, snitch):
|
|
||||||
super().__init__()
|
|
||||||
self.snitch = snitch
|
|
||||||
|
|
||||||
self.handlers = weakref.WeakValueDictionary()
|
|
||||||
self.latest_packet_id = 0
|
|
||||||
|
|
||||||
self._q = None
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
if self._q is not None:
|
|
||||||
self._q.unbind()
|
|
||||||
|
|
||||||
def pkt_callback(self, pkt):
|
|
||||||
try:
|
|
||||||
data = pkt.get_payload()
|
|
||||||
|
|
||||||
if self.snitch.dns.add_response(IP(data)):
|
|
||||||
pkt.accept()
|
|
||||||
return
|
|
||||||
|
|
||||||
self.latest_packet_id += 1
|
|
||||||
conn = Connection(self.snitch.procmon, self.snitch.dns,
|
|
||||||
self.latest_packet_id, data)
|
|
||||||
if conn.proto is None:
|
|
||||||
logging.debug("Could not detect protocol for packet.")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get verdict, if verdict cannot be found prompt user in thread
|
|
||||||
verd = self.snitch.rules.get_verdict(conn)
|
|
||||||
if verd is None:
|
|
||||||
handler = PacketHandler(conn, pkt, self.snitch.rules)
|
|
||||||
self.handlers[conn.id] = handler
|
|
||||||
self.snitch.dbus_service.prompt(
|
|
||||||
conn.id,
|
|
||||||
conn.hostname,
|
|
||||||
conn.dst_port or 0,
|
|
||||||
conn.dst_addr,
|
|
||||||
conn.proto,
|
|
||||||
conn.app.pid or 0,
|
|
||||||
conn.app.path or '',
|
|
||||||
conn.app.cmdline or '')
|
|
||||||
|
|
||||||
elif RuleVerdict(verd) == RuleVerdict.DROP:
|
|
||||||
drop_packet(pkt, conn)
|
|
||||||
|
|
||||||
elif RuleVerdict(verd) == RuleVerdict.ACCEPT:
|
|
||||||
pkt.accept()
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise RuntimeError("Unhandled state")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception("Exception on packet callback:")
|
|
||||||
logging.exception(e)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
try:
|
|
||||||
self._q = q = NetfilterQueue()
|
|
||||||
q.bind(0, self.pkt_callback, 1024 * 2)
|
|
||||||
q.run()
|
|
||||||
|
|
||||||
finally:
|
|
||||||
if q is not None:
|
|
||||||
q.unbind()
|
|
||||||
|
|
||||||
|
|
||||||
class PacketHandler(threading.Thread):
|
|
||||||
"""Handle a packet asynchronously in a thread"""
|
|
||||||
|
|
||||||
def __init__(self, connection, pkt, rules):
|
|
||||||
super().__init__()
|
|
||||||
self.future = Future()
|
|
||||||
self.future.set_running_or_notify_cancel()
|
|
||||||
self.conn = connection
|
|
||||||
self.pkt = pkt
|
|
||||||
self.rules = rules
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
try:
|
|
||||||
(save_option,
|
|
||||||
verdict,
|
|
||||||
apply_for_all) = self.future.result(PACKET_TIMEOUT)
|
|
||||||
|
|
||||||
except TimeoutError:
|
|
||||||
# What to do on timeouts?
|
|
||||||
# Should we even have timeouts?
|
|
||||||
self.pkt.accept()
|
|
||||||
|
|
||||||
else:
|
|
||||||
if RuleVerdict(verdict) == RuleVerdict.DROP:
|
|
||||||
drop_packet(self.pkt, self.conn)
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.pkt.accept()
|
|
||||||
|
|
||||||
|
|
||||||
class Snitch:
|
|
||||||
|
|
||||||
# TODO: Support IPv6!
|
|
||||||
def __init__(self, database):
|
|
||||||
self.lock = Lock()
|
|
||||||
self.rules = Rules(database)
|
|
||||||
self.dns = DNSCollector()
|
|
||||||
self.q = NetfilterQueueWrapper(self)
|
|
||||||
self.procmon = ProcMon()
|
|
||||||
self.iptcrules = None
|
|
||||||
|
|
||||||
self.dbus_service = OpensnitchService(
|
|
||||||
self.q.handlers, self.rules)
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
if ProcMon.is_ftrace_available():
|
|
||||||
self.procmon.enable()
|
|
||||||
self.procmon.start()
|
|
||||||
|
|
||||||
self.iptcrules = IPTCRules()
|
|
||||||
self.dbus_service.run()
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
self.procmon.disable()
|
|
||||||
self.q.stop()
|
|
||||||
|
|
||||||
if self.iptcrules is not None:
|
|
||||||
self.iptcrules.remove()
|
|
|
@ -1,21 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
__all__ = ('QtApp',)
|
|
||||||
|
|
||||||
from .app import QtApp
|
|
|
@ -1,46 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from PyQt5 import QtWidgets
|
|
||||||
import queue
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .desktop_parser import LinuxDesktopParser
|
|
||||||
from .dialog import Dialog
|
|
||||||
from .dbus import DBusHandler
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Implement tray icon and menu.
|
|
||||||
# TODO: Implement rules editor.
|
|
||||||
RESOURCES_PATH = "%s/resources/" % os.path.dirname(
|
|
||||||
sys.modules[__name__].__file__)
|
|
||||||
DIALOG_UI_PATH = "%s/dialog.ui" % RESOURCES_PATH
|
|
||||||
|
|
||||||
|
|
||||||
class QtApp:
|
|
||||||
def __init__(self):
|
|
||||||
self.desktop_parser = LinuxDesktopParser()
|
|
||||||
self.app = QtWidgets.QApplication([])
|
|
||||||
self.connection_queue = queue.Queue()
|
|
||||||
self.dialog = Dialog(self, self.desktop_parser)
|
|
||||||
|
|
||||||
self.dbus_handler = DBusHandler(self.app, self)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
self.app.exec()
|
|
|
@ -1,70 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Adam Hose
|
|
||||||
# adis@blad.is
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from collections import namedtuple
|
|
||||||
from PyQt5 import QtCore, QtDBus
|
|
||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
UIConnection = namedtuple('UIConnection', (
|
|
||||||
'id',
|
|
||||||
'hostname',
|
|
||||||
'dst_port',
|
|
||||||
'dst_addr',
|
|
||||||
'proto',
|
|
||||||
'app_pid',
|
|
||||||
'app_path',
|
|
||||||
'app_cmdline',
|
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
class DBusHandler(QtCore.QObject):
|
|
||||||
|
|
||||||
def __init__(self, app, parent):
|
|
||||||
self.parent = parent
|
|
||||||
self.app = app
|
|
||||||
super().__init__(app)
|
|
||||||
|
|
||||||
self.__dbus = QtDBus.QDBusConnection.sessionBus()
|
|
||||||
self.__dbus.registerObject('/', self)
|
|
||||||
self.interface = QtDBus.QDBusInterface(
|
|
||||||
'io.opensnitch.service',
|
|
||||||
'/',
|
|
||||||
'io.opensnitch.service',
|
|
||||||
self.__dbus)
|
|
||||||
|
|
||||||
if not self.interface.isValid():
|
|
||||||
raise RuntimeError('Could not connect to dbus')
|
|
||||||
logging.info('Connected to dbus service')
|
|
||||||
|
|
||||||
sig_connect = self.__dbus.connect(
|
|
||||||
'io.opensnitch.service',
|
|
||||||
'/',
|
|
||||||
'io.opensnitch.service',
|
|
||||||
'prompt',
|
|
||||||
self.prompt_user)
|
|
||||||
if not sig_connect:
|
|
||||||
raise RuntimeError('Could not connect dbus signal')
|
|
||||||
logging.info('Connected dbus signal')
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QtDBus.QDBusMessage)
|
|
||||||
def prompt_user(self, msg):
|
|
||||||
args = msg.arguments()
|
|
||||||
connection = UIConnection(*args)
|
|
||||||
self.parent.connection_queue.put(connection)
|
|
||||||
self.parent.dialog.add_connection_signal.emit()
|
|
|
@ -1,94 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from threading import Lock
|
|
||||||
import configparser
|
|
||||||
import pyinotify
|
|
||||||
import threading
|
|
||||||
import glob
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
DESKTOP_PATHS = tuple([
|
|
||||||
os.path.join(d, 'applications')
|
|
||||||
for d in os.getenv('XDG_DATA_DIRS', '/usr/share/').split(':')
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
class LinuxDesktopParser(threading.Thread):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self.lock = Lock()
|
|
||||||
self.daemon = True
|
|
||||||
self.running = False
|
|
||||||
|
|
||||||
self.apps = {}
|
|
||||||
for desktop_path in DESKTOP_PATHS:
|
|
||||||
if not os.path.exists(desktop_path):
|
|
||||||
continue
|
|
||||||
|
|
||||||
for desktop_file in glob.glob(os.path.join(desktop_path,
|
|
||||||
'*.desktop')):
|
|
||||||
self.populate_app(desktop_file)
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
def populate_app(self, desktop_path):
|
|
||||||
parser = configparser.ConfigParser(
|
|
||||||
strict=False) # Allow duplicate config entries
|
|
||||||
parser.read(desktop_path, 'utf8')
|
|
||||||
cmd = parser.get('Desktop Entry', 'exec', raw=True,
|
|
||||||
fallback=' ').split(' ')[0] or None
|
|
||||||
if cmd is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
icon = parser.get('Desktop Entry', 'icon',
|
|
||||||
raw=True, fallback=None)
|
|
||||||
name = parser.get('Desktop Entry', 'name',
|
|
||||||
raw=True, fallback=None)
|
|
||||||
|
|
||||||
with self.lock:
|
|
||||||
self.apps[cmd] = (name, icon, desktop_path)
|
|
||||||
|
|
||||||
def get_info_by_path(self, path):
|
|
||||||
path = os.path.basename(path)
|
|
||||||
return self.apps.get(path, (path, None))[:2]
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
self.running = True
|
|
||||||
wm = pyinotify.WatchManager()
|
|
||||||
notifier = pyinotify.Notifier(wm)
|
|
||||||
|
|
||||||
def inotify_callback(event):
|
|
||||||
if event.mask == pyinotify.IN_CLOSE_WRITE:
|
|
||||||
self.populate_app(event.pathname)
|
|
||||||
|
|
||||||
elif event.mask == pyinotify.IN_DELETE:
|
|
||||||
with self.lock:
|
|
||||||
for cmd, data in self.apps.items():
|
|
||||||
if data[2] == event.pathname:
|
|
||||||
del self.apps[cmd]
|
|
||||||
break
|
|
||||||
|
|
||||||
for p in DESKTOP_PATHS:
|
|
||||||
if os.path.exists(p):
|
|
||||||
wm.add_watch(p,
|
|
||||||
pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE,
|
|
||||||
inotify_callback)
|
|
||||||
notifier.loop()
|
|
|
@ -1,214 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from opensnitch.rule import RuleVerdict, RuleSaveOption
|
|
||||||
from PyQt5 import QtCore, QtGui, uic, QtWidgets
|
|
||||||
from PyQt5 import QtDBus
|
|
||||||
import threading
|
|
||||||
import logging
|
|
||||||
import queue
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from opensnitch.ui import helpers
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Implement tray icon and menu.
|
|
||||||
# TODO: Implement rules editor.
|
|
||||||
RESOURCES_PATH = "%s/resources/" % os.path.dirname(
|
|
||||||
sys.modules[__name__].__file__)
|
|
||||||
DIALOG_UI_PATH = "%s/dialog.ui" % RESOURCES_PATH
|
|
||||||
|
|
||||||
|
|
||||||
class Dialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|
||||||
|
|
||||||
DEFAULT_RESULT = (RuleSaveOption.ONCE, RuleVerdict.ACCEPT, False)
|
|
||||||
MESSAGE_TEMPLATE = "<b>%s</b> (pid=%s) wants to connect to <b>%s</b> on <b>%s port %s%s</b>" # noqa
|
|
||||||
|
|
||||||
add_connection_signal = QtCore.pyqtSignal()
|
|
||||||
|
|
||||||
def __init__(self, app, desktop_parser, parent=None):
|
|
||||||
self.connection = None
|
|
||||||
QtWidgets.QDialog.__init__(self, parent,
|
|
||||||
QtCore.Qt.WindowStaysOnTopHint)
|
|
||||||
self.setupUi(self)
|
|
||||||
self.init_widgets()
|
|
||||||
self.start_listeners()
|
|
||||||
|
|
||||||
self.connection_queue = app.connection_queue
|
|
||||||
self.add_connection_signal.connect(self.handle_connection)
|
|
||||||
|
|
||||||
self.app = app
|
|
||||||
|
|
||||||
self.desktop_parser = desktop_parser
|
|
||||||
|
|
||||||
self.rule_lock = threading.Lock()
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
|
||||||
def handle_connection(self):
|
|
||||||
# This method will get called again after the user took action
|
|
||||||
# on the currently handled connection
|
|
||||||
if self.connection is not None:
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
connection = self.connection_queue.get_nowait()
|
|
||||||
except queue.Empty:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Check if process is still alive, if not we dont need to handle
|
|
||||||
if connection.app_pid:
|
|
||||||
try:
|
|
||||||
os.kill(connection.app_pid, 0)
|
|
||||||
except ProcessLookupError:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Re-check in case permanent rule was added since connection was queued
|
|
||||||
verd = False
|
|
||||||
with self.rule_lock:
|
|
||||||
msg = self.app.dbus_handler.interface.call(
|
|
||||||
'connection_recheck_verdict', connection.id)
|
|
||||||
reply = QtDBus.QDBusReply(msg)
|
|
||||||
if reply.isValid() and reply.value():
|
|
||||||
verd = True
|
|
||||||
elif not reply.isValid():
|
|
||||||
logging.error(msg.arguments()[0])
|
|
||||||
|
|
||||||
# Lock needs to be released before callback can be triggered
|
|
||||||
if verd:
|
|
||||||
return self.add_connection_signal.emit()
|
|
||||||
|
|
||||||
self.connection = connection
|
|
||||||
if connection.app_path is not None:
|
|
||||||
app_name, app_icon = self.desktop_parser.get_info_by_path(
|
|
||||||
connection.app_path)
|
|
||||||
else:
|
|
||||||
app_name = 'Unknown'
|
|
||||||
app_icon = None
|
|
||||||
|
|
||||||
self.setup_labels(app_name)
|
|
||||||
self.setup_icon(app_icon)
|
|
||||||
self.setup_extra()
|
|
||||||
self.result = Dialog.DEFAULT_RESULT
|
|
||||||
self.action_combo_box.setCurrentIndex(0)
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def trigger_handle_connection(self):
|
|
||||||
return self.add_connection_signal.emit()
|
|
||||||
|
|
||||||
def setup_labels(self, app_name):
|
|
||||||
self.app_name_label.setText(app_name or 'Unknown')
|
|
||||||
|
|
||||||
message = self.MESSAGE_TEMPLATE % (
|
|
||||||
helpers.get_app_name_and_cmdline(self.connection),
|
|
||||||
self.connection.app_pid or 'Unknown',
|
|
||||||
self.connection.hostname,
|
|
||||||
self.connection.proto.upper(),
|
|
||||||
self.connection.dst_port,
|
|
||||||
helpers.get_service(self.connection))
|
|
||||||
self.message_label.setText(message)
|
|
||||||
|
|
||||||
def init_widgets(self):
|
|
||||||
self.app_name_label = self.findChild(QtWidgets.QLabel,
|
|
||||||
"appNameLabel")
|
|
||||||
self.message_label = self.findChild(QtWidgets.QLabel,
|
|
||||||
"messageLabel")
|
|
||||||
self.action_combo_box = self.findChild(QtWidgets.QComboBox,
|
|
||||||
"actionComboBox")
|
|
||||||
self.allow_button = self.findChild(QtWidgets.QPushButton,
|
|
||||||
"allowButton")
|
|
||||||
self.deny_button = self.findChild(QtWidgets.QPushButton,
|
|
||||||
"denyButton")
|
|
||||||
self.whitelist_button = self.findChild(QtWidgets.QPushButton,
|
|
||||||
"whitelistButton")
|
|
||||||
self.block_button = self.findChild(QtWidgets.QPushButton,
|
|
||||||
"blockButton")
|
|
||||||
self.icon_label = self.findChild(QtWidgets.QLabel, "iconLabel")
|
|
||||||
|
|
||||||
def start_listeners(self):
|
|
||||||
self.allow_button.clicked.connect(self._allow_action)
|
|
||||||
self.deny_button.clicked.connect(self._deny_action)
|
|
||||||
self.whitelist_button.clicked.connect(self._whitelist_action)
|
|
||||||
self.block_button.clicked.connect(self._block_action)
|
|
||||||
self.action_combo_box.currentIndexChanged[str].connect(
|
|
||||||
self._action_changed)
|
|
||||||
|
|
||||||
def setup_icon(self, app_icon):
|
|
||||||
if app_icon is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
icon = QtGui.QIcon().fromTheme(app_icon)
|
|
||||||
pixmap = icon.pixmap(icon.actualSize(QtCore.QSize(48, 48)))
|
|
||||||
self.icon_label.setPixmap(pixmap)
|
|
||||||
|
|
||||||
def setup_extra(self):
|
|
||||||
self._action_changed()
|
|
||||||
|
|
||||||
def _action_changed(self):
|
|
||||||
s_option = self.action_combo_box.currentText()
|
|
||||||
if s_option == "Until Quit" or s_option == "Forever":
|
|
||||||
self.whitelist_button.show()
|
|
||||||
self.block_button.show()
|
|
||||||
elif s_option == "Once":
|
|
||||||
self.whitelist_button.hide()
|
|
||||||
self.block_button.hide()
|
|
||||||
|
|
||||||
def _allow_action(self):
|
|
||||||
self._action(RuleVerdict.ACCEPT, False)
|
|
||||||
|
|
||||||
def _deny_action(self):
|
|
||||||
self._action(RuleVerdict.DROP, False)
|
|
||||||
|
|
||||||
def _whitelist_action(self):
|
|
||||||
self._action(RuleVerdict.ACCEPT, True)
|
|
||||||
|
|
||||||
def _block_action(self):
|
|
||||||
self._action(RuleVerdict.DROP, True)
|
|
||||||
|
|
||||||
def set_conn_result(self, connection_id, save_option,
|
|
||||||
verdict, apply_to_all):
|
|
||||||
msg = self.app.dbus_handler.interface.call(
|
|
||||||
'connection_set_result',
|
|
||||||
connection_id,
|
|
||||||
RuleSaveOption(save_option).value,
|
|
||||||
RuleVerdict(verdict).value,
|
|
||||||
apply_to_all)
|
|
||||||
reply = QtDBus.QDBusReply(msg)
|
|
||||||
if not reply.isValid():
|
|
||||||
logging.info(
|
|
||||||
'Could not apply result to connection "%s"', connection_id)
|
|
||||||
logging.error(msg.arguments()[0])
|
|
||||||
|
|
||||||
def _action(self, verdict, apply_to_all=False):
|
|
||||||
with self.rule_lock:
|
|
||||||
s_option = self.action_combo_box.currentText()
|
|
||||||
|
|
||||||
if s_option == "Once":
|
|
||||||
option = RuleSaveOption.ONCE
|
|
||||||
elif s_option == "Until Quit":
|
|
||||||
option = RuleSaveOption.UNTIL_QUIT
|
|
||||||
elif s_option == "Forever":
|
|
||||||
option = RuleSaveOption.FOREVER
|
|
||||||
|
|
||||||
self.set_conn_result(self.connection.id, option,
|
|
||||||
verdict, apply_to_all)
|
|
||||||
|
|
||||||
# Check if we have any unhandled connections on the queue
|
|
||||||
self.connection = None # Indicate next connection can be handled
|
|
||||||
self.hide()
|
|
||||||
return self.add_connection_signal.emit()
|
|
|
@ -1,45 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from socket import getservbyport
|
|
||||||
|
|
||||||
|
|
||||||
def get_service(conn):
|
|
||||||
dst_port = conn.dst_port
|
|
||||||
proto = conn.proto
|
|
||||||
try:
|
|
||||||
return ' ({}) '.format(getservbyport(int(dst_port), proto))
|
|
||||||
except:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
|
|
||||||
def get_app_name_and_cmdline(conn):
|
|
||||||
if conn.proto == 'icmp':
|
|
||||||
return 'Unknown'
|
|
||||||
|
|
||||||
if conn.app_cmdline is not None:
|
|
||||||
# TODO: Figure out why we get mixed types here
|
|
||||||
cmdline = conn.app_cmdline if isinstance(conn.app_cmdline, str) else conn.app_cmdline.decode() # noqa
|
|
||||||
path = conn.app_path if isinstance(conn.app_path, str) else conn.app.path_decode() # noqa
|
|
||||||
|
|
||||||
if cmdline.startswith(conn.app_path):
|
|
||||||
return cmdline
|
|
||||||
else:
|
|
||||||
return "%s %s" % (path, cmdline)
|
|
||||||
else:
|
|
||||||
return conn.app_path
|
|
|
@ -1,243 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog</class>
|
|
||||||
<widget class="QDialog" name="Dialog">
|
|
||||||
<property name="windowModality">
|
|
||||||
<enum>Qt::NonModal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>430</width>
|
|
||||||
<height>169</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>430</width>
|
|
||||||
<height>160</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>680</width>
|
|
||||||
<height>250</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="sizeIncrement">
|
|
||||||
<size>
|
|
||||||
<width>35</width>
|
|
||||||
<height>9</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<kerning>true</kerning>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>OpenSnitch</string>
|
|
||||||
</property>
|
|
||||||
<property name="sizeGripEnabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="modal">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="sizeConstraint">
|
|
||||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
|
||||||
</property>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QPushButton" name="whitelistButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Whitelist app</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="5">
|
|
||||||
<widget class="QLabel" name="iconLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1" colspan="2">
|
|
||||||
<widget class="QPushButton" name="blockButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Block app</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="3">
|
|
||||||
<widget class="QPushButton" name="denyButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Deny</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="4" colspan="2">
|
|
||||||
<widget class="QPushButton" name="allowButton">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Allow</string>
|
|
||||||
</property>
|
|
||||||
<property name="default">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="2">
|
|
||||||
<widget class="QComboBox" name="actionComboBox">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>97</width>
|
|
||||||
<height>26</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>97</width>
|
|
||||||
<height>26</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Once</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Until Quit</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Forever</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="actionLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Take this action:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="5">
|
|
||||||
<widget class="QLabel" name="appNameLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>15</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Chromium Web Browser</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="6">
|
|
||||||
<widget class="QLabel" name="messageLabel">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>600</width>
|
|
||||||
<height>400</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="sizeIncrement">
|
|
||||||
<size>
|
|
||||||
<width>35</width>
|
|
||||||
<height>18</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::ActionsContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Chromium Web Browser (/usr/lib/chromium-browser) wants to connect to host 127.0.0.1 on TCP port 443 (https)</string>
|
|
||||||
</property>
|
|
||||||
<property name="textFormat">
|
|
||||||
<enum>Qt::RichText</enum>
|
|
||||||
</property>
|
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="indent">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="textInteractionFlags">
|
|
||||||
<set>Qt::TextBrowserInteraction</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,229 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog</class>
|
|
||||||
<widget class="QDialog" name="Dialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>710</width>
|
|
||||||
<height>316</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>37</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>490</width>
|
|
||||||
<height>220</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>1000</width>
|
|
||||||
<height>400</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<kerning>true</kerning>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>OpenSnitch</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QLabel" name="appNameLabel">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>20</x>
|
|
||||||
<y>20</y>
|
|
||||||
<width>433</width>
|
|
||||||
<height>42</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>15</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Chromium Web Browser</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>60</y>
|
|
||||||
<width>711</width>
|
|
||||||
<height>16</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLabel" name="messageLabel">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>20</x>
|
|
||||||
<y>90</y>
|
|
||||||
<width>661</width>
|
|
||||||
<height>81</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Chromium Web Browser (/usr/lib/chromium-browser) wants to connect to host 127.0.0.1 on TCP port 443 (https)</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="whitelistButton">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>20</x>
|
|
||||||
<y>240</y>
|
|
||||||
<width>160</width>
|
|
||||||
<height>50</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Whitelist app</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="blockButton">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>190</x>
|
|
||||||
<y>240</y>
|
|
||||||
<width>160</width>
|
|
||||||
<height>50</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Block app</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="denyButton">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>360</x>
|
|
||||||
<y>240</y>
|
|
||||||
<width>160</width>
|
|
||||||
<height>50</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Deny</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="allowButton">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>530</x>
|
|
||||||
<y>240</y>
|
|
||||||
<width>160</width>
|
|
||||||
<height>50</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Allow</string>
|
|
||||||
</property>
|
|
||||||
<property name="default">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QComboBox" name="actionComboBox">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>190</x>
|
|
||||||
<y>190</y>
|
|
||||||
<width>160</width>
|
|
||||||
<height>35</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>97</width>
|
|
||||||
<height>26</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>204</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Once</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Until Quit</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Forever</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLabel" name="actionLabel">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>20</x>
|
|
||||||
<y>190</y>
|
|
||||||
<width>161</width>
|
|
||||||
<height>31</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Take this action:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLabel" name="iconLabel">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>640</x>
|
|
||||||
<y>5</y>
|
|
||||||
<width>60</width>
|
|
||||||
<height>60</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,19 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
VERSION = '0.0.2'
|
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
56
setup.py
56
setup.py
|
@ -1,56 +0,0 @@
|
||||||
# This file is part of OpenSnitch.
|
|
||||||
#
|
|
||||||
# Copyright(c) 2017 Simone Margaritelli
|
|
||||||
# evilsocket@gmail.com
|
|
||||||
# http://www.evilsocket.net
|
|
||||||
#
|
|
||||||
# This file may be licensed under the terms of of the
|
|
||||||
# GNU General Public License Version 2 (the ``GPL'').
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed
|
|
||||||
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
||||||
# express or implied. See the GPL for the specific language
|
|
||||||
# governing rights and limitations.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GPL along with this
|
|
||||||
# program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
from setuptools import setup, find_packages
|
|
||||||
from opensnitch.version import VERSION
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info[0] != 3:
|
|
||||||
raise RuntimeError('Unsupported python version "{0}"'.format(
|
|
||||||
sys.version_info[0]))
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open('README.md') as f:
|
|
||||||
long_description = f.read()
|
|
||||||
except:
|
|
||||||
long_description = 'OpenSnitch - An application level firewall for GNU/Linux.' # noqa
|
|
||||||
|
|
||||||
|
|
||||||
setup(name='opensnitch',
|
|
||||||
version=VERSION,
|
|
||||||
description=long_description,
|
|
||||||
long_description=long_description,
|
|
||||||
author='Simone Margaritelli',
|
|
||||||
author_email='evilsocket@gmail.com',
|
|
||||||
url='http://www.github.com/evilsocket/opensnitch',
|
|
||||||
packages=find_packages(),
|
|
||||||
scripts=['bin/opensnitchd', 'bin/opensnitch-qt'],
|
|
||||||
package_data={'': ['*.ui']},
|
|
||||||
license='GPL',
|
|
||||||
zip_safe=False,
|
|
||||||
install_requires=[
|
|
||||||
'scapy-python3',
|
|
||||||
'dpkt',
|
|
||||||
'NetfilterQueue',
|
|
||||||
'psutil',
|
|
||||||
'pyinotify',
|
|
||||||
'python-iptables',
|
|
||||||
'python-prctl',
|
|
||||||
'pygobject',
|
|
||||||
])
|
|
Loading…
Add table
Reference in a new issue