• 大小: 31.46MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-30
  • 语言: 其他
  • 标签: attackgraph  

资源简介

里面是一个贝叶斯攻击图源代码,内容很全,里面是一个贝叶斯攻击图源代码,内容很全,

资源截图

代码片段和文件信息

#-*- coding:utf-8 -*-
import xml.etree.ElementTree as ET
import networkx as nx
import json

#读取xml文件
def xmlpython(xml1n):
    xml2=open(xml1).read()
    G=create_graph(xml2n)  
    return G
#This Place should have any change
def create_graph(xml1n):
    G=nx.DiGraph()      #创建有向图      
    H=nx.DiGraph()      #创建存储父节点的图
    root=ET.fromstring(xml1)    #获取xml的根节点
    G=first_node(Groot)    #存储第一个点
    i=1
    ip1=G.node[1][‘ip‘]
    com1=G.node[1][‘com‘]
    G=post_node(GHirootn)
    return G

def post_node(GHirootn):
    d=i
    ip2=G.node[i][‘ip‘]
    com2=G.node[i][‘com‘]
    H.add_node(iip=ip2com=com2)       #将自身当做父节点存入H图中
    for vid1 in root.findall(‘./vid‘):  #遍历vid元素,查找ip
        lenH=H.nodes()
        if len(lenH)==n:        #判断父节点个数是否超过限定    
            break
        ip1=vid1.get(‘ip‘)      #获取vid的ip
        for attack1 in vid1.findall(‘./attack‘):    #遍历attack元素,查找攻击
            b=0
            c=0
            pr1=attack1.find(‘./pr‘).text
            post1=attack1.find(‘./post‘).text

            for x in H.nodes():     #如果后果点在父节点中,就返回
                if H.node[x][‘ip‘]==ip1 and post1 in H.node[x][‘com‘]:
                    b=1
                    break
            if b==1:
                continue

            for x in G.nodes():     #如果后果点在G图中,就直接建立边
                if G.node[x][‘ip‘]==ip1 and post1 in G.node[x][‘com‘]:
                    G.add_edge(dxpr=pr1)
                    c=1
                    break

            if c==1:
                continue
            else:
                if post1==‘root‘:
                    post2=[‘root‘‘user‘‘login‘‘access‘]
                elif post1==‘user‘:
                    post2=[‘user‘‘login‘‘access‘]
                elif post1==‘login‘:
                    post2=[‘login‘‘access‘]
                elif post1==‘access‘:
                    post2=[‘access‘]
                G.add_node(i+1ip=ip1com=post2)
                G.add_edge(di+1pr=pr1)
                i=i+1
                
                G=post_node(GHirootn)
                                    
    H.remove_node(d)
    return G

#输入第一个攻击点
def first_node(G1root):
    ip1=‘192.168.1.101‘
    pr1=‘0.5‘
    post1=‘root‘

    #判断权限包含关系
    if post1==‘root‘:
        post1=[‘root‘‘user‘‘login‘‘access‘]
    if post1==‘user‘:
        post1=[‘user‘‘login‘‘access‘]
    if post1==‘login‘:
        post1=[‘login‘‘access‘]
    if post1==‘access‘:
        post1=[‘access‘]
    G1.add_node(1ip=ip1com=post1)
    return G1
    

if __name__ == ‘__main__‘:
    n=raw_input(‘输入单一路径的最大节点数:‘)
    G=xmlpython(‘exploit.xml‘n)
    
    way1=raw_input(‘输入生成G.node的json文件的路径,不包括文件名:‘)
    f=open(way1+‘G.node.json‘‘w‘)
    f.write(json.dumps(G.node))
    f.close()
    way2=raw_input(‘输入生成G.edge的json文件的路径,不包括文件名:‘)
    f=open(way2+‘G.edge.json‘‘w‘)
    f.write(json.dumps(G.edge))
    f.close()

    print “生成的 G.node:“
    print G.node

    print “生成的 G.edge:“
    print G.edge
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-10-08 07:50  IBAG-master\
     目录           0  2014-10-08 07:50  IBAG-master\AG_Generation\
     文件        3307  2014-10-08 07:50  IBAG-master\AG_Generation\AG-generate.py
     文件        6142  2014-10-08 07:50  IBAG-master\AG_Generation\AG-generate_Revised.py
     文件         383  2014-10-08 07:50  IBAG-master\AG_Generation\G.edge.json
     文件         803  2014-10-08 07:50  IBAG-master\AG_Generation\G.node.json
     文件         198  2014-10-08 07:50  IBAG-master\AG_Generation\HostPrilvage.py
     文件         405  2014-10-08 07:50  IBAG-master\AG_Generation\HostPrilvage.pyc
     目录           0  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\
     文件        2753  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\2bgal_sql_injection.nasl
     文件        3910  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\2x_applicationserver_activex_file_overwrite.nasl
     文件        4648  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\2x_tuxclientsystem_activex_installclient.nasl
     文件        2803  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3com_3cserver_ftp_overflow.nasl
     文件        2653  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3com_config_disclosure.nasl
     文件        2640  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3com_network_supervisor_dir_traversal.nasl
     文件        2936  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3com_ras_crash.nasl
     文件        3168  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3com_switches.nasl
     文件        4249  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3ctftpsvc_mode_overflow.nasl
     文件        4268  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3cx_phone_system_multiple_xss.nasl
     文件        5256  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3dftp_dir_traversal.nasl
     文件        3286  2014-10-08 07:50  IBAG-master\AG_Generation\Nessus script\3dgreetings_player_activex_overflows.nasl
     文件         505  2014-10-08 07:50  IBAG-master\AG_Generation\Network_link.json
     文件         737  2014-10-08 07:50  IBAG-master\AG_Generation\exploit.xml
     目录           0  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\
     文件          69  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\INSTALL.txt
     文件        1772  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\LICENSE.txt
     文件         777  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\MANIFEST.in
     文件        1491  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\PKG-INFO
     文件         389  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\README.txt
     目录           0  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\build\
     目录           0  2014-10-08 07:50  IBAG-master\AG_Generation\networkx-1.8.1\build\lib\
............此处省略3494个文件信息

评论

共有 条评论

相关资源