add cve module

This commit is contained in:
Bob 2014-11-17 14:24:18 +01:00
parent 23b60814b7
commit 58d330c333
2 changed files with 41 additions and 0 deletions

37
modules/cve.py Normal file
View File

@ -0,0 +1,37 @@
import urllib.request
from bs4 import BeautifulSoup
import pprint
from hooks import hook
from more import Response
nemubotversion = 3.4
def help_tiny():
return "CVE description"
def help_full():
return "No help "
@hook("cmd_hook", "cve")
def get_cve_desc(msg):
DESC_INDEX = 17
BASEURL_MITRE = 'http://cve.mitre.org/cgi-bin/cvename.cgi?name='
cve_id = ''
if msg.cmds[1][:3] == 'cve' :
cve_id = msg.cmds[1]
else:
cve_id = 'cve-' + msg.cmds[1]
search_url = BASEURL_MITRE + cve_id.upper()
url = urllib.request.urlopen(search_url)
soup = BeautifulSoup(url)
desc = soup.body.findAll('td')
return Response(desc[DESC_INDEX].text, msg.channel)

4
modules/cve.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" ?>
<nemubotmodule name="cve">
<message type="cmd" name="cve" call="get_cve_desc" />
</nemubotmodule>