diff --git a/Drivers/Windows/Oneplus_9008_Driver/QUSB__BULK.cat b/Drivers/Windows/Oneplus_9008_Driver/QUSB__BULK.cat deleted file mode 100644 index 09a1a07..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/QUSB__BULK.cat and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/QUSB__BULK.inf b/Drivers/Windows/Oneplus_9008_Driver/QUSB__BULK.inf deleted file mode 100644 index 71fe777..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/QUSB__BULK.inf and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/amd64/WdfCoInstaller01009.dll b/Drivers/Windows/Oneplus_9008_Driver/amd64/WdfCoInstaller01009.dll deleted file mode 100644 index 1731b96..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/amd64/WdfCoInstaller01009.dll and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/amd64/libusb0.dll b/Drivers/Windows/Oneplus_9008_Driver/amd64/libusb0.dll deleted file mode 100644 index f916b08..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/amd64/libusb0.dll and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/amd64/libusbK.dll b/Drivers/Windows/Oneplus_9008_Driver/amd64/libusbK.dll deleted file mode 100644 index d8112b9..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/amd64/libusbK.dll and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/amd64/libusbK.sys b/Drivers/Windows/Oneplus_9008_Driver/amd64/libusbK.sys deleted file mode 100644 index e09ee12..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/amd64/libusbK.sys and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/desktop.ini b/Drivers/Windows/Oneplus_9008_Driver/desktop.ini deleted file mode 100644 index bb9f3d6..0000000 --- a/Drivers/Windows/Oneplus_9008_Driver/desktop.ini +++ /dev/null @@ -1,4 +0,0 @@ -[ViewState] -Mode= -Vid= -FolderType=Generic diff --git a/Drivers/Windows/Oneplus_9008_Driver/dpinst.xml b/Drivers/Windows/Oneplus_9008_Driver/dpinst.xml deleted file mode 100644 index cc2988e..0000000 --- a/Drivers/Windows/Oneplus_9008_Driver/dpinst.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - 1 - 1 - diff --git a/Drivers/Windows/Oneplus_9008_Driver/dpinst32.exe b/Drivers/Windows/Oneplus_9008_Driver/dpinst32.exe deleted file mode 100644 index 410a135..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/dpinst32.exe and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/dpinst64.exe b/Drivers/Windows/Oneplus_9008_Driver/dpinst64.exe deleted file mode 100644 index 0096441..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/dpinst64.exe and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/dpinst64.vbs b/Drivers/Windows/Oneplus_9008_Driver/dpinst64.vbs deleted file mode 100644 index b8b2f94..0000000 --- a/Drivers/Windows/Oneplus_9008_Driver/dpinst64.vbs +++ /dev/null @@ -1,2 +0,0 @@ -Set oShell = CreateObject("WScript.Shell") -oShell.Run("""dpinst64.exe """ & "/SW") \ No newline at end of file diff --git a/Drivers/Windows/Oneplus_9008_Driver/dpscat.exe b/Drivers/Windows/Oneplus_9008_Driver/dpscat.exe deleted file mode 100644 index c45f430..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/dpscat.exe and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/dpscat.vbs b/Drivers/Windows/Oneplus_9008_Driver/dpscat.vbs deleted file mode 100644 index ce1cc81..0000000 --- a/Drivers/Windows/Oneplus_9008_Driver/dpscat.vbs +++ /dev/null @@ -1,2 +0,0 @@ -Set oShell = CreateObject("WScript.Shell") -oShell.Run("""dpscat.exe""") diff --git a/Drivers/Windows/Oneplus_9008_Driver/test.vbs b/Drivers/Windows/Oneplus_9008_Driver/test.vbs deleted file mode 100644 index b015768..0000000 --- a/Drivers/Windows/Oneplus_9008_Driver/test.vbs +++ /dev/null @@ -1,2 +0,0 @@ -Set oShell = CreateObject("WScript.Shell") -oShell.Run("""dpinst64.exe /SW""") \ No newline at end of file diff --git a/Drivers/Windows/Oneplus_9008_Driver/x86/WdfCoInstaller01009.dll b/Drivers/Windows/Oneplus_9008_Driver/x86/WdfCoInstaller01009.dll deleted file mode 100644 index 30e81af..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/x86/WdfCoInstaller01009.dll and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/x86/libusb0_x86.dll b/Drivers/Windows/Oneplus_9008_Driver/x86/libusb0_x86.dll deleted file mode 100644 index 6e475b9..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/x86/libusb0_x86.dll and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/x86/libusbK.sys b/Drivers/Windows/Oneplus_9008_Driver/x86/libusbK.sys deleted file mode 100644 index 67b8ff4..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/x86/libusbK.sys and /dev/null differ diff --git a/Drivers/Windows/Oneplus_9008_Driver/x86/libusbK_x86.dll b/Drivers/Windows/Oneplus_9008_Driver/x86/libusbK_x86.dll deleted file mode 100644 index 0d41062..0000000 Binary files a/Drivers/Windows/Oneplus_9008_Driver/x86/libusbK_x86.dll and /dev/null differ diff --git a/Drivers/Windows/libusb-1.0.26-binaries.7z b/Drivers/Windows/libusb-1.0.26-binaries.7z new file mode 100644 index 0000000..7b002a1 Binary files /dev/null and b/Drivers/Windows/libusb-1.0.26-binaries.7z differ diff --git a/Drivers/Windows/zadig-2.8.exe b/Drivers/Windows/zadig-2.8.exe new file mode 100644 index 0000000..1e530ad Binary files /dev/null and b/Drivers/Windows/zadig-2.8.exe differ diff --git a/LICENSE b/LICENSE index b4b94db..782d5be 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,674 @@ -MIT License + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 -Copyright (c) 2018 Bjoern Kerler + 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. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + Preamble -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + 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 +. \ No newline at end of file diff --git a/Loaders b/Loaders index e443e5c..a838505 160000 --- a/Loaders +++ b/Loaders @@ -1 +1 @@ -Subproject commit e443e5c59f9f035c44024c3641b78e5175a365d5 +Subproject commit a83850577f32faaf4694cda8f00666e0d9d34654 diff --git a/README.md b/README.md index c34c4aa..6e61453 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Qualcomm Sahara / Firehose Attack Client / Diag Tools (c) B. Kerler 2018-2023 +Licensed under GPLv3 license. ## Why @@ -249,7 +250,7 @@ For Oneplus 6T, enter *#801#* on dialpad, set Engineer Mode and Serial to on and - Oneplus 3T/5/6T/7T/8/8t/9/Nord CE/N10/N100 (Read-Only), BQ X, BQ X5, BQ X2, Gigaset ME Pure, ZTE MF210, ZTE MF920V, Sierra Wireless EM7455, Netgear MR1100-10EUS, Netgear MR5100 - SIMCOM SIM8905E -Published under MIT license +Published under GPLv3 license Additional license limitations: No use in commercial products without prior permit. Enjoy ! diff --git a/boottodownload b/boottodownload new file mode 120000 index 0000000..a6c3aed --- /dev/null +++ b/boottodownload @@ -0,0 +1 @@ +edlclient/Tools/boottodwnload \ No newline at end of file diff --git a/edl b/edl index 96a5a08..85b6ac6 100755 --- a/edl +++ b/edl @@ -1,6 +1,11 @@ #!/usr/bin/env python3 -# Qualcomm Sahara / Firehose Client (c) B.Kerler 2018-2023 -# Licensed under MIT License +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! + """ Usage: edl -h | --help @@ -96,8 +101,8 @@ Description: Options: --loader=filename Use specific EDL loader, disable autodetection [default: None] - --vid=vid Set usb vendor image_id used for EDL [default: -1] - --pid=pid Set usb product image_id used for EDL [default: -1] + --vid=vid Set usb vendor id used for EDL [default: -1] + --pid=pid Set usb product id used for EDL [default: -1] --lun=lun Set lun to read/write from (UFS memory only) --maxpayload=bytes Set the maximum payload for EDL [default: 0x100000] --sectorsize=bytes Set default sector size @@ -188,7 +193,7 @@ class main(metaclass=LogBase): self.vid = None self.pid = None - def doconnect(self, loop): + def doconnect(self, loop) -> dict: while not self.cdc.connected: self.cdc.connected = self.cdc.connect(portname=self.portname) if not self.cdc.connected: @@ -302,53 +307,54 @@ class main(metaclass=LogBase): mode = conninfo["mode"] if mode == "sahara": cmd = conninfo["cmd"] - data = conninfo["data"] if cmd == cmd_t.SAHARA_HELLO_REQ: - if data.mode == sahara_mode_t.SAHARA_MODE_MEMORY_DEBUG: - if args["memorydump"] or self.cdc.pid==0x900E: - time.sleep(0.5) - print("Device is in memory dump mode, dumping memory") - if args["--partitions"]: - self.sahara.debug_mode(args["--partitions"].split(",")) - else: - self.sahara.debug_mode() - self.exit() - else: - print("Device is in streaming mode, uploading loader") - self.cdc.timeout = None - sahara_info = self.sahara.streaminginfo() - if sahara_info: - sahara_connect = self.sahara.connect() - if len(sahara_connect) == 3: - mode, cmd, resp = sahara_connect + if "data" in conninfo: + data = conninfo["data"] + if data.mode == sahara_mode_t.SAHARA_MODE_MEMORY_DEBUG: + if args["memorydump"] or self.cdc.pid == 0x900E: + time.sleep(0.5) + print("Device is in memory dump mode, dumping memory") + if args["--partitions"]: + self.sahara.debug_mode(args["--partitions"].split(",")) else: - mode, resp = sahara_connect + self.sahara.debug_mode() + self.exit() + else: + print("Device is in streaming mode, uploading loader") + self.cdc.timeout = None + sahara_info = self.sahara.streaminginfo() + if sahara_info: + sahara_connect = self.sahara.connect() + if len(sahara_connect) == 3: + mode, cmd, resp = sahara_connect + else: + mode, resp = sahara_connect + if mode == "sahara": + mode = self.sahara.upload_loader() + if "enprg" in self.sahara.programmer.lower(): + mode = "load_enandprg" + elif "nprg" in self.sahara.programmer.lower(): + mode = "load_nandprg" + elif mode != "": + mode = "load_" + mode + if "load_" in mode: + time.sleep(0.3) + else: + print("Error, couldn't find suitable enprg/nprg loader :(") + self.exit() + else: + sahara_info = self.sahara.cmd_info() + if sahara_info is not None: + resp = self.sahara.connect() + mode = resp["mode"] + if "data" in resp: + data = resp["data"] if mode == "sahara": mode = self.sahara.upload_loader() - if "enprg" in self.sahara.programmer.lower(): - mode = "load_enandprg" - elif "nprg" in self.sahara.programmer.lower(): - mode = "load_nandprg" - elif mode != "": - mode = "load_" + mode - if "load_" in mode: - time.sleep(0.3) - else: - print("Error, couldn't find suitable enprg/nprg loader :(") - self.exit() - else: - sahara_info = self.sahara.cmd_info() - if sahara_info is not None: - resp = self.sahara.connect() - mode = resp["mode"] - if "data" in resp: - data = resp["data"] - if mode == "sahara": - mode = self.sahara.upload_loader() - else: - print("Error on sahara handshake, resetting.") - self.sahara.cmd_reset() - sys.exit(1) + else: + print("Error on sahara handshake, resetting.") + self.sahara.cmd_reset() + sys.exit(1) if mode == "error": print("Connection detected, quiting.") sys.exit(1) diff --git a/edlclient/Config/qualcomm_config.py b/edlclient/Config/qualcomm_config.py index ebcd569..b3e7a41 100644 --- a/edlclient/Config/qualcomm_config.py +++ b/edlclient/Config/qualcomm_config.py @@ -1,3 +1,11 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! + vendor = { 0x0000: "Qualcomm ", 0x0001: "Foxconn/Sony ", diff --git a/edlclient/Config/usb_ids.py b/edlclient/Config/usb_ids.py index 1b4ee43..c27d176 100644 --- a/edlclient/Config/usb_ids.py +++ b/edlclient/Config/usb_ids.py @@ -1,3 +1,11 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! + default_ids = [ [0x05c6, 0x9008, -1], [0x0fce, 0x9dde, -1], diff --git a/edlclient/Library/Connection/devicehandler.py b/edlclient/Library/Connection/devicehandler.py index 8c29ce6..ab6d452 100644 --- a/edlclient/Library/Connection/devicehandler.py +++ b/edlclient/Library/Connection/devicehandler.py @@ -1,12 +1,19 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import serial import serial.tools.list_ports import inspect import traceback from binascii import hexlify -from edlclient.Library.utils import * +try: + from edlclient.Library.utils import * +except: + from Library.utils import * class DeviceClass(metaclass=LogBase): diff --git a/edlclient/Library/Connection/seriallib.py b/edlclient/Library/Connection/seriallib.py index 18451a6..95bd65b 100755 --- a/edlclient/Library/Connection/seriallib.py +++ b/edlclient/Library/Connection/seriallib.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2022 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import os.path import time import sys @@ -20,8 +24,13 @@ import serial.tools.list_ports import inspect import traceback from binascii import hexlify -from edlclient.Library.utils import * -from edlclient.Library.Connection.devicehandler import DeviceClass +try: + from edlclient.Library.utils import * + from edlclient.Library.Connection.devicehandler import DeviceClass +except: + from Library.utils import * + from Library.Connection.devicehandler import DeviceClass + class serial_class(DeviceClass): diff --git a/edlclient/Library/Connection/usblib.py b/edlclient/Library/Connection/usblib.py index 5686b2a..6750ce8 100755 --- a/edlclient/Library/Connection/usblib.py +++ b/edlclient/Library/Connection/usblib.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import io import logging @@ -9,17 +13,22 @@ import usb.util import time import inspect import array -from edlclient.Library.utils import is_windows import usb.backend.libusb0 -if not is_windows(): - import usb.backend.libusb1 from enum import Enum from binascii import hexlify from ctypes import c_void_p, c_int -from edlclient.Library.utils import * +try: + from edlclient.Library.utils import * +except: + from Library.utils import * +if not is_windows(): + import usb.backend.libusb1 from struct import pack, calcsize import traceback -from edlclient.Library.Connection.devicehandler import DeviceClass +try: + from edlclient.Library.Connection.devicehandler import DeviceClass +except: + from Library.Connection.devicehandler import DeviceClass USB_DIR_OUT = 0 # to device USB_DIR_IN = 0x80 # to host diff --git a/edlclient/Library/Connection/usbscsi.py b/edlclient/Library/Connection/usbscsi.py index 7caeeb8..72520cd 100755 --- a/edlclient/Library/Connection/usbscsi.py +++ b/edlclient/Library/Connection/usbscsi.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import argparse from edlclient.Library.Connection.usblib import * diff --git a/edlclient/Library/Modules/generic.py b/edlclient/Library/Modules/generic.py index ee3117c..b778dc3 100644 --- a/edlclient/Library/Modules/generic.py +++ b/edlclient/Library/Modules/generic.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import logging from edlclient.Library.utils import LogBase diff --git a/edlclient/Library/Modules/init.py b/edlclient/Library/Modules/init.py index 607d83f..eb3a4fc 100644 --- a/edlclient/Library/Modules/init.py +++ b/edlclient/Library/Modules/init.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import logging from edlclient.Library.utils import LogBase @@ -87,7 +91,7 @@ class modules(metaclass=LogBase): else: options[args[i]] = True if command == "": - print("Valid commands are:\noemunlock\n") + print("Valid commands are:\noemunlock, ops\n") return False if self.generic is not None and command == "oemunlock": if "enable" in options: @@ -98,5 +102,46 @@ class modules(metaclass=LogBase): self.error("Unknown mode given. Available are: enable, disable.") return False return self.generic.oem_unlock(enable) - else: - print("Valid options are: oemunlock [enable,disable]") + elif self.ops is not None and command == "ops": + if self.devicemodel is not None: + enable = False + partition = "param" + if "enable" in options: + enable = True + elif "disable" in options: + enable = False + else: + self.error("Unknown mode given. Available are: enable, disable.") + return False + res = self.fh.detect_partition(self.args, partition) + if res[0]: + lun = res[1] + rpartition = res[2] + paramdata = self.fh.cmd_read_buffer(lun, rpartition.sector, rpartition.sectors, False) + if paramdata.data == b"": + self.error("Error on reading param partition.") + return False + wdata = self.ops.enable_ops(paramdata.data, enable,self.devicemodel,self.serial) + if wdata is not None: + self.ops.run() + if self.fh.cmd_program_buffer(lun, rpartition.sector, wdata, False): + self.info("Successfully set mode") + return True + else: + self.error("Error on writing param partition") + return False + else: + self.error("No param info generated, did you provide the devicemodel ?") + return False + else: + fpartitions = res[1] + self.error(f"Error: Couldn't detect partition: {partition}\nAvailable partitions:") + for lun in fpartitions: + for rpartition in fpartitions[lun]: + if self.args["--memory"].lower() == "emmc": + self.error("\t" + rpartition) + else: + self.error(lun + ":\t" + rpartition) + else: + self.error("A devicemodel is needed for this command") + return False diff --git a/edlclient/Library/Modules/oneplus.py b/edlclient/Library/Modules/oneplus.py index a128cdb..52c3438 100755 --- a/edlclient/Library/Modules/oneplus.py +++ b/edlclient/Library/Modules/oneplus.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! """ Usage: @@ -75,7 +79,7 @@ deviceconfig = { # OP Nord, avicii "20801": dict(version=2, cm="eacf50e7", param_mode=0), - + # OP N10 5G Metro, billie8t "20885": dict(version=3, cm="3a403a71", param_mode=1), # OP N10 5G Global, billie8 @@ -87,7 +91,7 @@ deviceconfig = { # OP N100 Metro, billie2t "20880": dict(version=3, cm="6ccf5913", param_mode=1), - # OP N100 Global, billie2 + # OP N100 Global, billie2 "20881": dict(version=3, cm="fa9ff378", param_mode=1), # OP N100 TMO, billie2t "20882": dict(version=3, cm="4ca1e84e", param_mode=1), @@ -127,7 +131,7 @@ class oneplus(metaclass=LogBase): def __init__(self, fh, projid="18825", serial=123456, ATOBuild=0, Flash_Mode=0, cf=0, supported_functions=None, args=None, loglevel=logging.INFO): self.fh = fh - self.__logger=self.__logger + self.__logger = self.__logger self.args = args self.ATOBuild = ATOBuild self.Flash_Mode = Flash_Mode @@ -155,7 +159,16 @@ class oneplus(metaclass=LogBase): logfilename = "log.txt" filehandler = logging.FileHandler(logfilename) self.__logger.addHandler(filehandler) - self.ops_parm = None + try: + from edlclient.Library.Modules.oneplus_param import paramtools + if projid in deviceconfig: + mode = deviceconfig[projid]["param_mode"] + self.ops_parm = paramtools(mode=mode, serial=serial) + else: + self.ops_parm = paramtools(mode=0, serial=serial) + except ImportError as e: + self.__logger.error(str(e)) + self.ops_parm = None self.ops = self.convert_projid(fh, projid, serial) def getprodkey(self, projid): @@ -227,6 +240,11 @@ class oneplus(metaclass=LogBase): if self.ops.demacia(): return self.ops.demacia() + def enable_ops(self, data, enable, projid, serial): + if self.ops_parm is not None: + return self.ops_parm.enable_ops(data, enable) + return None + def addpatch(self): if "setprojmodel" in self.supported_functions or "setswprojmodel" in self.supported_functions: pk, token = self.ops.generatetoken(True) diff --git a/edlclient/Library/Modules/oneplus_param.py b/edlclient/Library/Modules/oneplus_param.py new file mode 100755 index 0000000..e141b72 --- /dev/null +++ b/edlclient/Library/Modules/oneplus_param.py @@ -0,0 +1,994 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! +""" +Usage: + oneplus_param.py param [--mode=mode] [--serial=serial] + oneplus_param.py ops [--mode=mode] [--serial=serial] + oneplus_param.py gencode + oneplus_param.py setparam [--mode=mode] [--serial=serial] +""" + +from enum import Enum +from struct import calcsize, pack, unpack +import hashlib +import zlib +import qrcode + +try: + from edlclient.Library.cryptutils import cryptutils +except ImportError as e: + import os, sys, inspect + + current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + parent_dir = os.path.dirname(current_dir) + sys.path.insert(0, parent_dir) + try: + from cryptutils import cryptutils + except ImportError as e: + print(str(e)) +try: + from edlclient.Library.Modules.oneplus_param import * +except ImportError: + pass +from binascii import unhexlify, hexlify + + +class sid(Enum): + PARAM_SID_PRODUCT = 0, + PARAM_SID_CONFIG = 1, + PARAM_SID_LCD = 2, + PARAM_SID_TP = 3, + PARAM_SID_TP_KPD = 4, + PARAM_SID_CAMERA = 5, + PARAM_SID_SENSORS = 6, + PARAM_SID_BATTERY = 7, + PARAM_SID_RTC = 8, + PARAM_SID_CRASH_RECORD = 9, + PARAM_SID_SALEINFO = 0xA, + PARAM_SID_MISC = 0xB, + PARAM_SID_DOWNLOAD = 0xC, + PARAM_SID_PHONE_HISTORY = 0xD, + PARAM_SID_DL_USERINFO = 0xE, + PARAM_SID_ENC_SECRECY = 0x12C, + PARAM_SID_ENC_CARRIER = 0x130, + PARAM_SID_ENC_MOBID = 0x134, + PARAM_SID_ENC_CVE = 0x138, + PARAM_SID_INVALID = -1 + + ''' + CUSTOM_TYPE.NONE = new CUSTOM_TYPE("NONE", 0); + CUSTOM_TYPE.JCC = new CUSTOM_TYPE("JCC", 1); French edition + CUSTOM_TYPE.SW = new CUSTOM_TYPE("SW", 2); Star Wars + CUSTOM_TYPE.AVG = new CUSTOM_TYPE("AVG", 3); Avengers + CUSTOM_TYPE.MCL = new CUSTOM_TYPE("MCL", 4); McLaren + CUSTOM_TYPE.OPR_RETAIL = new CUSTOM_TYPE("OPR_RETAIL", 5); + CUSTOM_TYPE.CYB = new CUSTOM_TYPE("CYB", 6); Cyberpunk + CUSTOM_TYPE v0 = new CUSTOM_TYPE("CMCC", 7); China Mobile + ''' + ''' + SW_TYPE.DEFAULT = new SW_TYPE("DEFAULT", 0); + SW_TYPE.O2 = new SW_TYPE("O2", 1); + SW_TYPE.H2 = new SW_TYPE("H2", 2); + SW_TYPE.IN = new SW_TYPE("IN", 3); + SW_TYPE.EU = new SW_TYPE("EU", 4); + SW_TYPE.TMO = new SW_TYPE("TMO", 5); + SW_TYPE.SPRINT = new SW_TYPE("SPRINT", 6); + SW_TYPE.VERIZON = new SW_TYPE("VERIZON", 7); + SW_TYPE.ATT = new SW_TYPE("ATT", 8); + SW_TYPE v0 = new SW_TYPE("C532", 9); + + ''' + ''' + CUSTOM_BACK_COVER_TYPE.NONE = new CUSTOM_BACK_COVER_TYPE("NONE", 0); + CUSTOM_BACK_COVER_TYPE.LCH = new CUSTOM_BACK_COVER_TYPE("LCH", 1); + CUSTOM_BACK_COVER_TYPE.MYH = new CUSTOM_BACK_COVER_TYPE("MYH", 2); + CUSTOM_BACK_COVER_TYPE.YYB = new CUSTOM_BACK_COVER_TYPE("YYB", 3); + CUSTOM_BACK_COVER_TYPE.HPH = new CUSTOM_BACK_COVER_TYPE("HPH", 4); + CUSTOM_BACK_COVER_TYPE.DGZ = new CUSTOM_BACK_COVER_TYPE("DGZ", 5); + CUSTOM_BACK_COVER_TYPE.OPGY = new CUSTOM_BACK_COVER_TYPE("OPGY", 6); + CUSTOM_BACK_COVER_TYPE.OPBL = new CUSTOM_BACK_COVER_TYPE("OPBL", 7); + CUSTOM_BACK_COVER_TYPE.OPGL = new CUSTOM_BACK_COVER_TYPE("OPGL", 8); + CUSTOM_BACK_COVER_TYPE.OPRD = new CUSTOM_BACK_COVER_TYPE("OPRD", 9); + CUSTOM_BACK_COVER_TYPE.OPHDBL = new CUSTOM_BACK_COVER_TYPE("OPHDBL", 10); + CUSTOM_BACK_COVER_TYPE.OPHDSL = new CUSTOM_BACK_COVER_TYPE("OPHDSL", 11); + CUSTOM_BACK_COVER_TYPE.OPHDMCL = new CUSTOM_BACK_COVER_TYPE("OPHDMCL", 12); + CUSTOM_BACK_COVER_TYPE.OPHDAGBL = new CUSTOM_BACK_COVER_TYPE("OPHDAGBL", 13); + CUSTOM_BACK_COVER_TYPE.OPINBLK = new CUSTOM_BACK_COVER_TYPE("OPINBLK", 14); + CUSTOM_BACK_COVER_TYPE.OPINGRN = new CUSTOM_BACK_COVER_TYPE("OPINGRN", 15); + CUSTOM_BACK_COVER_TYPE.OPINBLU = new CUSTOM_BACK_COVER_TYPE("OPINBLU", 16); + CUSTOM_BACK_COVER_TYPE.OPINGRD = new CUSTOM_BACK_COVER_TYPE("OPINGRD", 17); + CUSTOM_BACK_COVER_TYPE.OPINIB = new CUSTOM_BACK_COVER_TYPE("OPINIB", 18); + CUSTOM_BACK_COVER_TYPE.OPAVICGRIR = new CUSTOM_BACK_COVER_TYPE("OPAVICGRIR", 19); + CUSTOM_BACK_COVER_TYPE.OPAVICBLIC = new CUSTOM_BACK_COVER_TYPE("OPAVICBLIC", 20); + CUSTOM_BACK_COVER_TYPE.OPAVICGRFR = new CUSTOM_BACK_COVER_TYPE("OPAVICGRFR", 21); + CUSTOM_BACK_COVER_TYPE.OPKEBABGD = new CUSTOM_BACK_COVER_TYPE("OPKEBABGD", 22); + CUSTOM_BACK_COVER_TYPE.OPKEBABBG = new CUSTOM_BACK_COVER_TYPE("OPKEBABBG", 23); + CUSTOM_BACK_COVER_TYPE.OPKEBABSG = new CUSTOM_BACK_COVER_TYPE("OPKEBABSG", 24); + CUSTOM_BACK_COVER_TYPE.OPN1MB = new CUSTOM_BACK_COVER_TYPE("OPN1MB", 25); + CUSTOM_BACK_COVER_TYPE v0 = new CUSTOM_BACK_COVER_TYPE("OPN2GB", 26); + + ''' + + +class paramtools(): + paramitems = { + sid.PARAM_SID_PRODUCT.value[0]: { + 0x18: ["8c", "project_name"], + 0x20: ["I", "hw_version"], + 0x24: ["I", "rf_version"], + 0x28: ["16c", "rf_config_str"], + 0x38: ["I", "operator_num"], + 0x3C: ["10c", "operator_str"], + 0x4C: ["B", "Length PCBA_number"], + 0x4D: ["27c", "pcba_number"], + 0x68: ["I", "boot_aging_count"], + 0x6C: ["48c", "ota_info"], + 0x9C: ["80c", "firmware_info"], + 0xEC: ["32c", "build_info"], + 0x10C: ["I", "unknown_dword"], + 0x1A0: ["I", "OemCheckResetDevInfo"] # if 1, then reset dev info. if 2, then do below, wth is this ? + }, + sid.PARAM_SID_CONFIG.value[0]: { + 0x18: ["B", "dump_enable"], + }, + sid.PARAM_SID_CRASH_RECORD.value[0]: { + 0x18: ["I", "crash_record_count"], + 0x1c: ["20c", "Crash log 1"], + 0x30: ["20c", "Crash log 2"], + 0x44: ["20c", "Crash log 3"], + 0x58: ["20c", "Crash log 4"], + 0x6c: ["20c", "Crash log 5"], + 0x80: ["20c", "Crash log 6"], + 0x94: ["20c", "Crash log 7"], + 0xa8: ["20c", "Crash log 8"], + 0xbc: ["20c", "Crash log 9"], + 0xd0: ["20c", "Crash log 10"], + 0xe4: ["20c", "Crash log 11"], + 0xf8: ["20c", "Crash log 12"], + 0x10c: ["20c", "Crash log 13"], + 0x120: ["20c", "Crash log 14"], + 0x134: ["20c", "Crash log 15"], + 0x15c: ["I", "restart_08_count"], + 0x160: ["I", "restart_other_count"] + }, + sid.PARAM_SID_SALEINFO.value[0]: { # 0xA, Param_saleinfo, PARAM_SID_SALEINFO + 0x18: ["I", "is_rooted"], + 0x1c: ["I", "root_time"], + 0x20: ["16c", "flash_0"], + 0x30: ["16c", "flash_1"], + 0x40: ["16c", "flash_2"], + 0x50: ["16c", "erase_0"], + 0x60: ["16c", "erase_1"], + 0x70: ["16c", "erase_2"], + 0x80: ["I", "is_angela"], + # adb shell am start -n com.android.engineeringmode/.qualcomm.DiagEnabled --es "code" "angela" + # adb shell am start -n com.oneplus.factorymode/.qualcomm.DiagEnabled --es "code" "angela" + # disable: "setprop persist.sys.adb.engineermode 0" and "setprop persist.sys.adbroot 0" or call code *#8011# + 0x88: ["I", "Unknown flag"], + 0x8c: ["I", "Unknown value"], + 0x90: ["I", "Unknown flag"], + }, + sid.PARAM_SID_MISC.value[0]: { # 0xB + 0x20: ["I", "Misc flag 1"], + 0x24: ["44c", "Misc log a_1"], + 0x50: ["I", "Misc flag a_2"], + 0x54: ["44c", "Misc log a_2"], + 0x80: ["I", "Misc flag a_3"], + 0x84: ["44c", "Misc log a_3"], + 0xb0: ["I", "Misc flag a_4"], + 0xb4: ["44c", "Misc log a_4"], + 0xe4: ["I", "Misc flag b_1"], + 0xe8: ["44c", "Misc log b_1"], + 0x114: ["I", "Misc flag b_2"], + 0x118: ["44c", "Misc log b_2"], + 0x144: ["I", "Misc flag b_3"], + 0x148: ["44c", "Misc log b_3"], + 0x174: ["I", "Misc flag b_4"], + 0x178: ["44c", "Misc log b_4"], + 0x1a8: ["I", "Misc flag c_1"], + 0x1ac: ["44c", "Misc log c_1"], + 0x1d8: ["I", "Misc flag c_2"], + 0x1dc: ["44c", "Misc log c_2"], + 0x208: ["I", "Misc flag c_3"], + 0x20c: ["44c", "Misc log c_3"], + 0x238: ["I", "Misc flag c_4"], + 0x23c: ["44c", "Misc log c_4"], + }, + sid.PARAM_SID_DOWNLOAD.value[0]: { # 0xC + 0x18: ["24c", "Unknown date"], + 0x30: ["B", "SMT_Download_Status"], + 0x32: ["B", "Unknown flag"], + 0x33: ["B", "Unknown flag"], + 0x38: ["32c", "Unknown string_1"], + 0xd8: ["24c", "Unknown date_1"], + 0xF0: ["B", "Upgrade_Download_Status_1"], + 0xF2: ["B", "Unknown flag_1"], + + 0xF8: ["32c", "Unknown string_2"], + 0x118: ["24c", "Unknown date_2"], + 0x130: ["B", "Upgrade_Download_Status_2"], + 0x132: ["B", "Unknown flag_2"], + + 0x138: ["32c", "Unknown string_3"], + 0x158: ["24c", "Unknown date_3"], + 0x170: ["B", "Upgrade_Download_Status_3"], + 0x172: ["B", "Unknown flag_3"], + + 0x178: ["32c", "Unknown string_4"], + 0x188: ["24c", "Unknown date_4"], + + 0x198: ["I", "boot_stage"], + 0x19C: ["I", "data_stage"], + 0x1A0: ["B", "reset_devinfo"], # OemCheckResetRevInfo + 0x1A4: ["B", "intranet_3t"], + 0x1A8: ["B", "bootmode_3t"] + }, + + sid.PARAM_SID_PHONE_HISTORY.value[0]: { # 0xD + 0x24: ["I", "Update_Count"], + 0x28: ["I", "Unlock_Count"], + 0x2c: ["I", "Unknown value"], + 0x30: ["I", "param_poweroff_count"], + 0x34: ["I", "abl_tamper"], + }, + + sid.PARAM_SID_DL_USERINFO.value[0]: { # 0xE + 0x20: ["32c", "Computername_1"], + 0x40: ["32c", "Username_1"], + 0x60: ["I", "Flag_1"], + 0x68: ["20c", "IP_1"], + 0x7C: ["I", "Chksum_1_0"], + 0xA0: ["32c", "Computername_2"], + 0xC0: ["32c", "Username_2"], + 0xE0: ["I", "Flag_2"], + 0xE8: ["20c", "IP_2"], + 0xFC: ["I", "Chksum_2"], + 0x120: ["32c", "Computername_2"], + 0x140: ["32c", "Username_2"], + 0x160: ["I", "Flag_2"], + 0x168: ["20c", "IP_2"], + 0x17C: ["I", "Chksum_2"], + 0x1A0: ["32c", "Computername_3"], + 0x1C0: ["32c", "Username_3"], + 0x1E0: ["I", "Flag_3"], + 0x1E8: ["20c", "IP_3"], + 0x1FC: ["I", "Chksum_3"], + }, + + 0xB0: { + 0x2b4: ["128B", "Unknown"] + }, + + sid.PARAM_SID_ENC_SECRECY.value[0]: { # 0x12C + 0x80: ["I", "intranet"], # Allows factory commands via fastboot ops, *#808# engineermode + # dumpsys secrecy dump (persist) + # fastboot ops 4F50040TR18FTR7FSTD5F01 + # fastboot ops help + 0x84: ["I", "boottype"], # 0xA9E:"sdebug"; 0xB7:"debug";0xA0:"auto";0x0:"normal" + 0x88: ["I", "ONLINE_CFG_TEST_ENV"], + 0x8C: ["I", "TargetSWID"], + 0x90: ["I", "AgingFlag"] + }, + + sid.PARAM_SID_ENC_CARRIER.value[0]: { # 0x130 + 0xA0: ["I", "CustFlag"], + 0xA4: ["I", "CustFlagMigrationPlaintext"], + 0xA8: ["I", "carrier_id"], + 0xAC: ["I", "carrier_init_flag"] + }, + sid.PARAM_SID_ENC_MOBID.value[0]: { + 0x80: ["16c", "mobid/imei/meid1"], + 0x90: ["I", "mobid/imei_flag"], + 0x94: ["I", "Recondition flag (RCF)"], + 0x98: ["19c", "Unknown date1"], + 0xB0: ["19c", "Unknown date2"], + 0xC8: ["19c", "Unknown date3"], + 0xE0: ["8c", "Unknown_value_000000"], + 0xE8: ["16c", "mobid/imei/meid2"], + 0xF0: ["I", "mobid/meid flag"], + 0xF8: ["I", "Unknown flag"] + }, + sid.PARAM_SID_ENC_CVE.value[0]: { + 0x80: ["16c", "CVE_SystemBlob_A"], + 0x90: ["16c", "CVE_VendorBlob_A"], + 0xA0: ["16c", "CVE_SystemBlob_B"], + 0xB0: ["16c", "CVE_VendorBlob_B"], + 0xC0: ["16c", "CVE_Current_BootImg_A"], + 0xD0: ["16c", "CVE_Current_BootImg_B"], + 0xE0: ["I", "PWD Index 1"], + 0xE4: ["40c", "PWD Hash 1"], + 0x114: ["40c", "PWD Hash 2"], + 0x144: ["40c", "PWD Hash 3"], + 0x174: ["40c", "PWD Hash 4"], + 0x1a4: ["I", "PWD Index 2"], + 0x1a8: ["40c", "PWD Hash 1"], + 0x1d8: ["40c", "PWD Hash 2"], + 0x208: ["40c", "PWD Hash 3"], + 0x238: ["40c", "PWD Hash 4"], + 0x268: ["I", "PWD Index 3"], + 0x26c: ["40c", "PWD Hash 1"], + 0x29c: ["40c", "PWD Hash 2"], + 0x2cc: ["40c", "PWD Hash 3"], + 0x2fc: ["40c", "PWD Hash 4"], + } + } + + def __init__(self, mode, serial): + self.aes_iv = unhexlify("562E17996D093D28DDB3BA695A2E6F58") + self.aes_key = unhexlify("3030304F6E65506C7573383138303030") + if mode==1: + derivedkey=bytes.fromhex("a9264fbf8a"+("%08x"%serial)+"6b4487ea")[:0x1A] + derivedkey=hashlib.sha256(derivedkey).digest()[:16] + self.aes_key = derivedkey + + def getparam(self, offset, sidindex): + if sidindex & 0x1FF in self.paramitems: + siditems = self.paramitems[sidindex & 0x1FF] + if offset in siditems: + return siditems[offset] + return None + + def decryptsid(self, data): + aes = cryptutils().aes() + hash = cryptutils().hash() + header = data[:4 + 1 + 1] + magic, hv, cv = unpack("= len(rdata): + break + data = rdata[pos:pos + 0x18] + fm = data[0:0x10].replace(b'\x00', b'').decode('utf-8') + if fm != "": + print() + print(f"Offset {hex(pos)}: Field {fm}") + itemlength = unpack(" 4: + if (length % 4): + i += 4 - (length % 4) + + def parse_data(self, i, itemdata, offset, param, sidindex, encrypted=False): + stype = param[0] + name = param[1] + length = calcsize(stype) + item = itemdata[i:i + length] + content = unpack(stype, item) + try: + content = "\"" + b"".join(content).replace(b'\x00', b'').decode('utf-8') + "\"" + except: + if len(content) == 1: + content = hex(content[0]) + else: + tm = "" + for item in content: + if item == 0: + break + tm += hex(item) + content = tm + offsetstr = hex(offset) + while len(offsetstr) < 5: + offsetstr = offsetstr[:2] + "0" + offsetstr[2:] + while len(name) < 30: + name = name + " " + if "PWD Hash" in name: + items = content.split(" ") + pwdhash = items[0][1:9]+"00000000000000000000000000000000000000000000000000000000" + valid = "True" if items[1] != "-1" else "False" + flag = items[2] + date = items[3] + " "+ items[4][:-1] + content = f"{date} ({valid},{flag}): {pwdhash}" + ff = f"SID_Index {hex(sidindex)}, Offset {offsetstr}: {name}: {content}" + if encrypted: + ff = "Encrypted " + ff + else: + ff = f"SID_Index {hex(sidindex)}, Offset {offsetstr}: {name}: {content}" + if encrypted: + ff = "Encrypted " + ff + print(ff) + return length + + def setparamvalue(self, data, sid, offset, value): + if sid > 0x100: + rdata = data[sid * 0x400:(sid * 0x400) + 0x1000] + itemdata, hv, cv, updatecounter = self.decryptsid(rdata) + if itemdata is not None: + itemdata = bytearray(itemdata) + if isinstance(value, int): + itemdata[offset - 0x80:(offset + 4) - 0x80] = pack(" sha1 = 99e489e03107817f14ac06a1bb52de3455423542 => CRC32 -> +ecec6492 +ONEPLUS_YOU_CAN_PASS_NOW => sha1 = 9db4b7338e254669b8c703e77cbc9f119ade7fa6 => CRC32 -> 79707450 (wenn < 8, dann fill mit 0) +''' +''' +com.android.engineeringmode.encrypt + +3439 = oem.cust.flag 1 = French custom edition +9339 = oem.cust.flag 2 = Indian edition +3392 = oem.cust.flag 0 = Normal edition +7668 = com.android.engineeringmode.manualtest.CheckRootStatusActivity +5646 = com.android.engineeringmode.manualtest.DecryptActivity +838 = com.android.engineeringmode.manualtest.CheckRootStatusActivity + +com.oneplus.factorymode.CommonCommands +com.oem.engineermode.DoShellCommond +if(!arg18.getAction().equals(v1.mAction) && !arg18.getAction().equals(v1.na)) { +if((arg18.getAction().equals(v1.doshellcommond)) && ("get_config_params".equals(v0.getStringExtra("shell_cmd")))) { +adb shell am start -n com.oem.engineermode.DoShellCommond --es "shell_cmd" "get_config_params" + +action android:name +adb shell am start -n com.android.engineeringmode/.qualcomm.DiagEnabled --es "code" "Angela" +79a6a933dfc9b1975e444d4e8481c64c771d8ab40b7ac72f8bc1a1bca1718bef + +android.provider.Telephony.SECRET_CODE +*#66# com.android.engineeringmode.IMeiAndPcbCheck +*#99# com.android.engineeringmode.KeepSrceenOn +*#008# com.android.engineeringmode.LanguageSwitchToChineseActivity +*#268# com.android.engineeringmode.qualcomm.QualCommActivity +*#391# com.android.engineeringmode.SwitchSoftwareVersion +*#789# com.android.engineeringmode.qualcomm.ClearTelcelnetlock +*#800# com.android.engineeringmode.qualcomm.LogSwitch +*#800# com.oem.oemlogkit.OEMLogKitMainActivity +*#801# com.android.engineeringmode.qualcomm.DiagEnabled +*#802# com.android.engineeringmode.gps.GpsActivity +*#803# com.android.engineeringmode.wifitest.WifiSettings +*#804# com.android.engineeringmode.NetworkSearch +*#805# com.android.engineeringmode.bluetoothtest.BluetoothTest +*#806# com.android.engineeringmode.autoaging.AutoAgingMainListActivity +*#807# com.android.engineeringmode.autotest.AutoTest +*#808# com.android.engineeringmode.EngineerModeMain +*#808# com.android.engineeringmode.manualtest.ManualTest +*#809# com.android.engineeringmode.echotest.EchoTest +*#810# com.android.engineeringmode.SwitchSetupWizardActivity +*#814# com.android.engineeringmode.TDSNetworkSearch +*#818# com.android.engineeringmode.NetworkSearch_New +*#820# com.android.engineeringmode.DeleteNoNeedFilesActivity +*#824# com.android.engineeringmode.WCDMANetworkSearch +*#834# com.android.engineeringmode.LTENetworkSearch +*#838# com.android.engineeringmode.NetworkSearch_New +*#845# com.android.engineeringmode.wifitest.WifiApSettings +*#888# com.android.engineeringmode.PcbShow +*#899# com.oneplus.factorymode.aftersale.ChooseBackCoverColor +*#900# com.android.engineeringmode.BackCameraAdjusting +*#911# com.android.engineeringmode.PowerOff (Warning: Does factory reset) +*#912# com.android.engineeringmode.qualcomm.RecoverTelcelnetlock +*#912# com.android.engineeringmode.RebootManager +*#928# com.android.engineeringmode.wifitest.WifiFTMActivity +*#1234# com.android.engineeringmode.SHOW_ONEPLUS_VERSION +*#4321# com.android.engineeringmode.LanguageSwitchToZimbabweService +*#6776# com.android.engineeringmode.CheckSoftwareInfo +*#7327# com.oem.rftoolkit.RfToolkitCustomerService +*#7328# com.oem.rftoolkit.RfToolkitAgingTest +*#7332# com.oem.rftoolkit.RfToolkitFactory +*#8011# com.android.engineeringmode.NoUI +*#8017# com.android.engineeringmode.wifitest.WifiAdbHelper +*#8019# com.android.engineeringmode.wifitest.WifiSocketHelper +*#8020# com.android.engineeringmode.wifitest.WifiAdbHelper +*##*8110# com.android.engineeringmode.qualcomm.OtaSwitch +*#8668# com.oneplus.activation.action.STOP_ACTIVATION +*#8669# com.oneplus.activation.action.START_ACTIVATION +*#8778# com.android.engineeringmode.manualtest.MasterClear +*#8888# com.android.engineeringmode.manualtest.MasterClear +*#9886# com.oneplus.screensaver.off +*#9889# com.oneplus.screensaver.on +*#10000# com.android.engineeringmode.MarkResultShow +*#12345# com.android.activation.action.STOP_SERVICE +*#3954391# Switch activated +*##*37847# com.android.engineeringmode.manualtest.DeviceListActivity +*#2288379# com.android.engineeringmode.BatteryExtraInfo +*#36446337# com.android.engineeringmode.EngineeringMode +*#6776001# set_language en_US +*#6776007# set_language ru_RU +*#67760052# set_language es_MX +*#67760055# set_language pt_BR +*#67760066# set_language th_TH +*#67760062# set_language in_IN +*#67760084# set_language vi_VI +*#67760086# set_language zh_CN +*#67760886# set_language zh_TW +*#67760044# com.android.engineeringmode.LanguageSwitchToEnglishActivity +*#67766776# com.android.engineeringmode.oneplusConnectionADBActivity +*#677667764482# com.android.engineeringmode.UserAgentSwitchService +*#*#5646#*#* com.android.engineeringmode.manualtest.DecryptActivity +*#*#7668#*#* com.android.engineeringmode.manualtest.CheckRootStatusActivity +*#3439# = oem.cust.flag=1 +*#9339# = oem.cust.flag=2 +*#3392# = oem.cust.flag=0 + +fastboot ops 4F50040TR18FTR7FSTD5F01 +fastboot ops help + +fastboot ops 4F50040TR18FTR7FSTD5F01 +fastboot ops devkmsg on +fastboot ops boottype debug + + +(bootloader) ops android_log_all +(bootloader) ops kernel_log_all +(bootloader) ops devkmsg +(bootloader) ops boottype [normal, debug, sdebug] +(bootloader) ops set_cust +(bootloader) ops force_adb +(bootloader) ops qeaging_data_img +(bootloader) ops unmount tempfs +(bootloader) ops mount tempfs +(bootloader) ops enable_dm_verity +(bootloader) ops disable_dm_verity +(bootloader) ops boot_mode [rf,ftm,wlan,normal] +(bootloader) ops selinux +(bootloader) ops dump +(bootloader) ops help +(bootloader) ops datafs +(bootloader) ops unforce_training +(bootloader) ops force_training +(bootloader) ops reboot-bootloader +(bootloader) ops reboot-shutdown +(bootloader) ops kmemleak undetect +(bootloader) ops kmemleak detect +(bootloader) ops unconsole +(bootloader) ops console +(bootloader) oem get_unlock_code +(bootloader) oem lock +(bootloader) oem unlock +(bootloader) download: +(bootloader) getvar: +(bootloader) reboot-bootloader +(bootloader) reboot +(bootloader) continue +(bootloader) oem device-info +(bootloader) oem select-display-panel +(bootloader) oem off-mode-charge +(bootloader) oem disable-charger-screen +(bootloader) oem enable-charger-screen +(bootloader) boot +(bootloader) flashing lock +(bootloader) flashing unlock +(bootloader) flashing get_unlock_ability +(bootloader) set_active +(bootloader) erase: +(bootloader) flash: +(bootloader) Varlist + +(bootloader) hw-revision:20001 +(bootloader) unlocked:no +(bootloader) off-mode-charge:1 +(bootloader) charger-screen-enabled:1 +(bootloader) battery-soc-ok:yes +(bootloader) battery-voltage:4360 +(bootloader) version-baseband: +(bootloader) version-bootloader: +(bootloader) erase-block-size: 0x1000 +(bootloader) logical-block-size: 0x1000 +(bootloader) variant:SDM UFS +(bootloader) partition-type:fsc:raw +(bootloader) partition-size:fsc: 0x20000 +(bootloader) partition-type:fsg:raw +(bootloader) partition-size:fsg: 0x200000 +(bootloader) partition-type:modemst2:raw +(bootloader) partition-size:modemst2: 0x200000 +(bootloader) partition-type:modemst1:raw +(bootloader) partition-size:modemst1: 0x200000 +(bootloader) partition-type:ALIGN_TO_128K_2:raw +(bootloader) partition-size:ALIGN_TO_128K_2: 0x1A000 +(bootloader) partition-type:ImageFv:raw +(bootloader) partition-size:ImageFv: 0x200000 +(bootloader) partition-type:logdump:raw +(bootloader) partition-size:logdump: 0x4000000 +(bootloader) partition-type:sti:raw +(bootloader) partition-size:sti: 0x200000 +(bootloader) partition-type:logfs:raw +(bootloader) partition-size:logfs: 0x800000 +(bootloader) partition-type:toolsfv:raw +(bootloader) partition-size:toolsfv: 0x100000 +(bootloader) partition-type:limits:raw +(bootloader) partition-size:limits: 0x1000 +(bootloader) partition-type:splash:raw +(bootloader) partition-size:splash: 0x20A4000 +(bootloader) partition-type:spunvm:raw +(bootloader) partition-size:spunvm: 0x800000 +(bootloader) partition-type:msadp:raw +(bootloader) partition-size:msadp: 0x40000 +(bootloader) partition-type:apdp:raw +(bootloader) partition-size:apdp: 0x40000 +(bootloader) partition-type:dip:raw +(bootloader) partition-size:dip: 0x100000 +(bootloader) partition-type:devinfo:raw +(bootloader) partition-size:devinfo: 0x1000 +(bootloader) partition-type:sec:raw +(bootloader) partition-size:sec: 0x4000 +(bootloader) partition-type:op1:raw +(bootloader) partition-size:op1: 0x6400000 +(bootloader) partition-type:aging:raw +(bootloader) partition-size:aging: 0x4000000 +(bootloader) partition-type:minidump:raw +(bootloader) partition-size:minidump: 0x6400000 +(bootloader) partition-type:fw_ufs8_b:raw +(bootloader) partition-size:fw_ufs8_b: 0x200000 +(bootloader) partition-type:fw_ufs7_b:raw +(bootloader) partition-size:fw_ufs7_b: 0x200000 +(bootloader) partition-type:fw_ufs6_b:raw +(bootloader) partition-size:fw_ufs6_b: 0x200000 +(bootloader) partition-type:fw_ufs5_b:raw +(bootloader) partition-size:fw_ufs5_b: 0x200000 +(bootloader) partition-type:fw_ufs4_b:raw +(bootloader) partition-size:fw_ufs4_b: 0x200000 +(bootloader) partition-type:fw_ufs3_b:raw +(bootloader) partition-size:fw_ufs3_b: 0x200000 +(bootloader) partition-type:fw_4u1ea_b:raw +(bootloader) partition-size:fw_4u1ea_b: 0x200000 +(bootloader) partition-type:fw_4j1ed_b:raw +(bootloader) partition-size:fw_4j1ed_b: 0x200000 +(bootloader) partition-type:LOGO_b:raw +(bootloader) partition-size:LOGO_b: 0x1000000 +(bootloader) partition-type:storsec_b:raw +(bootloader) partition-size:storsec_b: 0x20000 +(bootloader) partition-type:dtbo_b:raw +(bootloader) partition-size:dtbo_b: 0x800000 +(bootloader) partition-type:vbmeta_b:raw +(bootloader) partition-size:vbmeta_b: 0x10000 +(bootloader) partition-type:vendor_b:raw +(bootloader) partition-size:vendor_b: 0x40000000 +(bootloader) partition-type:qupfw_b:raw +(bootloader) partition-size:qupfw_b: 0x10000 +(bootloader) partition-type:devcfg_b:raw +(bootloader) partition-size:devcfg_b: 0x20000 +(bootloader) partition-type:cmnlib64_b:raw +(bootloader) partition-size:cmnlib64_b: 0x80000 +(bootloader) partition-type:cmnlib_b:raw +(bootloader) partition-size:cmnlib_b: 0x80000 +(bootloader) partition-type:boot_b:raw +(bootloader) partition-size:boot_b: 0x4000000 +(bootloader) partition-type:keymaster_b:raw +(bootloader) partition-size:keymaster_b: 0x80000 +(bootloader) partition-type:dsp_b:raw +(bootloader) partition-size:dsp_b: 0x2000000 +(bootloader) partition-type:abl_b:raw +(bootloader) partition-size:abl_b: 0x800000 +(bootloader) partition-type:mdtp_b:raw +(bootloader) partition-size:mdtp_b: 0x2000000 +(bootloader) partition-type:mdtpsecapp_b:raw +(bootloader) partition-size:mdtpsecapp_b: 0x400000 +(bootloader) partition-type:bluetooth_b:raw +(bootloader) partition-size:bluetooth_b: 0x100000 +(bootloader) partition-type:modem_b:raw +(bootloader) partition-size:modem_b: 0x7800000 +(bootloader) partition-type:hyp_b:raw +(bootloader) partition-size:hyp_b: 0x80000 +(bootloader) partition-type:tz_b:raw +(bootloader) partition-size:tz_b: 0x200000 +(bootloader) partition-type:aop_b:raw +(bootloader) partition-size:aop_b: 0x80000 +(bootloader) partition-type:fw_ufs8_a:raw +(bootloader) partition-size:fw_ufs8_a: 0x200000 +(bootloader) partition-type:fw_ufs7_a:raw +(bootloader) partition-size:fw_ufs7_a: 0x200000 +(bootloader) partition-type:fw_ufs6_a:raw +(bootloader) partition-size:fw_ufs6_a: 0x200000 +(bootloader) partition-type:fw_ufs5_a:raw +(bootloader) partition-size:fw_ufs5_a: 0x200000 +(bootloader) partition-type:fw_ufs4_a:raw +(bootloader) partition-size:fw_ufs4_a: 0x200000 +(bootloader) partition-type:fw_ufs3_a:raw +(bootloader) partition-size:fw_ufs3_a: 0x200000 +(bootloader) partition-type:fw_4u1ea_a:raw +(bootloader) partition-size:fw_4u1ea_a: 0x200000 +(bootloader) partition-type:fw_4j1ed_a:raw +(bootloader) partition-size:fw_4j1ed_a: 0x200000 +(bootloader) partition-type:LOGO_a:raw +(bootloader) partition-size:LOGO_a: 0x1000000 +(bootloader) partition-type:storsec_a:raw +(bootloader) partition-size:storsec_a: 0x20000 +(bootloader) partition-type:dtbo_a:raw +(bootloader) partition-size:dtbo_a: 0x800000 +(bootloader) partition-type:vbmeta_a:raw +(bootloader) partition-size:vbmeta_a: 0x10000 +(bootloader) partition-type:vendor_a:raw +(bootloader) partition-size:vendor_a: 0x40000000 +(bootloader) partition-type:qupfw_a:raw +(bootloader) partition-size:qupfw_a: 0x10000 +(bootloader) partition-type:devcfg_a:raw +(bootloader) partition-size:devcfg_a: 0x20000 +(bootloader) partition-type:cmnlib64_a:raw +(bootloader) partition-size:cmnlib64_a: 0x80000 +(bootloader) partition-type:cmnlib_a:raw +(bootloader) partition-size:cmnlib_a: 0x80000 +(bootloader) partition-type:boot_a:raw +(bootloader) partition-size:boot_a: 0x4000000 +(bootloader) partition-type:keymaster_a:raw +(bootloader) partition-size:keymaster_a: 0x80000 +(bootloader) partition-type:dsp_a:raw +(bootloader) partition-size:dsp_a: 0x2000000 +(bootloader) partition-type:abl_a:raw +(bootloader) partition-size:abl_a: 0x800000 +(bootloader) partition-type:mdtp_a:raw +(bootloader) partition-size:mdtp_a: 0x2000000 +(bootloader) partition-type:mdtpsecapp_a:raw +(bootloader) partition-size:mdtpsecapp_a: 0x400000 +(bootloader) partition-type:bluetooth_a:raw +(bootloader) partition-size:bluetooth_a: 0x100000 +(bootloader) partition-type:modem_a:raw +(bootloader) partition-size:modem_a: 0x7800000 +(bootloader) partition-type:hyp_a:raw +(bootloader) partition-size:hyp_a: 0x80000 +(bootloader) partition-type:tz_a:raw +(bootloader) partition-size:tz_a: 0x200000 +(bootloader) partition-type:aop_a:raw +(bootloader) partition-size:aop_a: 0x80000 +(bootloader) partition-type:ddr:raw +(bootloader) partition-size:ddr: 0x100000 +(bootloader) partition-type:cdt:raw +(bootloader) partition-size:cdt: 0x20000 +(bootloader) partition-type:ALIGN_TO_128K_1:raw +(bootloader) partition-size:ALIGN_TO_128K_1: 0x1A000 +(bootloader) partition-type:xbl_config_b:raw +(bootloader) partition-size:xbl_config_b: 0x20000 +(bootloader) partition-type:xbl_b:raw +(bootloader) partition-size:xbl_b: 0x380000 +(bootloader) partition-type:xbl_config_a:raw +(bootloader) partition-size:xbl_config_a: 0x20000 +(bootloader) partition-type:xbl_a:raw +(bootloader) partition-size:xbl_a: 0x380000 +(bootloader) partition-type:userdata:ext4 +(bootloader) partition-size:userdata: 0x1B800BB000 +(bootloader) partition-type:odm_b:raw +(bootloader) partition-size:odm_b: 0x6400000 +(bootloader) partition-type:odm_a:raw +(bootloader) partition-size:odm_a: 0x6400000 +(bootloader) partition-type:system_b:ext4 +(bootloader) partition-size:system_b: 0xB2C00000 +(bootloader) partition-type:system_a:ext4 +(bootloader) partition-size:system_a: 0xB2C00000 +(bootloader) partition-type:config:raw +(bootloader) partition-size:config: 0x80000 +(bootloader) partition-type:reserve2:raw +(bootloader) partition-size:reserve2: 0xFD0000 +(bootloader) partition-type:reserve1:raw +(bootloader) partition-size:reserve1: 0x7E8000 +(bootloader) partition-type:oem_stanvbk:raw +(bootloader) partition-size:oem_stanvbk: 0xA00000 +(bootloader) partition-type:oem_dycnvbk:raw +(bootloader) partition-size:oem_dycnvbk: 0xA00000 +(bootloader) partition-type:op2:raw +(bootloader) partition-size:op2: 0x10000000 +(bootloader) partition-type:frp:raw +(bootloader) partition-size:frp: 0x80000 +(bootloader) partition-type:keystore:raw +(bootloader) partition-size:keystore: 0x80000 +(bootloader) partition-type:param:raw +(bootloader) partition-size:param: 0x100000 +(bootloader) partition-type:misc:raw +(bootloader) partition-size:misc: 0x100000 +(bootloader) partition-type:persist:raw +(bootloader) partition-size:persist: 0x2000000 +(bootloader) partition-type:ssd:raw +(bootloader) partition-size:ssd: 0x2000 +(bootloader) has-slot:modem:yes +(bootloader) has-slot:system:yes +(bootloader) current-slot:b +(bootloader) has-slot:boot:yes +(bootloader) slot-retry-count:b:6 +(bootloader) slot-unbootable:b:no +(bootloader) slot-successful:b:yes +(bootloader) slot-retry-count:a:6 +(bootloader) slot-unbootable:a:no +(bootloader) slot-successful:a:yes +(bootloader) slot-count:2 +(bootloader) secure:yes +(bootloader) serialno:45751efa +(bootloader) product:sdm845 +(bootloader) max-download-size:536870912 +(bootloader) kernel:uefi + +25d52959 + +am broadcast -n com.oneplus.factorymode/.EngineerModeActionReceiver -a android.provider.Telephony.SECRET_CODE -d android_secret_code://5646 + +am broadcast -n com.oneplus.factorymode/.EngineerModeActionReceiver -a com.android.engineeringmode.encrypt + +am broadcast -n com.oneplus.factorymode/.EngineerModeActionReceiver -a +com.oem.engineermode.StartOEMLogMain + +IMEI:866241047809937 +''' + + +def main(): + from docopt import docopt + args = docopt(__doc__, version='oneplus 1.1') + # filename="param_jacob_7pro.bin" + # filename="chris/param.bin" + if args["param"]: + filename = args[""] + mode = args["--mode"] + serial = args["--serial"] + param = paramtools(mode,serial) + with open(filename, 'rb') as rf: + data = rf.read() + param.parse_decrypted_fields(data) + print("\nEncrypted Values:\n-----------------\n") + param.parse_encrypted_fields(data) + # with open(filename + ".patched", 'wb') as wf: + # wf.write(param.setfactoryflags(data)) + elif args["ops"]: + filename = args[""] + mode = args["--mode"] + serial = args["--serial"] + param = paramtools(mode,serial) + with open(filename, 'rb') as rf: + data = rf.read() + with open(filename + ".patched", 'wb') as wf: + try: + data = param.setparamvalue(data, 0x12C, 0x80, 0x3) # >= Oneplus 5 + except: + pass + data = param.setparamvalue(data, 0xC, 0x1A4, 0x1) # < Oneplus 5 + wf.write(data) + elif args["setparam"]: + filename = args[""] + sid = int(args[""], 16) + offset = int(args[""], 16) + value = int(args[""], 16) + mode = args["--mode"] + serial = args["--serial"] + param = paramtools(mode,serial) + with open(filename, 'rb') as rf: + data = rf.read() + with open(filename + ".patched", 'wb') as wf: + wf.write(param.setparamvalue(data, sid, offset, value)) + elif args["gencode"]: + imei = args[""] + mode = 0 + serial = None + param = paramtools(mode,serial) + print("oneplus Factory qr code generator (c) B. Kerler 2019\nGPLv3 License\n----------------------") + print("Code : *#*#5646#*#* , *#808#, *#36446337# = com.android.engineeringmode.manualtest.DecryptActivity") + results = param.gencode([imei, "YOU_CAN_PASS_NOW"]) + img = qrcode.make("op_eng://" + results[0]) + print("Code : " + results[0]) + img.save(imei + ".png") + print("Image written as " + imei + ".png") + + +if __name__ == "__main__": + main() diff --git a/edlclient/Library/Modules/xiaomi.py b/edlclient/Library/Modules/xiaomi.py index cceaf04..53eadee 100644 --- a/edlclient/Library/Modules/xiaomi.py +++ b/edlclient/Library/Modules/xiaomi.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import logging from edlclient.Library.utils import LogBase diff --git a/edlclient/Library/asmtools.py b/edlclient/Library/asmtools.py index 9bda711..4d5354a 100755 --- a/edlclient/Library/asmtools.py +++ b/edlclient/Library/asmtools.py @@ -1,7 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 - +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! from capstone import * from keystone import * from binascii import unhexlify diff --git a/edlclient/Library/cryptutils.py b/edlclient/Library/cryptutils.py index d11a90a..9f7ff41 100755 --- a/edlclient/Library/cryptutils.py +++ b/edlclient/Library/cryptutils.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2019 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import hashlib from Cryptodome.Cipher import AES diff --git a/edlclient/Library/firehose.py b/edlclient/Library/firehose.py index 26c1811..7e2d197 100755 --- a/edlclient/Library/firehose.py +++ b/edlclient/Library/firehose.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2019 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import binascii import io diff --git a/edlclient/Library/firehose_client.py b/edlclient/Library/firehose_client.py index 5d13b70..9b2f18d 100644 --- a/edlclient/Library/firehose_client.py +++ b/edlclient/Library/firehose_client.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2019 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import os import sys diff --git a/edlclient/Library/gpt.py b/edlclient/Library/gpt.py index 563a55b..63b4e39 100755 --- a/edlclient/Library/gpt.py +++ b/edlclient/Library/gpt.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 MIT License +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import os import sys import argparse diff --git a/edlclient/Library/hdlc.py b/edlclient/Library/hdlc.py index e48ac1d..b242717 100755 --- a/edlclient/Library/hdlc.py +++ b/edlclient/Library/hdlc.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2019 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import logging from binascii import hexlify diff --git a/edlclient/Library/loader_db.py b/edlclient/Library/loader_db.py index 23c8085..a1f1430 100644 --- a/edlclient/Library/loader_db.py +++ b/edlclient/Library/loader_db.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2022 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import binascii import time import os @@ -11,8 +15,12 @@ from struct import unpack, pack current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parent_dir = os.path.dirname(current_dir) sys.path.insert(0, parent_dir) -from edlclient.Library.utils import read_object, print_progress, rmrf, LogBase -from edlclient.Config.qualcomm_config import sochw, msmids, root_cert_hash +try: + from edlclient.Library.utils import read_object, print_progress, rmrf, LogBase + from edlclient.Config.qualcomm_config import sochw, msmids, root_cert_hash +except: + from Library.utils import read_object, print_progress, rmrf, LogBase + from Config.qualcomm_config import sochw, msmids, root_cert_hash class loader_utils(metaclass=LogBase): def __init__(self, loglevel=logging.INFO): diff --git a/edlclient/Library/memparse.py b/edlclient/Library/memparse.py index 0dd4ec5..493102c 100755 --- a/edlclient/Library/memparse.py +++ b/edlclient/Library/memparse.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import os import pt64 diff --git a/edlclient/Library/nand_config.py b/edlclient/Library/nand_config.py index 2eb45dd..533d57c 100644 --- a/edlclient/Library/nand_config.py +++ b/edlclient/Library/nand_config.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2019 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import ctypes from enum import Enum from edlclient.Config.qualcomm_config import secgen, secureboottbl diff --git a/edlclient/Library/sahara.py b/edlclient/Library/sahara.py index bfff6cd..7a3ad2d 100755 --- a/edlclient/Library/sahara.py +++ b/edlclient/Library/sahara.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import binascii import time import os diff --git a/edlclient/Library/sahara_defs.py b/edlclient/Library/sahara_defs.py index 727e337..a5310f4 100644 --- a/edlclient/Library/sahara_defs.py +++ b/edlclient/Library/sahara_defs.py @@ -1,3 +1,11 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! + from edlclient.Library.utils import structhelper_io from io import BytesIO diff --git a/edlclient/Library/sparse.py b/edlclient/Library/sparse.py index b0ba3d1..68da60a 100755 --- a/edlclient/Library/sparse.py +++ b/edlclient/Library/sparse.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import logging import sys import os diff --git a/edlclient/Library/streaming.py b/edlclient/Library/streaming.py index c9c085d..b745f66 100755 --- a/edlclient/Library/streaming.py +++ b/edlclient/Library/streaming.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! from struct import pack from binascii import unhexlify from edlclient.Library.utils import * diff --git a/edlclient/Library/streaming_client.py b/edlclient/Library/streaming_client.py index 07e99d4..ccd77ff 100644 --- a/edlclient/Library/streaming_client.py +++ b/edlclient/Library/streaming_client.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import sys import os import logging diff --git a/edlclient/Library/streaming_defs.py b/edlclient/Library/streaming_defs.py index fdafca5..420a643 100644 --- a/edlclient/Library/streaming_defs.py +++ b/edlclient/Library/streaming_defs.py @@ -1,3 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! class open_mode_type: OPEN_MODE_NONE = 0x00 # Not opened yet OPEN_BOOTLOADER = 0x01 # Bootloader Image diff --git a/edlclient/Library/utils.py b/edlclient/Library/utils.py index b2b87ca..05bd7fd 100755 --- a/edlclient/Library/utils.py +++ b/edlclient/Library/utils.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import sys import logging import logging.config diff --git a/edlclient/Library/xmlparser.py b/edlclient/Library/xmlparser.py index 5cc65d0..3c54f80 100755 --- a/edlclient/Library/xmlparser.py +++ b/edlclient/Library/xmlparser.py @@ -1,6 +1,10 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2018-2021 +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import xml.etree.ElementTree as ET diff --git a/edlclient/Tools/Config b/edlclient/Tools/Config new file mode 120000 index 0000000..d0fb958 --- /dev/null +++ b/edlclient/Tools/Config @@ -0,0 +1 @@ +../Config \ No newline at end of file diff --git a/edlclient/Tools/Library b/edlclient/Tools/Library new file mode 120000 index 0000000..a1d2d99 --- /dev/null +++ b/edlclient/Tools/Library @@ -0,0 +1 @@ +../Library \ No newline at end of file diff --git a/edlclient/Tools/beagle_to_loader b/edlclient/Tools/beagle_to_loader index 8e48045..5504a1e 100755 --- a/edlclient/Tools/beagle_to_loader +++ b/edlclient/Tools/beagle_to_loader @@ -1,5 +1,11 @@ #!/usr/bin/env python3 -# Beagle to EDL Loader (c) B.Kerler 2021 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! +# Beagle to EDL Loader import os,sys from struct import unpack diff --git a/edlclient/Tools/boottodwnload b/edlclient/Tools/boottodwnload index 93cc788..e19f9a8 100755 --- a/edlclient/Tools/boottodwnload +++ b/edlclient/Tools/boottodwnload @@ -1,8 +1,10 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2020 under MIT license +# (c) B.Kerler 2018-2023 under GPLv3 license # If you use my code, make sure you refer to my name -# If you want to use in a commercial product, ask me before integrating it +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import time import serial import serial.tools.list_ports diff --git a/edlclient/Tools/enableadb b/edlclient/Tools/enableadb index 270df37..f42fa85 100755 --- a/edlclient/Tools/enableadb +++ b/edlclient/Tools/enableadb @@ -1,8 +1,10 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2020-2021 under MIT license +# (c) B.Kerler 2018-2023 under GPLv3 license # If you use my code, make sure you refer to my name -# If you want to use in a commercial product, ask me before integrating it +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import time from Exscript.protocols import Telnet import serial @@ -30,15 +32,76 @@ except ImportError: sys.path.insert(0, parent_dir) from sierrakeygen import SierraKeygen -try: - from edlclient.Library.utils import LogBase -except Exception as e: - import os, sys, inspect +import logging +import logging.config +import logging.handlers +import colorama - current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) - parent_dir = os.path.dirname(current_dir) - sys.path.insert(0, parent_dir) - from edlclient.Library.utils import LogBase +class ColorFormatter(logging.Formatter): + LOG_COLORS = { + logging.ERROR: colorama.Fore.RED, + logging.DEBUG: colorama.Fore.LIGHTMAGENTA_EX, + logging.WARNING: colorama.Fore.YELLOW, + } + + def format(self, record, *args, **kwargs): + # if the corresponding logger has children, they may receive modified + # record, so we want to keep it intact + new_record = copy.copy(record) + if new_record.levelno in self.LOG_COLORS: + pad = "" + if new_record.name != "root": + print(new_record.name) + pad = "[LIB]: " + # we want levelname to be in different color, so let's modify it + new_record.msg = "{pad}{color_begin}{msg}{color_end}".format( + pad=pad, + msg=new_record.msg, + color_begin=self.LOG_COLORS[new_record.levelno], + color_end=colorama.Style.RESET_ALL, + ) + # now we can let standart formatting take care of the rest + return super(ColorFormatter, self).format(new_record, *args, **kwargs) + + +class LogBase(type): + debuglevel = logging.root.level + + def __init__(cls, *args): + super().__init__(*args) + logger_attribute_name = '_' + cls.__name__ + '__logger' + logger_debuglevel_name = '_' + cls.__name__ + '__debuglevel' + logger_name = '.'.join([c.__name__ for c in cls.mro()[-2::-1]]) + LOG_CONFIG = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "root": { + "()": ColorFormatter, + "format": "%(name)s - %(message)s", + } + }, + "handlers": { + "root": { + # "level": cls.__logger.level, + "formatter": "root", + "class": "logging.StreamHandler", + "stream": "ext://sys.stdout", + } + }, + "loggers": { + "": { + "handlers": ["root"], + # "level": cls.debuglevel, + "propagate": False + } + }, + } + logging.config.dictConfig(LOG_CONFIG) + logger = logging.getLogger(logger_name) + + setattr(cls, logger_attribute_name, logger) + setattr(cls, logger_debuglevel_name, cls.debuglevel) class vendor(Enum): @@ -491,7 +554,7 @@ class adbtools(metaclass=LogBase): def main(): version = "1.2" - info = '\nModem Gimme-ADB ' + version + ' (c) B. Kerler 2020-2021\n-------------------------------------------\n' + info = '\nModem Gimme-ADB ' + version + ' (c) B. Kerler 2020-2023\n-------------------------------------------\n' parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=info) parser.add_argument( '-mode', help='Mode: enable or disable', diff --git a/edlclient/Tools/fhloaderparse b/edlclient/Tools/fhloaderparse index da9141c..9db7324 100755 --- a/edlclient/Tools/fhloaderparse +++ b/edlclient/Tools/fhloaderparse @@ -1,4 +1,10 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import os import sys from os import walk @@ -7,12 +13,9 @@ from struct import unpack, pack from shutil import copyfile import os, sys, inspect from io import BytesIO -current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) -parent_dir = os.path.dirname(os.path.dirname(current_dir)) -sys.path.insert(0, parent_dir) -from edlclient.Library.utils import elf -from edlclient.Library.loader_db import loader_utils -from edlclient.Config.qualcomm_config import vendor +from Library.utils import elf +from Library.loader_db import loader_utils +from Config.qualcomm_config import vendor lu=loader_utils() diff --git a/edlclient/Tools/qc_diag.py b/edlclient/Tools/qc_diag.py index 18c024a..4a156e9 100755 --- a/edlclient/Tools/qc_diag.py +++ b/edlclient/Tools/qc_diag.py @@ -1,7 +1,10 @@ #!/usr/bin/env python3 -""" -Licensed under MIT License, (c) B. Kerler 2018-2021 -""" +# -*- coding: utf-8 -*- +# (c) B.Kerler 2018-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! import inspect import argparse import json @@ -17,11 +20,11 @@ current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfra parent_dir = os.path.dirname(os.path.dirname(current_dir)) sys.path.insert(0, parent_dir) -from edlclient.Library.utils import print_progress, read_object, write_object, LogBase -from edlclient.Library.Connection.usblib import usb_class -from edlclient.Library.Connection.seriallib import serial_class -from edlclient.Library.hdlc import hdlc -from edlclient.Config.usb_ids import default_diag_vid_pid +from Library.utils import print_progress, read_object, write_object, LogBase +from Library.Connection.usblib import usb_class +from Library.Connection.seriallib import serial_class +from Library.hdlc import hdlc +from Config.usb_ids import default_diag_vid_pid qcerror = { 1: "None", @@ -332,9 +335,14 @@ class qcdiag(metaclass=LogBase): self.__logger.addHandler(fh) import os, inspect current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) - parent_dir = os.path.dirname(os.path.dirname(current_dir)) - nvxml = os.path.join(parent_dir, "edlclient", "Config", "nvitems.xml") - e = ElementTree.parse(nvxml).getroot() + try: + parent_dir = os.path.dirname(os.path.dirname(current_dir)) + nvxml = os.path.join(parent_dir, "edlclient", "Config", "nvitems.xml") + e = ElementTree.parse(nvxml).getroot() + except: + current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + nvxml = os.path.join(current_dir, "edlclient", "Config", "nvitems.xml") + e = ElementTree.parse(nvxml).getroot() for atype in e.findall("nv"): name = atype.get("name") identifier = int(atype.get("id")) diff --git a/edlclient/Tools/sierrakeygen.py b/edlclient/Tools/sierrakeygen.py index 5915b3a..495a741 100755 --- a/edlclient/Tools/sierrakeygen.py +++ b/edlclient/Tools/sierrakeygen.py @@ -1,24 +1,88 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# (c) B.Kerler 2019-2020 under MIT license +# (c) B.Kerler 2019-2023 under GPLv3 license # If you use my code, make sure you refer to my name -# If you want to use in a commercial product, ask me before integrating it - +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! +import copy import sys import argparse import time import serial.tools.list_ports from Exscript.protocols import Telnet from binascii import hexlify, unhexlify +import logging +import logging.config +import logging.handlers +import colorama + +class ColorFormatter(logging.Formatter): + LOG_COLORS = { + logging.ERROR: colorama.Fore.RED, + logging.DEBUG: colorama.Fore.LIGHTMAGENTA_EX, + logging.WARNING: colorama.Fore.YELLOW, + } + + def format(self, record, *args, **kwargs): + # if the corresponding logger has children, they may receive modified + # record, so we want to keep it intact + new_record = copy.copy(record) + if new_record.levelno in self.LOG_COLORS: + pad = "" + if new_record.name != "root": + print(new_record.name) + pad = "[LIB]: " + # we want levelname to be in different color, so let's modify it + new_record.msg = "{pad}{color_begin}{msg}{color_end}".format( + pad=pad, + msg=new_record.msg, + color_begin=self.LOG_COLORS[new_record.levelno], + color_end=colorama.Style.RESET_ALL, + ) + # now we can let standart formatting take care of the rest + return super(ColorFormatter, self).format(new_record, *args, **kwargs) + + +class LogBase(type): + debuglevel = logging.root.level + + def __init__(cls, *args): + super().__init__(*args) + logger_attribute_name = '_' + cls.__name__ + '__logger' + logger_debuglevel_name = '_' + cls.__name__ + '__debuglevel' + logger_name = '.'.join([c.__name__ for c in cls.mro()[-2::-1]]) + LOG_CONFIG = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "root": { + "()": ColorFormatter, + "format": "%(name)s - %(message)s", + } + }, + "handlers": { + "root": { + # "level": cls.__logger.level, + "formatter": "root", + "class": "logging.StreamHandler", + "stream": "ext://sys.stdout", + } + }, + "loggers": { + "": { + "handlers": ["root"], + # "level": cls.debuglevel, + "propagate": False + } + }, + } + logging.config.dictConfig(LOG_CONFIG) + logger = logging.getLogger(logger_name) + + setattr(cls, logger_attribute_name, logger) + setattr(cls, logger_debuglevel_name, cls.debuglevel) -try: - from edlclient.Library.utils import LogBase -except Exception as e: - import os,inspect - current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) - parent_dir = os.path.dirname(current_dir) - sys.path.insert(0, parent_dir) - from Library.utils import LogBase ''' C7 = 7 0 0 2 7 5 0 @@ -58,10 +122,12 @@ prodtable = { run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)"), # EM7565 "MDM9x06": dict(openlock=20, openmep=19, opencnd=20, clen=8, init=[7, 3, 0, 1, 5], run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)"), # WP77xx - "SDX55": dict(openlock=22, openmep=21, opencnd=22, clen=8, init=[7, 3, 0, 1, 5], #MR5100 - run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)"), - "MDM9x15A": dict(openlock=24, openmep=23, opencnd=24, clen=8, init=[7, 3, 0, 1, 5], #AC779S - run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)") + "SDX55": dict(openlock=22, openmep=21, opencnd=22, clen=8, init=[7, 3, 0, 1, 5], # MR5100, MR6400 old fw + run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)"), + "MDM9x15A": dict(openlock=24, openmep=23, opencnd=24, clen=8, init=[7, 3, 0, 1, 5], # AC779S + run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)"), + "SDX65": dict(openlock=25, openmep=21, opencnd=26, clen=8, init=[7, 3, 0, 1, 5], # MR6400 new fw + run="resultbuffer[i]=self.SierraAlgo(challenge[i], 4, 2, 1, 0, 3, 2, 0, 0)") } infotable = { @@ -83,63 +149,67 @@ infotable = { "MDM9x30_V1": ["Netgear AC790/MDM9230"], "MDM9x40": ["AC815s", "AC785s", "AC797S", "MR1100"], "MDM9x50": ["EM7565", "EM7565-9", "EM7511", "EM7411"], - "SDX55" : ["MR5100","MR5200","ac797-100eus","MR6400"] + "SDX55": ["MR5100", "MR5200", "ac797-100eus", "MR6400"], + "SDX65": ["MR6400", "MR6500", "MR6110", "MR6150", "MR6450", "MR6550"] } -keytable = bytearray([0xF0, 0x14, 0x55, 0x0D, 0x5E, 0xDA, 0x92, 0xB3, 0xA7, 0x6C, 0xCE, 0x84, 0x90, 0xBC, 0x7F, 0xED, # 0 MC8775_H2.0.8.19 !OPENLOCK, !OPENCND .. MC8765V,MC8765,MC8755V,MC8775,MC8775V,MC8775,AC850, # AC860,AC875,AC881,AC881U,AC875, AC340U 1.13.12.14 - 0x61, 0x94, 0xCE, 0xA7, 0xB0, 0xEA, 0x4F, 0x0A, 0x73, 0xC5, 0xC3, 0xA6, 0x5E, 0xEC, 0x1C, 0xE2, +keytable = bytearray([0xF0, 0x14, 0x55, 0x0D, 0x5E, 0xDA, 0x92, 0xB3, 0xA7, 0x6C, 0xCE, 0x84, 0x90, 0xBC, 0x7F, 0xED, # 1 MC8775_H2.0.8.19 AC340U, OPENMEP default - 0x39, 0xC6, 0x7B, 0x04, 0xCA, 0x50, 0x82, 0x1F, 0x19, 0x63, 0x36, 0xDE, 0x81, 0x49, 0xF0, 0xD7, - # 2 AC750,AC710,AC7XX,SB750A,SB750,PC7000,AC313u OPENMEP - 0xDE, 0xA5, 0xAD, 0x2E, 0xBE, 0xE1, 0xC9, 0xEF, 0xCA, 0xF9, 0xFE, 0x1F, 0x17, 0xFE, 0xED, 0x3B, - # 3 AC775,PC7200 - 0xFE, 0xD4, 0x40, 0x52, 0x2D, 0x4B, 0x12, 0x5C, 0xE7, 0x0D, 0xF8, 0x79, 0xF8, 0xC0, 0xDD, 0x37, - # 4 MC7455_02.30.01.01 OPENMEP - 0x3B, 0x18, 0x99, 0x6B, 0x57, 0x24, 0x0A, 0xD8, 0x94, 0x6F, 0x8E, 0xD9, 0x90, 0xBC, 0x67, 0x56, - # 5 MC7455_02.30.01.01 OPENLOCK - 0x47, 0x4F, 0x4F, 0x44, 0x4A, 0x4F, 0x42, 0x44, 0x45, 0x43, 0x4F, 0x44, 0x49, 0x4E, 0x47, 0x2E, - # 6 SWI9x50 Openmep Key SWI9X50C_01.08.04.00 - 0x4F, 0x4D, 0x41, 0x52, 0x20, 0x44, 0x49, 0x44, 0x20, 0x54, 0x48, 0x49, 0x53, 0x2E, 0x2E, 0x2E, - # 7 SWI9x50 Openlock Key SWI9X50C_01.08.04.00 - 0x8F, 0xA5, 0x85, 0x05, 0x5E, 0xCF, 0x44, 0xA0, 0x98, 0x8B, 0x09, 0xE8, 0xBB, 0xC6, 0xF7, 0x65, - # 8 MDM8200 Special - 0x4D, 0x42, 0xD8, 0xC1, 0x25, 0x44, 0xD8, 0xA0, 0x1D, 0x80, 0xC4, 0x52, 0x8E, 0xEC, 0x8B, 0xE3, - # 9 SWI9x07 Openlock Key 02.25.02.01 - 0xED, 0xA9, 0xB7, 0x0A, 0xDB, 0x85, 0x3D, 0xC0, 0x92, 0x49, 0x7D, 0x41, 0x9A, 0x91, 0x09, 0xEE, - # 10 SWI9x07 Openmep Key 02.25.02.01 - 0x8A, 0x56, 0x03, 0xF0, 0xBB, 0x9C, 0x13, 0xD2, 0x4E, 0xB2, 0x45, 0xAD, 0xC4, 0x0A, 0xE7, 0x52, - # 11 NTG9X40C_11.14.08.11 / mdm9x40r11_core AC815s / SWI9x50 MR1100 Openlock Key - 0x2A, 0xEF, 0x07, 0x2B, 0x19, 0x60, 0xC9, 0x01, 0x8B, 0x87, 0xF2, 0x6E, 0xC1, 0x42, 0xA8, 0x3A, - # 12 SWI9x50 MR1100 Openmep Key - 0x28, 0x55, 0x48, 0x52, 0x24, 0x72, 0x63, 0x37, 0x14, 0x26, 0x37, 0x50, 0xBE, 0xFE, 0x00, 0x00, - # 13 SWI9x50 Unknown key - 0x22, 0x63, 0x48, 0x02, 0x24, 0x72, 0x27, 0x37, 0x19, 0x26, 0x37, 0x50, 0xBE, 0xEF, 0xCA, 0xFE, - # 14 SWI9x50,SWI9X06Y IMEI nv key - 0x98, 0xE1, 0xC1, 0x93, 0xC3, 0xBF, 0xC3, 0x50, 0x8D, 0xA1, 0x35, 0xFE, 0x50, 0x47, 0xB3, 0xC4, - # 15 NTG9X35C_02.08.29.00 Openmep Key AC791L/AC790S Old 0x61, 0x94, 0xCE, 0xA7, 0xB0, 0xEA, 0x4F, 0x0A, 0x73, 0xC5, 0xC3, 0xA6, 0x5E, 0xEC, 0x1C, 0xE2, + # 2 AC750,AC710,AC7XX,SB750A,SB750,PC7000,AC313u OPENMEP + 0x39, 0xC6, 0x7B, 0x04, 0xCA, 0x50, 0x82, 0x1F, 0x19, 0x63, 0x36, 0xDE, 0x81, 0x49, 0xF0, 0xD7, + # 3 AC775,PC7200 + 0xDE, 0xA5, 0xAD, 0x2E, 0xBE, 0xE1, 0xC9, 0xEF, 0xCA, 0xF9, 0xFE, 0x1F, 0x17, 0xFE, 0xED, 0x3B, + # 4 MC7455_02.30.01.01 OPENMEP + 0xFE, 0xD4, 0x40, 0x52, 0x2D, 0x4B, 0x12, 0x5C, 0xE7, 0x0D, 0xF8, 0x79, 0xF8, 0xC0, 0xDD, 0x37, + # 5 MC7455_02.30.01.01 OPENLOCK + 0x3B, 0x18, 0x99, 0x6B, 0x57, 0x24, 0x0A, 0xD8, 0x94, 0x6F, 0x8E, 0xD9, 0x90, 0xBC, 0x67, 0x56, + # 6 SWI9x50 Openmep Key SWI9X50C_01.08.04.00 + 0x47, 0x4F, 0x4F, 0x44, 0x4A, 0x4F, 0x42, 0x44, 0x45, 0x43, 0x4F, 0x44, 0x49, 0x4E, 0x47, 0x2E, + # 7 SWI9x50 Openlock Key SWI9X50C_01.08.04.00 + 0x4F, 0x4D, 0x41, 0x52, 0x20, 0x44, 0x49, 0x44, 0x20, 0x54, 0x48, 0x49, 0x53, 0x2E, 0x2E, 0x2E, + # 8 MDM8200 Special + 0x8F, 0xA5, 0x85, 0x05, 0x5E, 0xCF, 0x44, 0xA0, 0x98, 0x8B, 0x09, 0xE8, 0xBB, 0xC6, 0xF7, 0x65, + # 9 SWI9x07 Openlock Key 02.25.02.01 + 0x4D, 0x42, 0xD8, 0xC1, 0x25, 0x44, 0xD8, 0xA0, 0x1D, 0x80, 0xC4, 0x52, 0x8E, 0xEC, 0x8B, 0xE3, + # 10 SWI9x07 Openmep Key 02.25.02.01 + 0xED, 0xA9, 0xB7, 0x0A, 0xDB, 0x85, 0x3D, 0xC0, 0x92, 0x49, 0x7D, 0x41, 0x9A, 0x91, 0x09, 0xEE, + # 11 NTG9X40C_11.14.08.11 / mdm9x40r11_core AC815s / SWI9x50 MR1100 Openlock Key + 0x8A, 0x56, 0x03, 0xF0, 0xBB, 0x9C, 0x13, 0xD2, 0x4E, 0xB2, 0x45, 0xAD, 0xC4, 0x0A, 0xE7, 0x52, + # 12 SWI9x50 MR1100 Openmep Key + 0x2A, 0xEF, 0x07, 0x2B, 0x19, 0x60, 0xC9, 0x01, 0x8B, 0x87, 0xF2, 0x6E, 0xC1, 0x42, 0xA8, 0x3A, + # 13 SWI9x50/SWI9x65 Unknown key + 0x28, 0x55, 0x48, 0x52, 0x24, 0x72, 0x63, 0x37, 0x14, 0x26, 0x37, 0x50, 0xBE, 0xFE, 0x00, 0x00, + # 14 SWI9x50,SWI9X06Y,SWI9x65 IMEI nv key + 0x22, 0x63, 0x48, 0x02, 0x24, 0x72, 0x27, 0x37, 0x19, 0x26, 0x37, 0x50, 0xBE, 0xEF, 0xCA, 0xFE, + # 15 NTG9X35C_02.08.29.00 Openmep Key AC791L/AC790S Old + 0x98, 0xE1, 0xC1, 0x93, 0xC3, 0xBF, 0xC3, 0x50, 0x8D, 0xA1, 0x35, 0xFE, 0x50, 0x47, 0xB3, 0xC4, # 16 NTG9X35C_02.08.29.00 Openmep Key AC791/AC790S, NTGX55_10.25.15.02 MR5100 Alternative, NTG9X40C_30.00.12.00 Alternative - 0xC5, 0x50, 0x40, 0xDA, 0x23, 0xE8, 0xF4, 0x4C, 0x29, 0xE9, 0x07, 0xDE, 0x24, 0xE5, 0x2C, 0x1D, + 0x61, 0x94, 0xCE, 0xA7, 0xB0, 0xEA, 0x4F, 0x0A, 0x73, 0xC5, 0xC3, 0xA6, 0x5E, 0xEC, 0x1C, 0xE2, # 17 NTG9X35C_02.08.29.00 Openlock Key AC791/AC790S Old - 0xF0, 0x14, 0x55, 0x0D, 0x5E, 0xDA, 0x92, 0xB3, 0xA7, 0x6C, 0xCE, 0x84, 0x90, 0xBC, 0x7F, 0xED, + 0xC5, 0x50, 0x40, 0xDA, 0x23, 0xE8, 0xF4, 0x4C, 0x29, 0xE9, 0x07, 0xDE, 0x24, 0xE5, 0x2C, 0x1D, # 18 NTG9X35C_02.08.29.00 Openlock Key AC791/AC790S, NTGX55_10.25.15.02 MR5100 Alternative, NTG9X40C_30.00.12.00 Alternative - 0x78, 0x19, 0xC5, 0x6D, 0xC3, 0xD8, 0x25, 0x3E, 0x51, 0x60, 0x8C, 0xA7, 0x32, 0x83, 0x37, 0x9D, + 0xF0, 0x14, 0x55, 0x0D, 0x5E, 0xDA, 0x92, 0xB3, 0xA7, 0x6C, 0xCE, 0x84, 0x90, 0xBC, 0x7F, 0xED, # 19 SWI9X06Y_02.14.04.00 Openmep Key WP77xx - 0x12, 0xF0, 0x79, 0x6B, 0x19, 0xC7, 0xF4, 0xEC, 0x50, 0xF3, 0x8C, 0x40, 0x02, 0xC9, 0x43, 0xC8, + 0x78, 0x19, 0xC5, 0x6D, 0xC3, 0xD8, 0x25, 0x3E, 0x51, 0x60, 0x8C, 0xA7, 0x32, 0x83, 0x37, 0x9D, # 20 SWI9X06Y_02.14.04.00 Openlock Key WP77xx - 0x49, 0x42, 0xFF, 0x76, 0x8A, 0x95, 0xCF, 0x7B, 0xA3, 0x47, 0x5F, 0xF5, 0x8F, 0xD8, 0x45, 0xE4, + 0x12, 0xF0, 0x79, 0x6B, 0x19, 0xC7, 0xF4, 0xEC, 0x50, 0xF3, 0x8C, 0x40, 0x02, 0xC9, 0x43, 0xC8, # 21 NTGX55 Openmep Key, NTGX55_10.25.15.02 MR5100, NTG9X40C_30.00.12.00 - 0xF8, 0x1A, 0x3A, 0xCC, 0xAA, 0x2B, 0xA5, 0xE8, 0x8B, 0x53, 0x5A, 0x55, 0xB9, 0x65, 0x57, 0x98, + 0x49, 0x42, 0xFF, 0x76, 0x8A, 0x95, 0xCF, 0x7B, 0xA3, 0x47, 0x5F, 0xF5, 0x8F, 0xD8, 0x45, 0xE4, # 22 NTGX55 Openlock Key, NTGX55_10.25.15.02 MR5100, NTG9X40C_30.00.12.00 - 0x54, 0xC9, 0xC7, 0xA4, 0x02, 0x1C, 0xB0, 0x11, 0x05, 0x22, 0x39, 0xB7, 0x84, 0xEF, 0x16, 0xCA, + 0xF8, 0x1A, 0x3A, 0xCC, 0xAA, 0x2B, 0xA5, 0xE8, 0x8B, 0x53, 0x5A, 0x55, 0xB9, 0x65, 0x57, 0x98, # 23 NTG9X15A Openlock Key, NTG9X15A_01.08.02.00 - 0xC7, 0xE6, 0x39, 0xFE, 0x0A, 0xC7, 0xCA, 0x4D, 0x49, 0x8F, 0xD8, 0x55, 0xEB, 0x1A, 0xCD, 0x8A + 0x54, 0xC9, 0xC7, 0xA4, 0x02, 0x1C, 0xB0, 0x11, 0x05, 0x22, 0x39, 0xB7, 0x84, 0xEF, 0x16, 0xCA, # 24 NTG9X15A Openlock Key, NTG9X15A_01.08.02.00 + 0xC7, 0xE6, 0x39, 0xFE, 0x0A, 0xC7, 0xCA, 0x4D, 0x49, 0x8F, 0xD8, 0x55, 0xEB, 0x1A, 0xCD, 0x8A, + # 25 NTGX65 Openlock Key, NTGX65_10.04.13.03 + 0xF2, 0x4A, 0x9A, 0x2C, 0xDA, 0x3D, 0xA5, 0xE2, 0x6B, 0x56, 0x9A, 0x45, 0x29, 0x25, 0x77, 0x9A, + # 26 NTGX65 Openadm Key, NTGX65_10.04.13.03 + 0x46, 0x30, 0x33, 0x43, 0x44, 0x36, 0x42, 0x34, 0x41, 0x32, 0x31, 0x32, 0x30, 0x35, 0x39, 0x37 ]) - class SierraGenerator(): tbl = bytearray() rtbl = bytearray() @@ -163,7 +233,7 @@ class SierraGenerator(): lockid = prodtable[devicegeneration]["openlock"] clen = prodtable[devicegeneration]["clen"] if len(challenge) < clen: - challenge=[0 for _ in range(0, clen - len(challenge))] + challenge = [0 for _ in range(0, clen - len(challenge))] challengelen = len(challenge) if _type == 0: # lockkey @@ -179,7 +249,7 @@ class SierraGenerator(): return resp def selftest(self): - test_table=[ + test_table = [ {"challenge": "8101A18AB3C3E66A", "devicegeneration": "MDM9x15", "response": "D1E128FCA8A963ED"}, {"challenge": "BE96CBBEE0829BCA", "devicegeneration": "MDM9x40", "response": "1033773720F6EE66"}, {"challenge": "BE96CBBEE0829BCA", "devicegeneration": "MDM9x30", "response": "1E02CE6A98B7DD2A"}, @@ -193,7 +263,8 @@ class SierraGenerator(): {"challenge": "BE96CBBEE0829BCA", "devicegeneration": "MDM9x30_V1", "response": "6A5E4C9CBCBDA7DC"}, {"challenge": "BE96CBBEE0829BCA", "devicegeneration": "MDM9200", "response": "EEDBF8BFF8DAE346"}, {"challenge": "20E253156762DACE", "devicegeneration": "SDX55", "response": "03940D7067145323"}, - {"challenge": "2387885E7D290FEE", "devicegeneration": "MDM9x15A", "response": "DC3E51897BAA9C1E"} + {"challenge": "2387885E7D290FEE", "devicegeneration": "MDM9x15A", "response": "DC3E51897BAA9C1E"}, + {"challenge": "4B1FEF9FD43C6DAA", "devicegeneration": "SDX65", "response":"1253C1B1E447B697"} ] for test in test_table: challenge = test["challenge"] @@ -202,9 +273,9 @@ class SierraGenerator(): openlock = self.run(devicegeneration, challenge, 0) padding = " " * (16 - len(devicegeneration)) if openlock != response: - print(devicegeneration+padding+" FAILED!") + print(devicegeneration + padding + " FAILED!") else: - print(devicegeneration+padding+" PASSED :)") + print(devicegeneration + padding + " PASSED :)") def SierraPreInit(self, counter, key, keylen, challengelen, mcount): if counter != 0: @@ -232,7 +303,7 @@ class SierraGenerator(): if keylen == 0 or keylen > 0x20: retval = [0, keylen] elif 1 <= keylen <= 0x20: - self.tbl = [(i&0xFF) for i in range(0, 0x100)] + self.tbl = [(i & 0xFF) for i in range(0, 0x100)] mcount = 0 cl = keylen & 0xffffff00 i = 0xFF @@ -306,13 +377,13 @@ class SierraGenerator(): self.rtbl[4] = 0 return 1 - def SierraKeygen(self, challenge:bytearray, key: bytearray, challengelen:int, keylen:int): + def SierraKeygen(self, challenge: bytearray, key: bytearray, challengelen: int, keylen: int): challenge = challenge - resultbuffer=bytearray([0 for _ in range(0, 0x100 + 1)]) + resultbuffer = bytearray([0 for _ in range(0, 0x100 + 1)]) ret, keylen = self.SierraInit(key, keylen) if ret: for i in range(0, challengelen): - exec(prodtable[self.devicegeneration]["run"]) # uses challenge + exec(prodtable[self.devicegeneration]["run"]) # uses challenge self.SierraFinish() return resultbuffer @@ -384,14 +455,15 @@ class connection: self.serial.close() self.connected = False + class SierraKeygen(metaclass=LogBase): - def __init__(self,cn,devicegeneration=None): - self.cn=cn + def __init__(self, cn, devicegeneration=None): + self.cn = cn self.keygen = SierraGenerator() - if devicegeneration==None: + if devicegeneration == None: self.detectdevicegeneration() else: - self.devicegeneration=devicegeneration + self.devicegeneration = devicegeneration def run_selftest(self): print("Running self-test ...") @@ -410,23 +482,23 @@ class SierraKeygen(metaclass=LogBase): _model = line.split(":")[1].strip() if revision != "": if "9200" in revision: - devicegeneration = "MDM9200" #AC762S NTG9200H2_03.05.14.12ap + devicegeneration = "MDM9200" # AC762S NTG9200H2_03.05.14.12ap if "9X07" in revision: devicegeneration = "MDM9x07" elif "9X25" in revision: if "NTG9X25C" in revision: - devicegeneration = "MDM9200" #AC781S NTG9X25C_01.00.57.00 + devicegeneration = "MDM9200" # AC781S NTG9X25C_01.00.57.00 elif "9X15" in revision: if "NTG9X15A" in revision: - devicegeneration = "MDM9x15A" #Aircard 779S + devicegeneration = "MDM9x15A" # Aircard 779S elif "NTG9X15C" in revision: - devicegeneration = "MDM9200" #AC770S NTG9X15C_01.18.02.00 + devicegeneration = "MDM9200" # AC770S NTG9X15C_01.18.02.00 elif "9X15A" in revision: devicegeneration = "MDM9x15A" else: devicegeneration = "MDM9x15" elif "9X30" in revision: - if "NTG9X35C" in revision: #790S NTG9X35C_11.11.15.03 + if "NTG9X35C" in revision: # 790S NTG9X35C_11.11.15.03 devicegeneration = "MDM9x30_V1" else: devicegeneration = "MDM9x30" @@ -434,26 +506,35 @@ class SierraKeygen(metaclass=LogBase): devicegeneration = "MDM9x40" elif "9X50" in revision: if "NTG9X50" in revision: - devicegeneration = "MDM9x40" #MR1100,AC797S NTG9X50C_12.06.03.00 + devicegeneration = "MDM9x40" # MR1100,AC797S NTG9X50C_12.06.03.00 else: devicegeneration = "MDM9x50" elif "9X06" in revision: devicegeneration = "MDM9x06" elif "X55" in revision or "9X40C" in revision: - if "NTGX55" in revision: #MR5100 NTGX55_10.25.15.02, MR5200 NTGX55_12.04.12.00 - devicegeneration = "SDX55" - elif "NTGX65" in revision: #MR6400 NTGX65_10.01.41.02 + if "NTGX55" in revision: # MR5100 NTGX55_10.25.15.02, MR5200 NTGX55_12.04.12.00 devicegeneration = "SDX55" devicegeneration = "SDX55" + elif "X65" in revision: + if "NTGX65" in revision: + version = revision[revision.find("_") + 1:revision.find(" ")].split(".") + maj = int(version[0]) * 1000000 + int(version[1]) * 10000 + int(version[2]) * 100 + int( + version[3]) + if maj < 10041303: + devicegeneration = "SDX55" + else: # MR6400 NTGX65_10.04.13.03 + devicegeneration = "SDX65" + # MR6550 NTGX65_12.01.31.00 + devicegeneration = "SDX65" else: devicegeneration = "" - #Missing: + # Missing: # SDX24 Sierra # MR2100 NTGX24_10.17.03.00 # SDX55 Sierra # AC810S NTG9X40C_11.14.08.16 # AC800S NTG9X40C_11.14.07.00 - self.devicegeneration=devicegeneration + self.devicegeneration = devicegeneration else: print("Error on getting ATI modem response. Wrong port? Aborting.") self.cn.close() @@ -461,9 +542,9 @@ class SierraKeygen(metaclass=LogBase): def openlock(self): print("Device generation detected: " + self.devicegeneration) - #print("Sending AT!ENTERCND=\"A710\" request.") - #info = self.cn.send("AT!ENTERCND=\"A710\"") - #if info == -1: + # print("Sending AT!ENTERCND=\"A710\" request.") + # info = self.cn.send("AT!ENTERCND=\"A710\"") + # if info == -1: # print("Uhoh ... invalid entercnd password. Aborting ...") # return print("Sending AT!OPENLOCK? request") @@ -472,7 +553,7 @@ class SierraKeygen(metaclass=LogBase): if info != -1: if len(info) > 2: challenge = info[1] - print("Received challenge: "+info[1]) + print("Received challenge: " + info[1]) else: print("Error on AT!OPENLOCK? request. Aborting.") return False @@ -489,10 +570,11 @@ class SierraKeygen(metaclass=LogBase): return True return False + def main(args): version = "1.5" info = 'Sierra Wireless Generator ' + version + ' (c) B. Kerler 2019-2021' - parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,description=info) + parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=info) parser.add_argument( '-openlock', '-l', @@ -546,10 +628,10 @@ def main(args): print(info) print("------------------------------------------------------------\n") print("Usage: ./sierrakeygen.py [-l,-m,-c] [challenge] -d [devicegeneration]") - print("Example: ./sierrakeygen.py.py -l BE96CBBEE0829BCA -d MDM9200") - print("or: ./sierrakeygen.py.py -u for auto unlock") - print("or: ./sierrakeygen.py.py -u -p [portname] for auto unlock with given portname") - print("or: ./sierrakeygen.py.py -s for self-test") + print("Example: ./sierrakeygen.py -l BE96CBBEE0829BCA -d MDM9200") + print("or: ./sierrakeygen.py -u for auto unlock") + print("or: ./sierrakeygen.py -u -p [portname] for auto unlock with given portname") + print("or: ./sierrakeygen.py -s for self-test") print("Supported devicegenerations :") for key in infotable: info = f"\t{key}:\t\t" @@ -569,14 +651,14 @@ def main(args): print("You need to specific a device generation as well. Option -d") exit(0) if devicegeneration == "": - devicegeneration=None + devicegeneration = None if args.selftest: - kg=SierraKeygen(None,"selftest") + kg = SierraKeygen(None, "selftest") kg.run_selftest() elif args.unlock: cn = connection(args.port, args.ip) if cn.connected: - kg=SierraKeygen(cn,devicegeneration) + kg = SierraKeygen(cn, devicegeneration) if kg.devicegeneration == "": print("Unknown device generation. Please send me details :)") else: diff --git a/edlclient/Tools/txt_to_loader.py b/edlclient/Tools/txt_to_loader.py new file mode 100755 index 0000000..e469cd9 --- /dev/null +++ b/edlclient/Tools/txt_to_loader.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) B.Kerler 2019-2023 under GPLv3 license +# If you use my code, make sure you refer to my name +# +# !!!!! If you use this code in commercial products, your product is automatically +# GPLv3 and has to be open sourced under GPLv3 as well. !!!!! +# TXT to EDL Loader (c) B.Kerler 2023 + +import os,sys +from struct import unpack + +def main(): + if len(sys.argv)<2: + print("Usage: ./txt_to_loader.py [log.txt] [loader.elf]") + sys.exit(0) + with open(sys.argv[1],"rb") as rf: + data=bytearray() + for line in rf.readlines(): + if line[0]==0x20: + tt=line.split(b" ")[:-1] + tt=tt[1:17] + xx=b"".join(tt) + data.extend(bytes.fromhex(xx.decode('utf-8'))) + + outdata=bytearray() + i=0 + seq=b"\x03\x00\x00\x00\x14\x00\x00\x00\x0D\x00\x00\x00" + with open(sys.argv[2], "wb") as wf: + while True: + idx=data.find(seq) + if idx==-1: + if i==0: + seq=b"\x12\x00\x00\x00\x20\x00\x00\x00\x0D\x00\x00\x00\x00\x00\x00\x00" + i+=1 + continue + else: + break + else: + cmd=unpack("