Beispiel #1
0
def getallcve():
    print "Get all cve from data file......"
    for i in range(2002,2016):
        print "Parsing F:\\CVEVD\\cvedata\\nvdcve-2.0-%d.xml" %i
        rs=parsexml("F:\\CVEVD\\cvedata\\nvdcve-2.0-%d.xml" %i,'entry')
        cvelist.extend(rs)
    lib_pickle.dump2file('F:/CVEVD/cvelist.pkl',cvelist)
Beispiel #2
0
def getallcnvd():
    print "Get all cnvd from net......."
    global cnvdlist
    for i in range(start,end):
        print "Get %d cnvd from internet now...." %i
        getcnvd4year(i)
        if pos==1:
            lib_pickle.dump2file(os.getcwd()+'/cnvd_%d.pkl' %i,cnvdlist)
        else:
            lib_pickle.dump2file('F:\\CVEVD\\cnvd_%d.pkl'%i,cnvdlist)
        print "\n %d Number:" %i,len(cnvdlist)
        cnvdlist=[]
Beispiel #3
0
rulename=sys.argv[2]
outfname=sys.argv[3]
grs=lib_pickle.get4file(rulename)
"""
f=open(logname)
for line in f:
    sid=getinfo(line)
    if not sid:
        continue
    if len(grs[sid])<2:
        grs[sid].append(set([cwdpcap]))
    else:
        grs[sid][1].add(cwdpcap)


outf=open(outfname,'w')
"""
for sid,info in grs.items():
    if len(info)<2:
        print sid,'\t',info[0]
        continue
    outf.write(sid+'\t'+info[0]+'\t')
    for pcap in list(info[1]):
        outf.write(pcap+'\t')
    outf.write('\n')
outf.close()
lib_pickle.dump2file("F:/packet/frs.pkl",grs)



    
Beispiel #4
0
if not os.path.exists(args['-p']):
    print "the path is not exists"
    exit(1)
if not os.path.isdir(args['-p']):
    print "the path must be a dir"
    exit(1)

os.chdir(args['-p'])
if args['-r']!='':
    if not os.path.isfile(args['-r']):
        print "%s is not exist,please input real path for rule file" %args['-r']
        exit(1)
    grs=lib_rule.getinfo4rule(args['-r'],2)
    print "load numbers of rule:",len(grs)
    if len(grs):
        lib_pickle.dump2file(args['-p']+"/rule.pkl",grs)
if args['-rpk']!='':
    if os.path.isfile("rule.pkl"):
        grs=lib_pickle.get4file("rule.pkl")
        print "load numbers of rule:",len(grs)
    else:
        print "rule.pkl is not exist,please input real path for rule file"
        exit(1)

if not len(grs):
    print "load rules error,again"
    exit(1)

snortlist(args['-p'])
print "snort exit..."
rsf=open('rs.txt','w')