miscfreemedium

Pivot Chain Challenge

hackthebox

Task: Find minimum detection risk path through a network graph. Solution: Dijkstra algorithm with priority queue for weighted shortest path.

$ ls tags/ techniques/
api_interactiongraph_traversaldijkstra_algorithmpriority_queue

$ cat /etc/rate-limit

Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.

Pivot Chain Challenge — HackTheBox

Description

After bypassing CygnusCorp's perimeter defenses and cracking the PIN to gain internal access, you've uncovered a crucial piece of the network: the Core Administration Server. Your goal is to pivot laterally through the internal network to reach the server, but the path is not clear. The network is heavily monitored, and each host you move through carries a detection risk. Can you navigate the network stealthily, identify the safest paths, and reach the Core Administration Server without being detected?

Target: 94.237.120.233:40330

Analysis

Reconnaissance

  • Connected to the service — discovered an HTTP server with a web code editor
  • Page title "Pivot Chain" with an interface for solving challenges
  • Found API endpoint /run for submitting code in Python, C, C++ or Rust

Challenge Format

  • Input: N (hosts), M (paths), start host, target host
  • Then M lines of edges: source destination risk
  • Output: minimum total detection risk from start to target
  • Constraints: 5 <= N <= 150000, 6 <= M <= 10^6
  • Example: 5 hosts, 6 paths, optimal path host_1→host_2→host_3→host_4→host_5 with total risk 26

Algorithm Selection

This is a classic shortest path problem in a weighted directed graph:

  • Dijkstra's algorithm — optimal for finding minimum cost path
  • heapq from Python — efficient priority queue implementation
  • Complexity: O((V + E) log V)

Solution

import sys import heapq from collections import defaultdict ...

$ grep --similar

Similar writeups