Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OAES example #49

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions examples/OAES/OAES_x86.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def generate_targetf():
e = rainbow_x86(trace_config=TraceConfig(register=HammingWeight(), mem_value=Identity()))
e = rainbow_x86(trace_config=TraceConfig(register=HammingWeight(), mem_value=Identity(), instruction=True, mem_address=Identity()))
e.load("libnative-lib_x86.so")
e.setup()

Expand All @@ -25,9 +25,13 @@ def targetf(inp, length):
e[e.STACK_ADDR + 4] = 0xBADC0FE0
e[e.STACK_ADDR + 8] = 0xA5A5A5A5
e.start(e.functions[target_func], 0, count=length)

return [event["register"] if event["type"] == "reg" else event["mem_value"] for event in e.trace]

trace_data = []
for event in e.trace:
if "register" in event.keys():
trace_data.append(event["register"])
elif "value" in event.keys():
trace_data.append(event["value"])
return trace_data
return e, targetf


Expand Down Expand Up @@ -58,9 +62,17 @@ def get_traces(targetf, nb, nb_samples):


if __name__ == "__main__":
_, func = generate_targetf()
e, func = generate_targetf()
values, traces = get_traces(func, 10, 1000000)

t = TraceBatchContainer(traces, values)
s = Session(t)
s.run()

trace_ins = []
for event in e.trace:
if "instruction" in event.keys():
trace_ins.append(event["instruction"])

from rainbow.utils.plot import viewer
viewer(trace_ins, s["var"].finalize())