Attacking OSPF - route injection

LOKI and author's Black Hat presentation can be downloaded here: 

Falsifying routing information can have disastrous consequences to network stability. For example an attacker could reroute traffic through a monitoring station and capture traffic for later analysis. An attacker could also reroute traffic to a black hole or reroute a 10 Gig transit link traffic towards a 1 GB link causing a Denial of Service (DoS) condition. 

Both network topology and scenario presented in this post are extremely simplistic but should be sufficient to present potential implications.

Our topology:

R1's routing table looks as follows:

R1#show ip route
C is directly connected, FastEthernet1/0 is subnetted, 1 subnets
C is directly connected, FastEthernet0/0
O [110/2] via, 00:00:01, FastEthernet0/0 is subnetted, 1 subnets
C is directly connected, Loopback0
O [110/3] via, 00:00:01, FastEthernet0/0

Its OSPF neighbor table:

R1#show ip ospf neighbor

Neighbor ID     Pri   State                  Dead Time   Address         Interface       1    FULL/BDR        00:00:35      FastEthernet0/0

To launch LOKI in its default directory -  #python /usr/bin/ 

Once we click run, LOKI will by default capture all control plane protocols it supports. In the screenshot below we can see that LOKI captured an OSPF Hello packet from its adjacent router. From the captured packet we can see the following:
  • IP address the hello was sent from is
  • router ID is (by default highest loopback interface address)
  • OSPF Area is 1
  • OSPF authentication is not enabled

From here we can craft our own OSPF packets. 

Firstly we'll send an empty Hello packet and see what happens. To do so we set "area" to "1" and Authentication type to "AUTH_NONE". We start sending packets by clicking "Hello".

In R1's console we confirm that adjacency was set up:

*Mar  1 04:42:46.654: %OSPF-5-ADJCHG: Process 1, Nbr on FastEthernet1/0 from LOADING to FULL, Loading Done

R1#show ip ospf neighbor

Neighbor ID     Pri   State                 Dead Time   Address         Interface              1   FULL/BDR        00:00:38          FastEthernet1/0       1   FULL/BDR        00:00:35      FastEthernet0/0

To get even more details we enable debugging. 

R1#debug ip ospf events

*Mar  1 00:58:49.691: OSPF: Rcv hello from area 1 from FastEthernet1/0
*Mar  1 00:58:49.691: OSPF: 2 Way Communication to on FastEthernet1/0, state 2WAY
*Mar  1 00:58:49.695: OSPF: Neighbor change Event on interface FastEthernet1/0
*Mar  1 00:58:49.695: OSPF: DR/BDR election on FastEthernet1/0
*Mar  1 00:58:49.695: OSPF: Elect BDR
*Mar  1 00:58:49.695: OSPF: Elect DR
*Mar  1 00:58:49.695:        DR: (Id)   BDR: (Id)
*Mar  1 00:58:49.699: OSPF: Send DBD to on FastEthernet1/0 seq 0x24F2 opt 0x52 flag 0x7 len 32
*Mar  1 00:58:49.699: OSPF: Neighbor change Event on interface FastEthernet1/0
*Mar  1 00:58:49.699: OSPF: DR/BDR election on FastEthernet1/0
*Mar  1 00:58:49.699: OSPF: Elect BDR
*Mar  1 00:58:49.703: OSPF: Elect DR
*Mar  1 00:58:49.703:        DR: (Id)   BDR: (Id)
*Mar  1 00:58:49.703: OSPF: Send immediate hello to nbr, src address, on FastEthernet1/0
*Mar  1 00:58:49.703: OSPF: Send hello to area 1 on FastEthernet1/0 from
*Mar  1 00:58:49.707: OSPF: End of hello processing 

At this point we've set ourselves up as an OSPF neighbor and successfully created an adjacency.

Now we'll inject a false route to network

Now R1 believes that it can get to network via F0/0 (real route) and F1/0 (bogus route). Both paths have the same cost.

R1#show ip route

C is directly connected, FastEthernet1/0 is subnetted, 1 subnets
C is directly connected, FastEthernet0/0
O [110/2] via, 00:00:00, FastEthernet0/0
                    [110/2] via, 00:00:00, FastEthernet1/0 is subnetted, 1 subnets
C is directly connected, Loopback0192.
O [110/3] via, 00:00:00, FastEthernet0/0

We didn't do any actual damage in this example, but this type of attack in an enterprise network could cause serious disruptions. 

This attack can be easily defeated in a number of ways. We can use OSPF authentication, passive interfaces, access control lists or route filtering. Actually all of the above should be used together. More on defenses some other time.  

LOKI supports both clear text (though I couldn't get it to work) and MD5 authentication for OSPF. Clear text is not much of security as the key is sent in clear text so it can be sniffed.  In 

LOKI detects type of authentication used and let's us attempt to crack it. We can feed it a word list or use brute force. LOKI cracked my key of "test" (not much of a key) on a slow VM in a couple of seconds. 


  1. I'd be interested to know what version of Loki you used here as every configuration I have tried with the latest version has failed to negotiate neighbour relationships....

  2. Hi Ryan,

    I can't say now. It was the version bundled with Backtrack at the time. If you haven't done so yet, I'd suggest you enable debug on the router and see what's going on. Also Wireshark should give you hints.


  3. Can you explain how ospf injection route work ? Thank you. It's very useful for me !