本文为看雪论坛优秀文章
看雪论坛作者ID:Nameless_a
sudo su
echo core >/proc/sys/kernel/core_pattern
afl-fuzz -i fuzz_in -o fuzz_out ./tcpdump -ee -vv -nnr @@
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
下面分布详细记录过程:
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
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
#以下代码为:生成随机散点图
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 -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
# 往期推荐
球分享
球点赞
球在看
点击“阅读原文”,了解更多!