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
11a9bcd4
Commit
11a9bcd4
authored
Dec 03, 2018
by
Buddy Vernon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed endianess to endianness.
parent
c55cb3f9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
45 deletions
+45
-45
magic.py
src/binwalk/core/magic.py
+13
-13
filesystems
src/binwalk/magic/filesystems
+1
-1
disasm.py
src/binwalk/modules/disasm.py
+10
-10
dlromfsextract.py
src/binwalk/plugins/dlromfsextract.py
+9
-9
unpfs.py
src/binwalk/plugins/unpfs.py
+12
-12
No files found.
src/binwalk/core/magic.py
View file @
11a9bcd4
...
...
@@ -131,13 +131,13 @@ class SignatureLine(object):
# little endian.
if
self
.
type
.
startswith
(
'be'
):
self
.
type
=
self
.
type
[
2
:]
self
.
endianess
=
'>'
self
.
endian
n
ess
=
'>'
elif
self
.
type
.
startswith
(
'le'
):
self
.
endianess
=
'<'
self
.
endian
n
ess
=
'<'
self
.
type
=
self
.
type
[
2
:]
# Assume big endian if no endianess was explicitly specified
# Assume big endian if no endian
n
ess was explicitly specified
else
:
self
.
endianess
=
'>'
self
.
endian
n
ess
=
'>'
# Check the comparison value for the type of comparison to be performed (e.g.,
# '=0x1234', '>0x1234', etc). If no operator is specified, '=' is implied.
...
...
@@ -237,9 +237,9 @@ class SignatureLine(object):
self
.
fmt
=
self
.
fmt
.
upper
()
# If a struct format was identified, create a format string to be passed to struct.unpack
# which specifies the endianess and data type format.
# which specifies the endian
n
ess and data type format.
if
self
.
fmt
:
self
.
pkfmt
=
'
%
c
%
c'
%
(
self
.
endianess
,
self
.
fmt
)
self
.
pkfmt
=
'
%
c
%
c'
%
(
self
.
endian
n
ess
,
self
.
fmt
)
else
:
self
.
pkfmt
=
None
...
...
@@ -312,7 +312,7 @@ class Signature(object):
# Strings and single byte signatures are taken at face value;
# multi-byte integer values are turned into regex strings based
# on their data type size and endianess.
# on their data type size and endian
n
ess.
if
line
.
type
==
'regex'
:
# Regex types are already compiled expressions.
# Note that since re.finditer is used, unless the specified
...
...
@@ -323,23 +323,23 @@ class Signature(object):
elif
line
.
size
==
1
:
restr
=
chr
(
line
.
value
)
elif
line
.
size
==
2
:
if
line
.
endianess
==
'<'
:
if
line
.
endian
n
ess
==
'<'
:
restr
=
chr
(
line
.
value
&
0xFF
)
+
chr
(
line
.
value
>>
8
)
elif
line
.
endianess
==
'>'
:
elif
line
.
endian
n
ess
==
'>'
:
restr
=
chr
(
line
.
value
>>
8
)
+
chr
(
line
.
value
&
0xFF
)
elif
line
.
size
==
4
:
if
line
.
endianess
==
'<'
:
if
line
.
endian
n
ess
==
'<'
:
restr
=
(
chr
(
line
.
value
&
0xFF
)
+
chr
((
line
.
value
>>
8
)
&
0xFF
)
+
chr
((
line
.
value
>>
16
)
&
0xFF
)
+
chr
(
line
.
value
>>
24
))
elif
line
.
endianess
==
'>'
:
elif
line
.
endian
n
ess
==
'>'
:
restr
=
(
chr
(
line
.
value
>>
24
)
+
chr
((
line
.
value
>>
16
)
&
0xFF
)
+
chr
((
line
.
value
>>
8
)
&
0xFF
)
+
chr
(
line
.
value
&
0xFF
))
elif
line
.
size
==
8
:
if
line
.
endianess
==
'<'
:
if
line
.
endian
n
ess
==
'<'
:
restr
=
(
chr
(
line
.
value
&
0xFF
)
+
chr
((
line
.
value
>>
8
)
&
0xFF
)
+
chr
((
line
.
value
>>
16
)
&
0xFF
)
+
...
...
@@ -348,7 +348,7 @@ class Signature(object):
chr
((
line
.
value
>>
40
)
&
0xFF
)
+
chr
((
line
.
value
>>
48
)
&
0xFF
)
+
chr
(
line
.
value
>>
56
))
elif
line
.
endianess
==
'>'
:
elif
line
.
endian
n
ess
==
'>'
:
restr
=
(
chr
(
line
.
value
>>
56
)
+
chr
((
line
.
value
>>
48
)
&
0xFF
)
+
chr
((
line
.
value
>>
40
)
&
0xFF
)
+
...
...
src/binwalk/magic/filesystems
View file @
11a9bcd4
...
...
@@ -558,7 +558,7 @@
0x10 string ROMFS\x20v D-Link ROMFS filesystem,
>0x17 string x version %s,
>0 string !\x2EmoR
>>0 string !Rom\x2E {invalid} unknown endianess
>>0 string !Rom\x2E {invalid} unknown endian
n
ess
>0 string \x2EmoR little endian,
>>8 lelong x size: <= %d
>>8 lelong-0x20 x {jump:%d}
...
...
src/binwalk/modules/disasm.py
View file @
11a9bcd4
...
...
@@ -51,42 +51,42 @@ class Disasm(Module):
ARCHITECTURES
=
[
Architecture
(
type
=
capstone
.
CS_ARCH_ARM
,
mode
=
capstone
.
CS_MODE_ARM
,
endianess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
description
=
"ARM executable code, 32-bit, big endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_ARM
,
mode
=
capstone
.
CS_MODE_ARM
,
endianess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
description
=
"ARM executable code, 32-bit, little endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_ARM64
,
mode
=
capstone
.
CS_MODE_ARM
,
endianess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
description
=
"ARM executable code, 64-bit, big endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_ARM64
,
mode
=
capstone
.
CS_MODE_ARM
,
endianess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
description
=
"ARM executable code, 64-bit, little endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_PPC
,
mode
=
capstone
.
CS_MODE_BIG_ENDIAN
,
endianess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
description
=
"PPC executable code, 32/64-bit, big endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_MIPS
,
mode
=
capstone
.
CS_MODE_64
,
endianess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
description
=
"MIPS executable code, 32/64-bit, big endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_MIPS
,
mode
=
capstone
.
CS_MODE_64
,
endianess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
description
=
"MIPS executable code, 32/64-bit, little endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_ARM
,
mode
=
capstone
.
CS_MODE_THUMB
,
endianess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_LITTLE_ENDIAN
,
description
=
"ARM executable code, 16-bit (Thumb), little endian"
),
Architecture
(
type
=
capstone
.
CS_ARCH_ARM
,
mode
=
capstone
.
CS_MODE_THUMB
,
endianess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
endian
n
ess
=
capstone
.
CS_MODE_BIG_ENDIAN
,
description
=
"ARM executable code, 16-bit (Thumb), big endian"
),
]
...
...
@@ -99,7 +99,7 @@ class Disasm(Module):
self
.
disasm_data_size
=
self
.
min_insn_count
*
10
for
arch
in
self
.
ARCHITECTURES
:
self
.
disassemblers
.
append
((
capstone
.
Cs
(
arch
.
type
,
(
arch
.
mode
+
arch
.
endianess
)),
arch
.
description
))
self
.
disassemblers
.
append
((
capstone
.
Cs
(
arch
.
type
,
(
arch
.
mode
+
arch
.
endian
n
ess
)),
arch
.
description
))
def
scan_file
(
self
,
fp
):
total_read
=
0
...
...
src/binwalk/plugins/dlromfsextract.py
View file @
11a9bcd4
...
...
@@ -11,7 +11,7 @@ except ImportError as e:
class
RomFSCommon
(
object
):
def
_read_next_word
(
self
):
value
=
struct
.
unpack
(
"
%
sL"
%
self
.
endianess
,
self
.
data
[
self
.
index
:
self
.
index
+
4
])[
0
]
value
=
struct
.
unpack
(
"
%
sL"
%
self
.
endian
n
ess
,
self
.
data
[
self
.
index
:
self
.
index
+
4
])[
0
]
self
.
index
+=
4
return
value
...
...
@@ -49,9 +49,9 @@ class RomFSEntry(RomFSCommon):
DATA_MASK
=
0x00000008
COMPRESSED_MASK
=
0x005B0000
def
__init__
(
self
,
data
,
endianess
=
"<"
):
def
__init__
(
self
,
data
,
endian
n
ess
=
"<"
):
self
.
data
=
data
self
.
endian
ess
=
endia
ness
self
.
endian
ness
=
endian
ness
self
.
index
=
0
self
.
type
=
self
.
_read_next_word
()
...
...
@@ -68,10 +68,10 @@ class RomFSDirStruct(RomFSCommon):
SIZE
=
0x20
def
__init__
(
self
,
data
,
endianess
=
"<"
):
def
__init__
(
self
,
data
,
endian
n
ess
=
"<"
):
self
.
index
=
0
self
.
data
=
data
self
.
endian
ess
=
endia
ness
self
.
endian
ness
=
endian
ness
self
.
directory
=
False
self
.
uid
=
None
self
.
ls
=
[]
...
...
@@ -116,8 +116,8 @@ class RomFS(object):
SUPERBLOCK_SIZE
=
0x20
FILE_ENTRY_SIZE
=
0x20
def
__init__
(
self
,
fname
,
endianess
=
"<"
):
self
.
endian
ess
=
endia
ness
def
__init__
(
self
,
fname
,
endian
n
ess
=
"<"
):
self
.
endian
ness
=
endian
ness
self
.
data
=
open
(
fname
,
"rb"
)
.
read
()
self
.
entries
=
self
.
_process_all_entries
()
...
...
@@ -151,7 +151,7 @@ class RomFS(object):
while
True
:
try
:
entry
=
RomFSEntry
(
self
.
data
[
offset
:
offset
+
self
.
FILE_ENTRY_SIZE
],
endian
ess
=
self
.
endia
ness
)
entry
=
RomFSEntry
(
self
.
data
[
offset
:
offset
+
self
.
FILE_ENTRY_SIZE
],
endian
ness
=
self
.
endian
ness
)
except
ValueError
as
e
:
break
...
...
@@ -166,7 +166,7 @@ class RomFS(object):
if
entry
.
type
&
entry
.
DIR_STRUCT_MASK
:
entries
[
entry
.
uid
]
.
type
=
"directory"
ds
=
RomFSDirStruct
(
self
.
data
[
entry
.
offset
:
entry
.
offset
+
entry
.
size
],
endian
ess
=
self
.
endia
ness
)
ds
=
RomFSDirStruct
(
self
.
data
[
entry
.
offset
:
entry
.
offset
+
entry
.
size
],
endian
ness
=
self
.
endian
ness
)
for
(
uid
,
name
)
in
ds
.
ls
:
if
not
uid
in
entries
:
entries
[
uid
]
=
FileContainer
()
...
...
src/binwalk/plugins/unpfs.py
View file @
11a9bcd4
...
...
@@ -7,27 +7,27 @@ import binwalk.core.plugin
class
PFSCommon
(
object
):
def
_make_short
(
self
,
data
,
endianess
):
def
_make_short
(
self
,
data
,
endian
n
ess
):
"""Returns a 2 byte integer."""
data
=
binwalk
.
core
.
compat
.
str2bytes
(
data
)
return
struct
.
unpack
(
'
%
sH'
%
endianess
,
data
)[
0
]
return
struct
.
unpack
(
'
%
sH'
%
endian
n
ess
,
data
)[
0
]
def
_make_int
(
self
,
data
,
endianess
):
def
_make_int
(
self
,
data
,
endian
n
ess
):
"""Returns a 4 byte integer."""
data
=
binwalk
.
core
.
compat
.
str2bytes
(
data
)
return
struct
.
unpack
(
'
%
sI'
%
endianess
,
data
)[
0
]
return
struct
.
unpack
(
'
%
sI'
%
endian
n
ess
,
data
)[
0
]
class
PFS
(
PFSCommon
):
"""Class for accessing PFS meta-data."""
HEADER_SIZE
=
16
def
__init__
(
self
,
fname
,
endianess
=
'<'
):
self
.
endian
ess
=
endia
ness
def
__init__
(
self
,
fname
,
endian
n
ess
=
'<'
):
self
.
endian
ness
=
endian
ness
self
.
meta
=
binwalk
.
core
.
common
.
BlockFile
(
fname
,
'rb'
)
header
=
self
.
meta
.
read
(
self
.
HEADER_SIZE
)
self
.
file_list_start
=
self
.
meta
.
tell
()
self
.
num_files
=
self
.
_make_short
(
header
[
-
2
:],
endianess
)
self
.
num_files
=
self
.
_make_short
(
header
[
-
2
:],
endian
n
ess
)
self
.
node_size
=
self
.
_get_fname_len
()
+
12
def
_get_fname_len
(
self
,
bufflen
=
128
):
...
...
@@ -42,7 +42,7 @@ class PFS(PFSCommon):
def
_get_node
(
self
):
"""Reads a chunk of meta data from file and returns a PFSNode."""
data
=
self
.
meta
.
read
(
self
.
node_size
)
return
PFSNode
(
data
,
self
.
endianess
)
return
PFSNode
(
data
,
self
.
endian
n
ess
)
def
get_end_of_meta_data
(
self
):
"""Returns integer indicating the end of the file system meta data."""
...
...
@@ -63,12 +63,12 @@ class PFS(PFSCommon):
class
PFSNode
(
PFSCommon
):
"""A node in the PFS Filesystem containing meta-data about a single file."""
def
__init__
(
self
,
data
,
endianess
):
def
__init__
(
self
,
data
,
endian
n
ess
):
self
.
fname
,
data
=
data
[:
-
12
],
data
[
-
12
:]
self
.
_decode_fname
()
self
.
inode_no
=
self
.
_make_int
(
data
[:
4
],
endianess
)
self
.
foffset
=
self
.
_make_int
(
data
[
4
:
8
],
endianess
)
self
.
fsize
=
self
.
_make_int
(
data
[
8
:],
endianess
)
self
.
inode_no
=
self
.
_make_int
(
data
[:
4
],
endian
n
ess
)
self
.
foffset
=
self
.
_make_int
(
data
[
4
:
8
],
endian
n
ess
)
self
.
fsize
=
self
.
_make_int
(
data
[
8
:],
endian
n
ess
)
def
_decode_fname
(
self
):
"""Extracts the actual string from the available bytes."""
...
...
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