예제 #1
0
def getcnvd4year(year):
    pool=lib_TheardPool.threadpool(tmax,invrt=ivt,start=False)#,ishttp=True,tasks=200)
    current=0
    total=0
    while True:
        url=geturl(year,total,current)
        if not url:
            break
        body=lib_rule.opencnvdurl(http,url)
        if body:
                soup=BeautifulSoup(body)
                if not total:total=int(soup.div('span')[-1].contents[0].replace(' ',' ')[2:-2])
                soups=soup.tbody('tr')
                for soup in soups:
                    try:
                        #title=soup.td.a['title']
                        cnvd=soup.td.a['href'][16:]
                        #print cnvd,
                        pool.addtask(getvid4cnvd,(pool,cnvd))
                    except Exception:
                        print "Exception",soup
        else:
            print "Error:",url
        current+=100
    print '\n================='
    pool.start()
    pool.waitPoolComplete()
예제 #2
0
        #exit(0)
        desc=""
    mylock.acquire()
    outinfo.write('@=========================\n')
    outinfo.write('msg:%s\n' %vinfo[0])
    outinfo.write('sid:%s\n' %vinfo[1])
    outinfo.write('gid:%s\n' %vinfo[2])
    outinfo.write('rev:%s\n' %vinfo[3])
    outinfo.write('cve:%s\n' %vinfo[4])
    outinfo.write('bid:%s\n' %vinfo[5])
    outinfo.write('cnvd:%s\n' %vinfo[6])
    outinfo.write('desc:%s\n' %desc)
    mylock.release()

i=1
pool=lib_TheardPool.threadpool()
mylock=threading.RLock()

dinfo=['msg','sid','gid','rev','reference']

for line in inrule:
    line=line.strip()
    if line:
        if line.find('noalert')>0:
            printerror("noalert: %s" %line)
            continue
        prule=lib_rule.parserule(line,i)
        vinfo=['msg','sid','gid','rev','','','']
        for info in prule['body']:
            try:
                index=dinfo.index(info[0].strip())
예제 #3
0
while i<len(sys.argv):
    keys=argvs.keys()
    try:
        keys.index(sys.argv[i])
        pl=setparameter(sys.argv[i],i)
    except Exception:
        print "parameter is error,again!!!"
    i+=pl
if argvs['-work']=='1':
    ofile=argvs['-f']+".grule"
elif argvs['-work']=='2':
    ofile=argvs['-f']+".rules"
else:
    print "work model error,again..."
    exit(1)
ofile=open(ofile,'w')
threadpool=lib_TheardPool.threadpool(tmax=argvs['-multi'],debug=argvs['-debug'],start=False)
opera(opera_crule)
if argvs['-multi']>1:
    threadpool.start()
    threadpool.waitPoolComplete()
ofile.close()
print len(gobject)