Operation Reroute
Can you intercept traffic from another ISP? - by munra
The following post by 0xb0b is licensed under CC BY 4.0
Scenario
We've gained access to one of TryRouteMe's (TRM) core network devices through a Kali implant. We should now be able to hijack traffic for any of their users! One of our main objectives while hacking TRM was to spy on one of their VIP users. But wait... It seems our initial research was wrong and our target isn't even a client of TRM!
We know for a fact that the victim uses Doogle's DNS at 10.10.10.10. Strangely enough, it seems there's more than one server with such an IP in the world... What does this even mean? And how are we supposed to hijack the victim's traffic if we only have access to TTM's router?
Your Kali jumpbox can be reached via:
From the Kali machine, you can SSH into the TTM router at IP 192.168.1.1 with the following credentials:
Credentials
ttm
ttm2024
192.168.1.1
ssh ttm@192.168.1.1
Note: The domain name for this challenge is contained in the DNS requests made by the victim to the 10.10.10.10 server.

We have access to one of TryRouteMe's (TRM) core network devices through a Kali implant in AS 1111. Our target is a VIP user in AS 2222 whose machine sends DNS queries to 10.10.10.10 in AS 3333. Two DNS servers share that same IP address in different autonomous systems (AS 1111 and AS 3333).
The victim's DNS queries for 10.10.10.10 currently travel through TIWS to NICENET AS 3333, where DNS2 lives. Our goal is to reroute those queries to DNS1 in AS 1111 so we can read them.
Recon
We connect to the kali box, and then connect to TryRouteMes router.
Connect to the Kali box:

SSH into the TryRouteMe router:

After SSH-ing into the TryRouteMe router ssh ttm@192.168.1.1, we land directly in a FRRouting CLI. FRRouting is an open-source routing software suite for Linux that implements BGP, OSPF, and other routing protocols. With that an ordinary Linux machine turns into a fully functional network router with a Cisco-like command-line interface.
We'll familiarize ourselves with the suite and take a look at the various commands; first, we want to find out more about the current configuration.


Running show running-config reveals the key facts.

The config starts with general settings; the router's hostname is TTM-CORE-01, it is running FRR version 10.0, and IPv6 is disabled.
The prefix lists are filters that control what routes are allowed in and out.
With bgp-in permit any the router accepts whatever routes its neighbor sends it. There are no filters on incoming routes. We have two bgp-out entries. Only 192.168.1.0/24 and 10.10.10.0/24 are allowed to be advertised outward. Anything else the router tries to announce gets silently dropped.
The three interfaces tell us where the router sits in the network.
The eth0 interface at 192.168.1.1/24 is the internal LAN where our Kali machine is. Interface eth1 at 10.1.1.1/30 is a narrow point-to-point link with only two usable IPs, connecting to TIWS, the router in AS 2222, and serves as the BGP peering connection between the two autonomous systems. The third interface at 10.10.10.1/24 is the subnet where DNS1 sits at 10.10.10.10.
The BGP section is where it gets interesting. The Border Gateway Protocol (BGP) is the routing protocol that autonomous systems use to tell each other which IP ranges they can reach.
The router belongs to AS 1111 and has one BGP neighbor: 10.1.1.2 in AS 2222 (TIWS). The two network statements tell BGP to advertise 10.10.10.0/24 and 192.168.1.0/24 to that neighbor. redistribute connected also shares routes for any directly connected subnet. The last two lines apply our prefix lists: bgp-in filters what we receive, bgp-out filters what we send.
So AS 1111 is announcing 10.10.10.0/24 to AS 2222. But we know from the scenario that the victim's DNS traffic goes to AS 3333, not to here. That means AS 2222 also receives a 10.10.10.0/24 route from AS 3333 and prefers that one, probably because it's a more direct path. Both routes are the same size /24, so BGP tiebreakers decide, and the traffic goes to AS 3333.
From show ip bgp we see that 10.10.10.0/24 appears twice. One locally and one via the path 2222 3333. The local route is marked as best (*>), but that only matters for this router's own forwarding. TIWS in AS 2222 still prefers the shorter path through AS 3333.

We have one BGP neighbour at 10.1.1.2 (TIWS, AS 2222) and the session is up.

BGP Hijacking Detour
A detailed explanation of BGP and BGP Hijacking can be found here:
What is BGP?
The Border Gateway Protocol (BGP) is the routing protocol autonomous systems (AS) use to exchange reachability information. While DNS resolves domain names to IP addresses, BGP determines which routes are available to reach a given IP prefix and selects a preferred path based on routing policy and path attributes. AS-path length is one factor in that choice, but BGP does not simply pick the route with the fewest hops.
BGP relies on autonomous systems (AS). These are large networks or groups of networks managed by a single entity (e.g., an Internet service provider or a large organization with a multihomed network) that share a unified routing policy. Each AS is identified by a unique Autonomous System Number (ASN). BGP routers continuously update their routing tables as autonomous systems advertise their IP prefixes, so each router can select a path to every prefix according to its routing policy.
How can BGP be hijacked?
When an AS announces prefixes it doesn't actually control and nothing filters the announcement, it can propagate into routing tables across the Internet. Until someone notices and corrects it, traffic for those addresses flows to that AS.
For a hijack to take effect, the announcement has to be preferred over the legitimate one, in one of two ways:
A more specific route: announcing a smaller address range than the real owner does.
A shorter route: announcing what looks like a closer path to the destination.
When a router forwards a packet, it uses the most specific installed route that matches the destination (the longest-prefix match rule). A /25 therefore takes precedence over a /24 for any address inside that /25 range.
This is possible because BGP has no built-in proof of prefix ownership; a neighbour trusts what it's told.
For example, if AS 3333 advertises 10.10.10.0/24 (covering .0 through .255) and AS 1111 advertises 10.10.10.0/25 (covering .0 through .127), any traffic for 10.10.10.10 goes to AS 1111.The /25 is more specific, so it wins unconditionally.
BGP has no built-in authentication of route ownership. Any AS can announce any prefix, and neighbours trust those announcements.
Exploitation
Now that we know a router will forward on the more specific prefix regardless of who announced it, we can put that to use. We need four changes to the router: update the prefix filter, create a static route, advertise the /25 via BGP, and redirect the traffic to the Kali machine.
We run configure terminal to make the changes like shown below.
Each step is explained afterwards.

First, we add the more-specific prefix to the outbound filter.
The existing bgp-out prefix list only permits /24. Without adding a rule for /25, the router would filter out our hijack route before it ever reaches TIWS.
Next, we install a static route for the /25 so BGP will originate it (a network statement needs a matching route in the table). The next hop here is the router's own eth2 address; this is what let BGP advertise the prefix in the lab.
Now we advertise the /25 via BGP. This is the hijack itself. TIWS now receives 10.10.10.0/25 from AS 1111, which is more specific than the /24 from AS 3333.
Finally we redirect traffic for 10.10.10.10 to the Kali machine on 192.168.1.100. The hijacked traffic arrives at the TryRouteMe router, but DNS1 at 10.10.10.10 isn't accessible from Kali. This static route sends the packets to the Kali machine instead.
Back on the kali machine we then have to add the destination IP to Kali's interface. Without this, Kali's kernel drops incoming packets destined for 10.10.10.10 because it doesn't recognize that IP as its own.

Next, we just need to capture the incoming DNS queries. The machine has no tcpdump or tshark installed and no network access to fetch packages, so we write a raw-socket DNS sniffer in Python using Claude. Shortly after the queries arrive from the victim and we are able to see the internal domain name the victim is trying to resolve and a flag encoded in base64.

Real-world implications
Sub-prefix hijacking is not just a theoretical concept. The same technique scales from just a CTF lab to nation-state operations, and the damage depends on what the threat actor does with the redirected traffic.
Surveillance and data exfiltration
A silent hijack on DNS lets an attacker log every domain a target resolves including browsing habits, internal service names, API endpoints, without ever compromising the target's machine, as shown in this scenario. Applied to a broader prefix, it would be possible to capture traffic from thousands of users. If the traffic is unencrypted, the attacker is able to read it in full.
Phishing and credential theft
Instead of forwarding the request to the real server, an attacker can send back fake DNS responses that redirect the victim to a fake website. The victim enters their login credentials on a page that looks identical to the real one.
Censorship
A government entity / state-level actor that controls a large AS can announce more specific prefixes for services it wishes to block. Traffic for these services is redirected to a blackhole or a blocking page.
Supply-chain attacks
By taking over the prefix of a software update server or a package registry, an attacker could deliver modified binaries to anyone whose traffic passes through the hijacked route.
Last updated