【原创分享】python获取乌云最新提交的漏洞,邮件发送
#!/usr/bin/env python
# coding:utf-8
# @Date : 2016年4月21日 15:08:44
# @Author : sevck (sevck@jdsec.com)
# @Link : http://www.qingteng.cn
#------------------------------------------------------------------------- import time
import urllib2
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
from bs4 import BeautifulSoup
from email.mime.text import MIMEText
import smtplib #===============================================================================
# 导入smtplib和MIMEText
#===============================================================================
from email.mime.text import MIMEText
import smtplib #===============================================================================
# 要发给谁,这里指定发送的邮箱地址(支持多个逗号间隔)
#===============================================================================
mailto_list=["sevck@jdsec.com"] #===============================================================================
# 设置服务器,用户名、口令以及邮箱的后缀
#===============================================================================
mail_host="smtp.qq.com"
mail_user=""
mail_pass=""
mail_postfix="qq.com"
mail_usernnick="XX播报平台" #===============================================================================
#定义厂商列表:
#务必填写在乌云厂商名字:比如360在乌云的名称是:奇虎360
#===============================================================================
list=["乌云厂商名称"]
buglist=[]
#===============================================================================
#获取当天时间
#===============================================================================
def gettime():
data=time.strftime('%Y-%m-%d',time.localtime(time.time()))
return data
#================================================================================
#获取html代码
#================================================================================
def getUrlRespHtmlSimply(url):
req = urllib2.Request(url)
res = urllib2.urlopen(req)
html = res.read()
res.close()
return html
#================================================================================
#获取html代码
#================================================================================
def getUrlRespHtml(url):
heads = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset':'GB2312,utf-8;q=0.7,*;q=0.7',
'Accept-Language':'zh-cn,zh;q=0.5',
'Cache-Control':'max-age=0',
'Connection':'keep-alive',
'Keep-Alive':'',
'User-Agent':'Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.14) Gecko/20110221 Ubuntu/10.10 (maverick) Firefox/3.6.14'} opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
req = urllib2.Request(url)
opener.addheaders = heads.items()
respHtml = opener.open(req).read()
return respHtml
#================================================================================
#处理爬虫数据
#================================================================================
def getwooyun():
for k in range(1,5):
url="http://www.wooyun.org/bugs/new_submit/page/"+str(k)
html=getUrlRespHtml(url).decode('utf-8')
#print html
#print "-----------------------------------"
soup=BeautifulSoup(html)
#print soup
tbody=soup.find("tbody")
#print tbody
tr=tbody.findAll("tr")
times=gettime()
for i in tr:
submittime=i.find("th").contents[0]
#print submittime
if times==submittime:
#print "ok"
title=i.find("td").find("a").contents[0]#漏洞标题
href="www.wooyun.org"+i.find("td").find("a").get("href")#漏洞地址
buglist.append(title)
buglist.append(href)
else:
#print "pass"
pass
#===============================================================================
#获取漏洞信息
#==============================================================================
con=""
def outbug():
for j in buglist:
global con
con+=str(j)+"\r\n"
print con #===============================================================================
# 发送邮件
#===============================================================================
def send_mail(to_list,sub,content):
'''''
to_list:发给谁
sub:主题
content:内容
send_mail("aaa@126.com","sub","content")
'''
me=mail_usernnick+"<"+mail_user+"@"+mail_postfix+">"
msg = MIMEText(content,_charset="utf-8")
msg['Subject'] = sub
msg['From'] = me
msg['To'] = ";".join(to_list)
try:
s = smtplib.SMTP_SSL()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me, to_list, msg.as_string())
s.close()
return True
except Exception, e:
print str(e)
return False def main():
date=gettime()
print con
getwooyun()
outbug()
if con!="":
if send_mail(mailto_list,"【WOOYUN-"+date+"-漏洞信息】",con.encode("utf-8")):
print "发送成功"
else:
print "发送失败" for i in list:
print i
if(i in con):
print "true"
print i
send_mail(mailto_list,"[紧急]【您关注的客户被爆漏洞了】",
"客户为:"+i.encode("utf-8")+"\r\n"+"\r\n"+
"详情请看如下:\r\n"+
"\r\n----------------------------\r\n"+
con.encode("utf-8"))
else:
print "false"
if __name__ == '__main__':
main()
python要改成支持ssl,不知道怎么改可以百度或者我的博客之前好像也写过。
linux下运行 crontab定时执行脚本即可
【原创分享】python获取乌云最新提交的漏洞,邮件发送的更多相关文章
- Python+request+ smtplib 测试结果html报告邮件发送(上)《五》
此方法通用适合所有邮箱的使用,只需注意几个点,如下: QQ邮箱.其他非QQ邮箱的写法,区别点如下: #--------------------------使用腾讯企业邮箱作为发件人的操作如下----- ...
- Python+request+ smtplib 测试结果html报告邮件发送(下)《六》
目录结构如下: 1.cfg.ini的配置信息写法如下: [email] ;--------------------------使用腾讯企业邮箱作为发件人的操作如下------------------- ...
- 【Linux】结合Python 简易实现监控公司网站,邮件发送异常
背景 由于一些原因,博主负责测试的网站的服务器切换到了香港,切换后出现了多次访问超时的情况 于是主动请缨写一个自动监测的脚本,本来准备完全使用shell来写,后来发现shell发送邮件只能在测试机之间 ...
- Python获取中国证券报最新资讯
# -*- coding: utf-8 -*- import urllib from bs4 import BeautifulSoup from time import time from time ...
- 分享一个获取代理ip的python函数
分享一个获取代理ip的python函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #coding:utf-8 from bs4 import Beaut ...
- 【原创分享·微信支付】C# MVC 微信支付教程系列之现金红包
微信支付教程系列之现金红包 最近最弄这个微信支付的功能,然后扫码.公众号支付,这些都做了,闲着无聊,就看了看微信支付的其他功能,发现还有一个叫“现金红包”的玩意,想 ...
- 【原创分享·微信支付】 C# MVC 微信支付教程系列之公众号支付
微信支付教程系列之公众号支付 今天,我们接着讲微信支付的系列教程,前面,我们讲了这个微信红包和扫码支付.现在,我们讲讲这个公众号支付.公众号支付的应用环境常见的用户通过公众号,然后再通 ...
- 【原创分享·支付宝支付】HBuilder打包APP调用支付宝客户端支付
前言 最近有点空余时间,所以,就研究了一下APP支付.前面很早就搞完APP的微信支付了,但是由于时间上和应用上的情况,支付宝一直没空去研究.然后等我空了的时候,发现支付宝居然升级了支付逻辑,虽然目前还 ...
- 【原创分享·微信支付】 C# MVC 微信支付教程系列之扫码支付
微信支付教程系列之扫码支付 今天,我们来一起探讨一下这个微信扫码支付.何为扫码支付呢?这里面,扫的码就是二维码了,就是我们经常扫一扫的那种二维码图片,例如,我们自己添 ...
随机推荐
- 使用 TFDConnection 的 pooled 连接池
从开始看到这个属性,就一直认为他可以提供一个连接池管理功能, 苦于文档资料太少, 甚至在帮助中对该属性的使用都没有任何介绍,如果你搜索百度,也会发现基本没资料. 最后终于在其官方网站看到了其完整相关的 ...
- 使用Application Loader打包上传AppStore流程
配置完你的证书,Bundle Identifier 和描述文件的配置 然后配置工程打开你项目工程 第一步,这里不能选择模拟器,选择iOS Device 如果不支持横屏,把这2个勾去掉 然后查看版本号和 ...
- LUA笔记之表
表据说是LUA的核, 呵呵, 看例子吧, 看上去, 跟java的list很像, 又有点像json: a = {} -- create a table and store its reference i ...
- JavaEE基础(九)
1.面向对象(多态的概述及其代码体现) A:多态(polymorphic)概述 事物存在的多种形态 B:多态前提 a:要有继承关系. b:要有方法重写. c:要有父类引用指向子类对象. C:案例演示 ...
- C#:文件、路径(Path_File)
public class Path_File { public string AppPath { get { return AppDomain.CurrentDomain.BaseDirectory; ...
- C#:将子Form加入父Form中
实现的功能:已建立了多个子Form界面,在父Form界面左面,点击不同标题的链接文本,父Form界面右面显示不同的子界面内容. 具体如下: 1.加入split拆分器控件 2.在splitControl ...
- Babelfish 分类: 哈希 2015-08-04 09:25 2人阅读 评论(0) 收藏
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 36398 Accepted: 15554 Descripti ...
- FTP操作类
using System; using System.Collections.Generic; using System.Net; using System.IO; namespace HGFTP { ...
- C++运算法优先级
- N-gram介绍
在实际应用中,我们经常需要解决这样一类问题:如何计算一个句子的概率?如: 机器翻译:P(high winds tonite) > P(large winds tonite) 拼写纠错:P(abo ...