Open Disane opened 9 years ago
The DEX template is actually the one I am currently working through - it brings up a lot of interesting behaviors in 010 editor that I hadn't initially thought of (#17, #13, #8 (not so much an error, but I had to implement #3 to get it to work), and a few more).
Could you provide the dex file you're parsing? I'm assuming you're just using the standard DEXTemplate.bt from 010's template archive?
Hi, The classes.dex was recovered from a malware sample that encrypted it and embedded it in its assets. It's a chinese AD library if I understood it correctly:
http://www.filedropper.com/classes
MD5: 9d8f9f88e08c790dc949b85416d9794a
Yes, I'm using the standard DEXTemplate.bt found here: http://www.sweetscape.com/010editor/templates/
I've opened #18 to address the issue
I'd suggest using the more up to date DEXTemplate.bt from my repository. 010Editor staff doesn't seem to like updating things on their web site and also does not want to do links to repos. This one will be the most up to date and contain bug fixes;
https://github.com/strazzere/010Editor-stuff/blob/master/Templates/DEXTemplate.bt
Thanks! I'm still going to work on getting the 010 editor DEXTemplate.bt to work; it has a lot of interesting cases that I need to work through with pfp.
With the latest version of pfp:
python -m pfp -t DEX.bt ~/Downloads/classes.dex
Traceback (most recent call last):
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 996, in _run
res = self._handle_node(self._ast, None, None, self._stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1148, in _handle_file_ast
self._handle_node(child, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1370, in _handle_decl
field._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 57, in _pfp__init
super(self.__class__, self)._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 150, in _pfp__init
self._pfp__interp._handle_node(decls, ctxt=self, stream=stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1667, in _handle_struct_decls
self._handle_node(decl, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1374, in _handle_decl
stream, metadata_processor=metadata_processor
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 196, in __init__
metadata_processor=metadata_processor,
File "/home/james/__ws__/dev/pfp/pfp/fields.py", line 1974, in __init__
self._pfp__parse(stream, save_offset=True)
File "/home/james/__ws__/dev/pfp/pfp/fields.py", line 2113, in _pfp__parse
field = self.field_cls(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 147, in __init__
self._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 150, in _pfp__init
self._pfp__interp._handle_node(decls, ctxt=self, stream=stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1667, in _handle_struct_decls
self._handle_node(decl, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2317, in _handle_if
return self._handle_node(node.iftrue, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2186, in _handle_compound
self._handle_node(child, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1370, in _handle_decl
field._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 150, in _pfp__init
self._pfp__interp._handle_node(decls, ctxt=self, stream=stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1667, in _handle_struct_decls
self._handle_node(decl, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2317, in _handle_if
return self._handle_node(node.iftrue, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2186, in _handle_compound
self._handle_node(child, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1370, in _handle_decl
field._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 57, in _pfp__init
super(self.__class__, self)._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 150, in _pfp__init
self._pfp__interp._handle_node(decls, ctxt=self, stream=stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1667, in _handle_struct_decls
self._handle_node(decl, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2343, in _handle_for
self._handle_node(node.stmt, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2186, in _handle_compound
self._handle_node(child, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1370, in _handle_decl
field._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 57, in _pfp__init
super(self.__class__, self)._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 150, in _pfp__init
self._pfp__interp._handle_node(decls, ctxt=self, stream=stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1667, in _handle_struct_decls
self._handle_node(decl, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1370, in _handle_decl
field._pfp__init(stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 150, in _pfp__init
self._pfp__interp._handle_node(decls, ctxt=self, stream=stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1667, in _handle_struct_decls
self._handle_node(decl, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2317, in _handle_if
return self._handle_node(node.iftrue, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2186, in _handle_compound
self._handle_node(child, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 2314, in _handle_if
cond = self._handle_node(node.cond, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1105, in _handle_node
res = self._node_switch[node.__class__](node, scope, ctxt, stream)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1839, in _handle_binary_op
res = switch[node.op](left_val, right_val)
File "/home/james/__ws__/dev/pfp/pfp/interp.py", line 1821, in <lambda>
">": lambda x, y: x > y,
File "/home/james/__ws__/dev/pfp/pfp/fields.py", line 610, in __gt__
return self._pfp__value > val
AttributeError: 'Array' object has no attribute '_pfp__value'
Using the DEX template from 010 and the classes.dex from google/enjarify
Hi,
I've noticed that when trying to use the DEX template, PFP yields a no attribute error on an 'Array'. I used the following template: http://www.sweetscape.com/010editor/templates/files/DEXTemplate.bt
Is there a possibility for you to add DEX binary template support to PFP?
In [2]: dom = pfp.parse(data_file='/mnt/hgfs//classes.dex', template_file='/mnt/hgfs//DEXTemplate.bt')---------------------------------------------------------------------------
PfpError Traceback (most recent call last)