forked from c0ll3cti0n/exploitpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXMLTreenode.java
More file actions
92 lines (80 loc) · 3.83 KB
/
Copy pathXMLTreenode.java
File metadata and controls
92 lines (80 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package exploitpack;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
*
* @author jsacco
*/
public class XMLTreenode {
public String ExploitName;
public String CodeName;
public String ExploitType;
public String Platform;
public String Service;
public String RemotePort;
public String LocalPort;
public String ShellPort;
public String ShellcodeAvailable;
public String Vulnerability;
public String Author;
public String Information;
public String Date;
public String Targets;
public String SpecialArgs;
public void main(String[] args, String XMLName) {
try {
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = documentBuilder.parse(new InputSource(new FileInputStream("exploits/" + XMLName)));
Node Exploit = (Node) (XPathFactory.newInstance().newXPath().evaluate("/Module/Exploit", doc, XPathConstants.NODE));
if (Exploit != null) {
ExploitName = Exploit.getAttributes().getNamedItem("NameXML").getTextContent();
CodeName = Exploit.getAttributes().getNamedItem("CodeName").getTextContent();
Service = Exploit.getAttributes().getNamedItem("Service").getTextContent();
Platform = Exploit.getAttributes().getNamedItem("Platform").getTextContent();
ExploitType = Exploit.getAttributes().getNamedItem("Type").getTextContent();
RemotePort = Exploit.getAttributes().getNamedItem("RemotePort").getTextContent();
LocalPort = Exploit.getAttributes().getNamedItem("LocalPort").getTextContent();
ShellcodeAvailable = Exploit.getAttributes().getNamedItem("ShellcodeAvailable").getTextContent();
ShellPort = Exploit.getAttributes().getNamedItem("ShellPort").getTextContent();
SpecialArgs = Exploit.getAttributes().getNamedItem("SpecialArgs").getTextContent();
} else {
System.out.println("error: " + XMLName);
}
Node Info = (Node) (XPathFactory.newInstance().newXPath().evaluate("/Module/Information", doc, XPathConstants.NODE));
if (Info != null) {
Information = Info.getTextContent();
Author = Info.getAttributes().getNamedItem("Author").getTextContent();
Date = Info.getAttributes().getNamedItem("Date").getTextContent();
Vulnerability = Info.getAttributes().getNamedItem("Vulnerability").getTextContent();
}
Node Target = (Node) (XPathFactory.newInstance().newXPath().evaluate("/Module/Targets", doc, XPathConstants.NODE));
if (Targets != null) {
Targets = Target.getTextContent();
}
Element elementRaiz = doc.getDocumentElement();
NodeList hijos = elementRaiz.getChildNodes();
for (int i = 0; i < hijos.getLength(); i++) {
Node nodo = hijos.item(i);
if (nodo instanceof Element) {
}
}
} catch (FileNotFoundException e) {
System.out.println("Error Parsin file: " + XMLName + e);
} catch (SAXException | XPathExpressionException | ParserConfigurationException | IOException e) {
System.out.println("Error Parsin file: " + XMLName + e);
}
}
}