将乌云漏洞图片下载到本地

Posted Reborn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将乌云漏洞图片下载到本地相关的知识,希望对你有一定的参考价值。

#coding=utf-8
import mysqldb
import re
import requests

conn = MySQLdb.connect(host=‘127.0.0.1‘,user=‘root‘,passwd=‘123456‘,db=‘wooyunbugs‘,charset=‘utf8‘)
cursor = conn.cursor()

def q():
    sql = ‘select * from `a`‘
    cursor.execute(sql)
    for row in cursor.fetchall():
        id = int(row[0])
        print id,
        content1 = row[2]
        filenameList = f(content1)
        if len(filenameList)== 0:
            pass
        else:
            for imgUrl in filenameList:
                try:
                    downloadImageFile(imgUrl)
                    print ‘success‘
                except:
                    pass        

def f(c):
    re1 = re.compile(‘<img src="(http:\/\/static.wooyun.org\/wooyun\/.*?)"‘)
    s = re1.findall(c)
    return s


def downloadImageFile(imgUrl):  
    local_filename = imgUrl.split(‘/‘)[-1]
    local_filedir = imgUrl.split(‘/‘)[-2]  
    print "Download Image File=", local_filename  
    r = requests.get(imgUrl, stream=True, timeout=20)
    dirName =local_filedir
    import os
    if not os.path.exists(dirName):
        os.makedirs(dirName)
    with open(dirName+‘/‘+local_filename, ‘wb‘) as f:  
        for chunk in r.iter_content(chunk_size=1024):  
            if chunk: 
                f.write(chunk)  
                f.flush()  
        f.close()
             
if __name__ == ‘__main__‘:
    q()

  

以上是关于将乌云漏洞图片下载到本地的主要内容,如果未能解决你的问题,请参考以下文章

使用selenium + Chrome爬取某网站乌云公开漏洞文章并保存为pdf文件

Android漏洞分析twitter资料

离线乌云漏洞详情vs知识库

吐槽国内各大公司的漏洞报告平台

快速修复 Log4j2 远程代码执行漏洞步骤

乌云回忆录