I was able to get a php reverse shell on a webserver, say X that is behind all sorts of perimeter security stuff.
Now I want to target a machine on the same LAN with X, how do I setup metasploit for that and set LHOST etc?
Information Security Stack Exchange is a question and answer site for information security professionals. It only takes a minute to sign up.Sign up to join this community
Try to forward that host and target port with reverse proxy and then set the reserve proxy address and port pointed to target as LHOST and LPORT.
You are talking about pivoting:
Pivoting is the unique technique of using an instance (also referred to as a ‘plant’ or ‘foothold’) to be able to “move” around inside a network. Basically using the first compromise to allow and even aid in the compromise of other otherwise inaccessible systems. In this scenario we will be using it for routing traffic from a normally non-routable network.
I recommend reading https://www.offensive-security.com/metasploit-unleashed/pivoting/ to get a better understanding how this works.
In addition to that, since the host X is compromised, you could use the tools installed on that machine (or install the required tools if you are root / system
If you would like to perform a network scan, you can use nmap on machine X and export its results in XML (-oX). Once you have that file, you can import it in Metasploit: db_import [filename]
Trying using Tunna to pivot through a web shell.
I've had success with this in the past.
the previous statement that you can only pivot with an active meterpreter shell is not true.
Tunna will help you, you can also pivot with an ssh tunnel, gaining access to a laptop, then configuring a VPN from that machine will also work.