From f0489baa4f0ae690e69bd67b5f7a7bb8d2e5e136 Mon Sep 17 00:00:00 2001 From: grt1st Date: Thu, 15 Sep 2016 19:21:41 +0800 Subject: [PATCH] Add files via upload --- app.py | 61 ++++++++++++++++++++++++ app1.py | 50 ++++++++++++++++++++ search.php | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 app.py create mode 100644 app1.py create mode 100644 search.php diff --git a/app.py b/app.py new file mode 100644 index 0000000..bd29ac5 --- /dev/null +++ b/app.py @@ -0,0 +1,61 @@ +#coding=utf-8 +import os +import re +import sys +import MySQLdb +from bs4 import BeautifulSoup +path='bugs' +#预编译 +pattern0=re.compile(r'.*?漏洞标题:(.*)提交时间:(.*)') +pattern2=re.compile(r'>(.*)') +pattern3=re.compile(r'>(.*)') +pattern4=re.compile(r':(.*)') +pattern5=re.compile(r'漏洞标题:(.*)') +for docs in os.listdir(path): + #打开文件,提取内容 + if os.path.isdir('bugs/'+docs): + print "目录跳过" + continue + doc=open('bugs/'+docs,'r') + html=doc.read() + doc.close() + #提取信息 + soup=BeautifulSoup(html,"html.parser") + corps=soup.find_all('h3',class_='wybug_corp') + corps=corps[0].find_all('a') + corp=corps[0] + corp=str(corp).replace(' ','').replace('\n','') + authors=soup.find_all('h3',class_='wybug_author') + authors=authors[0].find_all('a') + author=authors[0] + author=str(author).replace(' ','') + types=soup.find_all('h3',class_='wybug_type') + type0=str(types[0]).replace(' ','') + title=re.findall(pattern0,html) + if title: + title1=title[0].replace(' ','').replace(' ','') + else: + title=soup.find_all('h3',class_='wybug_title') + title0=title[0].text.encode('utf-8') + title0=re.findall(pattern5,title0) + title1=title0[0].replace('\n','').replace(' ','').replace(' ','') + date=re.findall(pattern1,html) + date1=date[0].replace(' ','') + corp1=re.findall(pattern2,corp) + author1=re.findall(pattern3,author) + type1=re.findall(pattern4,type0) + print title1,date1,author1[0],type1[0],corp1[0] + #连接数据库 + try: + conn=MySQLdb.connect(host='localhost',port=3306,user='root',passwd='',db='wooyun',charset='utf8') + cur=conn.cursor() + reload(sys) + sys.setdefaultencoding('utf-8') + tmp=(title1,date1,author1[0],type1[0],corp1[0],docs) + cur.execute("INSERT INTO `bugs`(`title`,`dates`,`author`,`type`,`corp`,`doc`) VALUES(%s,%s,%s,%s,%s,%s)",tmp) + conn.commit() + cur.close() + conn.close() + except MySQLdb.Error,e: + print "Mysql Error %d: %s" % (e.args[0], e.args[1]) diff --git a/app1.py b/app1.py new file mode 100644 index 0000000..7249828 --- /dev/null +++ b/app1.py @@ -0,0 +1,50 @@ +#coding:utf-8 +import os +import re +import sys +import MySQLdb +from bs4 import BeautifulSoup +path='drops' + +pattern0=re.compile(r'>(.*)') +pattern1=re.compile(r'>\s*(.*)') +pattern2=re.compile(r'>(.*) + + + + + 乌云搜索|搜索结果 + + + + + + +
+
+ search from wooyun.org + +
+
+关键词【".$keywords."】的搜索结果:"; +//mysql建立连接 +$db=new mysqli('localhost','root','','wooyun'); //localhost:3307 +//sql对象错误检查 +if(mysqli_connect_errno()){ + echo '
Error:Please try again later.'; + exit(); +} +// 建立查询 +$db->set_charset("utf8"); +//分页处理 +$query0="SELECT count(*) FROM `".$kind."` WHERE `title` LIKE '%".$keywords."%'"; +$num=$db->query($query0); +$row=$num->fetch_row(); +$rows=$row[0]/10; +if($page>$rows){ + $page=1; +} +echo "

共 ".$row[0]." 条记录

"; +$start=($page-1)*15; +$query="SELECT * FROM `".$kind."` WHERE `title` LIKE '%".$keywords."%' ORDER BY dates DESC LIMIT ".$start.",15"; +//执行查询 +$result=$db->query($query); +//逐行分解result +echo ""; +echo ""; + for($i=0;$i<$result->num_rows;$i++){ + $row_result=$result->fetch_object(); + echo "doc."');\" style=\"cursor:pointer;\">"; + $time0=str_split($row_result->dates,10); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } +// 显示result +// 释放连接,关闭sql. +$result->free(); +$db->close(); +//分页 +echo "
"; +echo "
    "; +$total=($row[0]-$row[0]%15)/15; +$i=0; +if($page==1){ + echo "
  • «
  • "; + } + else{ + echo "
  • «
  • "; + } +if($total>20&&$page<=9){ + $total=17; +} +if($total>20&&$page>=9&&$page+8<=$total){ + $i=$page-9; + $total=$page+8; +} +if($total>20&&$page>=9&&$page+8>$total){ + $i=$total-17; +} +for(;$i<=$total;$i++){ + if($page==$i+1){ + echo "
  • ".($i+1)."
  • "; + } + else{ + echo "
  • ".($i+1)."
  • "; + } +} +if($page==$total+1){ + echo "
  • »
  • "; + } + else{ + echo "
  • »
  • "; + } +echo "
"; +?> +
数据来源于wooyun.org
+ + + +
提交时间标题漏洞类型提交者
'.$time0[0].''.$row_result->title.''.$row_result->type.''.$row_result->author.'