Labs / Break into a network / Break into a network: discover, pivot, move, take

Lab 2 of 4 · Break into a network: discover, pivot, move, take

Pivot in: relay through the one box the core trusts

The core answers only through a machine you own. Turn it into a relay to reach the core, then shut the hole.

Start this lab 5 steps

The idea

Stage 1 handed you a map: the core portal at {{loot:coreMap.target}}, on a network your Kali machine cannot reach, open only through the web server at 10.0.1.20 — the one address the firewall trusts across. A map is not a way in. This stage makes the machine you own carry you across to the prize.

Steps

  1. A map is not access

    You carry stage 1's map: the core portal at 10.0.2.30, reachable only through the web server at 10.0.1.20. Prove both halves still hold from where you stand. From Kali the portal is still dark — the firewall drops you — and your deploy login on the web server still works.

    Knowing where the prize is changes nothing on its own. You have the map and you have the machine; you do not yet have a way from one to the other. That is this stage's whole job.

    kali:~# curl -m4 http://10.0.2.30/
    kali:~# ssh webbox hostname
  2. Make the foothold a relay

    Turn the machine you own into a relay: a door on your Kali machine whose traffic comes out the other side, on the web server. One SSH command builds it. -D 1080 opens that door on Kali's own localhost:1080 (its proper name is a SOCKS proxy); -f -N send SSH to the background with no command to run.

    Nothing has reached the core yet — you have only built the door. Check it is open by listing the ports your Kali machine is now listening on, and find the 1080 line.

    kali:~# ssh -f -N -D 1080 webbox
    kali:~# ss -tln
  3. Reach the core through the relay

    Point curl at the relay with --socks5-hostname localhost:1080 and ask for the core portal. The request leaves from the web server, whose address the firewall trusts, so it arrives: the exact request that failed from Kali now returns the portal.

    This relay is the thing you carry forward. It is your path into the core, and every later stage rides it.

    kali:~# curl -s --socks5-hostname localhost:1080 http://10.0.2.30/
  4. See what else the relay reaches

    A relay into the core reaches the whole network, not only the one machine. Pull the portal's own list of known machines through the relay. It names a second core machine — the inventory database at 10.0.2.35 — reachable the same way.

    That database is where the next stage goes. Fetch it through the relay now and watch it answer, so you know the path there is already open.

    kali:~# curl -s --socks5-hostname localhost:1080 http://10.0.2.30/hosts
    kali:~# curl -s --socks5-hostname localhost:1080 http://10.0.2.35/
  5. Shut the relay — the defender's answer

    The relay worked because the web server — reachable from outside — was free to open new connections into the core. Close that: stop the web server from starting connections to the core network. Open a fresh relay afterwards and the pivot fails.

    Then the checklist a defender keeps:

    • Filter traffic between networks, not only at the edge. A public-facing machine must not open fresh connections deeper in. This is the same lesson stage 1 named, now proven: the trust by sender address is the whole hole.
    • Least privilege on the machine itself. Turn off SSH connection-forwarding where it is not needed, so a stolen login cannot be turned into a relay in the first place.
    • Watch traffic between internal networks. A web server suddenly opening relayed connections to the core is a loud signal, and most edge monitoring never looks between internal networks.

    Running this against a network whose owner has not authorised you in writing is a crime under laws like the UK Computer Misuse Act and the United States' CFAA — the signed engagement is what makes it a test and not an offence.

    webbox:~# iptables -I OUTPUT -d 10.0.2.0/24 -j REJECT
    kali:~# curl -s -m8 --socks5-hostname localhost:1082 http://10.0.2.30/

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab