joxeankoret / pigaios

A tool for matching and diffing source codes directly against binaries.
GNU General Public License v3.0
634 stars 67 forks source link

Python3 `long` doesn't exist anymore #17

Closed ekaitz-zarraga closed 5 years ago

ekaitz-zarraga commented 5 years ago

long type does not exist in python3: It uses int.

http://python3porting.com/differences.html#long

(Working on a patch)

cclauss commented 5 years ago

Please add __raw_input(), reload(), and xrange()__ to the list.

flake8 testing of https://github.com/joxeankoret/pigaios on Python 3.7.1

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./sourceimp_core.py:22:3: F821 undefined name 'reload'
  reload(pigaios_ml)
  ^
./sourceimp_core.py:160:42: F821 undefined name 'long'
      elif type(src_row[field]) in [int, long]:
                                         ^
./sourceimp_core.py:247:42: F821 undefined name 'long'
      elif type(src_row[field]) in [int, long]:
                                         ^
./sourceimp_core.py:430:19: F821 undefined name 'long'
        func_ea = long(row[0])
                  ^
./sourceimp_core.py:479:17: F821 undefined name 'long'
      func_ea = long(row[0])
                ^
./sourceimp_core.py:638:43: F821 undefined name 'long'
            log(msg % (call_type, src_id, long(bin_ea), row["name"], len(bin_rows) * len(src_rows)))
                                          ^
./sourceimp_core.py:650:34: F821 undefined name 'long'
                  self.add_match(long(src_row[call_type]), bin_row[call_type],
                                 ^
./sourceimp_core.py:664:18: F821 undefined name 'long'
        bin_id = long(row["id"])
                 ^
./sourceimp_core.py:755:46: F821 undefined name 'long'
      bin_func_name = self.get_function_name(long(ea))
                                             ^
./sourceimp_ida.py:20:1: F821 undefined name 'reload'
reload(sourceimp_core)
^
./exporters/base_support.py:71:12: F821 undefined name 'xrange'
  for i in xrange(64):
           ^
./exporters/SimpleEval.py:112:14: F821 undefined name 'long'
      tmp1 = long(val1)
             ^
./exporters/SimpleEval.py:113:14: F821 undefined name 'long'
      tmp2 = long(val2)
             ^
./exporters/SimpleEval.py:117:14: F821 undefined name 'long'
      tmp1 = long(val1)
             ^
./exporters/SimpleEval.py:118:14: F821 undefined name 'long'
      tmp2 = long(val2)
             ^
./exporters/SimpleEval.py:122:14: F821 undefined name 'long'
      tmp1 = long(val1)
             ^
./exporters/SimpleEval.py:123:14: F821 undefined name 'long'
      tmp2 = long(val2)
             ^
./exporters/SimpleEval.py:127:14: F821 undefined name 'long'
      tmp1 = long(val1)
             ^
./exporters/SimpleEval.py:128:14: F821 undefined name 'long'
      tmp2 = long(val2)
             ^
./exporters/SimpleEval.py:160:15: F821 undefined name 'long'
      token = long(token, 16)
              ^
./exporters/SimpleEval.py:162:15: F821 undefined name 'long'
      token = long(token, 8)
              ^
./exporters/SimpleEval.py:249:11: F821 undefined name 'raw_input'
    cmd = raw_input("C expr> ")
          ^
./ml/pigaios_create_dataset.py:138:49: F821 undefined name 'long'
      elif type(row["src_%s" % field]) in [int, long]:
                                                ^
23    F821 undefined name 'long'
23
ekaitz-zarraga commented 5 years ago

Maybe open a full Python3 compatibility issue for that?

joxeankoret commented 5 years ago

The problem is that only parts of it could be ported to Python 3.X as, for example, IDA doesn't support Python 3 and the Python clang bindings, in my testing, didn't properly support either.

cclauss commented 5 years ago

Let's make sure that this codebase is Python 3 ready. That will give us more momentum to push any dependencies to also make the conversion.

joxeankoret commented 5 years ago

It was fixed some commits ago.

cclauss commented 5 years ago

When run on Python 3, flake8 still reports 2 syntax errors (print statements) and 22 undefined names.