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
6b0a85ac
Commit
6b0a85ac
authored
Apr 19, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed API and Python3 bugs.
parent
2eca30fc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
103 deletions
+12
-103
module.py
src/binwalk/core/module.py
+2
-0
parser.py
src/binwalk/core/parser.py
+4
-2
signature.py
src/binwalk/modules/signature.py
+6
-6
ViewBox.py
src/binwalk/pyqtgraph/graphicsItems/tests/ViewBox.py
+0
-95
No files found.
src/binwalk/core/module.py
View file @
6b0a85ac
...
@@ -538,6 +538,8 @@ class Modules(object):
...
@@ -538,6 +538,8 @@ class Modules(object):
k
=
self
.
_parse_api_opt
(
k
)
k
=
self
.
_parse_api_opt
(
k
)
argv
.
append
(
k
)
argv
.
append
(
k
)
if
v
not
in
[
True
,
False
,
None
]:
if
v
not
in
[
True
,
False
,
None
]:
if
not
isinstance
(
v
,
str
):
v
=
str
(
bytes2str
(
v
))
argv
.
append
(
v
)
argv
.
append
(
v
)
if
not
argv
and
not
self
.
arguments
:
if
not
argv
and
not
self
.
arguments
:
...
...
src/binwalk/core/parser.py
View file @
6b0a85ac
...
@@ -129,7 +129,7 @@ class MagicParser(object):
...
@@ -129,7 +129,7 @@ class MagicParser(object):
Returns the name of the generated temporary magic file.
Returns the name of the generated temporary magic file.
'''
'''
self
.
raw_fd
=
tempfile
.
NamedTemporaryFile
()
self
.
raw_fd
=
tempfile
.
NamedTemporaryFile
()
self
.
raw_fd
.
write
(
s
elf
.
MAGIC_STRING_FORMAT
%
(
offset
,
signature_string
,
display_name
))
self
.
raw_fd
.
write
(
s
tr2bytes
(
self
.
MAGIC_STRING_FORMAT
%
(
offset
,
signature_string
,
display_name
)
))
self
.
raw_fd
.
seek
(
0
)
self
.
raw_fd
.
seek
(
0
)
return
self
.
raw_fd
.
name
return
self
.
raw_fd
.
name
...
@@ -178,7 +178,8 @@ class MagicParser(object):
...
@@ -178,7 +178,8 @@ class MagicParser(object):
line_count
=
0
line_count
=
0
try
:
try
:
for
line
in
open
(
file_name
,
'rb'
)
.
readlines
():
fp
=
open
(
file_name
,
'rb'
)
for
line
in
fp
.
readlines
():
line
=
bytes2str
(
line
)
line
=
bytes2str
(
line
)
line_count
+=
1
line_count
+=
1
...
@@ -205,6 +206,7 @@ class MagicParser(object):
...
@@ -205,6 +206,7 @@ class MagicParser(object):
if
include
:
if
include
:
self
.
fd
.
write
(
str2bytes
(
line
))
self
.
fd
.
write
(
str2bytes
(
line
))
fp
.
close
()
self
.
build_signature_set
()
self
.
build_signature_set
()
except
KeyboardInterrupt
as
e
:
except
KeyboardInterrupt
as
e
:
raise
e
raise
e
...
...
src/binwalk/modules/signature.py
View file @
6b0a85ac
...
@@ -62,21 +62,21 @@ class Signature(Module):
...
@@ -62,21 +62,21 @@ class Signature(Module):
self
.
magic_files
=
[
self
.
parser
.
file_from_string
(
self
.
raw_bytes
)]
self
.
magic_files
=
[
self
.
parser
.
file_from_string
(
self
.
raw_bytes
)]
# Append the user's magic file first so that those signatures take precedence
# Append the user's magic file first so that those signatures take precedence
if
self
.
search_for_opcodes
:
el
if
self
.
search_for_opcodes
:
self
.
magic_files
+
=
[
self
.
magic_files
=
[
self
.
config
.
settings
.
get_file_path
(
'user'
,
self
.
config
.
settings
.
BINARCH_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'user'
,
self
.
config
.
settings
.
BINARCH_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'system'
,
self
.
config
.
settings
.
BINARCH_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'system'
,
self
.
config
.
settings
.
BINARCH_MAGIC_FILE
),
]
]
if
self
.
cast_data_types
:
el
if
self
.
cast_data_types
:
self
.
magic_files
+
=
[
self
.
magic_files
=
[
self
.
config
.
settings
.
get_file_path
(
'user'
,
self
.
config
.
settings
.
BINCAST_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'user'
,
self
.
config
.
settings
.
BINCAST_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'system'
,
self
.
config
.
settings
.
BINCAST_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'system'
,
self
.
config
.
settings
.
BINCAST_MAGIC_FILE
),
]
]
# Use the system default magic file if no other was specified, or if -B was explicitly specified
# Use the system default magic file if no other was specified, or if -B was explicitly specified
if
not
self
.
magic_files
or
self
.
force_default_scan
:
el
if
not
self
.
magic_files
or
self
.
force_default_scan
:
self
.
magic_files
+
=
[
self
.
magic_files
=
[
self
.
config
.
settings
.
get_file_path
(
'user'
,
self
.
config
.
settings
.
BINWALK_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'user'
,
self
.
config
.
settings
.
BINWALK_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'system'
,
self
.
config
.
settings
.
BINWALK_MAGIC_FILE
),
self
.
config
.
settings
.
get_file_path
(
'system'
,
self
.
config
.
settings
.
BINWALK_MAGIC_FILE
),
]
]
...
...
src/binwalk/pyqtgraph/graphicsItems/tests/ViewBox.py
deleted
100644 → 0
View file @
2eca30fc
"""
ViewBox test cases:
* call setRange then resize; requested range must be fully visible
* lockAspect works correctly for arbitrary aspect ratio
* autoRange works correctly with aspect locked
* call setRange with aspect locked, then resize
* AutoRange with all the bells and whistles
* item moves / changes transformation / changes bounds
* pan only
* fractional range
"""
import
pyqtgraph
as
pg
app
=
pg
.
mkQApp
()
imgData
=
pg
.
np
.
zeros
((
10
,
10
))
imgData
[
0
]
=
3
imgData
[
-
1
]
=
3
imgData
[:,
0
]
=
3
imgData
[:,
-
1
]
=
3
def
testLinkWithAspectLock
():
global
win
,
vb
win
=
pg
.
GraphicsWindow
()
vb
=
win
.
addViewBox
(
name
=
"image view"
)
vb
.
setAspectLocked
()
vb
.
enableAutoRange
(
x
=
False
,
y
=
False
)
p1
=
win
.
addPlot
(
name
=
"plot 1"
)
p2
=
win
.
addPlot
(
name
=
"plot 2"
,
row
=
1
,
col
=
0
)
win
.
ci
.
layout
.
setRowFixedHeight
(
1
,
150
)
win
.
ci
.
layout
.
setColumnFixedWidth
(
1
,
150
)
def
viewsMatch
():
r0
=
pg
.
np
.
array
(
vb
.
viewRange
())
r1
=
pg
.
np
.
array
(
p1
.
vb
.
viewRange
()[
1
])
r2
=
pg
.
np
.
array
(
p2
.
vb
.
viewRange
()[
1
])
match
=
(
abs
(
r0
[
1
]
-
r1
)
<=
(
abs
(
r1
)
*
0.001
))
.
all
()
and
(
abs
(
r0
[
0
]
-
r2
)
<=
(
abs
(
r2
)
*
0.001
))
.
all
()
return
match
p1
.
setYLink
(
vb
)
p2
.
setXLink
(
vb
)
print
"link views match:"
,
viewsMatch
()
win
.
show
()
print
"show views match:"
,
viewsMatch
()
img
=
pg
.
ImageItem
(
imgData
)
vb
.
addItem
(
img
)
vb
.
autoRange
()
p1
.
plot
(
x
=
imgData
.
sum
(
axis
=
0
),
y
=
range
(
10
))
p2
.
plot
(
x
=
range
(
10
),
y
=
imgData
.
sum
(
axis
=
1
))
print
"add items views match:"
,
viewsMatch
()
#p1.setAspectLocked()
#grid = pg.GridItem()
#vb.addItem(grid)
pg
.
QtGui
.
QApplication
.
processEvents
()
pg
.
QtGui
.
QApplication
.
processEvents
()
#win.resize(801, 600)
def
testAspectLock
():
global
win
,
vb
win
=
pg
.
GraphicsWindow
()
vb
=
win
.
addViewBox
(
name
=
"image view"
)
vb
.
setAspectLocked
()
img
=
pg
.
ImageItem
(
imgData
)
vb
.
addItem
(
img
)
#app.processEvents()
#print "init views match:", viewsMatch()
#p2.setYRange(-300, 300)
#print "setRange views match:", viewsMatch()
#app.processEvents()
#print "setRange views match (after update):", viewsMatch()
#print "--lock aspect--"
#p1.setAspectLocked(True)
#print "lockAspect views match:", viewsMatch()
#p2.setYRange(-200, 200)
#print "setRange views match:", viewsMatch()
#app.processEvents()
#print "setRange views match (after update):", viewsMatch()
#win.resize(100, 600)
#app.processEvents()
#vb.setRange(xRange=[-10, 10], padding=0)
#app.processEvents()
#win.resize(600, 100)
#app.processEvents()
#print vb.viewRange()
if
__name__
==
'__main__'
:
testLinkWithAspectLock
()
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