angr/claripy

If I want to add new content to Claripy, is there a way not to modify its original code file?

Closed this issue · 9 comments

I want to add a load to represent the value loaded from memory, such as <Load (esp)>. Is there a suitable way to achieve this without changing the Claripy source code?

Use Annotations to annotate a BVV or BVS.

@ltfish Sorry, I do n’t quite understand what you mean, can you give an example? Thank you.

class YourOwnAnnotation(claripy.Annotation):
    # all ASTs annotated by this annotation are values loaded from [esp]
    def __init__(self):
        pass

    def eliminatable(self):
        # return True or False based on your needs

    def relocatable(self):
        # return True or False based on your needs


value = state.memory.load(state.regs.esp, 4)
value = value.annotate(YourOwnAnnotation())
# now your value is annotated. you can access its annotations by value.annotations

Here are some test cases in terms of how to use Annotations: https://github.com/angr/claripy/blob/master/tests/test_annotations.py

@ltfish When performing an operation, will there be Annotation with elements in the operation result? For example, <BVS a> + <BVS b>, where <BVS a> has Annotation, then does the result have Annotation? I have observed before using it, in some cases the result will also have Annotation, in some cases it will not, what is the specific impact?

then does the result have Annotation?

This is what relocatable is for. See angr API doc.

I have observed before using it, in some cases the result will also have Annotation, in some cases it will not, what is the specific impact?

It's probably a bug. I know that If() will cause a loss of annotations, and that's something that we have fixed in another branch. I just need to push the student to submit a PR for that.

@ltfish Thank you for your patience.

This issue has been marked as stale because it has no recent activity. Please comment or add the pinned tag to prevent this issue from being closed.

This issue has been closed due to inactivity.