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-gitdep
binwalk
Commits
f0a45644
Commit
f0a45644
authored
Jan 27, 2016
by
Craig Heffner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added guid type field (Python2 only)
parent
78f22c77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
magic.py
src/binwalk/core/magic.py
+42
-0
No files found.
src/binwalk/core/magic.py
View file @
f0a45644
...
@@ -143,6 +143,12 @@ class SignatureLine(object):
...
@@ -143,6 +143,12 @@ class SignatureLine(object):
self
.
condition
=
'='
self
.
condition
=
'='
self
.
value
=
parts
[
2
]
self
.
value
=
parts
[
2
]
# If a GUID was specified, convert it to a string and treat the
# signature as a string from here on out.
if
self
.
type
==
'guid'
:
self
.
value
=
self
.
_guid2str
(
self
.
value
)
self
.
type
=
'string'
# If this is a wildcard value, explicitly set self.value to None
# If this is a wildcard value, explicitly set self.value to None
if
self
.
value
==
'x'
:
if
self
.
value
==
'x'
:
self
.
value
=
None
self
.
value
=
None
...
@@ -256,6 +262,42 @@ class SignatureLine(object):
...
@@ -256,6 +262,42 @@ class SignatureLine(object):
else
:
else
:
self
.
format
=
""
self
.
format
=
""
def
_guid2str
(
self
,
guid
):
'''
Converts a GUID formatted string to a raw byte string in the appropriate endianess.
'''
string
=
""
# Loop through each hyphen separated section of the GUID string
# e.g., "7A9354D9-0468-444A-81CE0BF617D890D" => ['7A9354D9', '0468', '444A', '81CE0BF617D890D']
guid_parts
=
guid
.
split
(
'-'
)
for
n
in
range
(
0
,
len
(
guid_parts
)):
guid_part
=
guid_parts
[
n
]
# Parse out each 2 byte value from the guid_part string,
# e.g., "0A1034" => ["0A", "10", "34"]
guid_bytes
=
[
guid_part
[
i
:
i
+
2
]
for
i
in
range
(
0
,
len
(
guid_part
),
2
)]
# If guid is stored little endian, flip the byte order of all parts
# except for the last eight bytes:
#
# typedef struct {
# unsigned long Data1;
# unsigned short Data2;
# unsigned short Data3;
# byte Data4[8];
# } GUID;
if
self
.
endianess
==
'<'
and
n
!=
(
len
(
guid_parts
)
-
1
):
guid_bytes
=
[
x
for
x
in
reversed
(
guid_bytes
)]
# Convert each ASCII hex byte to a character and append it to self.value
for
guid_byte
in
guid_bytes
:
string
+=
chr
(
int
(
guid_byte
,
16
))
#import binascii
#print ("Converted '%s' => '%s'" % (guid, binascii.hexlify(binwalk.core.compat.str2bytes(string))))
return
string
class
Signature
(
object
):
class
Signature
(
object
):
'''
'''
Class to hold signature data and generate signature regular expressions.
Class to hold signature data and generate signature regular expressions.
...
...
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