erebus-attack / Bitcoin-Emulator

A comprehensive and accurate emulation of Bitcoin network implementation
MIT License
14 stars 5 forks source link

Erebus Attack Simulation

The Erebus Attack allows large malicious Internet Service Providers (ISPs) to isolate any targeted public Bitcoin nodes from the Bitcoin peer-to-peer network. Our recent work also evaluates a potential defense against this attack.

Here we faithfully implement the connection making behaviour of the Bitcoin protocol in the application space and mount the attack based on data collected from the actual Bitcoin Network. Further, we also deploy the countermeasures stated in the defense paper which can be toggled on or off. The code is broadly paritioned into three components:

  1. addrman.py - a replication of the Bitcoin Peer Management protocol.
  2. prepare.py - the environment setting component that loads data into memory
  3. libemulate.py - the emulation runner that drives addrman

The entire configuration is set in cfg.py.

By default, the emulation runs for 381 days and the attack begins at day 30.

Data prerequisites

Our emulation scenario includes an adversary AS (attacker_as) mounting the attack against a victim (victim_as). The victim AS denotes the AS network that the target victim node is connected to.

A sample data package is provided here. The attacker is considered to be the L3 AS and the victim is considered to be a node in the Amazon AS.

The following files are required to run the emulator (paths defined in cfg.EmulationParam):

Running the emulator

First, set the necessary configuration details defined in cfg.py.

Second, ensure that the data directory is extracted and placed in the project root, and all the files described above are correctly referenced in cfg.py.

We use the python virtual environment to manage dependencies.

# create venv
$ python3 -m venv ./venv
# activate it
$ source ./venv/bin/activate
# install dependencies
(venv) $ pip install -r requirements.txt

The following command will run the simulation:

(venv) $ python main.py

The run time depends on the input parameters, and may take approximately 20 minutes. The output will be saved in the ./output directory!

We consider the attack to succeed if the attacker has occupied all outgoing connections before the end time of the simulation. That is currently set to approximately 381 days (nStart - nEnd, in seconds). Otherwise, the attack is said to fail.

The only two conditions for completion are:

  1. The simulation runs till nEnd.
  2. The attacker occupies all outgoing connections.

The result of the simulation is printed to the console in the end.

The code has been tested on Ubuntu 16.04 and 18.04, with Python 3.8.

Support

Feel free to raise questions in the Issues section.