binaryanalysisplatform / bap-python Goto Github PK
View Code? Open in Web Editor NEWBAP python bindings
License: MIT License
BAP python bindings
License: MIT License
Hi,
bap
does not have the image
method anymore and I think the page needs to be updated with a new example. Am i right?
Thanks
I'm seeing this warning on Python 3.10:
.../lib/python3.10/site-packages/bap/noeval_parser.py:124: DeprecationWarning: invalid escape sequence '\.'
parent = objs[k] = (in_s[i+1:endpos]).encode('utf-8').decode('unicode_escape')
Hi all,
I really enjoy using BAP, but I encountered some bugs today while using SSA pass. I attached the minimal reproducible source code and the compiled binary.
phi.zip
Configurations:
I invoked BAP with: bap.run('a.out', args=['--pass=ssa'])
and got
Traceback (most recent call last):
File "./run.py", line 14, in <module>
proj = bap.run(args.filename, args=['--pass=ssa'])
File "[truncated]/lib/python3.5/site-packages/bap/bap.py", line 124, in run
return parser['load'](out)
File "[truncated]/lib/python3.5/site-packages/bap/bir.py", line 369, in loads
return noeval_parser.parser(s)
File "[truncated]/lib/python3.5/site-packages/bap/noeval_parser.py", line 328, in parser
result = _parser(input_str, logger=logger)
File "[truncated]/lib/python3.5/site-packages/bap/noeval_parser.py", line 282, in _parser
i = parse_func(in_c, in_s, i, objs, stk)
File "[truncated]/lib/python3.5/site-packages/bap/noeval_parser.py", line 207, in _parse_end
parent = objs[j] = getattr(bir, name)(*parent.get('children', ())) # pylint: disable=redefined-variable-type
File "[truncated]/lib/python3.5/site-packages/bap/adt.py", line 509, in __init__
self.elements = dict((x.arg[0],x.arg[1]) for x in args[0])
File "[truncated]/lib/python3.5/site-packages/bap/adt.py", line 509, in <genexpr>
self.elements = dict((x.arg[0],x.arg[1]) for x in args[0])
AttributeError: 'tuple' object has no attribute 'arg'
After examing the traceback and your source code, I believe it's either a bug in SSA pass that outputs malformed ADT string or a bug of the parser that fails to handle tuples.
Use bap.noeval_parser.parser
to parse
Phi(Tid(0x00000237, "%00000237"), Attrs([]), Var("RBX.2",Imm(64)), Values([(Tid(0x00000049, "%00000049"),Var("RBX.1",Imm(64))),(Tid(0x0000005a, "%0000005a"),Var("RBX.3",Imm(64)))]))
can reproduce the bug. The string is a part of output from SSA pass that caused the problem (Values([(Tid(0x00000049, "%00000049"),Var("RBX.1",Imm(64))),(Tid(0x0000005a, "%0000005a"),Var("RBX.3",Imm(64)))])
is the root cause, Values should contain a list of ADT objects rather than a list of tuples).
I already sent a pull request #11 that contains a quick workaround on the bap-python side.
Following the setup instructions, running opam install bap-server
and building from source (after figuring out LLVM dependencies, etc):
bap-server
uses ~/.opam/system/bin/bap
. This binary is version 1.4.0
, quite old..deb
packages on the system doesn't change the version used by bap-server
, I think.How can I configure the Python bindings to use a current BAP version through bap-server
? Maybe bap-server
can be added to the Debian releases, since it's a bit challenging to build?
adt.py
seems to be missing an import for bap.bir.Tid
, so an attempt at using find
with a key of that type fails (such as the simple example on the main page)
I got the following error while executing bap.run on a node binary. I was told on bap forum that it is a bug in bap:
Traceback (most recent call last):
File "extract_bpir.py", line 406, in
main()
File "extract_bpir.py", line 402, in main
proj = bap.run(sys.argv[1], ['--no-byteweight'])
File "/usr/local/lib/python2.7/dist-packages/bap/bap.py", line 124, in run
return parser'load'
File "/usr/local/lib/python2.7/dist-packages/bap/bir.py", line 367, in loads
return noeval_parser.parser(s)
File "/usr/local/lib/python2.7/dist-packages/bap/noeval_parser.py", line 328, in parser
result = _parser(input_str, logger=logger)
File "/usr/local/lib/python2.7/dist-packages/bap/noeval_parser.py", line 291, in _parser
assert len(stk) == 1
AssertionError
Currently setup.py
explicitly requires python2.7. Many distributions remove python 2 packages. Would be nice to kill it finally in favor of Python 3.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.