Giter VIP home page Giter VIP logo

wooyun_search's Introduction

wooyun_search

乌云公开漏洞、知识库搜索

index search author

0x00.介绍

  • 灵感来源于hanc00l的github项目wooyun_public

  • wooyun_public基于flask或者tornado,而本项目可以布置在apache、nginx等web服务器上。

  • 如果你有wooyun的静态网页数据,那么我们可以开始了!

  • 整个项目包括两个部分,第一部分是索引,将网页信息存储进数据库;第二部分是搜索,从数据库中查找信息。轻量级,支持进行二次开发。

  • 静态网页网盘链接:

bugs   链接: https://pan.baidu.com/s/1n_kkUaZZxcTEa4-v6sGa9Q 密码: sg98 (20180707)
drops  链接: https://pan.baidu.com/s/1r2Y7rfntwnjglX6HtzDk6w 密码: 738f (20180707)

0x01.依赖组件及说明

  • python 2.7和pip

  • python依赖:MySQLdb,lxml(推荐)

  • mysql,php及任意web服务器(php需开启pdo-mysql模块

  • 将本项目放进web服务器目录下,bugs目录下为漏洞库文件,drops目录下为知识库文件。

文件说明:
	app_bugs.py                      bugs的索引,依赖lxml
	app_drops.py                     drops的索引,依赖lxml
	index.html                       搜索的主页
	search.php                       执行搜索的页面
	config.php                       php配置文件
	./bugs                           bugs静态文件的目录
	./drops                          drops静态文件的目录

0x02.索引配置

  • app_bugs.py为建立bugs索引的脚本,app_drops为建立drops索引的脚本。

  • 因为python脚本中open()函数打开的文件名不能为中文,建议将drops目录下的中文文件名改为英文(例如,安全运维-xxxx.html=>safe-xxxx.html)

  • python脚本运行前需要修改如下语句,更改参数如主机、端口号、用户名、密码。

    conn=MySQLdb.connect(host='localhost',port=3306,user='root',passwd='',db='wooyun',charset='utf8')
  • 在mysql中建立数据库wooyun,数据表bugs、drops,分别建立字段title,dates,author,type,corp,doc与title,dates,author,type,doc。
    CREATE DATABASE `wooyun` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    create table bugs(title VARCHAR(500),dates DATETIME, author CHAR(255),type CHAR(255),corp CHAR(255),doc VARCHAR(200) PRIMARY KEY);
    create table drops(title VARCHAR(500),dates DATETIME, author CHAR(255),type CHAR(255),doc VARCHAR(200) PRIMARY KEY);
  • 注意mysql编码如下,需要为utf-8(character_set_server不为utf-8要修改mysql配置文件
use wooyun;
show variables like 'character%'; #查看编码
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

如果编码错误会报错,比如:

Warning: Incorrect string value: '\xE5\xBB\xB6\xE9\x95\xBF...' for column 'title' at row 1
cur.execute("INSERT INTO `drops`(`title`,`dates`,`author`,`type`,`doc`) VALUES(%s,%s,%s,%s,%s)", tmp)

在mysql里查看会发现有一堆???

  • 之后就可以建立索引了
sudo python ./app_bugs.py
sudo python ./app_drops.py
  • bugs数目为40280,drops数目为1264
use wooyun;
select count(*) from bugs;
select count(*) from drops;

0x03.搜索配置

  • 修改config.php中修改如下语句中参数,分别是主机、端口、用户名、密码与数据库。
$config['host'] = '127.0.0.1';
$config['port'] = '3306';
$config['user'] = 'root';
$config['passwd'] = '';
$config['database'] = 'wooyun'; 
  • index.html与search.php样式来自于前端静态资源托管库。f12进入开发者模式,如果样式文件访问不到可以使用本地或cdn的样式(bootstrap3.3.7、jquery3.1.0)。只需要更改两个网页里面的如下内容。
<link href="//lib.baomitu.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="//lib.baomitu.com/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="//lib.baomitu.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
  • 为了防止因为web服务器配置不正确,导致访问http(s)://example.link/bugs/或者http(s)://example.link/drops/而进入index of页面泄露所有文件,在目录下放置内容为空的index.html即可。

  • linux下由于selinux可能会导致无法连接数据库,可以使用如下命令:

getenforce   //查看selinux状态
setenforce 0   //暂时关闭selinux

0x04.问题

  • drops很奇怪的会都需web目录下的js而不是本身目录里的js,所以drops的页面会有些乱。开发者模式看一下,缺少的js为web目录/static/drops/css与web目录/static/drops/js。新建目录再把drops下的css、js文件夹复制过去即可

0x05.更新日志

  • 2016.10.08更新:上传了bugs.py。由于bugs部分页面(约143条)的author带有js,正则匹配出的信息出错,所以上传了bugs.py用于修正,在app.py后执行,python bugs.py。(2016.11.09已修正,无需执行bugs.py)

  • 2016.10.10更新:重写了search.php和search.css,基本适配了各种浏览器和移动端。

  • 2016.11.09更新:匹配索引将BeautifulSoup换成了lxml,运行速度更快。优化了匹配(感谢@tuola)。

  • 2017.01.01更新:增加了作者搜索,优化了分页逻辑。

  • 2017.3.7更新:重写了前端,优化了php代码。

  • 欢迎反馈问题。可以提问issue也可以通过[email protected]联系我。后续也会进行其他细节优化。

0x06.后记

  • 本来打算把wooyun_public布置在我的树莓派上,因为一些原因失败,所以萌生了自己搭建的念头

  • 总共搭建了十天,接触了js、bootstarap、beautifulsoup、mysqldb、mysqli和pdo。虽然以前也会css与php,但这是第一次真正写一个动态网页,感觉很棒。

0x07.其他

  • 本程序只用于技术研究和个人使用,程序组件均为开源程序,漏洞和知识库来源于乌云公开漏洞,版权归wooyun.org。

  • 新浪微博:http://weibo.com/grt1st

  • 个人邮箱:[email protected]

wooyun_search's People

Contributors

grt1st avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wooyun_search's Issues

python2 ./app_drops.py是总是中途报Segmentation fault

本以为是mysql的term.c中的字符串缓冲而崩溃,后来换mariadb还是中途报Segmentation fault。

我用的板子是bpi-m3 ,
mariadb Ver 15.1 Distrib 10.1.44-MariaDB, for debian-linux-gnueabihf (armv7l) using readline 5.2,
Python 2.7.17

执行python2 ./app_drops.py是总是中途报Segmentation fault

知识库页面显示有问题

知识库所有网页左边显示黑条,文章不居中,被左边的黑条挡住了,基本不能愉快的看
html的css、js、image原来的位置是static/drops/下的css、js、full三个文件夹,楼主自己在html中嵌入的css有问题,我调了一下,不过能力有限调不出来
我把原来的代码复制在html中显示正常,不过这样做好麻烦,那么多网页没法一张纸修改,请高手出招

正则到mysql数据库的时候出点错

Traceback (most recent call last):
File "app2.py", line 25, in
corp=xml.xpath("//h3[@Class='wybug_corp']//a")[0].text.replace(' ','').replace('\n','')
AttributeError: 'NoneType' object has no attribute 'xpath'

不知道是咋回会,求解答

app.py author正则匹配有问题

wooyun-2013-022100.html

漏洞作者: 漏洞作者: <a href="http://www.wooyun.org/whitehats/z@cx"><span class="__cf_email__" data-cfemail="a8d2e8cbd0">[email&#160;protected]</span><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script></a>

原来的正则:pattern3=re.compile(r'>(.*)</a>')
修正后的正则:pattern3=re.compile(r'<a href="http://www.wooyun.org/whitehats/(.*?)">')

分页问题

http://...../wooyun/search.php?kind=bugs&keywords=a&page={(1+1)}
类似这样的就不能下一页了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.