Created
June 8, 2026 15:51
-
-
Save Ozymandias42/f8da04ce73d26a23b718be10ea8bc28a to your computer and use it in GitHub Desktop.
listCapabilitiesOfPID.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| INPUT=$1 | |
| CAPABILITIES="" | |
| function parseCapsFromProc(){ | |
| grep CapPrm /proc/$1/status \ | |
| | awk '{print $2}' | |
| } | |
| function computeInput(){ | |
| #check if $1 is set at all of input is from pipe | |
| if [ -z "${INPUT}" ]; then | |
| read -r INPUT | |
| echo $INPUT | |
| fi | |
| #check if input PID or Cap-Hex-representation | |
| case $INPUT in | |
| #if Cap-Hex-rep | |
| 0*) CAPABILITIES=$INPUT ;; | |
| #else, default cse. | |
| *) CAPABILITIES=$(parseCapsFromProc $INPUT) ;; | |
| esac | |
| } | |
| case $1 in | |
| --help) echo "help" ;; | |
| *) computeInput ;; | |
| esac | |
| CAPABILITIES=$(\ | |
| capsh --decode=$CAPABILITIES | \ | |
| awk -F'=' '{print $2}' | \ | |
| tr ',' '\n' | |
| ) | |
| printf "%s\n" ${CAPABILITIES:-"No Capabilities set for PID $PID"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment