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
a51ddb23
Commit
a51ddb23
authored
Oct 13, 2020
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added __main__.py file; updated binwalk script accordingly
parent
6f64ba30
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
61 deletions
+66
-61
__main__.py
src/binwalk/__main__.py
+64
-0
binwalk
src/scripts/binwalk
+2
-61
No files found.
src/binwalk/__main__.py
0 → 100755
View file @
a51ddb23
import
os
import
sys
# If installed to a custom prefix directory, binwalk may not be in
# the default module search path(s). Try to resolve the prefix module
# path and make it the first entry in sys.path.
# Ensure that 'src/binwalk' becomes '.' instead of an empty string
_parent_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
for
_module_path
in
[
# from repo: src/scripts/ -> src/
_parent_dir
,
# from build dir: build/scripts-3.4/ -> build/lib/
os
.
path
.
join
(
_parent_dir
,
"lib"
),
# installed in non-default path: bin/ -> lib/python3.4/site-packages/
os
.
path
.
join
(
_parent_dir
,
"lib"
,
"python
%
d.
%
d"
%
(
sys
.
version_info
[
0
],
sys
.
version_info
[
1
]),
"site-packages"
)
]:
if
os
.
path
.
exists
(
_module_path
)
and
_module_path
not
in
sys
.
path
:
sys
.
path
=
[
_module_path
]
+
sys
.
path
import
binwalk
import
binwalk.modules
def
runme
():
with
binwalk
.
Modules
()
as
modules
:
try
:
if
len
(
sys
.
argv
)
==
1
:
sys
.
stderr
.
write
(
modules
.
help
())
sys
.
exit
(
1
)
# If no explicit module was enabled in the command line arguments,
# run again with the default signature scan explicitly enabled.
elif
not
modules
.
execute
():
# Make sure the Signature module is loaded before attempting
# an implicit signature scan; else, the error message received
# by the end user is not very helpful.
if
hasattr
(
binwalk
.
modules
,
"Signature"
):
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
)
else
:
sys
.
stderr
.
write
(
"Error: Signature scans not supported; "
)
sys
.
stderr
.
write
(
"make sure you have python-lzma installed and try again.
\n
"
)
sys
.
exit
(
2
)
except
binwalk
.
ModuleException
as
e
:
sys
.
exit
(
3
)
def
main
():
try
:
# Special options for profiling the code. For debug use only.
if
'--profile'
in
sys
.
argv
:
import
cProfile
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
'--profile'
))
cProfile
.
run
(
'runme()'
)
else
:
runme
()
except
IOError
:
pass
except
KeyboardInterrupt
:
sys
.
stdout
.
write
(
"
\n
"
)
if
__name__
==
"__main__"
:
main
()
src/scripts/binwalk
View file @
a51ddb23
#!/usr/bin/env python
#!/usr/bin/env python
from
binwalk.__main__
import
main
import
os
main
()
import
sys
# If installed to a custom prefix directory, binwalk may not be in
# the default module search path(s). Try to resolve the prefix module
# path and make it the first entry in sys.path.
# Ensure that 'src/binwalk' becomes '.' instead of an empty string
_parent_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
for
_module_path
in
[
# from repo: src/scripts/ -> src/
_parent_dir
,
# from build dir: build/scripts-3.4/ -> build/lib/
os
.
path
.
join
(
_parent_dir
,
"lib"
),
# installed in non-default path: bin/ -> lib/python3.4/site-packages/
os
.
path
.
join
(
_parent_dir
,
"lib"
,
"python
%
d.
%
d"
%
(
sys
.
version_info
[
0
],
sys
.
version_info
[
1
]),
"site-packages"
)
]:
if
os
.
path
.
exists
(
_module_path
)
and
_module_path
not
in
sys
.
path
:
sys
.
path
=
[
_module_path
]
+
sys
.
path
import
binwalk
import
binwalk.modules
def
main
():
with
binwalk
.
Modules
()
as
modules
:
try
:
if
len
(
sys
.
argv
)
==
1
:
sys
.
stderr
.
write
(
modules
.
help
())
sys
.
exit
(
1
)
# If no explicit module was enabled in the command line arguments,
# run again with the default signature scan explicitly enabled.
elif
not
modules
.
execute
():
# Make sure the Signature module is loaded before attempting
# an implicit signature scan; else, the error message received
# by the end user is not very helpful.
if
hasattr
(
binwalk
.
modules
,
"Signature"
):
modules
.
execute
(
*
sys
.
argv
[
1
:],
signature
=
True
)
else
:
sys
.
stderr
.
write
(
"Error: Signature scans not supported; "
)
sys
.
stderr
.
write
(
"make sure you have python-lzma installed and try again.
\n
"
)
sys
.
exit
(
2
)
except
binwalk
.
ModuleException
as
e
:
sys
.
exit
(
3
)
if
__name__
==
'__main__'
:
try
:
# Special options for profiling the code. For debug use only.
if
'--profile'
in
sys
.
argv
:
import
cProfile
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
'--profile'
))
cProfile
.
run
(
'main()'
)
else
:
main
()
except
IOError
:
pass
except
KeyboardInterrupt
:
sys
.
stdout
.
write
(
"
\n
"
)
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