用python結(jié)合jieba和wordcloud實現(xiàn)詞云效果
0x00 前言
突然想做一個漏洞詞云,看看哪些漏洞比較高頻,如果某些廠商有漏洞公開(比如ly),也好針對性挖掘。就選x云吧(鏡像站 http://wy.hxsec.com/bugs.php )。用jieba和wordcloud兩個強大的第三方庫,就可以輕松打造出x云漏洞詞云。
github地址: https://github.com/theLSA/wooyun_wordcloud
本站下載地址:wooyun_wordcloud
0x01 爬取標題
直接上代碼:
#coding:utf-8 #Author:LSA #Description:wordcloud for wooyun #Date:20170904 import urllib import urllib2 import re import threading import Queue q0 = Queue.Queue() threads = 20 threadList = [] def gettitle(): while not q0.empty(): i = q0.get() url = 'http://wy.hxsec.com/bugs.php?page=' + str(i) html = urllib.urlopen(url).read() reg = re.compile(r'<li style="width:60%;height:25px;background-color:#FFFFFF;float:left" ><a href=".*?" rel="external nofollow" >(.*?)</a>') titleList = re.findall(reg,html) fwy = open("wooyunBugTitle.txt","a") for title in titleList: fwy.write(title+'\n') fwy.flush() fwy.close() print 'Page ' + str(i) + ' over!' def main(): for page in range(1,2962): q0.put(page) for thread in range(threads): t = threading.Thread(target=gettitle) t.start() threadList.append(t) for th in threadList: th.join() print '***********************All pages over!**********************' if __name__ == '__main__': main()
0x02 打造詞云
還是直接上代碼:
# coding: utf-8 import jieba from wordcloud import WordCloud import matplotlib.pyplot as plt data = open("wooyunBugTitle.txt","r").read() cutData = jieba.cut(data, cut_all=True) word = " ".join(cutData) cloud = WordCloud( #設(shè)置字體,不指定可能會出現(xiàn)中文亂碼 font_path="msyh.ttf", #font_path=path.join(e,'xxx.ttc'), #設(shè)置背景色 background_color='white', #詞云形狀 #mask=color_mask, #允許最大詞匯 max_words=2000, #最大號字體 max_font_size=40 ) wc = cloud.generate(word) wc.to_file("wooyunwordcloud.jpg") plt.imshow(wc) plt.axis("off") plt.show()
0x03 效果演示:
0x04 結(jié)語
由詞云圖可以看出,SQL注入依舊風光無限,其次是命令執(zhí)行,繼而是信息泄漏,整體看還是比較直觀的。
相關(guān)文章
在Django下創(chuàng)建項目以及設(shè)置settings.py教程
今天小編就為大家分享一篇在Django下創(chuàng)建項目以及設(shè)置settings.py教程,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-12-12Python實現(xiàn)批量將MP3音頻轉(zhuǎn)為WAV格式詳解
這篇文章主要介紹了通過Python實現(xiàn)將MP3音頻轉(zhuǎn)為WAV格式的方法,文中的示例代碼講解詳細,對我們學(xué)習Python有一定幫助,感興趣的可以了解一下2021-12-12python?numpy庫之如何使用matpotlib庫繪圖
Numpy的主要對象是同構(gòu)多維數(shù)組,它是一個元素表,所有類型都相同,由非負整數(shù)元組索引,在Numpy維度中稱為軸,這篇文章主要介紹了python?numpy庫?使用matpotlib庫繪圖,需要的朋友可以參考下2022-10-10神經(jīng)網(wǎng)絡(luò)相關(guān)之基礎(chǔ)概念的講解
今天小編就為大家分享一篇關(guān)于神經(jīng)網(wǎng)絡(luò)相關(guān)之基礎(chǔ)概念的講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-12-12基于python的itchat庫實現(xiàn)微信聊天機器人(推薦)
這篇文章主要介紹了基于python的itchat庫實現(xiàn)微信聊天機器人,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10Python Pickling 和 Unpickling 的區(qū)別
Python中的Pickling和Unpickling是與數(shù)據(jù)序列化和反序列化相關(guān)的重要概念,本文主要介紹了Python Pickling和Unpickling的區(qū)別,具有一定的參考價值,感興趣的可以了解一下2023-11-11詳解Python執(zhí)行py文件是否需要可執(zhí)行權(quán)限
這篇文章主要通過幾個案例為大家詳細介紹一下在Python中執(zhí)行py文件是否需要可執(zhí)行權(quán)限,文中的示例代碼講解詳細,對我們學(xué)習Python有一定幫助,需要的可以了解一下2023-03-03