Pentesterlab--Axis2 Web Service and Tomcat Manager
When you engage in actual fighting, if victory is long in coming, then men’s weapons will grow dull and their ardor will be damped. If you lay siege to a town, you will exhaust your strength. —– The Art of War
This course details the exploitation of an issue in an Axis2 Web service and how using this issue it is possible to retrieve arbitrary files. Then using this, we will see how an attacker can retrieve Tomcat users' file to access the Tomcat Manager and gain commands execution on the server. —Pentesterlab
Difficluty: 3/5
Forces:
- Nmap
- wfuzz
- nc
- msfvenom
Detail Assessment and Planning
- Port scan to identify opened ports, running services and services version. —Nmap
- Burte force hidden path of the server. —-wfuzz
- generate webshell. —msfvenom
- backdoor. —nc
- webshell. —Car.arr
Waging War
Weaknesses and Strengths
Used Nmap to idenfity opened ports. TCP port 80 is opened and Apache service is running on it.
nmap -sV -v -A 192.168.79.168
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_001.png)
Use wfuzz to burte force hidden path of the server
1
| |
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_002.png)
Now we find that the server host a web service using Axis2.
In order to test is the web server using Tomcat, we can try to visit a non-existing web page and watch the 404 error page.
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_003.png)
Now we find the server uses Tomcat and we get the version of the Tomcat. Keep going…
Lets check the path axis2/ , we get the page:
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_004.png)
get the list of the available services by visiting the page http://192.168.79.168/axis2/services/listServices or click the serices link
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_005.png)
The WSDL information can be accessed by clicking the service’s name in the listServices page or directly using the following URL: http://192.168.79.168/axis2/services/ProxyService?wsdl.
We can see that get operation is defined in WSDL
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_006.png)
Axis2 provides an easy way to call Web services, you just need to follow the pattern http://[WS_URL]/method?parameters
Attack
Easy way
Get Tomcat manager configuration to get login credentials. In Debian Linux, the tomcat configuration file tomcat-users.xml has default location: /etc/tomcat6/tomcat-users.xml
So we can try:
1
| |
Then we get the Tomcat manager’s credentials:
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_008.png)
the tomcat manager-gui login password can be found: username: manager password: !mp0ss!bl32gu355
Then login tomcat manager from the URL http://192.168.79.168/manager/html to upload and deploy JSP webshell in WAR file.
deploy webshell
Generate webshell:
1 2 3 4 | |
Then uplpad the websehll.war to manager page
in Kali setup nc:
nc -nlvp 4444
go to http://192.168.79.168/webshell/sh4.jsp
then you will get the shell:
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_009.png)
‘Hard’ way
In Debian Linux, the axis2 configuration file axis2.xml has default location: /var/lib/tomcat6/webapps/axis2/WEB-INF/conf/axis2.xml
so we can visit this page by using,
http://192.168.79.168/axis2/services/ProxyService/get?uri=file:///var/lib/tomcat6/webapps/axis2/WEB-INF/conf/axis2.xml
from axis2.xml, we find the credential is admin/axis2
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_010.png)
Then login axis2 admin page from the URL http://192.168.79.168/axis2/axis2-admin/
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_011.png)
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_012.png)
then try to upload webshell.war we used in last method.
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_013.png)
Looks like it doesn’t support the war file format. WTF, okay, try harder.
After google search, I found a webshell for axis2, called Cat.arr
Download it and upload it to the server, it requres host IP and port number:
1
| |
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/Selection_014.png)
Oh…..
![[title manually exploit [alt text]]](/images/blog/pentesterlab/axis2/gameover.jpeg)