Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
quick primer on how to exploit path traversals in Java web apps (i.e. you can read WEB-INF/web.xml)
so, you can read WEB-INF/web.xml. how can you escalate this issue?
[step 1]. try to read other common Java files such as WEB-INF/web-jetty.xml.
use a specialized wordlist such as the following (from Sergey Bobrov/BlackFan):
with time you can build your own wordlist adding files you've discovered over time.
use Burp Intruder for this, it's perfect for this job.
sort Intruder results by status code so you can see instantly which files were found.
[step 2]. take a look at WEB-INF/web.xml and try to understand what framework was used.
most Java web applications nowadays are using Spring (
if you see in WEB-INF/web.xml some class name with org.springframework (usually DispatcherServlet), it means it's Spring.
for example:
if it's Spring, look for the servlet-mapping (servlet-name) section.
for example:
in this case, the name of the servlet is "golfing".
according to Spring convention, you will need to have a file called WEB-INF/golfing-servlet.xml in your application.
this file will contain all of your Spring Web MVC-specific components (beans).
try to read this file.
for Spring, also look for WEB-INF/applicationContext.xml
if it's not Spring, it could be Struts (
look for something like this
if it's Struts, look for something like try to read these files
more info here:
if it's not Spring and not Struts try to read attentively the web.xml file to figure out what framework they could be using and read its docs.
[step 3]. classpath:bla in web.xml
If you find in web.xml a file referenced using classpath:filename such as the following example:
it means the file is located in class path. class path is usually located in WEB-INF/classes/ or WEB-INF/lib/
this means that you can read the file referenced there (my-main-spring.xml) by reading:
WEB-INF/classes/my-main-spring.xml or
[step 4]. look for class names in web.xml and try to read the .class files
in WEB-INF/web.xml and/or the other files you were able to read following steps 1-3 you will find a lot of class names.
class names are referenced like this:
<bean class=""> or like this
in any case, the name of the class is ""
in Java, this class is stored in this folder + file:
classes are usually stored in either WEB-INF/classes/ or WEB-INF/lib/
therefore, you should try to read the class file by reading
to download the class files I usually use curl like this:
curl -O --path-as-is
if it works, this will save a file className.class in the current directory.
Sergey Bobrov/BlackFan wrote a tool that helps with this:
if you are able to download the className.class you need to decompile it so you can take a look at Java source code
i use the following 2 tools:
when you decompile it you get access to more class names (from imports) and then download more source code and so on.
somebody should write a tool to automate this so it will decompile classes, read imports, download more classes, decompile, ...
have fun!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment