Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
binwalk
Commits
54d40f60
Commit
54d40f60
authored
3 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial symlink 'repair' solution
parent
8f1dcca4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
extractor.py
src/binwalk/modules/extractor.py
+19
-10
No files found.
src/binwalk/modules/extractor.py
View file @
54d40f60
...
...
@@ -174,8 +174,8 @@ class Extractor(Module):
self
.
config
.
verbose
=
True
def
add_pending
(
self
,
f
):
# Ignore symlinks
if
os
.
path
.
islink
(
f
):
# Ignore symlinks
, don't add new files unless recursion was requested
if
os
.
path
.
islink
(
f
)
or
not
self
.
matryoshka
:
return
# Get the file mode to check and see if it's a block/char device
...
...
@@ -286,13 +286,7 @@ class Extractor(Module):
# If recursion was specified, and the file is not the same
# one we just dd'd
if
(
self
.
matryoshka
and
file_path
!=
dd_file_path
and
scan_extracted_files
and
self
.
directory
in
real_file_path
):
# If the recursion level of this file is less than or
# equal to our desired recursion level
if
len
(
real_file_path
.
split
(
self
.
directory
)[
1
]
.
split
(
os
.
path
.
sep
))
<=
self
.
matryoshka
:
if
file_path
!=
dd_file_path
:
# If this is a directory and we are supposed to process directories for this extractor,
# then add all files under that directory to the
# list of pending files.
...
...
@@ -300,10 +294,18 @@ class Extractor(Module):
for
root
,
dirs
,
files
in
os
.
walk
(
file_path
):
for
f
in
files
:
full_path
=
os
.
path
.
join
(
root
,
f
)
if
os
.
path
.
islink
(
full_path
):
self
.
symlink_repair
(
full_path
)
# If the recursion level of this file is less than or equal to our desired recursion level
if
len
(
real_file_path
.
split
(
self
.
directory
)[
1
]
.
split
(
os
.
path
.
sep
))
<=
self
.
matryoshka
:
if
scan_extracted_files
and
self
.
directory
in
real_file_path
:
self
.
add_pending
(
full_path
)
# If it's just a file, it to the list of pending
# files
else
:
elif
scan_extracted_files
and
self
.
directory
in
real_file_path
:
self
.
add_pending
(
file_path
)
# Update the last directory listing for the next time we
...
...
@@ -959,3 +961,10 @@ class Extractor(Module):
sys
.
exit
(
rval
)
else
:
return
os
.
wait
()[
1
]
def
symlink_repair
(
self
,
symlink
):
linktarget
=
os
.
path
.
realpath
(
symlink
)
if
not
linktarget
.
startswith
(
self
.
directory
):
os
.
remove
(
symlink
)
os
.
symlink
(
os
.
devnull
,
symlink
)
binwalk
.
core
.
common
.
warning
(
"Symlink points outside of the extraction directory:
%
s ->
%
s"
%
(
symlink
,
linktarget
))
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment