每个漏洞条目包含:

乌云ID,漏洞标题,漏洞所属厂商,白帽子,漏洞类型,厂商或平台给的Rank值

主要是做数据分析使用:

可以分析某厂商的各类型漏洞的统计;

或者对白帽子的能力进行分析.....

数据更新时间:2016/5/27

漏洞条目:104796条

数据截图如下:

数据网盘链接:

链接:http://pan.baidu.com/s/1bpDNKOv 密码:6y57

爬虫脚本:

# coding:utf-8

# author: anka9080

# version: 1.0 py3

import sys,re,time,socket

from requests import get

from queue import Queue, Empty

from threading import Thread

# 全局变量

COUNT = 1

START_URL = 'http://wooyun.org/bugs'

ID_DETAILS = []

ALL_ID = []

Failed_ID = []

PROXIES = []

HEADERS = {

"Accept": "text/html,application/xhtml+xml,application/xml,application/json;q=0.9,image/webp,*/*;q=0.8",

"Accept-Encoding": "gzip, deflate, sdch",

"Accept-Language": "zh-CN,zh;q=0.8",

"Cache-Control": "max-age=0",

"Connection": "keep-alive",

"DNT": "1",

"Host": "wooyun.org",

"Upgrade-Insecure-Requests": "1",

"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2716.0 Safari/537.36"

}

class WooYunSpider(Thread):

"""docstring for WooYunSpider"""

def __init__(self,queue):

Thread.__init__(self)

self.pattern1 = re.compile(r'title>(.*?)\| WooYun.*?keywords" content="(.*?),(.*?),(.*?),wooyun',re.S) # 匹配模式在 compile 的时候指定

self.pattern2 = re.compile(r"漏洞Rank:(\d{1,3})")

self.queue = queue

self.start() # 执行 run()

def run(self):

"每次读取 queue 的一条"

global COUNT,RES_LOG,ERR_LOG

while(1):

try:

id = self.queue.get(block = False)

r = get('http://wooyun.org/bugs/' + id,headers = HEADERS)

html = r.text

except Empty:

break

except Exception as e:

msg = '[ - Socket_Excpt ] 链接被拒绝,再次添加到队列:' + id

print(msg)

ERR_LOG.write(msg+'\n')

self.queue.put(id) # 访问失败则把这个 URL从新加入队列

else:

title,comp,author,bug_type,rank = self.get_detail(html,id)

detail = id+'----'+title+'----'+comp+'----'+author+'----'+bug_type+'----'+rank

try: # 写入文件可能会诱发 gbk 编码异常,这里保存 id 到 failed

RES_LOG.write(detail + '\n')

except Exception as e:

Failed_ID.append(id)

msg = '[ - Encode_Excpt ] 字符编码异常:' + id

print(msg)

ERR_LOG.write(msg+'\n')

ID_DETAILS.append(detail)

# time.sleep(1)

print('[ - info ] id: {} count: {} time: {:.2f}s'.format(id,COUNT,time.time() - start))

COUNT += 1

# 由 缺陷编号 获得对应的 厂商 和 漏洞类型信息

def get_detail(self,html,id):

global ERR_LOG

try:

# print(html)

res = self.pattern1.search(html)

title = res.group(1).strip()

comp = res.group(2).strip()

author = res.group(3).strip()

bug_type = res.group(4).strip()

except Exception as e:

msg = '[ - Detail_Excpt ] 未解析出 标题等相关信息:' + id

print(msg)

ERR_LOG.write(msg+'\n')

Failed_ID.append(id)

title,comp,author,bug_type,rank = 'Null','Null','Null','Null','Null'

else:

try:

res2 = self.pattern2.search(html) # 若厂商暂无回应则 rank 为 Null

rank = res2.group(1).strip()

except Exception as e:

msg = '[ - Rank_Excpt ] 未解析出 Rank:' + id

print(msg)

ERR_LOG.write(msg+'\n')

rank = 'Null'

finally:

try:

print (title,comp,author,bug_type,rank)

except Exception as e:

msg = '[ - Print_Excpt ] 字符编码异常:' + id +'::'+ str(e)

print(msg)

ERR_LOG.write(msg+'\n')

return title,comp,author,bug_type,rank

class ThreadPool(object):

def __init__(self,thread_num,id_file):

self.queue = Queue() # 需要执行的队列

self.threads = [] # 多线程列表

self.add_task(id_file)

self.init_threads(thread_num)

def add_task(self,id_file):

with open(id_file) as input:

for id in input.readlines():

self.queue.put(id.strip())

def init_threads(self,thread_num):

for i in range(thread_num):

print ('[ - info :] loading threading ---> ',i)

# time.sleep(1)

self.threads.append(WooYunSpider(self.queue)) # threads 列表装的是 爬虫线程

def wait(self):

for t in self.threads:

if t.isAlive():

t.join()

def test():

url = 'http://wooyun.org/bugs/wooyun-2016-0177647'

r = get(url,headers = HEADERS)

html = r.text

# print type(html)

# keywords" content="(.*?),(.*?),(.*?),wooyun ====> 厂商,白帽子,类型

pattern1 = re.compile(r'title>(.*?)\| WooYun')

pattern2 = re.compile(r'keywords" content="(.*?),(.*?),(.*?),wooyun')

pattern3 = re.compile(r'漏洞Rank:(\d{1,3})')

for x in range(500):

res = pattern1.search(html)

# print (res.group(1))

res = pattern2.search(html)

# print (res.group(1),res.group(2),res.group(3))

res = pattern3.search(html)

# print (res.group(1))

x += 1

print(x)

# rank = res.group(4).strip()

# print html

def test2():

url = 'http://wooyun.org/bugs/wooyun-2016-0177647'

r = get(url,headers = HEADERS)

html = r.text

pattern = re.compile(r'title>(.*?)\| WooYun.*?keywords" content="(.*?),(.*?),(.*?),wooyun.*?漏洞Rank:(\d{1,3})',re.S)

for x in range(500):

res = pattern.search(html)

# print (res.group(1),res.group(2),res.group(3),res.group(4),res.group(5))

x += 1

print(x)

# 保存结果

def save2file(filename,filename_failed_id):

with open(filename,'w') as output:

for item in ID_DETAILS:

try: # 写入文件可能会诱发 gbk 编码异常,这里忽略

output.write(item + '\n')

except Exception as e:

pass

with open(filename_failed_id,'w') as output:

output.write('\n'.join(Failed_ID))

if __name__ == '__main__':

socket.setdefaulttimeout(1)

start = time.time()

# test()

# 日志记录

ERR_LOG = open('err_log.txt','w')

RES_LOG = open('res_log.txt','w')

id_file = 'id_0526.txt'

# id_file = 'id_test.txt'

tp = ThreadPool(20,id_file)

tp.wait()

save2file('id_details.txt','failed_id.txt')

end = time.time()

print ('[ - info ] cost time :{:.2f}s'.format(end - start))

爬虫python漏洞群_『Python』 爬取 WooYun 论坛所有漏洞条目的相关信息相关推荐

  1. 深圳python数据分析师招聘_Python爬取智联招聘数据分析师岗位相关信息的方法

    Python爬取智联招聘数据分析师岗位相关信息的方法 发布时间:2020-09-23 23:23:12 来源:脚本之家 阅读:88 进入智联招聘官网,在搜索界面输入'数据分析师',界面跳转,按F12查 ...

  2. python爬虫搜狐新闻_应用案例2:爬取搜狐体育的新闻信息

    爬虫学习使用指南 Auth: 王海飞 Data:2018-06-25 Email:779598160@qq.com github:https://github.com/coco369/knowledg ...

  3. python爬虫携程酒店_携程酒店爬取分享

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 import urllib.request from bs4 import BeautifulSoup import csv import re def ...

  4. python集群_使用Python集群文档

    python集群 Natural Language Processing has made huge advancements in the last years. Currently, variou ...

  5. [爬虫实战]利用python快速爬取NCBI中参考基因组assembly的相关信息

    1.问题导向 最近在做某个课题的时候,按老师的要求需要从NCBI中批量下载不同物种的参考基因组,同时收集相应参考基因组的一些组装信息,基因组非常多,导致工作量巨大,一个一个手动收集的话,既费时又费力, ...

  6. 爬虫练手项目_酷狗音乐爬取

    酷狗音乐爬虫 前言 分析网站 第一步 第二步 第三步 第四步 准备爬虫 大体框架 获取signature 完整代码 前言 利用暑假闲暇时间学习了一下爬虫,也尝试了几个爬取图片的小项目,但感觉爬取图片有 ...

  7. python多进程优化_『Python』多进程处理

    尝试学习python的多进程模组,对比多线程,大概的区别在: 1.多进程的处理速度更快 2.多进程的各个子进程之间交换数据很不方便 多进程调用方式 进程基本使用multicore() 进程池优化进程的 ...

  8. python画羊_『Python Kivy』官方乒乓球游戏示例解析

    本篇文章用于对Kivy框架官方所给出的一个「乒乓球」小游戏的源码进行简单地解析.我会尽可能的将方方面面的内容都说清楚.在文章的最下方为官方所给出的这个小游戏的教程以及游戏源码. 由于篇幅所限,本文只简 ...

  9. python kivy事件_『Python Kivy』API说明:kivy.app

    App类是创建Kivy应用的基础.我们可以将其看成是Kivy运行循环当中的主入口.在绝大多数的例子中,你创建这个类的子类,然后构建你自己的应用.当你已经准备好开始应用的整个生命周期时,你可以实例化你定 ...

  10. Python爬取哔哩哔哩视频的相关信息后续

    上一篇文章通过selenium工具自动搜索爬取哔哩哔哩上面的视频相关信息,今天我们接着上一篇文章,保存视频的图片到本地. 首先找到要爬取的网页数据所在的位置,如下图 并且,右键点击该网址,可以选择在新 ...

最新文章

  1. 设计基于MAX1240,MAX5353的ADDC模块STC8G1KSOP8
  2. 我和奇葩的故事之失联第七天
  3. 用电脑发短信_重磅!一个软件实现电脑上接打手机电话、收发短信、传文件、屏幕镜像!...
  4. bzoj 4814: [Cqoi2017]小Q的草稿【计算几何】
  5. 征战蓝桥 —— 2013年第四届 —— C/C++A组第8题——买不到的数目
  6. Ghost的相关问题
  7. 月老办事处月云开发微信小程序源码
  8. linux下怎么卸载mysql数据库_linux 怎么完全卸载mysql数据库
  9. Apache运行模式MPM详解
  10. 使用高德开放平台显示指定的坐标点和线
  11. 图解最短路径之迪杰斯特拉算法(Java实现)
  12. ESP8266开发之旅 基础篇⑤ ESP8266 SPI通信和I2C通信
  13. Cocos2dx--使用Shader
  14. 什么软件可以测试内存条稳定性,内存检测就这么简单,学会这几个软件就可以了...
  15. 开箱测评丨VEAZEN VZ200民谣吉他
  16. 以太网网络变压器的作用
  17. 手把手教你使用Typecho搭建自己的个人博客
  18. reactive和ref区别
  19. 美国全国就业普遍低迷“技术”就业却加速增长;爱立信发布2030年10大消费者趋势 | 美通社头条...
  20. css3 烟 蚊香_如何使用纯CSS实现蚊香燃烧的效果(附源码)

热门文章

  1. 如何保证软件质量?汽车软件基于模型开发的十个问题与质量工具推荐
  2. Atitit 常用二维码对比(QR、PDF417、DM、汉信码 Aztec code maxicode
  3. Atitit.编程语言and 自然语言的比较and 编程语言未来的发展
  4. Atitit. 数据库-----catalog与schema的设计区别以及在实际中使用 获取数据库所有库表 java jdbc php  c#.Net
  5. atitit.新增编辑功能 跟orm的实现 attilax p31
  6. Rust : RUST_BACKTRACE=1错误提示
  7. (转)《精通比特币》原码分析: pow机制
  8. (转)机器学习算法比较
  9. 机器学习笔记(十八):模型正则化
  10. 陈弘:7月24日阿里云上海峰会存储大神