How to use the diagrams.CNode function in diagrams

To help you get started, we’ve selected a few diagrams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joxeankoret / pyew / plugins / fgraphs.py View on Github external
functions.append(c)
                        
                        n1 = CNode(self.pyew.names[ep], self.pyew.names[ep])
                        n2 = CNode(self.pyew.names[c], self.pyew.names[c])
                        dot.addConnectedNode(n1, n2)
        
        dones = []
        while len(functions) > 0:
            addr = functions.pop()
            f = self.pyew.functions[addr]
            for c in f.connections:
                if c in self.pyew.functions and c not in dones:
                    functions.append(c)
                    dones.append(c)
                    
                    n1 = CNode(self.pyew.names[addr], self.pyew.names[addr])
                    n2 = CNode(self.pyew.names[c], self.pyew.names[c])
                    dot.addConnectedNode(n1, n2)
                    
        x = dot.generateDot()
        return x
github joxeankoret / pyew / plugins / fgraphs.py View on Github external
l = [self.pyew.ep]
        else:
            l = [ep]
        
        functions = []
        
        for ep in l:
            if self.pyew.functions.has_key(ep):
                fep = self.pyew.functions[ep]
                for c in fep.connections:
                    if c in self.pyew.functions:
                        if c not in functions:
                            functions.append(c)
                        
                        n1 = CNode(self.pyew.names[ep], self.pyew.names[ep])
                        n2 = CNode(self.pyew.names[c], self.pyew.names[c])
                        dot.addConnectedNode(n1, n2)
        
        dones = []
        while len(functions) > 0:
            addr = functions.pop()
            f = self.pyew.functions[addr]
            for c in f.connections:
                if c in self.pyew.functions and c not in dones:
                    functions.append(c)
                    dones.append(c)
                    
                    n1 = CNode(self.pyew.names[addr], self.pyew.names[addr])
                    n2 = CNode(self.pyew.names[c], self.pyew.names[c])
                    dot.addConnectedNode(n1, n2)
                    
        x = dot.generateDot()
github joxeankoret / pyew / plugins / fgraphs.py View on Github external
nodes = {}
        for bb in func.basic_blocks:
            instructions = []
            bb_start = bb.instructions[0].offset
            end_offset = bb.instructions[-1].offset
            bb_end = end_offset + bb.instructions[-1].size
            
            buf = self.pyew.getBytes(bb_start, bb_end-bb_start)
            instructions = self.pyew.disassemble(buf=buf, baseoffset=bb_start, marker=False)
            instructions = instructions.replace("\r", "").replace("\n", "\\l")
            instructions = instructions.replace('"', '\"')
            
            bbs[bb_start] = instructions
            bbs[end_offset] = instructions
            
            n = CNode(bb.offset, instructions)
            dot.addNode(n)
            nodes[bb.offset] = n
        
        for bb in func.basic_blocks:
            for conn in bb.connections:
                a, b = conn
                next_head = self.pyew.NextHead(bb.instructions[-1].offset)
                if nodes.has_key(b) and nodes.has_key(bb.offset):
                    if len(bb.connections) == 1:
                        color = "blue"
                    elif next_head == b:
                        color = "red"
                    else:
                        color = "green"
                    
                    dot.addConnectedNode(nodes[bb.offset], nodes[b], color)