Skip to content

Instantly share code, notes, and snippets.

@byt3bl33d3r
Created May 12, 2015 02:00
Show Gist options
  • Save byt3bl33d3r/b8605fd5068fc8ff1c6c to your computer and use it in GitHub Desktop.
Save byt3bl33d3r/b8605fd5068fc8ff1c6c to your computer and use it in GitHub Desktop.
Parses a Java 'Vulnerability Details' page on http://www.cvedetails.com and prints all of the Java version strings affected (e.g '1.6.0.23')
#! /usr/bin/env python2
import requests
import lxml.html
import sys
r = requests.get(sys.argv[1])
tree = lxml.html.fromstring(r.text)
try:
vulntable = tree.xpath('//table[@id="vulnprodstable"]/*')
list_len = len(vulntable)
tuple_list = []
for i in vulntable[2:list_len]:
java_v = (i.getchildren()[4].text.strip(), i.getchildren()[5].text.strip()[6:].strip())
tuple_list.append(java_v)
except IndexError:
pass
for v in sorted(set(tuple_list)):
version, update = v
if update:
print "{}.{}".format(version, update)
else:
print version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment