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
14eda44c
Commit
14eda44c
authored
Jan 10, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added binwalk.common.core.debug function
parent
9a5a7237
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
C.py
src/binwalk/core/C.py
+4
-3
common.py
src/binwalk/core/common.py
+11
-0
magic.py
src/binwalk/core/magic.py
+6
-1
No files found.
src/binwalk/core/C.py
View file @
14eda44c
...
...
@@ -22,8 +22,8 @@ class FunctionHandler(object):
'''
PY2CTYPES
=
{
bytes
:
ctypes
.
c_char_p
,
str
:
ctypes
.
c_char_p
,
int
:
ctypes
.
c_int
,
str
:
ctypes
.
c_char_p
,
int
:
ctypes
.
c_int
,
float
:
ctypes
.
c_float
,
bool
:
ctypes
.
c_int
,
None
:
ctypes
.
c_int
,
...
...
@@ -47,8 +47,9 @@ class FunctionHandler(object):
Returns None.
'''
self
.
name
=
function
.
name
self
.
retype
=
function
.
type
self
.
function
=
getattr
(
library
,
function
.
name
)
self
.
function
=
getattr
(
library
,
self
.
name
)
if
has_key
(
self
.
PY2CTYPES
,
self
.
retype
):
self
.
function
.
restype
=
self
.
PY2CTYPES
[
self
.
retype
]
...
...
src/binwalk/core/common.py
View file @
14eda44c
...
...
@@ -3,6 +3,7 @@
import
io
import
os
import
re
import
sys
import
ast
import
hashlib
import
operator
as
op
...
...
@@ -14,6 +15,16 @@ if has_key(__builtins__, 'BLOCK_FILE_PARENT_CLASS'):
else
:
BLOCK_FILE_PARENT_CLASS
=
io
.
FileIO
def
debug
(
msg
):
'''
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
'''
# The __debug__ value is a bit backwards; by default it is set to True, but
# then set to False if the Python interpreter is run with the -O option.
if
not
__debug__
:
sys
.
stderr
.
write
(
"DEBUG: "
+
msg
+
"
\n
"
)
sys
.
stderr
.
flush
()
def
file_md5
(
file_name
):
'''
Generate an MD5 hash of the specified file.
...
...
src/binwalk/core/magic.py
View file @
14eda44c
import
binwalk.core.C
import
binwalk.core.common
from
binwalk.core.compat
import
*
class
Magic
(
object
):
...
...
@@ -26,11 +27,15 @@ class Magic(object):
self
.
magic_file
=
str2bytes
(
magic_file
)
else
:
self
.
magic_file
=
None
self
.
libmagic
=
binwalk
.
core
.
C
.
Library
(
"magic"
,
self
.
LIBMAGIC_FUNCTIONS
)
binwalk
.
core
.
common
.
debug
(
"libmagic.magic_open(0x
%
X)"
%
(
self
.
MAGIC_FLAGS
|
flags
))
self
.
magic_cookie
=
self
.
libmagic
.
magic_open
(
self
.
MAGIC_FLAGS
|
flags
)
binwalk
.
core
.
common
.
debug
(
"libmagic.magic_load(0x
%
X,
%
s)"
%
(
self
.
magic_cookie
,
self
.
magic_file
))
self
.
libmagic
.
magic_load
(
self
.
magic_cookie
,
self
.
magic_file
)
binwalk
.
core
.
common
.
debug
(
"libmagic loaded OK!"
)
def
close
(
self
):
if
self
.
magic_cookie
:
...
...
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