每个漏洞条目包含:

乌云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』 爬取 WooYun 论坛所有漏洞条目的相关信息的更多相关文章

  1. 【Python】爬取理想论坛单帖爬虫

    代码: # 单帖爬虫,用于爬取理想论坛帖子得到发帖人,发帖时间和回帖时间,url例子见main函数 from bs4 import BeautifulSoup import requests impo ...

  2. 『Scrapy』爬取斗鱼主播头像

    分析目标 爬取的是斗鱼主播头像,示范使用的URL似乎是个移动接口(下文有提到),理由是网页主页属于动态页面,爬取难度陡升,当然爬取斗鱼主播头像这么恶趣味的事也不是我的兴趣...... 目标URL如下, ...

  3. 『Scrapy』爬取腾讯招聘网站

    分析爬取对象 初始网址, http://hr.tencent.com/position.php?@start=0&start=0#a (可选)由于含有多页数据,我们可以查看一下这些网址有什么相 ...

  4. python scrapy爬取HBS 汉堡南美航运公司柜号信息

    下面分享个scrapy的例子 利用scrapy爬取HBS 船公司柜号信息 1.前期准备 查询提单号下的柜号有哪些,主要是在下面的网站上,输入提单号,然后点击查询 https://www.hamburg ...

  5. 大神:python怎么爬取js的页面

    大神:python怎么爬取js的页面 可以试试抓包看看它请求了哪些东西, 很多时候可以绕过网页直接请求后面的API 实在不行就上 selenium (selenium大法好) selenium和pha ...

  6. python连续爬取多个网页的图片分别保存到不同的文件夹

      python连续爬取多个网页的图片分别保存到不同的文件夹 作者:vpoet mail:vpoet_sir@163.com #coding:utf-8 import urllib import ur ...

  7. python定时器爬取豆瓣音乐Top榜歌名

    python定时器爬取豆瓣音乐Top榜歌名 作者:vpoet mail:vpoet_sir@163.com 注:这些小demo都是前段时间为了学python写的,现在贴出来纯粹是为了和大家分享一下 # ...

  8. python大规模爬取京东

    python大规模爬取京东 主要工具 scrapy BeautifulSoup requests 分析步骤 打开京东首页,输入裤子将会看到页面跳转到了这里,这就是我们要分析的起点 我们可以看到这个页面 ...

  9. Python爬虫 - 爬取百度html代码前200行

    Python爬虫 - 爬取百度html代码前200行 - 改进版,  增加了对字符串的.strip()处理 源代码如下: # 改进版, 增加了 .strip()方法的使用 # coding=utf-8 ...

随机推荐

  1. hdu 4424 & zoj 3659 Conquer a New Region (并查集 + 贪心)

    Conquer a New Region Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...

  2. bootstrap 仿实例

    bootstrap实现一个网页 html文件 <!DOCTYPE html> <html> <head lang="en"> <meta ...

  3. linux 搭建vpn (pptp)

    一.VPN服务器环境说明 操作系统:CentOS release 6.4 (Final) 本地网卡: 复制代码 代码如下: # ifconfig em1 Link encap:Ethernet HWa ...

  4. 定制属于自己的Chrome起始页

    个人感觉没什么技术含量,可是很有用.我定制的起始页面例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2FuZ19saWNodW4=/font/5 ...

  5. Android之发送短信的两种方式

    SMS涉及的主要类SmsManager 实现SMS主要用到SmsManager类,该类继承自java.lang.Object类,下面我们介绍一下该类的主要成员. 公有方法: ArrayList< ...

  6. Android(java)学习笔记215:多线程断点下载的原理(JavaSE实现)

    1. 为什么需要多线程下载?     服务器的资源有限,同时的平均地分配给每个客户端.开启的线程越多抢占的服务的资源就越多,下载的速度就越块. 2. 下载速度的限制条件? (1)你的电脑手机宽带的带宽 ...

  7. 经验分享:CSS浮动(float,clear)通俗讲解(转载)

    很早以前就接触过CSS,但对于浮动始终非常迷惑,可能是自身理解能力差,也可能是没能遇到一篇通俗的教程. 前些天小菜终于搞懂了浮动的基本原理,迫不及待的分享给大家. 写在前面的话: 由于CSS内容比较多 ...

  8. CSS before和after伪元素

    CSS中有一个特性允许我们添加额外元素而不扰乱文档本身,它们是以CSS选择器的形式出现的,具有标签的表现效果,但是呢又不是真正的标签元素,所以叫做“伪元素”.下面就说一下常见的两个伪元素before和 ...

  9. 使用ajax与服务器通信的步骤

    使用ajax与服务器通信的步骤: 1. 创建一个XMLHttpRequest对象 2. 创建url,data,通过xmlHttpRequest.send() 3. 服务器端接收ajxa的请求,做相应处 ...

  10. HTML5 File 对象

    实例说明1: <div class="container"> <input type="file" id="file" m ...