diff --git a/DISCLAIMER.md b/DISCLAIMER.md
new file mode 100644
index 0000000..4b064b6
--- /dev/null
+++ b/DISCLAIMER.md
@@ -0,0 +1,14 @@
+DISCLAIMER
+==========
+
+**P4wnP1 A.L.O.A.** is dedicated to penetration testers, redteamers and InfoSec personal.
+It should be used for authorized testing and/or educational purposes only.
+The only exception is using it against devices or a network, owned by yourself.
+
+I take no responsibility for the abuse of P4wnP1 A.L.O.A. or any information given in the
+related documents.
+
+**I DO NOT GRANT PERMISSIONS TO USE P4wnP1 A.L.O.A. TO BREAK THE LAW.**
+
+As P4wnP1 A.L.O.A. is in alpha stage, it is likely that bugs occur.
+I disclaim any warranty for P4wnP1 A.L.O.A., it is provided "as is".
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
index 900c6b6..8641e07 100644
--- a/README.md
+++ b/README.md
@@ -1208,13 +1208,208 @@ You have learned about the very basic workflow concepts of P4wnP1 A.L.O.A.
## 3. Where to go from here
-Under construction
+It is currently not possible to provide a full documentations. So here are some comments on topics which haven't been
+touched, yet, but are worth investigating.
-- bash scripts
-- GPIO
-- nexmon (karma)
-- WiFi covert channel example
-- bluetooth NAP
+### BashScripts
+
+P4wnP1 allows running BashScripts from TriggerActions. The scripts which are usable from TriggerActions are homed at
+`/usr/local/P4wnP1/scripts`. If a script is called from a TriggerAction, several arguments (like the actual trigger) are
+handed in via bash variables. The file `/usr/local/P4wnP1/scripts/trigger-aware.sh` provides a nice example of a bash
+script which acts differently, depending on the calling trigger. It is worth having a look onto this script, as it uses
+all "TriggerAction variables" currently available.
+
+### GPIO
+
+The community of the old P4wnP1 version occasionally came up with hardware mods or extensions of the Rapsberry PI and
+the question how to integrate them. It isn't possible for me to provide a generic solution to this problem. Neither
+is it a good idea, to provide support for a very specific hardware extension, which is only used by a few people. With
+the introduction of TriggerAction the idea came up, to support GPIO as both, Triggers via GPIO input and Actions issuing
+GPIO output. Although not planned for the first release, this feature has already been implemented. I still haven't
+had the time to document it and it could easily happen that some things change. The functionality uses the "periph.io"
+library with some minor extension (customized edge detection with custom de-bounce for GPIO, thanks to @marcaruel for
+exchange on this)
+
+### nexmon KARMA
+
+The WiFi firmware included with P4wnP1 A.L.O.A. has been modified (utilizing nexmon framework) to support KARMA.
+This feature hasn't made it into the core so far (needs some rework firmware-wise) and thus isn't available from
+webclient or CLI. If you want to play around with the karma features, there is a legacy python CLI, which allows setting
+the KARMA options on the fly. The python script could be found here:
+`/usr/local/P4wnP1/legacy/karmatool.py`
+
+Tip: To get most out of the KARMA functionality, you should setup P4wnP1 A.L.O.A. to provide a WiFi Access Point without
+authentication, otherwise it wouldn't make to much sense. For poor beacon flooding this isn't needed, but (static)
+custom SSIDs for beaconing are limited in their number (saving resources on the WiFi chip)
+
+### WiFi covert channel
+
+The WiFi covert channel hasn't been ported to Go and isn't part of the P4wnP1 core. Anyways, the legacy functionality
+is provided. In order to make the covert channel run, several conditions have to be met:
+- a keystroke injection has to be applied to the target client to inject stage1
+- stage1 loads stage2 over a (simplified version) of the HID covert channel, thus a special USB HID device has to be
+provided and a special HID covert channel server has to be started on P4wnP1, in order to provide stage2
+- a second server has to be started and interface the modified WiFi firmware, in order to manage client connecting
+in via the WiFi covert channel and provide interactive shell access to those clients (the server is a console
+application which is meant to run in a terminal multiplexer, like `screen`)
+
+All of the aforementioned conditions could be fulfilled using P4wnP1 A.L.O.A.'s feature set, if the needed components
+(HID stager, WiFi cover channel server, client agent to deliver) are provided.
+
+To carry out such a task with P4wnP1 A.L.O.A. is a great example for its capabilities. Additionally it helps to
+distinguish what P4wnP1 A.L.O.A. is meant to be and what is not meant to be.
+
+P4wnP1 A.L.O.A. is not meant to:
+- be a "weaponized" tool
+- provide RTR payloads, which could be carried out by everybody, without understanding what's going on or which risks
+are involved
+
+P4wnP1 A.L.O.A. is meant to:
+- be a flexible, low-cost, pocket sized platform
+- serve as enabler for tasks like the one described here
+- support prototyping, testing and carrying out all kinds of USB related tasks, commonly used during pentest or
+redteam engagements, without providing a finalized static solution
+
+In set sense, the `/usr/local/P4wnP1/legacy` folder homes the needed external tools to run the WiFi covert channel
+(namely the WiFi server, the HID covert channel stager server and the WiFi covert channel client agent). Those
+components could be considered as external parts (don't belong to P4wnP1 A.L.O.A. core).
+
+Additionally P4wnP1 A.L.O.A. provides a configuration, which utilizes the given components to do the following things:
+- drive-by against Windows hosts in order to deliver in-memory client code to download stage2 via HID covert channel,
+based on keystroke injection (HIDScript)
+- starting the keystroke injection, as soon as P4wnP1 is connected to a USB host (TriggerAction issuing HIDScript)
+- bring up the stager, which delivers the WiFi covert channel client agent via HID covert channel, as soon as the
+keystroke injection starts (TriggerAction running a bash script, which again starts the external server)
+- bring up the WiFi covert channel server, when needed (same TriggerAction and BashScript)
+- deploy a USB setup which provides a USB keyboard (to allow keystroke injection) and an additional raw HID device
+(serves as covert channel for stage2 delivery) - the USB settings are stored in a settings template
+- deploy a WiFi setup, which allows remote access to P4wnP1, in order to allow interaction with the CLI frontend of
+the WiFi covert channel server - the WiFi settings are stored in a settings template
+- provide a single point of entry, to deploy all the needed configurations at once (done by a Master Template, which
+consists of proper WiFi settings, proper USB settings and the TriggerActions needed to start the HIDScript)
+
+The Master Template is called "wifi covert channel". By deploying it from the "generic settings" tap of the webclient
+("DEPLOY STORED" from the Master Template Editor) P4wnP1 A.L.O.A. is ready configured to execute all the describe steps.
+
+As soon as it is re-attached to a USB host, it should start typing out stage1 and the according servers are started
+internally.
+From a SSH session (for example over WiFi) the WiFi covert channel server could be accessed using `screen -d -r wifi_c2`
+to interact with clients, which connected back over the WiFi covert channel.
+As the keystroke injection depends on the USB hosts language layout, the according HIDScript called
+`wifi_covert_channel.js` has a variable `language` which could be used to adjust the keyboard layout in use.
+Additionally there is a variable called `hide` (false by default). If `hide` is set to true, the console Window on
+the client gets hidden while stage1 is typed. This, again, pinpoints how complex tasks could be reduced to a simple bool
+variable, thanks to HIDScript and the backing JavaScript engine.
+
+The "wifi covert channel" demo provided with P4wnP1's Master Templates could be used as Startup Master Template, too, as
+WiFi access is still possible and thus the setup could be changed again, remotely at any time.
+
+The involved BashScript, which is called from a TriggerAction is a good example how flexible the CLI client could get.
+As the HID stager needs to know on which device file to listen (the one which represents the generic HID device), but
+this information is only available at runtime (depends on enabled USB gadget functions), the script requests the CLI
+to report the correct HID device by running `hidraw=$(P4wnP1_cli usb get device raw)`.
+
+The full BashScript is hosted in the folder `/usr/local/P4wnP1/scripts`, as all bash scripts which should be accessible
+from TriggerActions.
+
+### Bluetooth NAP
+
+P4wnP1 provides Bluetooth based network functionality over the Bluetooth Network Encapsulation Protocol (BNEP).
+The currently most interesting feature is the Bluetooth Network Access Point (NAP), which allows IP based Bluetooth
+remote access to P4wnP1, for example from mobiles.
+
+In order to use this feature some things should be known:
+- The bluetooth network interface, called `bteth` could be configured and templated like the other network interfaces
+(webclient or CLI)
+- In order to allow NAP access from an Android mobile (iPhone untested), the mobile not only needs to connect, but
+additionally P4wnP1 has to hand out a proper IP for the default gateway on the `bteth` interface via DHCP. This is,
+because the mobile wants to use the NAP as gateway to the Internet (which would be the intended use). If the NAP itself
+wouldn't provide a gateway, the Android Mobile would do no further requests after the DHCP D.O.R.A. The easiest way to
+overcome this, is to instruct the DHCP server to provide the IP of the `bteth` interface itself as default gateway
+(DHCP option 3). Even if there is no real upstream connection, this worked during my tests - as the mobile has to access
+the gateway with layer3 communication in order to "phone home". Even if successive connectivity tests fail, the working
+layer 3 connection persists. This allows, for example, SSH access via Bluetooth. With "High Speed" enabled, the
+webclient works pretty nice, too.
+- In order to allow PIN based pairing Simple Secure Pairing (SSP) has to be disabled. If SSP is enabled, the running
+Pairing agent confirms every passkey (which means even less security than with legacy PIN pairing, as every device is
+able to connect). Maybe a confirmation dialog for SSP based passkey pairing will be implemented for the CLI/webclient
+in future, but currently this is out of scope. I highly suggest to disable "discoverable" and "bondable" if SSP is in
+use, as soon as the intended device has paired.
+- Another shortcoming of having SSP disabled, is that "High Speed" wouldn't be usable for bluetooth conections (or
+to enable High Speed, pairing has to be done with SSP). Without "High Speed" enabled (uses 802.11 frames for
+communication) it would take about 10 minutes to request the webclient, with high speed enabled it takes some seconds.
+Using SSH and the CLI client over a NAP without "High Speed" should be fine, though.
+- The default Bluetooth network interface settings (`bteth_startup`) and the default Bluetooth settings (`startup`)
+should allow "Low Speed" access over SSH with legacy PIN pairing. The PIN is `1337` and could be changed from the
+webclient.
+
+### TriggerAction Groups
+
+The TriggerActions come with a nice rooting capability called "Groups". I didn't managed to come up with a feature demo
+in time, but I'm planning to include an example for an LED based 4 bit binary counter (using GPIOs, a toggle switch
+and 4 LEDs).
+
+The idea of groups is the following:
+
+Consider you want to have 4 TriggerActions (TAs) firing on the exact same Trigger (for example "on attached to USB host").
+You could achieve this by creating 4 TAs, each with the Trigger "on attached to USB host".
+
+Alternatively, you could bring up a TriggerAction which sends the value `1` to a group named `"connected"` when the
+"on attached to USB host" occurs. Now you define your other 4 TriggerActions to fire when the value `1` is received on
+a group named `"connected"`. The result would be the same and not make too much sense for now (in fact it needs one
+more TriggerAction). The only positive effect, for now, is that the TriggerActions are slightly more readable, thanks
+to the group name, which could be chosen freely.
+
+Now the first advanced thing you could do, is to run the following CLI command:
+
+```
+P4wnP1_cli trigger send --group-name=connected --group-value=1
+```
+
+This command would have the exatc same effect as the "on attached to USB host" host TriggerAction and all 4 other
+TAs, which are waiting for the value `1` to arrive on the group `connected` would fire. As you maybe remember, the
+CLI client could run remotely (from different platforms), so it could be used to Trigger command remotely.
+
+The Trigger which reacts on "Group channels" is called "value on group channel". The more interesting trigger is called
+"multiple values on group channel". This "multiple values" trigger allows to listen for ordered sequences of values, or
+one of multiple values or all values in an unordered sequence, before it fires.
+
+Let's say you qant to fire a BashScript, when these conditions are met:
+- The WiFi AP is up
+- P4wnP1 has been connected to a USB host
+
+You could create TAs for both events like this:
+1) On "WiFi AP up" --> send value 1 to group "conditions"
+2) On "attached to USB host" --> send value 2 to group "conditions"
+
+Now you could deploy a third TriggerAction like this
+- On "multiple values on group channel"; values (1,2); type "All (logical AND)" --> start bash script
+
+In this configuration, the bash script would only start if both "condition" Trigger have fired.
+
+If "exact ordered sequence" would have been used, instead of "All (logical AND)" for the type, the bash script would
+only start if the WiFi AP come up before the USB connected Trigger (not the otherway around). In combination with GPIO
+triggers, this could for example be used, to trigger actions based on the input of a simple PIN pad.
+
+I'm sure you have some nice usage ideas for "group" channels.
+
+Worth mentioning:
+
+The CLI client is able to do a blocking wait, till a dedicated value arrives on a "group channel", using a command like
+this:
+
+```
+P4wnP1_cli trigger wait --group-name=waitgroup --group-value=1
+```
+
+This could be used, to drive scripts from TriggerActions, utilizing the CLI (with their full power like GPIO).
+
+
+Work in progress, missing sections:
+- HIDScript Trigger variables (variables handed in to HIDScripts fired from TriggerActions)
+- HIDScript helpers (powershell functions)
+- HIDScript demo snake (mouse)
+- USB Mass storage
## 4. Rescue: Help, I can't reach P4wnP1 A.L.O.A. as i messed up the configuration
@@ -1277,7 +1472,68 @@ Sorry, seems you have to recreate your P4wnP1 A.L.O.A. SD crad from a clean imag
## 5. Credits
-Under construction
+Under construction, random order
-## 6. Licencing (3rd party under construction)
+- @JohanBrandhorst (close exchange on gRPC-web via gopherjs, ridiculous fast implementation of
+"websocket for server streaming", feature request)
+- @steevdave, @_binkybear (kali build scripts, discussion ongoing exchange)
+- @Re4sonKernel (Support on moving P4wnP1 kernel changes to a well maintained and popular repo, collaboration on Bluez
+fixes)
+- @SymbianSyMoh (Inspiration for HID attack re-trigger without reboot)
+- @quasarframework (could list this under 3rd party libs, but the work done here is insane; the look&feel of the
+P4wnP1 webclient is more or lees based on default components of this beautiful library)
+- @CyberArms (one of the most early P4wnP1 supporters, writer of the best tutorial and even books on such topics)
+- @LucaBongiorni (not only one of the earliest supporters, he does in hardware, what I'm only to do in software; he
+gives talks on the USB topic and honors Open Source solutions, all in all a great guy and an inspiration)
+- @evilsocket (his block pushed me towards Go, a great OSS developer, read his code and you know what I mean)
+- @RoganDawes and @Singe from @SensePost (inspiring guys)
+- @Swiftb0y (Early supporter, creator of the "old" P4wnP1 WiKi, early tester for ideas on P4wnP1 A.L.O.A.)
+- @marcaruel (discussion on GPIO edge detection using periph.io)
+## 6. ToDos and support
+
+This isn't a full fledged ToDo list, but some milestones are left and I'd be happy to receive som community support on
+this
+- Porting the full HID covert channel functionality to Go core (I'm on my own with that)
+- **add Bluetooth configuration command for CLI**
+- **Create missing keyboard layouts** (currently only "us" and "de" are supported, as this has been a low priority task
+during development of core features)
+- extend Bluetooth functionality to allow connection to other discoverable devices (authentication and trust)
+- move WiFi KARMA functionality from dedicated python tool to P4wnP1 core (with webclient support))
+- Create full documentation for HIDScript (basically only the mouse part is missing)
+- Create full documentation for P4wnP1 (hoping for community)
+- Get rid of a remaining dependency on the docker netlink (see README of the `netlink` folder)
+
+Note on Bluetooth:
+
+P4wnP1 works with custom bindings to the Bluez API. Although the Bluez API supports Low Energy (GATT,
+emulating peripherals etc.) it isn't planned to integrate this functionality into P4wnP1 A.L.O.A.
+
+Note on Nexmon:
+
+P4wnP1 utilizes nexmon. Most people know nexmon as a firmware modification which allows enabling monitor
+mode and package injection for broadcom WiFi chips (including the BCM43430a1, which is used by the Raspberry Pi Zero W).
+But nexmon is more, it is a framework which allows modifying ARM firmware blobs (after a bit of reversing), with patches
+written in high level C code. P4wnP1 uses this framework, to apply custom patches to the WiFi firmware, which enable
+hardware based KARMA support and firmware (as well as driver) support for the WiFi covert channel. It isn't the aim
+of this modifications to provide proper monitor mode or injection support for the built-in WiFi interface. Although,
+the legacy nexmon monitor mode functionality is included in the current WiFi firmware, it is considered "erroneous", as
+it interferes with standard WiFi functionality used by P4wnP1 (crashes if the interface is used in station mode etc.).
+
+## 7. Copyright
+
+ P4wnP1 A.L.O.A.
+ Copyright (C) 2018 Marcus Mengs
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
\ No newline at end of file
diff --git a/netlink/LICENSE b/netlink/LICENSE
new file mode 100644
index 0000000..2744858
--- /dev/null
+++ b/netlink/LICENSE
@@ -0,0 +1,191 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ Copyright 2014 Docker, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/netlink/NOTICE b/netlink/NOTICE
new file mode 100644
index 0000000..fc79897
--- /dev/null
+++ b/netlink/NOTICE
@@ -0,0 +1,16 @@
+libcontainer
+Copyright 2012-2015 Docker, Inc.
+
+This product includes software developed at Docker, Inc. (http://www.docker.com).
+
+The following is courtesy of our legal counsel:
+
+
+Use and transfer of Docker may be subject to certain restrictions by the
+United States and other governments.
+It is your responsibility to ensure that your use and/or transfer does not
+violate applicable laws.
+
+For more information, please see http://www.bis.doc.gov
+
+See also http://www.apache.org/dev/crypto.html and/or seek legal counsel.
diff --git a/netlink/README.md b/netlink/README.md
new file mode 100644
index 0000000..d72776d
--- /dev/null
+++ b/netlink/README.md
@@ -0,0 +1,12 @@
+This folder contains an extended version of
+
+github.com/docker/libcontainer
+
+The changes to the original (which only consists of additions) could be seen in `docker.diff`.
+
+The LICENSE of the unmodified library applies (Apache-2.0).
+
+Please see the LICENSE and NOTICE file for details.
+
+It is planned to migrate the needed functionality of this library, which is needed to work for P4wnP1 A.L.O.A. to the
+`mnetlink` library of this project, as soon as there is the time to do so.
\ No newline at end of file
diff --git a/netlink/docker.diff b/netlink/docker.diff
new file mode 100644
index 0000000..421fee8
--- /dev/null
+++ b/netlink/docker.diff
@@ -0,0 +1,513 @@
+--- ../../docker/libcontainer/netlink/netlink_linux.go 2018-05-03 13:34:22.615800101 +0200
++++ netlink/netlink_linux.go 2018-11-13 12:42:55.325253104 +0100
+@@ -11,6 +11,7 @@
+ "syscall"
+ "time"
+ "unsafe"
++ "errors"
+ )
+
+ const (
+@@ -31,12 +32,24 @@
+ )
+
+ const (
+- MACVLAN_MODE_PRIVATE = 1 << iota
++ MACVLAN_MODE_PRIVATE = 1 << iota
+ MACVLAN_MODE_VEPA
+ MACVLAN_MODE_BRIDGE
+ MACVLAN_MODE_PASSTHRU
+ )
+
++const (
++ // See linux/if_arp.h.
++ // Note that Linux doesn't support IPv4 over IPv6 tunneling.
++ sysARPHardwareIPv4IPv4 = 768 // IPv4 over IPv4 tunneling
++ sysARPHardwareIPv6IPv6 = 769 // IPv6 over IPv6 tunneling
++ sysARPHardwareIPv6IPv4 = 776 // IPv6 over IPv4 tunneling
++ sysARPHardwareGREIPv4 = 778 // any over GRE over IPv4 tunneling
++ sysARPHardwareGREIPv6 = 823 // any over GRE over IPv6 tunneling
++)
++
++var errNoSuchInterface = errors.New("no such network interface")
++
+ var nextSeqNr uint32
+
+ type ifreqHwaddr struct {
+@@ -143,6 +156,29 @@
+ return syscall.SizeofIfAddrmsg
+ }
+
++type RtGenmsg struct {
++ syscall.RtGenmsg
++}
++
++func newRtGenMsg(family int) *RtGenmsg {
++ return &RtGenmsg{
++ RtGenmsg: syscall.RtGenmsg{
++ Family: uint8(family),
++ },
++ }
++}
++
++func (msg *RtGenmsg) ToWireFormat() []byte {
++ length := syscall.SizeofRtGenmsg
++ b := make([]byte, length)
++ b[0] = msg.Family
++ return b
++}
++
++func (msg *RtGenmsg) Len() int {
++ return syscall.SizeofRtGenmsg
++}
++
+ type RtMsg struct {
+ syscall.RtMsg
+ }
+@@ -462,6 +498,78 @@
+ return s.HandleAck(wb.Seq)
+ }
+
++// see https://www.infradead.org/~tgr/libnl/doc/route.html
++
++// Returns an array of IPNet for all the currently routed subnets on ipv4
++// This is similar to the first column of "ip route" output
++func NetworkLinkGetStateUp(iface *net.Interface) (res bool,err error) {
++ //fmt.Println("Needed if idx", iface.Index)
++
++ s, err := getNetlinkSocket()
++ if err != nil {
++ return false,err
++ }
++ defer s.Close()
++
++ wb := newNetlinkRequest(syscall.RTM_GETLINK, syscall.NLM_F_DUMP)
++
++ msg := newIfInfomsg(syscall.AF_UNSPEC)
++ msg.Index = int32(iface.Index)
++
++ wb.AddData(msg)
++
++ if err := s.Send(wb); err != nil {
++ return false, err
++ }
++
++ // retrieve PID
++ pid, err := s.GetPid()
++ if err != nil {
++ return false, err
++ }
++
++outer:
++// Receive loop
++ for {
++ msgs, err := s.Receive()
++ if err != nil {
++ return false, err
++ }
++ // loop over incoming NL messages
++ for _, m := range msgs {
++ // fmt.Printf("Message %+v\n", m)
++
++ // check if seq number and receiver PID are correct, abort receive loop on Type == NLMSG_DONE (translated to EOF)
++ if err := s.CheckMessage(m, wb.Seq, pid); err != nil {
++ if err == io.EOF {
++ break outer // abort receive loop if multipart messages reached eof
++ }
++ return false, err
++ }
++
++ // the result we want to fetch
++ if m.Header.Type != syscall.RTM_NEWLINK {
++ continue
++ }
++
++ //Cast first part to IfInfoMsg
++ msg := (*IfInfomsg)(unsafe.Pointer(&m.Data[0:syscall.SizeofIfInfomsg][0]))
++
++ // Ignore message for different interface
++ if msg.Index != int32(iface.Index) {
++ continue
++ }
++
++ if_up := msg.Flags&syscall.IFF_UP != 0
++ //fmt.Printf("Message: %+v\n", msg)
++ //fmt.Printf("Flag IFF_UP: %+v\n", if_up)
++ return if_up, nil
++ }
++ }
++
++ return false, errors.New("Couldn't retreive link state")
++}
++
+ // Bring up a particular network interface.
+ // This is identical to running: ip link set dev $name up
+ func NetworkLinkUp(iface *net.Interface) error {
+@@ -550,6 +658,38 @@
+ return s.HandleAck(wb.Seq)
+ }
+
++//Added by MaMe82
++// Bring down a particular network interface.
++// This is identical to running: ip link set $name down
++func NetworkSetMulticast(iface *net.Interface, enable bool) error {
++ s, err := getNetlinkSocket()
++ if err != nil {
++ return err
++ }
++ defer s.Close()
++
++ wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK)
++
++ msg := newIfInfomsg(syscall.AF_UNSPEC)
++ msg.Index = int32(iface.Index)
++ msg.Flags = syscall.NLM_F_REQUEST
++ msg.Change = DEFAULT_CHANGE
++ msg.IfInfomsg.Change |= syscall.IFF_MULTICAST
++ if enable {
++ msg.IfInfomsg.Flags |= syscall.IFF_MULTICAST
++ } else {
++ msg.IfInfomsg.Flags = uint32(int(msg.IfInfomsg.Flags) & ^syscall.IFF_MULTICAST)
++ }
++
++ wb.AddData(msg)
++
++ if err := s.Send(wb); err != nil {
++ return err
++ }
++
++ return s.HandleAck(wb.Seq)
++}
++
+ // Set link Maximum Transmission Unit
+ // This is identical to running: ip link set dev $name mtu $MTU
+ // bridge is a bitch here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=292088
+@@ -907,6 +1047,45 @@
+ return s.HandleAck(wb.Seq)
+ }
+
++func networkLinkIpAction4(action, flags int, ifa IfAddr, ifa_broadcast IfAddr) error {
++ s, err := getNetlinkSocket()
++ if err != nil {
++ return err
++ }
++ defer s.Close()
++
++ family := getIpFamily(ifa.IP)
++ if family != syscall.AF_INET {
++ return errors.New("Address family has to be AF_INET (IPv4)")
++ }
++
++ wb := newNetlinkRequest(action, flags)
++
++ msg := newIfAddrmsg(family)
++ msg.Index = uint32(ifa.Iface.Index)
++ prefixLen, _ := ifa.IPNet.Mask.Size()
++ msg.Prefixlen = uint8(prefixLen)
++ wb.AddData(msg)
++
++ ipData := ifa.IP.To4()
++
++ localData := newRtAttr(syscall.IFA_LOCAL, ipData)
++ wb.AddData(localData)
++
++ addrData := newRtAttr(syscall.IFA_ADDRESS, ipData)
++ wb.AddData(addrData)
++
++ ipBcData := ifa_broadcast.IP.To4()
++ brAddrData := newRtAttr(syscall.IFA_BROADCAST, ipBcData)
++ wb.AddData(brAddrData)
++
++ if err := s.Send(wb); err != nil {
++ return err
++ }
++
++ return s.HandleAck(wb.Seq)
++}
++
+ // Delete an IP address from an interface. This is identical to:
+ // ip addr del $ip/$ipNet dev $iface
+ func NetworkLinkDelIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error {
+@@ -917,12 +1096,273 @@
+ )
+ }
+
++func IpBroadcast4(n *net.IPNet) (net.IP, error) {
++ ipv4 := n.IP.To4()
++ if ipv4 == nil {
++ return nil, errors.New("No IPv4 net")
++ }
++ maskv4 := n.Mask
++ if len(maskv4) == net.IPv6len {
++ maskv4 = maskv4[12:]
++ }
++
++ res := net.IPv4(0xff, 0xff, 0xff, 0xff).To4()
++ for i := 0; i < net.IPv4len; i++ {
++ res[i] = (res[i] ^ maskv4[i]) + ipv4[i]
++ }
++ //log.Printf("Calculated broadcast %s", res)
++ return res, nil
++}
++
+ // Add an Ip address to an interface. This is identical to:
+ // ip addr add $ip/$ipNet dev $iface
+ func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error {
++ family := getIpFamily(ip)
++ ifa := IfAddr{iface, ip, ipNet}
++ if family == syscall.AF_INET6 {
++ return networkLinkIpAction(
++ syscall.RTM_NEWADDR,
++ syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK,
++ ifa,
++ )
++ } else {
++ //For IPv4 calculate broadcast
++ ipBc, err := IpBroadcast4(ipNet)
++ //log.Printf("Adding with broadcast ip %v", ipBc)
++ if err != nil {
++ return errors.New(fmt.Sprintf("Errof calculating braodcast IP: %v", err))
++ }
++ return networkLinkIpAction4(
++ syscall.RTM_NEWADDR,
++ syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK,
++ ifa,
++ IfAddr{iface, ipBc, ipNet},
++ )
++ }
++
++}
++
++// Add an Ip address to an interface. This is identical to:
++// ip addr change $ip/$ipNet dev $iface
++func NetworkLinkChangeIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error {
++ return networkLinkIpAction(
++ syscall.RTM_NEWADDR,
++ syscall.NLM_F_REPLACE|syscall.NLM_F_ACK,
++ IfAddr{iface, ip, ipNet},
++ )
++}
++
++func linkFlags(rawFlags uint32) net.Flags {
++ var f net.Flags
++ if rawFlags&syscall.IFF_UP != 0 {
++ f |= net.FlagUp
++ }
++ if rawFlags&syscall.IFF_BROADCAST != 0 {
++ f |= net.FlagBroadcast
++ }
++ if rawFlags&syscall.IFF_LOOPBACK != 0 {
++ f |= net.FlagLoopback
++ }
++ if rawFlags&syscall.IFF_POINTOPOINT != 0 {
++ f |= net.FlagPointToPoint
++ }
++ if rawFlags&syscall.IFF_MULTICAST != 0 {
++ f |= net.FlagMulticast
++ }
++ return f
++}
++
++func newAddr(ifam *syscall.IfAddrmsg, attrs []syscall.NetlinkRouteAttr) net.Addr {
++ var ipPointToPoint bool
++ // Seems like we need to make sure whether the IP interface
++ // stack consists of IP point-to-point numbered or unnumbered
++ // addressing.
++ for _, a := range attrs {
++ if a.Attr.Type == syscall.IFA_LOCAL {
++ ipPointToPoint = true
++ break
++ }
++ }
++ for _, a := range attrs {
++ if ipPointToPoint && a.Attr.Type == syscall.IFA_ADDRESS {
++ continue
++ }
++ switch ifam.Family {
++ case syscall.AF_INET:
++ return &net.IPNet{IP: net.IPv4(a.Value[0], a.Value[1], a.Value[2], a.Value[3]), Mask: net.CIDRMask(int(ifam.Prefixlen), 8*net.IPv4len)}
++ case syscall.AF_INET6:
++ ifa := &net.IPNet{IP: make(net.IP, net.IPv6len), Mask: net.CIDRMask(int(ifam.Prefixlen), 8*net.IPv6len)}
++ copy(ifa.IP, a.Value[:])
++ return ifa
++ }
++ }
++ return nil
++}
++
++func newLink(ifim *syscall.IfInfomsg, attrs []syscall.NetlinkRouteAttr) *net.Interface {
++ ifi := &net.Interface{Index: int(ifim.Index), Flags: linkFlags(ifim.Flags)}
++ for _, a := range attrs {
++ switch a.Attr.Type {
++ case syscall.IFLA_ADDRESS:
++ // We never return any /32 or /128 IP address
++ // prefix on any IP tunnel interface as the
++ // hardware address.
++ switch len(a.Value) {
++ case net.IPv4len:
++ switch ifim.Type {
++ case sysARPHardwareIPv4IPv4, sysARPHardwareGREIPv4, sysARPHardwareIPv6IPv4:
++ continue
++ }
++ case net.IPv6len:
++ switch ifim.Type {
++ case sysARPHardwareIPv6IPv6, sysARPHardwareGREIPv6:
++ continue
++ }
++ }
++ var nonzero bool
++ for _, b := range a.Value {
++ if b != 0 {
++ nonzero = true
++ break
++ }
++ }
++ if nonzero {
++ ifi.HardwareAddr = a.Value[:]
++ }
++ case syscall.IFLA_IFNAME:
++ ifi.Name = string(a.Value[:len(a.Value)-1])
++ case syscall.IFLA_MTU:
++ ifi.MTU = int(*(*uint32)(unsafe.Pointer(&a.Value[:4][0])))
++ }
++ }
++ return ifi
++}
++
++func interfaceTable(ifindex int) ([]net.Interface, error) {
++ tab, err := syscall.NetlinkRIB(syscall.RTM_GETLINK, syscall.AF_UNSPEC)
++ if err != nil {
++ return nil, os.NewSyscallError("netlinkrib", err)
++ }
++ msgs, err := syscall.ParseNetlinkMessage(tab)
++ if err != nil {
++ return nil, os.NewSyscallError("parsenetlinkmessage", err)
++ }
++ var ift []net.Interface
++loop:
++ for _, m := range msgs {
++ switch m.Header.Type {
++ case syscall.NLMSG_DONE:
++ break loop
++ case syscall.RTM_NEWLINK:
++ ifim := (*syscall.IfInfomsg)(unsafe.Pointer(&m.Data[0]))
++ if ifindex == 0 || ifindex == int(ifim.Index) {
++ attrs, err := syscall.ParseNetlinkRouteAttr(&m)
++ if err != nil {
++ return nil, os.NewSyscallError("parsenetlinkrouteattr", err)
++ }
++ ift = append(ift, *newLink(ifim, attrs))
++ if ifindex == int(ifim.Index) {
++ break loop
++ }
++ }
++ }
++ }
++ return ift, nil
++}
++
++func interfaceByIndex(ift []net.Interface, index int) (*net.Interface, error) {
++ for _, ifi := range ift {
++ if index == ifi.Index {
++ return &ifi, nil
++ }
++ }
++ return nil, errNoSuchInterface
++}
++
++func addrTable(ift []net.Interface, ifi *net.Interface, msgs []syscall.NetlinkMessage) ([]net.Addr, error) {
++ var ifat []net.Addr
++loop:
++ for _, m := range msgs {
++ switch m.Header.Type {
++ case syscall.NLMSG_DONE:
++ break loop
++ case syscall.RTM_NEWADDR:
++ ifam := (*syscall.IfAddrmsg)(unsafe.Pointer(&m.Data[0]))
++ if len(ift) != 0 || ifi.Index == int(ifam.Index) {
++ if len(ift) != 0 {
++ var err error
++ ifi, err = interfaceByIndex(ift, int(ifam.Index))
++
++ if err != nil {
++ return nil, err
++ }
++ }
++ attrs, err := syscall.ParseNetlinkRouteAttr(&m)
++ if err != nil {
++ return nil, os.NewSyscallError("parsenetlinkrouteattr", err)
++ }
++ ifa := newAddr(ifam, attrs)
++ if ifa != nil {
++ ifat = append(ifat, ifa)
++ }
++ }
++ }
++ }
++ return ifat, nil
++}
++
++func interfaceAddrTable(ifi *net.Interface) ([]net.Addr, error) {
++ tab, err := syscall.NetlinkRIB(syscall.RTM_GETADDR, syscall.AF_UNSPEC)
++ if err != nil {
++ return nil, os.NewSyscallError("netlinkrib", err)
++ }
++ msgs, err := syscall.ParseNetlinkMessage(tab)
++ if err != nil {
++ return nil, os.NewSyscallError("parsenetlinkmessage", err)
++ }
++ var ift []net.Interface
++ if ifi == nil {
++ var err error
++ ift, err = interfaceTable(0)
++ if err != nil {
++ return nil, err
++ }
++ }
++ ifat, err := addrTable(ift, ifi, msgs)
++ if err != nil {
++ return nil, err
++ }
++ return ifat, nil
++}
++
++func NetworkLinkList(iface *net.Interface) ([]net.Addr, error) {
++ return interfaceAddrTable(iface)
++}
++
++func NetworkLinkFlush(iface *net.Interface) (error) {
++ at, err := NetworkLinkList(iface)
++ if err != nil {
++ return err
++ }
++ for _, a := range at {
++ ip, ipnet, err := net.ParseCIDR(a.String())
++ if err != nil {
++ return err
++ }
++ err = NetworkLinkDelIp(iface, ip, ipnet)
++ if err != nil {
++ return err
++ }
++ }
++ return nil
++}
++
++// Add an Ip address to an interface. This is identical to:
++// ip addr replace $ip/$ipNet dev $iface
++func NetworkLinkReplaceIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error {
+ return networkLinkIpAction(
+ syscall.RTM_NEWADDR,
+- syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK,
++ syscall.NLM_F_CREATE|syscall.NLM_F_REPLACE|syscall.NLM_F_ACK,
+ IfAddr{iface, ip, ipNet},
+ )
+ }
+@@ -1108,6 +1548,7 @@
+ }
+ wb.AddData(uint32Attr(syscall.RTA_OIF, uint32(iface.Index)))
+
++ //Send the message
+ if err := s.Send(wb); err != nil {
+ return err
+ }