乌云漏洞爬虫的数据库版本(mysql)

特别鸣谢阮思绮同学!虽然感觉这个冷冷的博客也没人看23333

import mysql.connector
import sys, os
import urllib.request
import re
import itertools
user = ‘root‘
pwd  = ‘‘
host = ‘127.0.0.1‘
db   = ‘test‘
data_file = ‘wooyun.dat‘
create_table_sql = "CREATE TABLE IF NOT EXISTS mytable (id int(10) AUTO_INCREMENT PRIMARY KEY, type varchar(300) , info varchar(1000) , detail varchar(5000) , repair varchar(1000) )CHARACTER SET utf8"
insert_sql = "INSERT INTO mytable (type, info, detail, repair) VALUES ( %s, %s, %s, %s)"
select_sql = "SELECT id, type, info, detail, repair FROM mytable"
cnx = mysql.connector.connect(user=user, password=pwd, host=host, database=db)
cursor = cnx.cursor()

def create_table_sql_api(a):
    try:
        cursor.execute(a)
    except mysql.connector.Error as err:
        print("create table ‘mytable‘ failed.")
        print("Error: {}".format(err.msg))
        sys.exit()

def insert_sql_api(a,b):
    try:
        cursor.execute(a,b)
    except mysql.connector.Error as err:
        print("insert table ‘mytable‘ failed.")
        print("Error: {}".format(err.msg))
        sys.exit()

def select_sql_api(a):
    try:
        cursor.execute(a)
        for (id, type, info, detail, repair) in cursor:
            print("ID:{}  type:{}  info:{}  repair:{}".format(id, type, info, detail, repair))
    except mysql.connector.Error as err:
        print("query table ‘mytable‘ failed.")
        print("Error: {}".format(err.msg))
        sys.exit()

def get_html_response(url):
    html_response = urllib.request.urlopen(url).read().decode(‘utf-8‘)
    return html_response

def geturl(starturl):
    a=get_html_response(starturl)
    childurl=(re.findall(r‘/bugs/wooyun-\w*-\w*\b‘,a))
    return childurl

def get_nextpage(starturl):
    d=get_html_response(starturl)
    nextpage=(re.findall(r‘searchbug.php\?q=6YeR6J6N&pNO=\w‘,d))
    return nextpage

starturl="http://www.wooyun.org/searchbug.php?q=6YeR6J6N"
result=[]
final=[]
type_wooyun_n=[]
info_n=[]
detail_n=[]
repair_n=[]
#output=open("D:\\wooyun.csv","w+")

create_table_sql_api(create_table_sql)

for i in get_nextpage(starturl):
    result+=geturl(‘http://wooyun.org/‘+re.sub(‘金融‘,‘6YeR6J6N‘,i))
    #扫描各种漏洞的url地址放入result中
result=set(result)#去除result中重复的地址

for i in result:
    k=get_html_response(‘http://wooyun.org/‘+re.sub(‘金融‘,‘%E9%87%91%E8%9E%8D‘,i))#下载页面到k
    type_wooyun=re.findall(r‘漏洞类型:.*.</h3>‘,k)
    info=re.findall(r‘<h3>\w*:.*.</h3>‘,k)#空白字符用/s,寻找所有适用于<h3>标签的文字
    detail=re.findall(r‘<p class="detail">.*.</p>‘,k)
    repair=re.findall(r‘修复方案:</h3>\s*<p class="detail">.*.\s*</p>‘,k)
    for j in type_wooyun:#漏洞类型,为之后进行数据库分类做准备
        j=re.sub(r‘:\s‘,‘:‘,j)
        j=re.sub(r‘\t‘,‘‘,j)
        j=re.sub(r‘</h3>‘,‘‘,j)
        type_wooyun_n+=j
    for j in info:#处理概要
        j=re.sub(r‘:\s‘,‘:‘,j)
        j=re.sub(r‘<h3>‘,‘‘,j)
        j=re.sub(r‘</h3>‘,‘‘,j)
        j=re.sub(r‘<a\shref=".*.">‘,‘‘,j)
        j=re.sub(r‘</a>‘,‘‘,j)
        j=re.sub(r‘<imgheight=".*./>‘,‘‘,j)
        j=j.split()
        info_n+=j
    for j in detail:#处理详情
        j=re.sub(r‘:\s‘,‘:‘,j)
        j=re.sub(r‘<p\sclass="detail">‘,‘‘,j)
        j=re.sub(r‘</p>‘,‘‘,j)
        j=re.sub(r‘"\starget="_blank"><img\ssrc="/upload/.*.width="600"/></a>‘,‘,‘,j)
        j=re.sub(r‘<a href="‘,‘ http://www.wooyun.org‘,j)
        j=re.sub(r‘对本漏洞信息进行评价,.*.备学习价值‘,‘‘,j)
        detail_n+=j
    for j in repair:#处理回复方法
        j=re.sub(r‘</br>‘,‘,‘,j)
        j=re.sub(r‘</p>‘,‘,‘,j)
        j=re.sub(r‘</h3>‘,‘,‘,j)
        j=re.sub(r‘<p\sclass="detail">‘,‘‘,j)
        j=re.sub(r‘:‘,‘:‘,j)
        j=j.split()
        repair_n+=j

    type_wooyun_str="".join(itertools.chain(*type_wooyun_n))
    info_str="".join(itertools.chain(*info_n))
    detail_str="".join(itertools.chain(*detail_n))
    repair_str="".join(itertools.chain(*repair_n))
    final.append(type_wooyun_str)
    final.append(info_str)
    final.append(detail_str)
    final.append(repair_str)
    insert_sql_api(insert_sql,tuple(final))
    select_sql_api(select_sql)
    #output.writelines(final)
    #output.writelines(‘\n\n‘)
    final.clear()
    repair_n.clear()
    info_n.clear()
    type_wooyun_n.clear()
    detail_n.clear()

cnx.commit()
cursor.close()
cnx.close()
#output.close()

乌云漏洞爬虫的数据库版本(mysql)

时间: 2024-07-29 17:47:12

乌云漏洞爬虫的数据库版本(mysql)的相关文章

Mysql数据库的mysql Schema 到底有哪些东西&amp; 手工注入的基础要领

#查看数据库版本 mysql> select @@version; +------------+ | @@version  | +------------+ | 5.5.16-log | +------------+ 1 row in set (0.00 sec) mysql> select * from information_schema.schemata; # 保存了系统的所有的数据库名 ,关键的字段是schema_name # 2 rows in set (0.04 sec)表示只有2

查看数据库版本及当前登录用户是什么?

查看数据库当前版本: 1)mysql> select version(); ==>查看mysql版本:(在库里面查看) +------------+ | version() | +------------+ | 5.5.32-log | +------------+ 1 row in set (0.00 sec) 2)mysql> status; ==>查看当前数据库状态,包括数据库版本.当前用户,socket等: -------------- mysql Ver 14.14 Di

简单的python爬虫 爬的乌云漏洞类型

import urllib.request import re starturl="http://wooyun.org/searchbug.php?q=%E9%87%91%E8%9E%8D" def get_html_response(url): html_response = urllib.request.urlopen(url).read().decode('utf-8') return html_response def geturl(starturl): a=get_html_

查看mysql数据库版本方法总结

当你接手某个mysql数据库管理时,首先你需要查看维护的mysql数据库版本:当开发人员问你mysql数据库版本时,而恰好你又遗忘了,那么此时也需要去查看mysql数据库的版本...............下文总结一下Linux平台下查看mysql数据库的方法.个人觉得总结的比较全面了. 方法1:登录数据库时,你可以看到对应mysql数据库的版本信息,如下所示: [[email protected] ~]# mysql -u root -p Enter password: Welcome to

查看MySQL数据库版本方法总结!

前言: 当你接手某个mysql数据库管理时,首先你需要查看维护的mysql数据库版本,或者当开发人员问你mysql数据库版本时,而恰好你又遗忘了,那么此时也需要去查看mysql数据库的版本.这些是我自己搜集的,分享给大家! 1.如果你是yum安装 rpm -qa|grep mysql或者rpm -qa|grep -i mysql mysql-server-5.1.73-3.el6_5.x86_64 如果你能登陆数据库 2.登陆时查看  mysql -u root -p 3.mysql> sele

CentOS6.8下MySQL数据库版本信息查看

方法1:使用mysql -v命令查看: [[email protected] mysql]# mysql -V mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1 [[email protected] mysql]# mysql --version mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using re

python连接mysql数据库——版本问题

今天终于解决了使用python连接数据库不成功的问题,现将过程总结如下: 一.出现的问题 在使用python连接mysql数据库是一直出现如下问题: 1.只能连接到我数据库中的的第一个数据库,但是不能操作里面的表,会报错表不存在.(表是存在的)2.更换其他数据库后,直接报错找不到该数据库.(数据库和表均存在) 运行连接数据库的代码,会出现: conn = pymysql.connect(user='root', password='password', database='XXX') Trace

MYSQL 查看当前用户与数据库版本

问题一: 查看当前用户 select user(); 问题二: 查看数据库版本 select version();

数据库之MySQL的基本使用

数据库简介 数据库 数据库就是一种特殊的文件,其中存储着需要的数据:关系型数据库核心元素: 数据行(记录) 数据列(字段) 数据表(数据行的集合) 数据库(数据表的集合) Ubuntu进入数据库: 1.sudo -s; 2.cd /var/lib/mysql; 3.ls -h; 4.cd 数据库名: 5.ls 一个表中:一列--->一个字段一行--->一条记录 字段和记录组成表:几个表组成一个数据库: 一个大的系统可能有几个数据库,而几个数据库里面有很多表: RDBMS Relational