Fuzz学习记录
本文为看雪论坛优秀文章
看雪论坛作者ID:Nameless_a
当前需要解决的问题
优化思路
AFL
优化思路
crashes如何打开
afl-fuzz的变异策略
个人对afl-fuzz的理解
fuzz tcpdump
fuzz目标tcpdump的生成
报错的初始化配置:
sudo su
echo core >/proc/sys/kernel/core_pattern
指令:
afl-fuzz -i fuzz_in -o fuzz_out ./tcpdump -ee -vv -nnr @@
探究种子的重新筛选对fuzz的运行效率有无影响
数据一
跑了23个小时后的数据重新跑(未cmin) 操作系统ubnutu20
跑了23个小时的数据(cmin后)
数据二
跑了23个小时后的数据重新跑(未cmin)ubnutu18
跑了23个小时后的数据重新跑(cmin后)ubnutu18
择种算法
sklearn的kmeans算法
kmeans
聚类效果评判
kmeans++
关于种子的模型
afl-showmap -o mapfile ./tcpdump -ee -vv -nnr ./queue/id:000000,orig:small_capture.pcap
000087:1
000142:1
000248:1
000928:1
001092:1
001322:1
001382:1
002101:4
002141:1
002184:1
002346:1
002403:2
002589:1
003031:2
003072:1
003160:2
003220:1
003251:1
003567:1
003574:2
003827:1
003984:2
004084:1
004178:4
hamming距离
如何将种子转换为二进制数并且保存
下面分布详细记录过程:
步骤一:通过python读取文件名,然后对每一个文件调用showmap得到信息文本文件
python获得当前目录下所有文件名:
import os
path = "文件目录"
datanames = os.listdir(path)
for i in datanames:
print(i)
import os
inpath = "./tcpdump/queue"
outpath= "./tcpdump/save_showmap"
datanames = os.listdir(inpath)
a=1
##print(cmd)
for i in datanames:
outname=outpath+'/'+str(a)
inname=inpath+'/'+i
cmd="afl-showmap -o {} ./tcpdump/tcpdump -ee -vv -nnr {}".format(outname,inname)
os.system(cmd)
a=a+1
步骤二:通过python脚本,将信息文本文件转换为二进制数并以文本形式保存
import os
inpath='./tcpdump/save_showmap'
outpath='./tcpdump/save_binary'
file_path = inpath
datanames = os.listdir(file_path)
a=1
for i in datanames:
inname=inpath+'/'+str(a)
outname=outpath+'/'+str(a)
f_in=open(inname,'r')
f_out=open(outname,'w')
line=f_in.readline()
last_number=1
while line:
now_number=int(line[:6])
##print(now_number)
for j in range(last_number,now_number):
f_out.write(str(0)+'\n')
f_out.write(str(1)+"\n")
last_number=now_number+1
line=f_in.readline()
f_in.close()
f_out.close()
a+=1
新思路:将种子对应成一个大数
a=1<<1000000
print(a)
a=1
b=11
c=((a<<100000)-1) | (b<<100000)
print(c)
a=1
b=11
c=((a<<100000)-1) | (b<<100000)
def count_one(x):
s=0
while(x):
if (x & 1):
s+=1
x=x>>1
return s
print(count_one(c))
将种子转换成大数的脚本
import os
inpath='./tcpdump/save_showmap'
outpath='./tcpdump/save_bignum'
file_path = inpath
datanames = os.listdir(file_path)
a=1
for i in datanames:
inname=inpath+'/'+str(a)
outname=outpath+'/'+str(a)
f_in=open(inname,'r')
f_out=open(outname,'w')
big_number=0
line=f_in.readline()
while line:
now_number=int(line[:6])
big_number+=1<<now_number
line=f_in.readline()
f_out.write(str(big_number))
f_in.close()
f_out.close()
a+=1
pyclusring库下的kmeans聚类
先造个沙堡!
#以下代码为:生成随机散点图
from turtle import color
import numpy as np
import matplotlib.pyplot as plt
from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
from pyclustering.cluster.kmeans import kmeans
## 前面是安装的库
cluster_num=20
def draw_line(a,b):
a_x=a[0]
a_y=a[1]
b_x=b[0]
b_y=b[1]
plt.plot([a_x,b_x], [a_y,b_y],linewidth=1,color='green')
def add_line_between_center_and_members(cs,group,x): # cs:聚类中心 group:二维数组表示的分组情况 x:原始的二维数组
for i in range(0,cluster_num):
for j in group[i]:
draw_line(cs[i],x[j])
def draw_initial_point(x):
x1=[]
y1=[]
for i in x:
x1+=[i[0]]
y1+=[i[1]]
plt.plot(x1,y1, 'o',color='b')
## 画初始的点,把一个二维数组拆成一维
def draw_center(cs):
x1=[]
y1=[]
for i in cs:
x1+=[i[0]]
y1+=[i[1]]
###print(x1)
plt.plot(x1,y1, 'o',color='r')
##plt.scatter(i[0],i[1],'o',color='r')
## 画聚类中心
## 聚类个数 kmeans中的k
x=np.random.randint(0,100,(100,2))
print("初始数据:")
print(x)
## 随机一个二维数组
draw_initial_point(x)
initial_centers = kmeans_plusplus_initializer(x, cluster_num).initialize()
kmeans_instance = kmeans(x, initial_centers)
kmeans_instance.process()
clusters = kmeans_instance.get_clusters()
cs = kmeans_instance.get_centers()
## 详见:https://segmentfault.com/a/1190000039785725
print("聚类中心:")
print(cs)
draw_center(cs)
print("分类情况:")
print(clusters)
print("test:")
##plt.plot(x1,y1, 'o',color='b')
add_line_between_center_and_members(cs,clusters,x)
plt.show()
上手用自定义距离聚类
#以下代码为:生成随机散点图
from turtle import color
import os
import numpy as np
import matplotlib.pyplot as plt
from pyclustering.utils.metric import distance_metric, type_metric
from pyclustering.cluster.kmeans import kmeans, kmeans_visualizer
from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
from pyclustering.cluster import cluster_visualizer
from pyclustering.samples.definitions import FCPS_SAMPLES
from pyclustering.utils import read_sample
## 前面是安装的库
inpath = "./save_bignum"
datanames = os.listdir(inpath)
slen=len(datanames)
x=np.random.randint(0,1,(slen,2))
mp=np.random.randint(0,1,(slen+1000,slen+1000))
for i in range(0,slen):
x[i,0]=i+1
x[i,1]=1
print(x)
def my_manhattan(p1,p2):
print(str(p1[0])+" "+str(p2[0]))
if mp[p1[0]][p2[0]]:
return mp[p1[0]][p2[0]]
f1=open(inpath+'/'+str(p1[0]))
f2=open(inpath+'/'+str(p2[0]))
s1=int(f1.read())
s2=int(f2.read())
f1.close()
f2.close()
s=s1 ^ s2
ans=0
while(s):
if(s&1):
ans+=1
s>>=1
mp[p1[0]][p2[0]]=mp[p2[0]][p1[0]]=ans
return ans
my_metric = distance_metric(type_metric.USER_DEFINED, func=my_manhattan)
cluster_num=100
initial_centers = kmeans_plusplus_initializer(x, cluster_num).initialize()
kmeans_instance = kmeans(x, initial_centers,metric=my_metric)
kmeans_instance.process()
clusters = kmeans_instance.get_clusters()
cs = kmeans_instance.get_centers()
Screen用法
创建
screen -S [Name] ##创造一个名字为Name的screen
screen -ls ##看查当前所有screen和编号
连接
screen -r [ID]
ps:如果连不上,先screen -d[ID]再-r
screen -X -S [ID] quit
参考文献
看雪ID:Nameless_a
https://bbs.pediy.com/user-home-943085.htm
# 往期推荐
球分享
球点赞
球在看
点击“阅读原文”,了解更多!
[广告]赞助链接:
关注数据与安全,洞悉企业级服务市场:https://www.ijiandao.com/
让资讯触达的更精准有趣:https://www.0xu.cn/
关注KnowSafe微信公众号
随时掌握互联网精彩
随时掌握互联网精彩
- 人物 | 悬镜安全random:解密供应链安全情报的头号黑客
- 男医生社交平台发女患者就诊隐私照,已被暂停执业
- T-Mobile(TMUS.US)正在调查数据泄露事件 涉及3700万个账户
- 科锐第45期预科班、正式班火热招生中...
- 小米12S Ultra体验报告:总有精彩,值得被记录
- APT Turla样本分析
- 编译 | SSE不能止步于限制访问
- 守护中国软件供应链安全,「悬镜安全」完成B轮数亿元融资
- 华为汪涛:走向智能世界2030,无线网络未来十年十大产业趋势
- 【疯狂盲盒】9.9 狂欢节,让你提前嗨!
- 低代码平台如何一步步摧毁开发团队的效率与创新!
- 【网络尖刀 Simp1e】获「思科cisco」和「福昕」双致谢
赞助链接