Giter VIP home page Giter VIP logo

bap-python's Issues

Documentation outdated

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

Error while executing bap.run

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

nodeO2.tar.gz

DeprecationWarning in noeval_parser on Python 3.10

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')

How to use with current BAP, e.g. v2.2 or higher?

Following the setup instructions, running opam install bap-server and building from source (after figuring out LLVM dependencies, etc):

  • It seems bap-server uses ~/.opam/system/bin/bap. This binary is version 1.4.0, quite old.
  • Installing the latest release .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?

Parsing Error for ADT Output with SSA Pass

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:

  • OS: Debian 9.9
  • BAP: 1.6.0
  • bap-python: 1.3.1

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.

Missing small imports in adt.py

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.