DFIRnotes / pyew

Automatically exported from code.google.com/p/pyew
GNU General Public License v2.0
0 stars 0 forks source link

TypeError in pyew/plugins/graphs.py, line 110, in showBinaryImage #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load (as part of bokken) pyew with a binary
2. Click "Visualize binary"
3. Nothing appears in GUI, TypeError traceback appears in console

What is the expected output? What do you see instead?
 Visualization of a binary. The traceback is:

Traceback (most recent call last):
  File "/usr/share/pyshared/bokken/ui/pyew_toolbar.py", line 462, in execute
    self.uicore.execute_plugin(plugin)
  File "/usr/share/pyshared/bokken/ui/core.py", line 522, in execute_plugin
    self.core.plugins[plg[0]](self.core)
  File "/usr/share/pyshared/pyew/plugins/graphs.py", line 110, in showBinaryImage
    img = Image.new("RGB", (size, size), "red")
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1763, in new
    return Image()._new(core.fill(mode, size, color))
TypeError: integer argument expected, got float

What version of the product are you using? On what operating system?
Kali, version as described in pyew.py: 

VERSION=0x01020000
HUMAN_VERSION="1.2.0.0"

Please provide any additional information below.

The issue seems to be the result of a typo. graphs.py contains this code (lines 
108-110):

    buf = pyew.getBuffer()
    size = len(buf)**(1./3)+1
    img = Image.new("RGB", (size, size), "red")

It seems that someone was trying to either trying to type "len(buf)**(1//3)+1" 
or "len(buf)**(1/3)+1", but their finger slipped. The type of "1." is float, a 
float + 1 is also a float, and finally, an int to the power of a float is also 
a float.

Given that BOTH 1/3 and 1//3 evaluate to 0 in python 2.x, I'm more confused, as 
len(buf)**(0+1) == len(buf), why the exponentiation?

Original issue reported on code.google.com by test35...@gmail.com on 10 Apr 2014 at 2:54

GoogleCodeExporter commented 9 years ago
Hi,

Version 1.2.0.0 is veeeeeery old. The current version is:

{{
PROGRAM="PYEW! A Python tool for malware analysis"
VERSION=0x02030000
HUMAN_VERSION="2.3.0.0"
}}

Also, I do not support Bokken myself but, anyway. Could you please try to 
reproduce it with the latest version from the Mercurial repository available 
here: 

https://code.google.com/p/pyew/source/checkout

Thanks!

Original comment by joxean.p...@gmail.com on 11 Apr 2014 at 3:43