Skip to content

Commit 8f3dd37

Browse files
committed
Added option to disable symlink sanitization if desired
1 parent adb02d2 commit 8f3dd37

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/binwalk/modules/extractor.py

+9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ class Extractor(Module):
9999
# type=int,
100100
# kwargs={'recursive_max_size': 0},
101101
# description="Limit the total size of all extracted files"),
102+
Option(short='1',
103+
long='preserve-symlinks',
104+
kwargs={'do_not_sanitize_symlinks': True},
105+
description="Do not sanitize extracted symlinks that point outside the extraction directory (dangerous)"),
102106
Option(short='r',
103107
long='rm',
104108
kwargs={'remove_after_execute': True},
@@ -118,6 +122,7 @@ class Extractor(Module):
118122
Kwarg(name='recursive_max_size', default=None),
119123
Kwarg(name='max_count', default=None),
120124
Kwarg(name='base_directory', default=None),
125+
Kwarg(name='do_not_sanitize_symlinks', default=False),
121126
Kwarg(name='remove_after_execute', default=False),
122127
Kwarg(name='load_default_rules', default=False),
123128
Kwarg(name='run_extractors', default=True),
@@ -986,6 +991,10 @@ def shell_call(self, command):
986991
return os.wait()[1]
987992

988993
def symlink_sanitizer(self, file_list, extraction_directory):
994+
# User can disable this if desired
995+
if self.do_not_sanitize_symlinks is True:
996+
return
997+
989998
# Allows either a single file path, or a list of file paths to be passed in for sanitization.
990999
if type(file_list) is not list:
9911000
file_list = [file_list]

0 commit comments

Comments
 (0)