first commit
661
LICENSE
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server 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,
|
||||
our General Public Licenses are 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.
|
||||
|
||||
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.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
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 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 work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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 Affero 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 Affero 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 Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
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 AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
63
README.md
Normal file
@ -0,0 +1,63 @@
|
||||
# MihoyoBBS-gt-server
|
||||
适用于米游社签到的打码服务
|
||||
|
||||
**本项目仅供学习交流使用,请勿用于商业用途,否则后果自负。**
|
||||
|
||||
**本项目仅供学习交流使用,请勿用于商业用途,否则后果自负。**
|
||||
|
||||
**本项目仅供学习交流使用,请勿用于商业用途,否则后果自负。**
|
||||
|
||||
# 使用方法
|
||||
|
||||
## 服务端
|
||||
|
||||
安装相关依赖
|
||||
|
||||
```commandline
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
运行
|
||||
|
||||
```commandline
|
||||
python3 main.py
|
||||
```
|
||||
|
||||
## 调用接口
|
||||
|
||||
``` python
|
||||
import httpx
|
||||
|
||||
def geetest(gt, challenge):
|
||||
data = httpx.post(
|
||||
"https://example.com",
|
||||
json={"gt": gt, "challenge": challenge},
|
||||
timeout=30,
|
||||
).json()
|
||||
if data["status"] == "success":
|
||||
return data["validate"]
|
||||
return None
|
||||
```
|
||||
|
||||
九宫格、图标点选成功率均接近100%(1000次测试全部成功)
|
||||
|
||||
# 实现思路
|
||||
|
||||
## 九宫格
|
||||
* 采用均方误差(MSE)法对小图标进行分类
|
||||
* 使用resnet18对图片进行分类
|
||||
|
||||
## 图标点选
|
||||
* 使用ddddocr进行目标检测
|
||||
* 使用孪生神经网络计算相似度
|
||||
|
||||
# 协议
|
||||
本项目遵循 AGPL-3.0 协议开源,请遵守相关协议。
|
||||
|
||||
# 鸣谢
|
||||
[ravizhan/geetest-v3-click-crack](https://github.com/ravizhan/geetest-v3-click-crack) 提供极验接口逆向
|
||||
|
||||
[taisuii/ClassificationCaptchaOcr](https://github.com/ultralytics/ultralytics/) 提供九宫格识别思路及模型
|
||||
|
||||
[Siamese-pytorch](https://github.com/bubbliiiing/Siamese-pytorch) 提供孪生网络模型
|
||||
|
||||
[sml2h3/ddddocr](https://github.com/sml2h3/ddddocr) 提供目标检测SDK
|
533
crack.py
Normal file
@ -0,0 +1,533 @@
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import random
|
||||
import time
|
||||
|
||||
import httpx
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from cryptography.hazmat.primitives import padding, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15
|
||||
|
||||
|
||||
class Crack:
|
||||
def __init__(self, gt=None, challenge=None):
|
||||
self.pic_path = None
|
||||
self.s = None
|
||||
self.c = None
|
||||
self.session = httpx.Client(http2=True)
|
||||
self.session.headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
||||
}
|
||||
# self.session.verify = False
|
||||
self.gt = gt
|
||||
self.challenge = challenge
|
||||
self.aeskey = "".join(
|
||||
f"{int((1 + random.random()) * 65536):04x}"[1:] for _ in range(4)
|
||||
)
|
||||
public_key = """-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDB45NNFhRGWzMFPn9I7k7IexS5
|
||||
XviJR3E9Je7L/350x5d9AtwdlFH3ndXRwQwprLaptNb7fQoCebZxnhdyVl8Jr2J3
|
||||
FZGSIa75GJnK4IwNaG10iyCjYDviMYymvCtZcGWSqSGdC/Bcn2UCOiHSMwgHJSrg
|
||||
Bm1Zzu+l8nSOqAurgQIDAQAB
|
||||
-----END PUBLIC KEY-----"""
|
||||
self.public_key = serialization.load_pem_public_key(public_key.encode())
|
||||
self.enc_key = self.public_key.encrypt(self.aeskey.encode(), PKCS1v15()).hex()
|
||||
with open("mousepath.json", "r") as f:
|
||||
self.mouse_path = json.loads(f.read())
|
||||
|
||||
def get_type(self) -> dict:
|
||||
url = f"https://api.geetest.com/gettype.php?gt={self.gt}"
|
||||
res = self.session.get(url)
|
||||
return json.loads(res.text[1:-1])["data"]
|
||||
|
||||
@staticmethod
|
||||
def encode(input_bytes: list):
|
||||
def get_char_from_index(index):
|
||||
char_table = (
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()"
|
||||
)
|
||||
return char_table[index] if 0 <= index < len(char_table) else "."
|
||||
|
||||
def transform_value(value, bit_mask):
|
||||
result = 0
|
||||
for r in range(23, -1, -1):
|
||||
if (bit_mask >> r) & 1:
|
||||
result = (result << 1) + ((value >> r) & 1)
|
||||
return result
|
||||
|
||||
encoded_string = ""
|
||||
padding = ""
|
||||
input_length = len(input_bytes)
|
||||
for i in range(0, input_length, 3):
|
||||
chunk_length = min(3, input_length - i)
|
||||
chunk = input_bytes[i : i + chunk_length]
|
||||
if chunk_length == 3:
|
||||
value = (chunk[0] << 16) + (chunk[1] << 8) + chunk[2]
|
||||
encoded_string += (
|
||||
get_char_from_index(transform_value(value, 7274496))
|
||||
+ get_char_from_index(transform_value(value, 9483264))
|
||||
+ get_char_from_index(transform_value(value, 19220))
|
||||
+ get_char_from_index(transform_value(value, 235))
|
||||
)
|
||||
elif chunk_length == 2:
|
||||
value = (chunk[0] << 16) + (chunk[1] << 8)
|
||||
encoded_string += (
|
||||
get_char_from_index(transform_value(value, 7274496))
|
||||
+ get_char_from_index(transform_value(value, 9483264))
|
||||
+ get_char_from_index(transform_value(value, 19220))
|
||||
)
|
||||
padding = "."
|
||||
elif chunk_length == 1:
|
||||
value = chunk[0] << 16
|
||||
encoded_string += get_char_from_index(
|
||||
transform_value(value, 7274496)
|
||||
) + get_char_from_index(transform_value(value, 9483264))
|
||||
padding = ".."
|
||||
return encoded_string + padding
|
||||
|
||||
@staticmethod
|
||||
def MD5(text: str):
|
||||
return hashlib.md5(text.encode()).hexdigest()
|
||||
|
||||
@staticmethod
|
||||
def encode_mouse_path(path: list, c: list, s: str):
|
||||
def preprocess(path: list):
|
||||
def BFIQ(e):
|
||||
t = 32767
|
||||
if not isinstance(e, int):
|
||||
return e
|
||||
else:
|
||||
if t < e:
|
||||
e = t
|
||||
elif e < -t:
|
||||
e = -t
|
||||
return round(e)
|
||||
|
||||
def BGAB(e):
|
||||
t = ""
|
||||
n = 0
|
||||
len(e or [])
|
||||
while n < len(e) and not t:
|
||||
if e[n]:
|
||||
t = e[n][4]
|
||||
n += 1
|
||||
if not t:
|
||||
return e
|
||||
r = ""
|
||||
i = ["mouse", "touch", "pointer", "MSPointer"]
|
||||
for s in range(len(i)):
|
||||
if t.startswith(i[s]):
|
||||
r = i[s]
|
||||
_ = list(e)
|
||||
for a in range(len(_) - 1, -1, -1):
|
||||
c = _[a]
|
||||
l = c[0]
|
||||
if l in ["move", "down", "up"]:
|
||||
value = c[4] or ""
|
||||
if not value.startswith(r):
|
||||
_.pop(a)
|
||||
return _
|
||||
|
||||
t = 0
|
||||
n = 0
|
||||
r = []
|
||||
s = 0
|
||||
if len(path) <= 0:
|
||||
return []
|
||||
o = None
|
||||
_ = None
|
||||
a = BGAB(path)
|
||||
c = len(a)
|
||||
for l in range(0 if c < 300 else c - 300, c):
|
||||
u = a[l]
|
||||
h = u[0]
|
||||
if h in ["down", "move", "up", "scroll"]:
|
||||
if not o:
|
||||
o = u
|
||||
_ = u
|
||||
r.append([h, [u[1] - t, u[2] - n], BFIQ(u[3] - s if s else s)])
|
||||
t = u[1]
|
||||
n = u[2]
|
||||
s = u[3]
|
||||
elif h in ["blur", "focus", "unload"]:
|
||||
r.append([h, BFIQ(u[1] - s if s else s)])
|
||||
s = u[1]
|
||||
return r
|
||||
|
||||
def process(prepared_path: list):
|
||||
h = {
|
||||
"move": 0,
|
||||
"down": 1,
|
||||
"up": 2,
|
||||
"scroll": 3,
|
||||
"focus": 4,
|
||||
"blur": 5,
|
||||
"unload": 6,
|
||||
"unknown": 7,
|
||||
}
|
||||
|
||||
def p(e, t):
|
||||
n = bin(e)[2:]
|
||||
r = ""
|
||||
i = len(n) + 1
|
||||
while i <= t:
|
||||
i += 1
|
||||
r += "0"
|
||||
return r + n
|
||||
|
||||
def d(e):
|
||||
t = []
|
||||
n = len(e)
|
||||
r = 0
|
||||
while r < n:
|
||||
i = e[r]
|
||||
s = 0
|
||||
while True:
|
||||
if s >= 16:
|
||||
break
|
||||
o = r + s + 1
|
||||
if o >= n:
|
||||
break
|
||||
if e[o] != i:
|
||||
break
|
||||
s += 1
|
||||
r += 1 + s
|
||||
_ = h[i]
|
||||
if s != 0:
|
||||
t.append(_ | 8)
|
||||
t.append(s - 1)
|
||||
else:
|
||||
t.append(_)
|
||||
a = p(n | 32768, 16)
|
||||
c = ""
|
||||
for l in range(len(t)):
|
||||
c += p(t[l], 4)
|
||||
return a + c
|
||||
|
||||
def g(e, tt):
|
||||
def temp1(e1):
|
||||
n = len(e)
|
||||
r = 0
|
||||
i = []
|
||||
while r < n:
|
||||
s = 1
|
||||
o = e[r]
|
||||
_ = abs(o)
|
||||
while True:
|
||||
if n <= r + s:
|
||||
break
|
||||
if e[r + s] != o:
|
||||
break
|
||||
if (_ >= 127) or (s >= 127):
|
||||
break
|
||||
s += 1
|
||||
if s > 1:
|
||||
i.append((49152 if o < 0 else 32768) | s << 7 | _)
|
||||
else:
|
||||
i.append(o)
|
||||
r += s
|
||||
return i
|
||||
|
||||
e = temp1(e)
|
||||
|
||||
r = []
|
||||
i = []
|
||||
|
||||
def n(e, t):
|
||||
return 0 if e == 0 else math.log(e) / math.log(t)
|
||||
|
||||
for temp in e:
|
||||
t = math.ceil(n(abs(temp) + 1, 16))
|
||||
if t == 0:
|
||||
t = 1
|
||||
r.append(p(t - 1, 2))
|
||||
i.append(p(abs(temp), t * 4))
|
||||
|
||||
s = "".join(r)
|
||||
o = "".join(i)
|
||||
|
||||
def temp2(t):
|
||||
return t != 0 and t >> 15 != 1
|
||||
|
||||
def temp3(e1):
|
||||
n = []
|
||||
|
||||
def temp(e2):
|
||||
if temp2(e2):
|
||||
n.append(e2)
|
||||
|
||||
for r in range(len(e1)):
|
||||
temp(e1[r])
|
||||
return n
|
||||
|
||||
def temp4(t):
|
||||
if t < 0:
|
||||
return "1"
|
||||
else:
|
||||
return "0"
|
||||
|
||||
if tt:
|
||||
n = []
|
||||
e1 = temp3(e)
|
||||
for r in range(len(e1)):
|
||||
n.append(temp4(e1[r]))
|
||||
n = "".join(n)
|
||||
else:
|
||||
n = ""
|
||||
return p(len(e) | 32768, 16) + s + o + n
|
||||
|
||||
def u(e):
|
||||
t = ""
|
||||
n = len(e) // 6
|
||||
for r in range(n):
|
||||
t += "()*,-./0123456789:?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"[
|
||||
int(e[6 * r : 6 * (r + 1)], 2)
|
||||
]
|
||||
return t
|
||||
|
||||
t = []
|
||||
n = []
|
||||
r = []
|
||||
i = []
|
||||
for a in range(len(prepared_path)):
|
||||
_ = prepared_path[a]
|
||||
a = len(_)
|
||||
t.append(_[0])
|
||||
n.append(_[1] if a == 2 else _[2])
|
||||
if a == 3:
|
||||
r.append(_[1][0])
|
||||
i.append(_[1][1])
|
||||
c = d(t) + g(n, False) + g(r, True) + g(i, True)
|
||||
l = len(c)
|
||||
if l % 6 != 0:
|
||||
c += p(0, 6 - l % 6)
|
||||
return u(c)
|
||||
|
||||
def postprocess(e, t, n):
|
||||
i = 0
|
||||
s = e
|
||||
o = t[0]
|
||||
_ = t[2]
|
||||
a = t[4]
|
||||
while True:
|
||||
r = n[i : i + 2]
|
||||
if not r:
|
||||
break
|
||||
i += 2
|
||||
c = int(r, 16)
|
||||
l = chr(c)
|
||||
u = (o * c * c + _ * c + a) % len(e)
|
||||
s = s[:u] + l + s[u:]
|
||||
return s
|
||||
|
||||
return postprocess(process(preprocess(path)), c, s)
|
||||
|
||||
def aes_encrypt(self, content: str):
|
||||
cipher = Cipher(
|
||||
algorithms.AES(self.aeskey.encode()), modes.CBC(b"0000000000000000")
|
||||
)
|
||||
encryptor = cipher.encryptor()
|
||||
padder = padding.PKCS7(128).padder()
|
||||
padded_data = padder.update(content.encode())
|
||||
padded_data += padder.finalize()
|
||||
ct = encryptor.update(padded_data) + encryptor.finalize()
|
||||
return ct
|
||||
|
||||
def get_c_s(self):
|
||||
o = {
|
||||
"gt": self.gt,
|
||||
"challenge": self.challenge,
|
||||
"offline": False,
|
||||
"new_captcha": True,
|
||||
"product": "embed",
|
||||
"width": "300px",
|
||||
"https": True,
|
||||
"protocol": "https://",
|
||||
}
|
||||
o.update(self.get_type())
|
||||
o.update(
|
||||
{
|
||||
"cc": 16,
|
||||
"ww": True,
|
||||
"i": "-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1",
|
||||
}
|
||||
)
|
||||
o = json.dumps(o, separators=(",", ":"))
|
||||
# print(o)
|
||||
ct = self.aes_encrypt(o)
|
||||
s = []
|
||||
for byte in ct:
|
||||
s.append(byte)
|
||||
i = self.encode(s)
|
||||
r = self.enc_key
|
||||
w = i + r
|
||||
params = {
|
||||
"gt": self.gt,
|
||||
"challenge": self.challenge,
|
||||
"lang": "zh-cn",
|
||||
"pt": 0,
|
||||
"client_type": "web",
|
||||
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
||||
"w": w,
|
||||
}
|
||||
resp = self.session.get("https://api.geetest.com/get.php", params=params).text
|
||||
# print(resp)
|
||||
data = json.loads(resp[22:-1])["data"]
|
||||
self.c = data["c"]
|
||||
self.s = data["s"]
|
||||
return data["c"], data["s"]
|
||||
|
||||
def gettype(self):
|
||||
url = f"https://api.geetest.com/gettype.php?gt={self.gt}&callback=geetest_{str(int(round(time.time() * 1000)))}"
|
||||
return self.session.get(url).text
|
||||
|
||||
def ajax(self):
|
||||
def transform(e, t, n):
|
||||
if not t or not n:
|
||||
return e
|
||||
o = 0
|
||||
i = list(e)
|
||||
s = t[0]
|
||||
a = t[2]
|
||||
b = t[4]
|
||||
while o < len(n):
|
||||
r = n[o : o + 2]
|
||||
o += 2
|
||||
c = int(r, 16)
|
||||
l = chr(c)
|
||||
u = (s * c * c + a * c + b) % len(i)
|
||||
i.insert(u, l)
|
||||
return "".join(i)
|
||||
|
||||
mouse_path = [
|
||||
["move", 385, 313, 1724572150164, "pointermove"],
|
||||
["move", 385, 315, 1724572150166, "pointermove"],
|
||||
["move", 386, 315, 1724572150174, "pointermove"],
|
||||
["move", 387, 315, 1724572150182, "pointermove"],
|
||||
["move", 387, 316, 1724572150188, "pointermove"],
|
||||
["move", 388, 316, 1724572150204, "pointermove"],
|
||||
["move", 388, 317, 1724572150218, "pointermove"],
|
||||
["down", 388, 317, 1724572150586, "pointerdown"],
|
||||
["focus", 1724572150587],
|
||||
["up", 388, 317, 1724572150632, "pointerup"],
|
||||
]
|
||||
tt = transform(
|
||||
self.encode_mouse_path(mouse_path, self.c, self.s), self.c, self.s
|
||||
)
|
||||
rp = self.MD5(self.gt + self.challenge + self.s)
|
||||
temp1 = (
|
||||
""""lang":"zh-cn","type":"fullpage","tt":"%s","light":"DIV_0","s":"c7c3e21112fe4f741921cb3e4ff9f7cb","h":"321f9af1e098233dbd03f250fd2b5e21","hh":"39bd9cad9e425c3a8f51610fd506e3b3","hi":"09eb21b3ae9542a9bc1e8b63b3d9a467","vip_order":-1,"ct":-1,"ep":{"v":"9.1.9-dbjg5z","te":false,"me":true,"ven":"Google Inc. (Intel)","ren":"ANGLE (Intel, Intel(R) Iris(R) Xe Graphics (0x0000A7A0) Direct3D11 vs_5_0 ps_5_0, D3D11)","fp":["scroll",0,1602,1724571628498,null],"lp":["up",386,217,1724571629854,"pointerup"],"em":{"ph":0,"cp":0,"ek":"11","wd":1,"nt":0,"si":0,"sc":0},"tm":{"a":1724571567311,"b":1724571567549,"c":1724571567562,"d":0,"e":0,"f":1724571567312,"g":1724571567312,"h":1724571567312,"i":1724571567317,"j":1724571567423,"k":1724571567330,"l":1724571567423,"m":1724571567545,"n":1724571567547,"o":1724571567569,"p":1724571568259,"q":1724571568259,"r":1724571568261,"s":1724571570378,"t":1724571570378,"u":1724571570380},"dnf":"dnf","by":0},"passtime":1600,"rp":"%s","""
|
||||
% (tt, rp)
|
||||
)
|
||||
r = "{" + temp1 + '"captcha_token":"1198034057","du6o":"eyjf7nne"}'
|
||||
# print(r)
|
||||
ct = self.aes_encrypt(r)
|
||||
s = [byte for byte in ct]
|
||||
w = self.encode(s)
|
||||
params = {
|
||||
"gt": self.gt,
|
||||
"challenge": self.challenge,
|
||||
"lang": "zh-cn",
|
||||
"pt": 0,
|
||||
"client_type": "web",
|
||||
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
||||
"w": w,
|
||||
}
|
||||
resp = self.session.get("https://api.geetest.com/ajax.php", params=params).text
|
||||
return json.loads(resp[22:-1])["data"]
|
||||
|
||||
def get_pic(self, retry):
|
||||
params = {
|
||||
"type": "click",
|
||||
"gt": self.gt,
|
||||
"challenge": self.challenge,
|
||||
"lang": "zh-cn",
|
||||
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
||||
}
|
||||
if retry == 0:
|
||||
url = "https://api.geevisit.com/get.php"
|
||||
params.update(
|
||||
{
|
||||
"is_next": "true",
|
||||
"https": "true",
|
||||
"protocol": "https://",
|
||||
"offline": "false",
|
||||
"product": "float",
|
||||
"api_server": "api.geevisit.com",
|
||||
"isPC": True,
|
||||
"autoReset": True,
|
||||
"width": "100%",
|
||||
}
|
||||
)
|
||||
else:
|
||||
url = "https://api.geetest.com/refresh.php"
|
||||
resp = self.session.get(url, params=params).text
|
||||
data = json.loads(resp[22:-1])["data"]
|
||||
self.pic_path = data["pic"]
|
||||
pic_url = "https://" + data["image_servers"][0][:-1] + data["pic"]
|
||||
return data["pic_type"], self.session.get(pic_url).content
|
||||
|
||||
def verify(self, points: list):
|
||||
u = self.enc_key
|
||||
o = {
|
||||
"lang": "zh-cn",
|
||||
"passtime": 1600,
|
||||
"a": ",".join(points),
|
||||
"pic": self.pic_path,
|
||||
"tt": self.encode_mouse_path(self.mouse_path, self.c, self.s),
|
||||
"ep": {
|
||||
"ca": [
|
||||
{"x": 524, "y": 209, "t": 0, "dt": 1819},
|
||||
{"x": 558, "y": 299, "t": 0, "dt": 428},
|
||||
{"x": 563, "y": 95, "t": 0, "dt": 952},
|
||||
{"x": 670, "y": 407, "t": 3, "dt": 892},
|
||||
],
|
||||
"v": "3.1.0",
|
||||
"$_FB": False,
|
||||
"me": True,
|
||||
"tm": {
|
||||
"a": 1724585496403,
|
||||
"b": 1724585496605,
|
||||
"c": 1724585496613,
|
||||
"d": 0,
|
||||
"e": 0,
|
||||
"f": 1724585496404,
|
||||
"g": 1724585496404,
|
||||
"h": 1724585496404,
|
||||
"i": 1724585496404,
|
||||
"j": 1724585496404,
|
||||
"k": 0,
|
||||
"l": 1724585496413,
|
||||
"m": 1724585496601,
|
||||
"n": 1724585496603,
|
||||
"o": 1724585496618,
|
||||
"p": 1724585496749,
|
||||
"q": 1724585496749,
|
||||
"r": 1724585496751,
|
||||
"s": 1724585498068,
|
||||
"t": 1724585498068,
|
||||
"u": 1724585498069,
|
||||
},
|
||||
},
|
||||
"h9s9": "1816378497",
|
||||
}
|
||||
o["rp"] = self.MD5(self.gt + self.challenge + str(o["passtime"]))
|
||||
o = json.dumps(o, separators=(",", ":"))
|
||||
# print(o)
|
||||
ct = self.aes_encrypt(o)
|
||||
s = []
|
||||
for byte in ct:
|
||||
s.append(byte)
|
||||
p = self.encode(s)
|
||||
w = p + u
|
||||
params = {
|
||||
"gt": self.gt,
|
||||
"challenge": self.challenge,
|
||||
"lang": "zh-cn",
|
||||
"pt": 0,
|
||||
"client_type": "web",
|
||||
"w": w,
|
||||
}
|
||||
resp = self.session.get("https://api.geevisit.com/ajax.php", params=params).text
|
||||
return resp[1:-1]
|
82
main.py
Normal file
@ -0,0 +1,82 @@
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from crack import Crack
|
||||
import predict
|
||||
|
||||
from flask import Flask, request, jsonify
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
stats_file = "stats.json"
|
||||
|
||||
if not os.path.exists(stats_file):
|
||||
with open(stats_file, "w") as f:
|
||||
json.dump({"total": 0, "success": 0, "failure": 0, "error": 0}, f)
|
||||
|
||||
|
||||
def read_stats():
|
||||
with open(stats_file, "r") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def update_stats(msg):
|
||||
stats = read_stats()
|
||||
stats[msg] += 1
|
||||
stats["total"] += 1
|
||||
with open(stats_file, "w") as f:
|
||||
json.dump(stats, f)
|
||||
|
||||
|
||||
@app.route("/statistic", methods=["get"])
|
||||
def statistic():
|
||||
stats = read_stats()
|
||||
return f"调用{stats['total']}次,成功{stats['success']}次,失败{stats['failure']}次,错误{stats['error']}次"
|
||||
|
||||
|
||||
@app.route("/", methods=["POST"])
|
||||
def handle_post():
|
||||
data = request.get_json()
|
||||
if "gt" in data and "challenge" in data:
|
||||
crack = Crack(data["gt"], data["challenge"])
|
||||
crack.get_type()
|
||||
crack.get_c_s()
|
||||
crack.ajax()
|
||||
for retry in range(6):
|
||||
a = []
|
||||
type, image = crack.get_pic(retry)
|
||||
t = time.time()
|
||||
if type == "nine":
|
||||
points = predict.nine(image)
|
||||
for x, y in points:
|
||||
a.append(f"{x}_{y}")
|
||||
elif type == "icon":
|
||||
points = predict.icon(image)
|
||||
for x, y in points:
|
||||
left = round(x / 333 * 10000)
|
||||
top = round(y / 333 * 10000)
|
||||
a.append(f"{left}_{top}")
|
||||
else:
|
||||
update_stats("error")
|
||||
return jsonify({"status": "error", "msg": "unsupported type"})
|
||||
wait_time = t + 2 - time.time()
|
||||
if wait_time > 0:
|
||||
time.sleep(wait_time)
|
||||
res = eval(crack.verify(a))
|
||||
if res["data"]["result"] == "success":
|
||||
update_stats("success")
|
||||
return jsonify(
|
||||
{"status": "success", "validate": res["data"]["validate"]}
|
||||
)
|
||||
update_stats("failure")
|
||||
return jsonify({"status": "failed"})
|
||||
else:
|
||||
return (
|
||||
jsonify({"status": "error", "message": "Missing 'gt' or 'challenge'"}),
|
||||
400,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
336
mousepath.json
Normal file
@ -0,0 +1,336 @@
|
||||
[
|
||||
["move", 170, 514, 1721639139496, "pointermove"],
|
||||
["move", 171, 514, 1721639139518, "pointermove"],
|
||||
["move", 172, 514, 1721639139564, "pointermove"],
|
||||
["move", 174, 514, 1721639139578, "pointermove"],
|
||||
["move", 174, 514, 1721639139586, "pointermove"],
|
||||
["move", 175, 514, 1721639139646, "pointermove"],
|
||||
["move", 178, 514, 1721639139651, "pointermove"],
|
||||
["move", 177, 513, 1721639139652, "mousemove"],
|
||||
["move", 179, 514, 1721639139660, "pointermove"],
|
||||
["move", 182, 514, 1721639139676, "pointermove"],
|
||||
["move", 186, 514, 1721639139682, "pointermove"],
|
||||
["move", 190, 514, 1721639139690, "pointermove"],
|
||||
["move", 195, 514, 1721639139697, "pointermove"],
|
||||
["move", 195, 513, 1721639139698, "mousemove"],
|
||||
["move", 202, 514, 1721639139705, "pointermove"],
|
||||
["move", 210, 514, 1721639139712, "pointermove"],
|
||||
["move", 218, 514, 1721639139719, "pointermove"],
|
||||
["move", 230, 513, 1721639139727, "pointermove"],
|
||||
["move", 242, 512, 1721639139735, "pointermove"],
|
||||
["move", 254, 510, 1721639139741, "pointermove"],
|
||||
["move", 263, 507, 1721639139749, "pointermove"],
|
||||
["move", 263, 507, 1721639139750, "mousemove"],
|
||||
["move", 274, 504, 1721639139757, "pointermove"],
|
||||
["move", 283, 503, 1721639139765, "pointermove"],
|
||||
["move", 283, 503, 1721639139766, "mousemove"],
|
||||
["move", 292, 501, 1721639139772, "pointermove"],
|
||||
["move", 302, 500, 1721639139779, "pointermove"],
|
||||
["move", 310, 500, 1721639139787, "pointermove"],
|
||||
["move", 316, 499, 1721639139795, "pointermove"],
|
||||
["move", 316, 499, 1721639139796, "mousemove"],
|
||||
["move", 322, 498, 1721639139801, "pointermove"],
|
||||
["move", 326, 498, 1721639139810, "pointermove"],
|
||||
["move", 328, 497, 1721639139817, "pointermove"],
|
||||
["move", 330, 497, 1721639139825, "pointermove"],
|
||||
["move", 331, 497, 1721639139831, "pointermove"],
|
||||
["move", 332, 497, 1721639139839, "pointermove"],
|
||||
["move", 334, 496, 1721639139856, "pointermove"],
|
||||
["move", 335, 496, 1721639139861, "pointermove"],
|
||||
["move", 336, 496, 1721639139869, "pointermove"],
|
||||
["move", 336, 496, 1721639139870, "mousemove"],
|
||||
["move", 338, 496, 1721639139886, "pointermove"],
|
||||
["move", 339, 496, 1721639139891, "pointermove"],
|
||||
["move", 342, 495, 1721639139900, "pointermove"],
|
||||
["move", 346, 495, 1721639139907, "pointermove"],
|
||||
["move", 350, 494, 1721639139916, "pointermove"],
|
||||
["move", 354, 493, 1721639139921, "pointermove"],
|
||||
["move", 359, 493, 1721639139929, "pointermove"],
|
||||
["move", 359, 493, 1721639139930, "mousemove"],
|
||||
["move", 364, 492, 1721639139937, "pointermove"],
|
||||
["move", 370, 491, 1721639139946, "pointermove"],
|
||||
["move", 375, 490, 1721639139951, "pointermove"],
|
||||
["move", 382, 489, 1721639139959, "pointermove"],
|
||||
["move", 387, 488, 1721639139967, "pointermove"],
|
||||
["move", 394, 487, 1721639139975, "pointermove"],
|
||||
["move", 400, 487, 1721639139981, "pointermove"],
|
||||
["move", 406, 486, 1721639139989, "pointermove"],
|
||||
["move", 411, 485, 1721639139997, "pointermove"],
|
||||
["move", 415, 483, 1721639140006, "pointermove"],
|
||||
["move", 419, 482, 1721639140011, "pointermove"],
|
||||
["move", 422, 481, 1721639140019, "pointermove"],
|
||||
["move", 426, 480, 1721639140028, "pointermove"],
|
||||
["move", 427, 479, 1721639140041, "pointermove"],
|
||||
["move", 430, 478, 1721639140050, "pointermove"],
|
||||
["move", 430, 477, 1721639140057, "pointermove"],
|
||||
["move", 431, 476, 1721639140066, "pointermove"],
|
||||
["move", 431, 475, 1721639140072, "pointermove"],
|
||||
["move", 431, 474, 1721639140088, "pointermove"],
|
||||
["move", 431, 472, 1721639140102, "pointermove"],
|
||||
["move", 431, 471, 1721639140110, "pointermove"],
|
||||
["move", 431, 469, 1721639140118, "pointermove"],
|
||||
["move", 431, 468, 1721639140126, "pointermove"],
|
||||
["move", 431, 466, 1721639140132, "pointermove"],
|
||||
["move", 431, 464, 1721639140148, "pointermove"],
|
||||
["move", 431, 462, 1721639140156, "pointermove"],
|
||||
["move", 431, 460, 1721639140186, "pointermove"],
|
||||
["move", 431, 459, 1721639140261, "pointermove"],
|
||||
["move", 432, 460, 1721639140530, "pointermove"],
|
||||
["move", 432, 462, 1721639140538, "pointermove"],
|
||||
["move", 434, 462, 1721639140546, "pointermove"],
|
||||
["move", 434, 463, 1721639140552, "pointermove"],
|
||||
["move", 432, 464, 1721639140912, "pointermove"],
|
||||
["move", 429, 466, 1721639140920, "pointermove"],
|
||||
["move", 426, 467, 1721639140928, "pointermove"],
|
||||
["move", 422, 470, 1721639140934, "pointermove"],
|
||||
["move", 417, 471, 1721639140942, "pointermove"],
|
||||
["move", 413, 472, 1721639140950, "pointermove"],
|
||||
["move", 408, 474, 1721639140964, "pointermove"],
|
||||
["move", 404, 475, 1721639140972, "pointermove"],
|
||||
["move", 399, 475, 1721639140980, "pointermove"],
|
||||
["move", 395, 476, 1721639140988, "pointermove"],
|
||||
["move", 390, 478, 1721639140994, "pointermove"],
|
||||
["move", 386, 478, 1721639141002, "pointermove"],
|
||||
["move", 381, 479, 1721639141010, "pointermove"],
|
||||
["move", 376, 479, 1721639141018, "pointermove"],
|
||||
["move", 370, 479, 1721639141024, "pointermove"],
|
||||
["move", 364, 479, 1721639141032, "pointermove"],
|
||||
["move", 357, 479, 1721639141040, "pointermove"],
|
||||
["move", 352, 479, 1721639141048, "pointermove"],
|
||||
["move", 347, 479, 1721639141054, "pointermove"],
|
||||
["move", 342, 479, 1721639141062, "pointermove"],
|
||||
["move", 339, 478, 1721639141070, "pointermove"],
|
||||
["move", 336, 478, 1721639141078, "pointermove"],
|
||||
["move", 334, 478, 1721639141084, "pointermove"],
|
||||
["move", 333, 478, 1721639141100, "pointermove"],
|
||||
["move", 332, 479, 1721639141138, "pointermove"],
|
||||
["move", 331, 479, 1721639141152, "pointermove"],
|
||||
["move", 330, 479, 1721639141160, "pointermove"],
|
||||
["move", 329, 480, 1721639141168, "pointermove"],
|
||||
["move", 328, 482, 1721639141182, "pointermove"],
|
||||
["move", 327, 483, 1721639141198, "pointermove"],
|
||||
["move", 326, 483, 1721639141204, "pointermove"],
|
||||
["move", 324, 484, 1721639141212, "pointermove"],
|
||||
["move", 322, 486, 1721639141220, "pointermove"],
|
||||
["move", 319, 487, 1721639141228, "pointermove"],
|
||||
["move", 316, 488, 1721639141234, "pointermove"],
|
||||
["move", 313, 491, 1721639141242, "pointermove"],
|
||||
["move", 310, 494, 1721639141250, "pointermove"],
|
||||
["move", 306, 495, 1721639141258, "pointermove"],
|
||||
["move", 304, 495, 1721639141264, "pointermove"],
|
||||
["move", 301, 498, 1721639141272, "pointermove"],
|
||||
["move", 299, 499, 1721639141280, "pointermove"],
|
||||
["move", 297, 499, 1721639141288, "pointermove"],
|
||||
["move", 295, 499, 1721639141294, "pointermove"],
|
||||
["move", 293, 499, 1721639141302, "pointermove"],
|
||||
["move", 292, 500, 1721639141310, "pointermove"],
|
||||
["move", 291, 500, 1721639141324, "pointermove"],
|
||||
["down", 291, 500, 1721639141543, "pointerdown"],
|
||||
["up", 291, 500, 1721639141580, "pointerup"],
|
||||
["move", 294, 500, 1721639141654, "pointermove"],
|
||||
["move", 299, 500, 1721639141662, "pointermove"],
|
||||
["move", 306, 500, 1721639141670, "pointermove"],
|
||||
["move", 314, 499, 1721639141678, "pointermove"],
|
||||
["move", 323, 498, 1721639141684, "pointermove"],
|
||||
["move", 334, 497, 1721639141692, "pointermove"],
|
||||
["move", 344, 495, 1721639141708, "pointermove"],
|
||||
["move", 356, 493, 1721639141714, "pointermove"],
|
||||
["move", 367, 491, 1721639141722, "pointermove"],
|
||||
["move", 378, 489, 1721639141730, "pointermove"],
|
||||
["move", 387, 487, 1721639141738, "pointermove"],
|
||||
["move", 395, 485, 1721639141744, "pointermove"],
|
||||
["move", 402, 483, 1721639141752, "pointermove"],
|
||||
["move", 407, 482, 1721639141760, "pointermove"],
|
||||
["move", 410, 481, 1721639141768, "pointermove"],
|
||||
["move", 412, 480, 1721639141774, "pointermove"],
|
||||
["move", 414, 479, 1721639141924, "pointermove"],
|
||||
["move", 415, 479, 1721639141932, "pointermove"],
|
||||
["move", 416, 478, 1721639141940, "pointermove"],
|
||||
["move", 419, 477, 1721639141949, "pointermove"],
|
||||
["move", 422, 475, 1721639141954, "pointermove"],
|
||||
["move", 426, 475, 1721639141962, "pointermove"],
|
||||
["move", 430, 473, 1721639141970, "pointermove"],
|
||||
["move", 434, 472, 1721639141978, "pointermove"],
|
||||
["move", 436, 470, 1721639141984, "pointermove"],
|
||||
["move", 440, 469, 1721639141992, "pointermove"],
|
||||
["move", 443, 468, 1721639142000, "pointermove"],
|
||||
["move", 446, 467, 1721639142008, "pointermove"],
|
||||
["move", 450, 466, 1721639142014, "pointermove"],
|
||||
["move", 450, 466, 1721639142022, "pointermove"],
|
||||
["move", 451, 466, 1721639142030, "pointermove"],
|
||||
["move", 452, 466, 1721639142038, "pointermove"],
|
||||
["move", 454, 466, 1721639142044, "pointermove"],
|
||||
["down", 454, 466, 1721639142082, "pointerdown"],
|
||||
["up", 454, 466, 1721639142134, "pointerup"],
|
||||
["move", 454, 467, 1721639142194, "pointermove"],
|
||||
["move", 454, 471, 1721639142202, "pointermove"],
|
||||
["move", 451, 475, 1721639142210, "pointermove"],
|
||||
["move", 448, 479, 1721639142216, "pointermove"],
|
||||
["move", 444, 483, 1721639142224, "pointermove"],
|
||||
["move", 439, 488, 1721639142232, "pointermove"],
|
||||
["move", 434, 494, 1721639142240, "pointermove"],
|
||||
["move", 429, 499, 1721639142246, "pointermove"],
|
||||
["move", 424, 503, 1721639142262, "pointermove"],
|
||||
["move", 419, 508, 1721639142270, "pointermove"],
|
||||
["move", 415, 512, 1721639142276, "pointermove"],
|
||||
["move", 411, 516, 1721639142284, "pointermove"],
|
||||
["move", 407, 520, 1721639142292, "pointermove"],
|
||||
["move", 404, 524, 1721639142300, "pointermove"],
|
||||
["move", 402, 527, 1721639142306, "pointermove"],
|
||||
["move", 399, 530, 1721639142314, "pointermove"],
|
||||
["move", 398, 531, 1721639142322, "pointermove"],
|
||||
["move", 397, 531, 1721639142330, "pointermove"],
|
||||
["move", 396, 532, 1721639142336, "pointermove"],
|
||||
["move", 395, 534, 1721639142344, "pointermove"],
|
||||
["move", 394, 535, 1721639142352, "pointermove"],
|
||||
["move", 393, 535, 1721639142360, "pointermove"],
|
||||
["move", 392, 536, 1721639142366, "pointermove"],
|
||||
["move", 391, 538, 1721639142374, "pointermove"],
|
||||
["move", 390, 539, 1721639142382, "pointermove"],
|
||||
["move", 389, 539, 1721639142390, "pointermove"],
|
||||
["move", 387, 540, 1721639142396, "pointermove"],
|
||||
["move", 386, 542, 1721639142404, "pointermove"],
|
||||
["move", 384, 543, 1721639142412, "pointermove"],
|
||||
["move", 383, 546, 1721639142420, "pointermove"],
|
||||
["move", 381, 547, 1721639142426, "pointermove"],
|
||||
["move", 379, 550, 1721639142434, "pointermove"],
|
||||
["move", 378, 551, 1721639142450, "pointermove"],
|
||||
["move", 377, 551, 1721639142456, "pointermove"],
|
||||
["move", 376, 554, 1721639142464, "pointermove"],
|
||||
["move", 376, 555, 1721639142472, "pointermove"],
|
||||
["move", 375, 556, 1721639142480, "pointermove"],
|
||||
["move", 373, 558, 1721639142486, "pointermove"],
|
||||
["move", 372, 559, 1721639142495, "pointermove"],
|
||||
["move", 371, 562, 1721639142502, "pointermove"],
|
||||
["move", 370, 563, 1721639142511, "pointermove"],
|
||||
["move", 370, 564, 1721639142516, "pointermove"],
|
||||
["move", 369, 566, 1721639142524, "pointermove"],
|
||||
["down", 369, 566, 1721639142554, "pointerdown"],
|
||||
["up", 369, 566, 1721639142606, "pointerup"],
|
||||
["move", 369, 564, 1721639142652, "pointermove"],
|
||||
["move", 369, 562, 1721639142661, "pointermove"],
|
||||
["move", 368, 558, 1721639142666, "pointermove"],
|
||||
["move", 366, 554, 1721639142674, "pointermove"],
|
||||
["move", 363, 548, 1721639142682, "pointermove"],
|
||||
["move", 359, 541, 1721639142690, "pointermove"],
|
||||
["move", 353, 534, 1721639142696, "pointermove"],
|
||||
["move", 346, 524, 1721639142704, "pointermove"],
|
||||
["move", 337, 514, 1721639142712, "pointermove"],
|
||||
["move", 328, 505, 1721639142720, "pointermove"],
|
||||
["move", 318, 496, 1721639142726, "pointermove"],
|
||||
["move", 308, 487, 1721639142734, "pointermove"],
|
||||
["move", 299, 480, 1721639142742, "pointermove"],
|
||||
["move", 291, 474, 1721639142750, "pointermove"],
|
||||
["move", 283, 468, 1721639142756, "pointermove"],
|
||||
["move", 277, 464, 1721639142764, "pointermove"],
|
||||
["move", 273, 460, 1721639142772, "pointermove"],
|
||||
["move", 270, 457, 1721639142780, "pointermove"],
|
||||
["move", 268, 455, 1721639142786, "pointermove"],
|
||||
["move", 266, 453, 1721639142794, "pointermove"],
|
||||
["move", 265, 451, 1721639142802, "pointermove"],
|
||||
["move", 264, 448, 1721639142816, "pointermove"],
|
||||
["move", 263, 446, 1721639142824, "pointermove"],
|
||||
["move", 262, 444, 1721639142832, "pointermove"],
|
||||
["move", 262, 442, 1721639142840, "pointermove"],
|
||||
["move", 261, 440, 1721639142846, "pointermove"],
|
||||
["move", 261, 438, 1721639142854, "pointermove"],
|
||||
["move", 261, 436, 1721639142862, "pointermove"],
|
||||
["move", 261, 434, 1721639142870, "pointermove"],
|
||||
["move", 261, 432, 1721639142876, "pointermove"],
|
||||
["move", 261, 430, 1721639142884, "pointermove"],
|
||||
["move", 261, 428, 1721639142892, "pointermove"],
|
||||
["move", 261, 426, 1721639142900, "pointermove"],
|
||||
["move", 261, 424, 1721639142906, "pointermove"],
|
||||
["move", 261, 423, 1721639142914, "pointermove"],
|
||||
["move", 261, 421, 1721639142922, "pointermove"],
|
||||
["move", 261, 420, 1721639142930, "pointermove"],
|
||||
["move", 261, 418, 1721639142936, "pointermove"],
|
||||
["move", 261, 415, 1721639142952, "pointermove"],
|
||||
["move", 260, 414, 1721639142960, "pointermove"],
|
||||
["move", 259, 412, 1721639142974, "pointermove"],
|
||||
["move", 258, 411, 1721639142982, "pointermove"],
|
||||
["move", 258, 410, 1721639142990, "pointermove"],
|
||||
["move", 258, 407, 1721639143012, "pointermove"],
|
||||
["move", 257, 406, 1721639143020, "pointermove"],
|
||||
["move", 256, 404, 1721639143034, "pointermove"],
|
||||
["move", 256, 403, 1721639143042, "pointermove"],
|
||||
["move", 255, 402, 1721639143050, "pointermove"],
|
||||
["down", 255, 401, 1721639143124, "pointerdown"],
|
||||
["up", 255, 401, 1721639143192, "pointerup"],
|
||||
["move", 256, 404, 1721639143252, "pointermove"],
|
||||
["move", 258, 410, 1721639143260, "pointermove"],
|
||||
["move", 262, 415, 1721639143266, "pointermove"],
|
||||
["move", 266, 423, 1721639143274, "pointermove"],
|
||||
["move", 271, 431, 1721639143282, "pointermove"],
|
||||
["move", 276, 439, 1721639143290, "pointermove"],
|
||||
["move", 282, 448, 1721639143296, "pointermove"],
|
||||
["move", 286, 459, 1721639143304, "pointermove"],
|
||||
["move", 294, 470, 1721639143312, "pointermove"],
|
||||
["move", 300, 482, 1721639143320, "pointermove"],
|
||||
["move", 307, 492, 1721639143326, "pointermove"],
|
||||
["move", 314, 503, 1721639143334, "pointermove"],
|
||||
["move", 322, 515, 1721639143342, "pointermove"],
|
||||
["move", 330, 523, 1721639143348, "pointermove"],
|
||||
["move", 336, 535, 1721639143356, "pointermove"],
|
||||
["move", 344, 544, 1721639143372, "pointermove"],
|
||||
["move", 354, 555, 1721639143378, "pointermove"],
|
||||
["move", 362, 563, 1721639143386, "pointermove"],
|
||||
["move", 370, 572, 1721639143394, "pointermove"],
|
||||
["move", 375, 580, 1721639143402, "pointermove"],
|
||||
["move", 380, 587, 1721639143408, "pointermove"],
|
||||
["move", 386, 595, 1721639143416, "pointermove"],
|
||||
["move", 391, 600, 1721639143424, "pointermove"],
|
||||
["move", 396, 607, 1721639143433, "pointermove"],
|
||||
["move", 402, 612, 1721639143438, "pointermove"],
|
||||
["move", 406, 619, 1721639143446, "pointermove"],
|
||||
["move", 410, 624, 1721639143454, "pointermove"],
|
||||
["move", 415, 630, 1721639143462, "pointermove"],
|
||||
["move", 419, 635, 1721639143468, "pointermove"],
|
||||
["move", 422, 640, 1721639143476, "pointermove"],
|
||||
["move", 426, 644, 1721639143484, "pointermove"],
|
||||
["move", 430, 647, 1721639143492, "pointermove"],
|
||||
["move", 431, 650, 1721639143498, "pointermove"],
|
||||
["move", 434, 651, 1721639143506, "pointermove"],
|
||||
["move", 434, 652, 1721639143514, "pointermove"],
|
||||
["move", 435, 655, 1721639143522, "pointermove"],
|
||||
["move", 436, 656, 1721639143528, "pointermove"],
|
||||
["move", 436, 658, 1721639143536, "pointermove"],
|
||||
["move", 438, 659, 1721639143544, "pointermove"],
|
||||
["move", 438, 659, 1721639143552, "pointermove"],
|
||||
["move", 438, 660, 1721639143574, "pointermove"],
|
||||
["move", 439, 660, 1721639143656, "pointermove"],
|
||||
["move", 440, 662, 1721639143672, "pointermove"],
|
||||
["move", 442, 663, 1721639143678, "pointermove"],
|
||||
["move", 443, 663, 1721639143686, "pointermove"],
|
||||
["move", 444, 664, 1721639143695, "pointermove"],
|
||||
["move", 446, 666, 1721639143702, "pointermove"],
|
||||
["move", 446, 666, 1721639143708, "pointermove"],
|
||||
["move", 447, 667, 1721639143716, "pointermove"],
|
||||
["move", 447, 666, 1721639143717, "mousemove"],
|
||||
["move", 448, 667, 1721639143724, "pointermove"],
|
||||
["move", 450, 667, 1721639143732, "pointermove"],
|
||||
["move", 450, 670, 1721639143746, "pointermove"],
|
||||
["move", 452, 671, 1721639143754, "pointermove"],
|
||||
["move", 454, 672, 1721639143762, "pointermove"],
|
||||
["move", 456, 675, 1721639143768, "pointermove"],
|
||||
["move", 458, 676, 1721639143776, "pointermove"],
|
||||
["move", 460, 679, 1721639143784, "pointermove"],
|
||||
["move", 462, 680, 1721639143792, "pointermove"],
|
||||
["move", 466, 683, 1721639143798, "pointermove"],
|
||||
["move", 467, 684, 1721639143806, "pointermove"],
|
||||
["move", 470, 687, 1721639143814, "pointermove"],
|
||||
["move", 470, 688, 1721639143822, "pointermove"],
|
||||
["move", 472, 691, 1721639143828, "pointermove"],
|
||||
["move", 474, 692, 1721639143836, "pointermove"],
|
||||
["move", 475, 695, 1721639143844, "pointermove"],
|
||||
["move", 478, 696, 1721639143852, "pointermove"],
|
||||
["move", 479, 699, 1721639143858, "pointermove"],
|
||||
["move", 482, 700, 1721639143866, "pointermove"],
|
||||
["move", 482, 703, 1721639143874, "pointermove"],
|
||||
["move", 483, 703, 1721639143882, "pointermove"],
|
||||
["move", 483, 704, 1721639143888, "pointermove"],
|
||||
["move", 483, 706, 1721639143912, "pointermove"],
|
||||
["down", 483, 706, 1721639143965, "pointerdown"],
|
||||
["focus", 1721639143965],
|
||||
["up", 483, 706, 1721639144024, "pointerup"]
|
||||
]
|
8
predict/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
current_dir = os.path.dirname(__file__)
|
||||
sys.path.append(current_dir)
|
||||
|
||||
from nine.nine import nine
|
||||
from icon.icon import icon
|
0
predict/icon/__init__.py
Normal file
73
predict/icon/icon.py
Normal file
@ -0,0 +1,73 @@
|
||||
import os
|
||||
import ddddocr
|
||||
from PIL import Image
|
||||
from io import BytesIO
|
||||
import numpy as np
|
||||
import onnxruntime as ort
|
||||
|
||||
det = ddddocr.DdddOcr(det=True, ocr=False)
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
model_path = os.path.join(current_dir, "siamese.onnx")
|
||||
Siamese = ort.InferenceSession(model_path)
|
||||
|
||||
|
||||
def get_icons(image_bytes):
|
||||
def remove_subicon(data):
|
||||
result = []
|
||||
for i in data:
|
||||
remove = False
|
||||
for j in data:
|
||||
if (
|
||||
i != j
|
||||
and i[0] >= j[0]
|
||||
and i[1] >= j[1]
|
||||
and i[2] <= j[2]
|
||||
and i[3] <= j[3]
|
||||
):
|
||||
remove = True
|
||||
if not remove:
|
||||
result.append(i)
|
||||
return result
|
||||
|
||||
img = Image.open(BytesIO(image_bytes))
|
||||
bboxes = det.detection(image_bytes)
|
||||
small_bboxes = [i for i in bboxes if i[1] > 300]
|
||||
big_bboxes = [i for i in bboxes if i[1] <= 300]
|
||||
small_bboxes = sorted(small_bboxes, key=lambda x: x[0])
|
||||
big_bboxes = remove_subicon(big_bboxes)
|
||||
small_images = [img.crop(i) for i in small_bboxes]
|
||||
big_images = [img.crop(i) for i in big_bboxes]
|
||||
return big_bboxes, small_images, big_images
|
||||
|
||||
|
||||
def calculate_similarity(img1, img2):
|
||||
def preprocess_image(img, size=(105, 105)):
|
||||
img_resized = img.resize(size)
|
||||
img_normalized = np.array(img_resized) / 255.0
|
||||
img_transposed = np.transpose(img_normalized, (2, 0, 1))
|
||||
img_expanded = np.expand_dims(img_transposed, axis=0).astype(np.float32)
|
||||
return img_expanded
|
||||
|
||||
image_data_1 = preprocess_image(img1)
|
||||
image_data_2 = preprocess_image(img2)
|
||||
|
||||
inputs = {"input": image_data_1, "input.53": image_data_2}
|
||||
|
||||
output = Siamese.run(None, inputs)
|
||||
|
||||
output_sigmoid = 1 / (1 + np.exp(-output[0]))
|
||||
similarity_score = output_sigmoid[0][0]
|
||||
|
||||
return similarity_score
|
||||
|
||||
|
||||
def icon(image_bytes):
|
||||
big_bboxes, small_images, big_images = get_icons(image_bytes)
|
||||
ans = []
|
||||
for i in small_images:
|
||||
similarities = [calculate_similarity(i, j) for j in big_images]
|
||||
target_bbox = big_bboxes[similarities.index(max(similarities))]
|
||||
x = (target_bbox[0] + target_bbox[2]) / 2
|
||||
y = (target_bbox[1] + target_bbox[3]) / 2
|
||||
ans.append((x, y))
|
||||
return ans
|
223193
predict/icon/siamese.onnx
Normal file
0
predict/nine/__init__.py
Normal file
BIN
predict/nine/icon/0.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/1.jpg
Normal file
After Width: | Height: | Size: 979 B |
BIN
predict/nine/icon/10.jpg
Normal file
After Width: | Height: | Size: 994 B |
BIN
predict/nine/icon/11.jpg
Normal file
After Width: | Height: | Size: 987 B |
BIN
predict/nine/icon/12.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/13.jpg
Normal file
After Width: | Height: | Size: 861 B |
BIN
predict/nine/icon/14.jpg
Normal file
After Width: | Height: | Size: 982 B |
BIN
predict/nine/icon/15.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/16.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/17.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/18.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/19.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/2.jpg
Normal file
After Width: | Height: | Size: 956 B |
BIN
predict/nine/icon/20.jpg
Normal file
After Width: | Height: | Size: 929 B |
BIN
predict/nine/icon/21.jpg
Normal file
After Width: | Height: | Size: 1011 B |
BIN
predict/nine/icon/22.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/23.jpg
Normal file
After Width: | Height: | Size: 921 B |
BIN
predict/nine/icon/24.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/25.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/26.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/27.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/28.jpg
Normal file
After Width: | Height: | Size: 998 B |
BIN
predict/nine/icon/29.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/3.jpg
Normal file
After Width: | Height: | Size: 1017 B |
BIN
predict/nine/icon/30.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/31.jpg
Normal file
After Width: | Height: | Size: 882 B |
BIN
predict/nine/icon/32.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/33.jpg
Normal file
After Width: | Height: | Size: 999 B |
BIN
predict/nine/icon/34.jpg
Normal file
After Width: | Height: | Size: 908 B |
BIN
predict/nine/icon/35.jpg
Normal file
After Width: | Height: | Size: 990 B |
BIN
predict/nine/icon/36.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/37.jpg
Normal file
After Width: | Height: | Size: 964 B |
BIN
predict/nine/icon/38.jpg
Normal file
After Width: | Height: | Size: 890 B |
BIN
predict/nine/icon/39.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/4.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/40.jpg
Normal file
After Width: | Height: | Size: 1007 B |
BIN
predict/nine/icon/41.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/42.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/43.jpg
Normal file
After Width: | Height: | Size: 827 B |
BIN
predict/nine/icon/44.jpg
Normal file
After Width: | Height: | Size: 922 B |
BIN
predict/nine/icon/45.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/46.jpg
Normal file
After Width: | Height: | Size: 952 B |
BIN
predict/nine/icon/47.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/48.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/49.jpg
Normal file
After Width: | Height: | Size: 955 B |
BIN
predict/nine/icon/5.jpg
Normal file
After Width: | Height: | Size: 953 B |
BIN
predict/nine/icon/50.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/51.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/52.jpg
Normal file
After Width: | Height: | Size: 971 B |
BIN
predict/nine/icon/53.jpg
Normal file
After Width: | Height: | Size: 914 B |
BIN
predict/nine/icon/54.jpg
Normal file
After Width: | Height: | Size: 875 B |
BIN
predict/nine/icon/55.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/56.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/57.jpg
Normal file
After Width: | Height: | Size: 884 B |
BIN
predict/nine/icon/58.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/59.jpg
Normal file
After Width: | Height: | Size: 858 B |
BIN
predict/nine/icon/6.jpg
Normal file
After Width: | Height: | Size: 870 B |
BIN
predict/nine/icon/60.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/61.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/62.jpg
Normal file
After Width: | Height: | Size: 998 B |
BIN
predict/nine/icon/63.jpg
Normal file
After Width: | Height: | Size: 934 B |
BIN
predict/nine/icon/64.jpg
Normal file
After Width: | Height: | Size: 1020 B |
BIN
predict/nine/icon/65.jpg
Normal file
After Width: | Height: | Size: 942 B |
BIN
predict/nine/icon/66.jpg
Normal file
After Width: | Height: | Size: 998 B |
BIN
predict/nine/icon/67.jpg
Normal file
After Width: | Height: | Size: 973 B |
BIN
predict/nine/icon/68.jpg
Normal file
After Width: | Height: | Size: 994 B |
BIN
predict/nine/icon/69.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/7.jpg
Normal file
After Width: | Height: | Size: 980 B |
BIN
predict/nine/icon/70.jpg
Normal file
After Width: | Height: | Size: 1009 B |
BIN
predict/nine/icon/71.jpg
Normal file
After Width: | Height: | Size: 987 B |
BIN
predict/nine/icon/72.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/73.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/74.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/75.jpg
Normal file
After Width: | Height: | Size: 818 B |
BIN
predict/nine/icon/76.jpg
Normal file
After Width: | Height: | Size: 994 B |
BIN
predict/nine/icon/77.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/78.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/79.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/8.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/80.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/81.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/82.jpg
Normal file
After Width: | Height: | Size: 998 B |
BIN
predict/nine/icon/83.jpg
Normal file
After Width: | Height: | Size: 980 B |
BIN
predict/nine/icon/84.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
predict/nine/icon/85.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/86.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
predict/nine/icon/87.jpg
Normal file
After Width: | Height: | Size: 958 B |
BIN
predict/nine/icon/88.jpg
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
predict/nine/icon/89.jpg
Normal file
After Width: | Height: | Size: 946 B |
BIN
predict/nine/icon/9.jpg
Normal file
After Width: | Height: | Size: 906 B |