def cvesearch(query="last", option=None): if query == "last": if option is None: limit = 10 else: limit = int(option) if limit > opts.max or limit < 1: return "Request not in range 0-%d" % opts.max return json.dumps(lastentries(limit=limit), sort_keys=True, indent=4, default=json_util.default) elif query == "get": if option is None: return "A cve-id must be specified" return apigetcve(opts.api,cveid=option) elif query == "browse": return apibrowse(opts.api, vendor=option) elif query == "search": return apisearch(opts.api, query=option) elif query == "cvetweet": text = " " if option is None: limit = 10 else: limit = int(option) if limit > opts.max or limit < 1: return "Request not in range 0-%d" % opts.max for t in lastentries(limit=limit): text = text + str(t['id']) + " , " + str(t['summary']) + " " + " , ".join(t['references']) + "\n" return text elif query == "browse": return apibrowse(vendor=option) else: return False
def do_command(self, e, cmd): words = cmd.split(' ') if len(words) >= 2: cmd = words[0] option = words[1] else: option = None if cmd == "die": self.die() elif cmd == "last": if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: self.reply(e, "Request not in range 0-%d" % args.m) self.reply( e, json.dumps(lastentries(limit=limit), sort_keys=True, indent=4, default=json_util.default)) elif cmd == "get": if option is None: self.reply(e, "A cve-id must be specified") self.reply(e, apigetcve(cveid=option)) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) elif cmd == "search": self.reply(e, apisearch(query=option)) elif cmd == "cvetweet": text = " " if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: return "Request not in range 0-%d" % args.m for t in lastentries(limit=limit): text = text + str(t['id']) + " , " + str( t['summary']) + " " + " , ".join(t['references']) + "\n" self.reply(e, text) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) else: self.reply(e, "Not understood: " + cmd)
def do_command(self, e, cmd): words = cmd.split(' ') if len(words)>=2: cmd=words[0] option=words[1] else: option=None if cmd == "die": self.die() elif cmd == "last": if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: self.reply(e, "Request not in range 0-%d" % args.m) self.reply(e, json.dumps(lastentries(limit=limit), sort_keys=True, indent=4, default=json_util.default)) elif cmd == "get": if option is None: self.reply(e, "A cve-id must be specified") self.reply(e, apigetcve(cveid=option)) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) elif cmd == "search": self.reply(e, apisearch(query=option)) elif cmd == "cvetweet": text = " " if option is None: limit = 10 else: limit = int(option) if limit > args.m or limit < 1: return "Request not in range 0-%d" % args.m for t in lastentries(limit=limit): text = text + str(t['id']) + " , " + str(t['summary']) + " " + " , ".join(t['references']) + "\n" self.reply(e, text) elif cmd == "browse": self.reply(e, apibrowse(vendor=option)) else: self.reply(e, "Not understood: " + cmd)
help="CVE id to convert") optp.add_option("-f", "--format", dest="format", default="asciidoc", help="output format : asciidoc") optp.add_option( "-a", "--api", dest="api", default="http://cve.circl.lu/", help="HTTP API url (default: http://cve.circl.lu)", ) (opts, args) = optp.parse_args() cve = json.loads(apigetcve(opts.api, cveid=opts.cve)) if not cve: sys.exit(10) print("= Common Vulnerabilities and Exposures - {}".format(cve["id"])) print("cve-search <{}/cve/{}>".format(opts.api, cve["id"])) print("{},{}".format(cve["id"], cve["Modified"])) print(":toc:") print("== {} Summary".format(cve["id"])) print("\n" + cve["summary"]) print("\n== Vulnerable configurations\n") for vul in cve["vulnerable_configuration"]: print("* {}".format(re.sub(r"\n", "-", vul["title"]))) if cve.get("cvss"):
import json import re from optparse import OptionParser from lib.Query import apigetcve optp = OptionParser() optp.add_option('-c', '--cve', dest='cve', default='CVE-2015-0001', help='CVE id to convert') optp.add_option('-f', '--format', dest='format', default='asciidoc', help='output format : asciidoc') optp.add_option('-a', '--api', dest='api', default='http://cve.circl.lu/', help='HTTP API url (default: http://cve.circl.lu)') (opts, args) = optp.parse_args() cve = json.loads(apigetcve(opts.api, cveid=opts.cve)) if not cve: sys.exit(10) print ("= Common Vulnerabilities and Exposures - {}".format(cve['id'])) print ("cve-search <{}/cve/{}>".format(opts.api,cve['id'])) print ("{},{}".format(cve['id'],cve['Modified'])) print (":toc:") print ("== {} Summary".format(cve['id'])) print ("\n"+cve['summary']) print ("\n== Vulnerable configurations\n") for vul in cve['vulnerable_configuration']: print ("* {}".format(re.sub(r'\n', '-', vul['title']))) if cve.get('cvss'):