Comments (1)
Hi, sorry for my late answer!
Unfortunatelly I don't follow angr since 3 years, but as far as I know, DDG is deprecated or at least buggy. Thats why I removed the DDG samples from this repository.
Anyhow, I've looked up the script (see at the end of the message) from git history, what I've used to generate DDG graphs back in 2016, made some changes to it, to work with the current angr version, but all the graphs it produces are empty. I've checked ddg.graph.nodes()
, which produced 0 result, so in this case the problem is not with visualization, but with DDG itself.
As far as I know, in the current angr there are better solutions provided which you could use to extract these kind of dependencies. Try to check ReachingDefinitionsAnalysis (which I think can produce a UseDefGraph), VariableRecovery, LightEngine in angr, or ask on the official slack channel what they propose/use instead of DDG.
Here is the script:
#! /usr/bin/env python
import angr
from angrutils import plot_cfg, plot_ddg_stmt, plot_ddg_data
from angr.sim_variable import SimMemoryVariable, SimStackVariable, SimRegisterVariable
def analyze(b, addr, name=None):
start_state = b.factory.blank_state(addr=addr)
start_state.stack_push(0x0)
cfg = b.analyses.CFGEmulated(fail_fast=True, starts=[addr], initial_state=start_state, context_sensitivity_level=2, keep_state=True, call_depth=100, normalize=True)
plot_cfg(cfg, "%s_cfg" % (name), asminst=True, vexinst=True, debug_info=False, remove_imports=True, remove_path_terminator=True)
ddg = b.analyses.DDG(cfg=cfg)
plot_ddg_stmt(ddg.graph, "%s_ddg_stmt" % name, project=b)
ddg._build_function_dependency_graphs()
for k,v in ddg._function_data_dependencies.items():
plot_ddg_stmt(v, "%s_fdg_stmt_%x" % (name, k.addr), project=b)
plot_ddg_data(ddg.data_graph, "%s_ddg_data" % name, project=b)
plot_ddg_data(ddg.simplified_data_graph, "%s_ddg_simplified_data" % name, project=b)
for node in ddg.simplified_data_graph.nodes:
if node.initial:
label = None
if isinstance(node.variable, SimStackVariable):
label = "stack_%s_%x" % (node.variable.base, node.variable.offset)
elif isinstance(node.variable, SimMemoryVariable):
label = "mem_"+hex(node.variable.addr)
elif isinstance(node.variable, SimRegisterVariable):
label = "reg_"+b.arch.register_names[node.variable.reg]
else:
raise NotImplementedError(type(node.variable))
subgraph = ddg.data_sub_graph(node, simplified=False, killing_edges=True)
plot_ddg_data(subgraph, "%s_ddg_subgraph_%s" % (name, label), format="png", project=b)
if __name__ == "__main__":
proj = angr.Project("../samples/simple1", load_options={'auto_load_libs':False})
main = proj.loader.main_object.get_symbol("main")
analyze(proj, main.rebased_addr, "simple1")
Here you can check what kind of graphs it produced:
https://github.com/axt/angr-utils/tree/bc0e701e4f643cb8ea32e1393e043060f4f874c4/examples/plot_ddg
from angr-utils.
Related Issues (20)
- plot_cfg not working HOT 3
- how to speed up cfg_path HOT 1
- Getting error while running examples HOT 5
- WARNING | 2018-07-16 17:19:33,677 | angr.analyses.disassembly_utils | Your version of capstone does not support MIPS instruction groups. HOT 2
- No module named "expr" HOT 3
- Multiple duplicated CFG in a graph HOT 2
- RuntimeError when running angrutils.plot_ddg_data(ddg.simplified_data_graph, xxx) HOT 2
- Getting VEX-IR of a function HOT 1
- Save CFG to a file instead of rendering in new window HOT 2
- plot_cfg(): Plotted CFG is not readable HOT 2
- Are there limitations to plot_cfg()? HOT 2
- can't generate graph HOT 1
- Is there a way to walk a dissasembly graph? HOT 2
- graph is not getting generated HOT 1
- No module named 'angrutils' HOT 1
- plot_ CFG cannot draw disassembly code HOT 8
- AttributeError: 'XRef' object has no attribute 'sort' HOT 5
- I got an error when I was import angr HOT 3
- Regarding CFG construction HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angr-utils.