–0724
还有几分钟,把burpsuite安装一下
—0804
hh当然,和室友聊天去啦hhh
java目录下找不到jdk,环境变量没法配emm,重新装一下。
emm原来这个文件夹是在安装时自己创建的
啊啊啊,我是猪emm
javasuite闪退是因为环境变量没配好~我还把新版本的java卸了,下了旧版本的,为此还注册了oracle。
具体可能通过javac测试环境变量是否配好了。
成功啦
–0858emm已经一个小时啦,快去看代码!!!
一、debug AttacKG
大概用两个小时,弄清model具体内容,也就是读论文中不明晰的地方
居然找不到昨天写的文档了emmm
还好问题不大,在代码里写了很多注释,直接看代码也ok
(一)techniqueTemplateGeneration
1、re.sub用法
这篇比较清楚
https://www.cnblogs.com/z-x-y/p/9633212.html
2、examples是什么呢
需要看一下这个文件的来源,没找到,感觉是自己pick的初始technique
3、template
后期画整体图的时候,部分注释又有更新。
但是还是不太明晰instance在这里是什么意思
(1)template结构定义.
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MpNVhwOW-1669259809814)(E:\stup\Typora\pics\image-20221124094711525.png)]
(2)update_template更新模板
def update_template(self, attack_graph: AttackGraph):
logging.info("---technique template: Update template!---")
# 总实例数+1
self.total_instance_count += 1
sample_node_template_node_dict = {
}
# node matching
# 查看sample图中的node,进行匹配与更新
for node in attack_graph.attackgraph_nx.nodes:
max_similarity_score = 0
most_similar_node_index = -1
node_index = 0
# 遍历template中的technique_node技术结点
for template_node in self.technique_node_list:
# 对每一个新的节点node,与原有图中节点template_node进行相似度比对,找到相似度最大的,记录索引和分之
similarity_score = template_node.get_similarity(attack_graph.attackNode_dict[node])
if similarity_score > max_similarity_score:
max_similarity_score = similarity_score
most_similar_node_index = node_index
node_index += 1
# whether node in new sample is aligned with exist template node
# 如果新的node的相似度分数大于THRESHOLD,则将其加入sample_node_template_dict(单独针对每个新的template为update template创立)
# 并用该节点将与其最相似的老节点更新
# 具体similar算法,和更新方法?
if max_similarity_score > self.NODE_SIMILAR_ACCEPT_THRESHOLD:
sample_node_template_node_dict[node] = most_similar_node_index
self.technique_node_list[most_similar_node_index].update_with(attack_graph.attackNode_dict[node])
else:
# 如果不大于,则直接加入technique_node_list,作为新的节点
tn = TemplateNode(attack_graph.attackNode_dict[node])
self.technique_node_list.append(tn)
# 设置index
sample_node_template_node_dict[node] = len(self.technique_node_list) - 1
instance = []
# 查看sample图中的edge,进行匹配与更新
for edge in attack_graph.attackgraph_nx.edges:
# 得到现在图里面的边,后面做的是结点index的转换(由原来图,换位现在结点匹配更新后新生成的图的index)
technique_template_edge = (sample_node_template_node_dict[edge[0]], sample_node_template_node_dict[edge[1]])
# 查看原来的template是否包含该边
if technique_template_edge in self.technique_edge_dict.keys():
self.technique_edge_dict[technique_template_edge] += 1
else:
self.technique_edge_dict[technique_template_edge] = 1
# 将边加入到instance中,所以instance就是现有边的集合
instance.append(technique_template_edge)
# 统计现有边的情况,记入technique_instance_dict,初始化时和原有edge_list相同,不知后续有什么变化?
instance = tuple(instance)
if instance in self.technique_instance_dict.keys():
self.technique_instance_dict[instance] += 1
else:
self.technique_instance_dict[instance] = 1
(4)结点相似性对比函数 get_similarity
def