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

patch for python 3.10, LLVM-14, IDA 7.7 #38

Closed TyeYeah closed 1 year ago

TyeYeah commented 1 year ago

Here I set up env: kali-rolling, python 3.10, LLVM-14, IDA 7.7, operated according to README and met some errors. Most errors come from changes between py2 and py3, like library/API name changing, and misuse of bytes/str. Some are only found by --no-parallel and removing "try-catch" to test, like SQLite connection cannot be pickled for parallel in py3.

I modified each place reporting error, migrating to py3 and removed codes supporting py2, not sure if it is ok. This patch works in my env to generate sbd.project and *.sqlite, and available for matching:

$ python srcbindiff.py -create
Project file 'sbd.project' already exists.

$ python srcbindiff.py --no-parallel -export    # parallel also work
[i] Removing existing file zlib-1.2.13.sqlite
[+] CC contrib/blast/blast.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -..
[+] CC contrib/infback9/infback9.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include..
[+] CC contrib/infback9/inftree9.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include..
[+] CXX contrib/iostream/test.cpp -I/usr/lib/llvm-14/lib/clang/14.0.6/include ..
contrib/iostream/zfstream.h:5,10: fatal: 'fstream.h' file not found
[+] CXX contrib/iostream/zfstream.cpp -I/usr/lib/llvm-14/lib/clang/14.0.6/incl..
contrib/iostream/zfstream.h:5,10: fatal: 'fstream.h' file not found
[+] CXX contrib/iostream2/zstream_test.cpp -I/usr/lib/llvm-14/lib/clang/14.0.6..
contrib/iostream2/zstream.h:27,10: fatal: 'strstream.h' file not found
[+] CXX contrib/iostream3/test.cc -I/usr/lib/llvm-14/lib/clang/14.0.6/include ..
[+] CXX contrib/iostream3/zfstream.cc -I/usr/lib/llvm-14/lib/clang/14.0.6/incl..
[+] CC contrib/minizip/ioapi.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I...
[+] CC contrib/minizip/iowin32.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -..
contrib/minizip/iowin32.h:14,10: fatal: 'windows.h' file not found
[+] CC contrib/minizip/miniunz.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -..
[+] CC contrib/minizip/minizip.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -..
[+] CC contrib/minizip/mztools.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -..
[+] CC contrib/minizip/unzip.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I...
[+] CC contrib/minizip/zip.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -..
[+] CC contrib/puff/puff.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I...
[+] CC contrib/puff/pufftest.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I...
[+] CC contrib/testzlib/testzlib.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include..
contrib/testzlib/testzlib.c:3,10: fatal: 'windows.h' file not found
[+] CC contrib/untgz/untgz.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -..
contrib/untgz/untgz.c:277,7: warning: implicit declaration of function 'chmod'..
contrib/untgz/untgz.c:341,7: warning: implicit declaration of function 'mkdir'..
contrib/untgz/untgz.c:659,11: warning: incompatible pointer types assigning to..
contrib/untgz/untgz.c:665,18: warning: incompatible pointer types passing 'gzF..
[+] CC examples/enough.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./i..
[+] CC examples/fitblk.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./i..
[+] CC examples/gun.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./incl..
[+] CC examples/gzappend.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I...
[+] CC examples/gzjoin.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./i..
[+] CC examples/gzlog.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./in..
[+] CC examples/gznorm.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./i..
[+] CC examples/zpipe.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./in..
[+] CC examples/zran.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./inc..
[+] CC test/example.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./incl..
[+] CC test/infcover.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./inc..
[+] CC test/minigzip.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./inc..
[+] CC adler32.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC compress.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC crc32.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC deflate.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC gzclose.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC gzlib.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC gzread.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC gzwrite.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC infback.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC inffast.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC inflate.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC inftrees.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC trees.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC uncompr.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC ztest19.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] CC zutil.c -I/usr/lib/llvm-14/lib/clang/14.0.6/include -I. -I./include
[+] Building definitions...
[+] Building the callgraphs...
[+] Building the constants table...
[+] Creating indexes...

4 warning(s), 0 error(s), 5 fatal error(s)

I also tested on Windows and failed, will keep trying and find more testcases. Hope this help.

joxeankoret commented 1 year ago

Hi! Thank you very much! I will take a look and check it and merge if everything goes ok.

joxeankoret commented 1 year ago

There are some more things to patch here, after a bit of testing:

I will need some more days.

TyeYeah commented 1 year ago

Thanks for following up, and truly more tests are needed.

It also reminds me that (●∀●), my test runs on linux IDA 7.6, instead of IDA 7.7 on my windows that failed some tests.

As IDA api changes between different versions, maybe this commit can be a temporary branch.