Skip to content

Commit

Permalink
Added option to disable symlink sanitization if desired
Browse files Browse the repository at this point in the history
  • Loading branch information
devttys0 committed Sep 7, 2021
1 parent adb02d2 commit 8f3dd37
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/binwalk/modules/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class Extractor(Module):
# type=int,
# kwargs={'recursive_max_size': 0},
# description="Limit the total size of all extracted files"),
Option(short='1',
long='preserve-symlinks',
kwargs={'do_not_sanitize_symlinks': True},
description="Do not sanitize extracted symlinks that point outside the extraction directory (dangerous)"),
Option(short='r',
long='rm',
kwargs={'remove_after_execute': True},
Expand All @@ -118,6 +122,7 @@ class Extractor(Module):
Kwarg(name='recursive_max_size', default=None),
Kwarg(name='max_count', default=None),
Kwarg(name='base_directory', default=None),
Kwarg(name='do_not_sanitize_symlinks', default=False),
Kwarg(name='remove_after_execute', default=False),
Kwarg(name='load_default_rules', default=False),
Kwarg(name='run_extractors', default=True),
Expand Down Expand Up @@ -986,6 +991,10 @@ def shell_call(self, command):
return os.wait()[1]

def symlink_sanitizer(self, file_list, extraction_directory):
# User can disable this if desired
if self.do_not_sanitize_symlinks is True:
return

# Allows either a single file path, or a list of file paths to be passed in for sanitization.
if type(file_list) is not list:
file_list = [file_list]
Expand Down

0 comments on commit 8f3dd37

Please sign in to comment.