RFC: Pipe Wielding Shellisms #9841
Replies: 6 comments
-
shell magic is the kicker here; differences between bash, dash, and busybox limit what we can do there. |
Beta Was this translation helpful? Give feedback.
-
Good point sir, i figure if we start making replacement approaches to bin invocation, we will have to test against those and probably ksh to see what can and can't stick across 'em. |
Beta Was this translation helpful? Give feedback.
-
#9854 - Related, regarding the use of |
Beta Was this translation helpful? Give feedback.
-
In addition to the problems outlined above, such as The current code pattern for local exploits is to However, a session within a user namespace may have root privileges, yet we may want to proceed with exploitation to break out of the namespace. This hasn't been a problem... yet...
Edit: I've updated many of the Linux local modules to allow the operator to bypass the |
Beta Was this translation helpful? Give feedback.
-
#10119 has now been merged which is a good start in this direction. It introduces the functionality described in the OP by falling back to shellisms when system commands are not available. For example, reading from files: # Result on systems without cat command
session.shell_command_token("while read line; do echo $line; done <#{file_name}") |
Beta Was this translation helpful? Give feedback.
-
Metasploit has been around longer than a lot of, if not most Linux userspace environments in play today. Our Framework libraries rely on some assumptions in shell and mettle sessions which may not be true everywhere, such as stripped-down containerized targets for our exploits (and subsequent session context). The Post libs are designed to abstract the magic of interacting with the environment for the users, and in that spirit, i'd like to suggest a refactoring effort which would replace invocations to "binaries we assume to be present" with shell magic reading from proc and sys fs'. For example, /bin/cat might not exist in some environments, and cat /proc/cpuinfo is actually equivalent to while read l;do printf "$l\n";done</proc/cpuinfo which is "pathless" as it doesn't call any binaries to do its dirty work.
This is absolutely not glamorous, its busy work for greybeards, or a good chance for those who dont know how this stuff works to learn and solidify the skills by implementing. We're going to need this more and more as process isolation becomes more "hardcore" (@ SVIT we use raw namespacing, firejail, and other dirty tricks, including runing actual jails in hardned bsd which look like Linux userspace with a minimum attack surface, everyone else is going in similar directions).
Off the bat, i'd say this warrants a look from @busterb+team, @hdm, @egypt, @kernelsmith, @zeroSteiner, @OJ, and @bcoles (reap whats sown and all 😈 ) if those folks are able and willing.
Beta Was this translation helpful? Give feedback.
All reactions