Skip to content

Instantly share code, notes, and snippets.

@3lpsy
Last active December 6, 2019 23:55
Show Gist options
  • Save 3lpsy/4f66de729ca11eb5df5943a3fbc9c025 to your computer and use it in GitHub Desktop.
Save 3lpsy/4f66de729ca11eb5df5943a3fbc9c025 to your computer and use it in GitHub Desktop.
import sys
from pathlib import Path
import lxml.etree as et
if len(sys.argv) < 1:
print("usage: [script].py nessusfile.nessus")
sys.exit(1)
file = sys.argv[1]
#if isinstance(file, str):
# file_path = Path(file)
# content = file_path.read_text()#
#else:
# content = file.read().decode("utf-8")
# file.close()
# tree = et.fromstring(content)
p = et.XMLParser(huge_tree=True)
tree = et.parse(file, parser=p)
for elem in tree.xpath("//tag"):
if elem.attrib.get('name', None):
if elem.attrib.get('name') == 'host-ip':
print(elem.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment