首页 > 代码库 > WebGoat教程学习(七)--XPATH 注入(XPATH-Injection)

WebGoat教程学习(七)--XPATH 注入(XPATH-Injection)

1、除了SQL注入外还要考虑XPTH的过滤。

 

File d = new File(dir);
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
InputSource inputSource = new InputSource(new FileInputStream(d));
String expression = "/employees/employee[loginID/text()=‘" + username + "‘ and passwd/text()=‘" + password
        + "‘]";
nodes = (NodeList) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);

 

在用户名处注入 Smith‘ or 1=1 or ‘a‘=‘a,这将会显示你登录系统的第一个用户。密码是必须的字段,可以任意输入。

 

WebGoat教程学习(七)--XPATH 注入(XPATH-Injection)