Skip to content

feat(capabilities): add workaround for low-privileged users when tryi… #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TKostrzewski
Copy link

…ng to set the CAP_SETUID capability on the copied binaries

…ng to set the CAP_SETUID capability on the copied binaries
@@ -58,7 +58,7 @@ sudo:

capabilities:
label: Capabilities
description: If the binary has the Linux `CAP_SETUID` capability set or it is executed by another binary with the capability set, it can be used as a backdoor to maintain privileged access by manipulating its own process UID.
description: If the binary has the Linux `CAP_SETUID` capability set or it is executed by another binary with the capability set, it can be used as a backdoor to maintain privileged access by manipulating its own process UID. The `getcap -r / 2>/dev/null | grep cap_setuid` command will give the locations of the original binaries that have the `CAP_SETUID` capability set already, in case your user is too low-privileged to set the capability on the copied binary.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I was following the exploit given in https://gtfobins.github.io/gtfobins/view/#capabilities, and noticed that when trying to run sudo setcap cap_setuid+ep view, the command failed, as my user didn't have the necessary permissions.

I thought that this might be quite a common occurrence, especially for these privilege escalation vectors, so thought it worth adding the extra bit of information here.

Essentially, if your user is too low privileged to assign the copied binary the CAP_SETUID capability, then you can just navigate to the original binary that has the CAP_SETUID capability, and then run ./view -c ':py import os; os.setuid(0); os.execl("/bin/sh", "sh", "-c", "reset; exec sh")', pointing to the original binary.

What do you think? I'm pretty new to this all, so happy to be wrong/happy for you to ignore and close the PR, if you don't think it's too useful.

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.

1 participant