JSP Page Crawler that extracts all input parameters

旧巷老猫 提交于 2019-12-08 05:08:32

The idea is to build a static analyzer that has the capacity to detect all parameter fields from all dynamic pages.

You cannot use a web crawler (basically, a HTML parser) to extract request parameters. They can at highest scan the HTML structure. You can use for example Jsoup for this:

for (Element form : Jsoup.connect("http://google.com").get().select("form")) {
    System.out.printf("Form found: action=%s, method=%s%n", form.attr("action"), form.attr("method"));
    for (Element input : form.select("input,select,textarea")) {
        System.out.printf("\tInput found: name=%s, value=%s%n", input.attr("name"), input.attr("value"));
    }
}

This prints currently

Form found: action=, method=
    Input found: name=hl, value=en
    Input found: name=source, value=hp
    Input found: name=ie, value=ISO-8859-1
    Input found: name=q, value=
    Input found: name=btnG, value=Google Search
    Input found: name=btnI, value=I'm Feeling Lucky
    Input found: name=, value=
Form found: action=/search, method=
    Input found: name=hl, value=en
    Input found: name=source, value=hp
    Input found: name=ie, value=ISO-8859-1
    Input found: name=q, value=
    Input found: name=btnG, value=Google Search
    Input found: name=btnI, value=I'm Feeling Lucky

If you want to scan the JSP source code for any forms/inputs, then you have to look in a different direction, it's definitely not to be called "web crawler". Unfortunately no such static analysis tool comes to mind. Closest what you can get is to create a Filter which logs all submitted request parameters.

Map<String, String[]> params = request.getParameterMap();
// ...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!