Skip to content

Conversation

sempervictus
Copy link
Contributor

This PR introduces the post modues from #2075. Since they rely on the /lib components in that PR, it is included in this one. We can remove the conflicting components or just commit this PR once we resolve what issues may come.

Notable features of the changes in post are a more in-depth abstraction to simple method calls for executing, cleaning up, and not killing other people's PIDs when running powershell from the "user" side of the framework (writing a post module/rc script). The cleanup process will now check a PID before attempting to kill it, removing the "access denied" errors we were seeing prior when killing a PID which committed suicide anyway.

The modules included are both util modules for executing PSH from a script or a simple command. Point them to a PS1 containing all the relvant pieces of a powersploit attack and they become more than management tools. The post modules and lib illustrate how to consume and prepare PSH code before pushing it to the target system. It is not a long shot from here to write specific modules consuming segments of PSH from different sources, combining, obfuscating, staging, and executig them... with full output.

g0tmi1k and others added 21 commits July 4, 2013 13:27
If the regex fails then the entire moudle would too
Add Rex powershell parser:
 reads PSH, determines functions, variables, blocks
 compresses and cleans up the code it's read, obfuscates
 handles string literals and reserved variable names
 extracts code blocks and functions for reuse
  turns powersploit into a useful sub-component for MSF
Rewire Msf powershell modules
 Make use of Rex parser
 Handles payload generation, substituions
 Brings convenience methods - byte array generation and download
 Re-add .NET compiler
  Compiles .NET code (C#/VB.NET) in memory
  Can generate binary output file (dynamic persistence)
  Handles code-signing (steal cert with mimikatz, sign your bin)
  Not detected by AV (still...)
 Update payload generation
  GZip compression and decompression (see Rex module as well)
  msftidy violations for space efficiency - each char counts
Re-submit psexec-psh
 Makes use of updated Msf and Rex modules
 Runs shellcode in-memory (in a hidden PSH window)
 Completely bypasses all AVs tested for the last year...
@g0tm1lk: no clue, you must've pwned me in your sl33p. :)
Resolve conflicts from old code being pulled into master.

Conflicts:
	lib/msf/core/exploit/powershell.rb
	modules/exploits/windows/smb/psexec_psh.rb
Remove .NET compiler, post lib and modules.
This is temporary and rather messy. Since the internals for
dealing with PSH code have moved to Rex there may be a hiccup or
two here. This was my original attempt at basic PSH integration
and does not make use of the new libraries and namespaces in
this PR.

Will introduce the updated modules and libraries in separate PR.
Replace powershell lib which snuck in as psexec_psh.
Introduce psexec_psh module which uses the Rex and Msf PSH
methods provided in the lib import.
… psh_merge

Conflicts:
	modules/exploits/windows/smb/psexec_psh.rb
Looks good from here, though we may want to address the all caps opt names.
This is the core post component broken out from rapid7#2075.
Includes new post library leveraging the rex and msf namespace
changes in lib.
Includes basic modules for script and command execution. These
modules can be used a simple base for complex powershell execution
from post modules and RC scripts.
@jvazquez-r7
Copy link
Contributor

According to gihub, there are conflicts to solve before we can proceed with this.

@jvazquez-r7
Copy link
Contributor

This pull request is creating conflicts and can't be landed, please @sempervictus feel free to fix the conflicts and reopen again once ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants