Browse Source

added attack simulation scripts

expiry-test
Kevin Froman 2 years ago
parent
commit
6500229000
  1. 4
      scripts/README.md
  2. 25
      scripts/announce-attack.py
  3. 21
      scripts/block-spammer.py
  4. 2
      src/etc/onionrvalues.py

4
scripts/README.md

@ -1,4 +1,6 @@
This directory contains useful scripts and utilities that don't make sense to include as official Onionr features.
passphrase-generator.py: very simple utility to generate and print a strong passphrase to stdout. 256 bits of entropy by default.
enable-dev-config.py/disable-dev-config.py: enable/disable dev default config setup
enable-dev-config.py/disable-dev-config.py: enable/disable dev default config setup
block-spammer.py: attack tool for spamming blocks
announce-attack.py: flood a node with false nodes

25
scripts/announce-attack.py

@ -0,0 +1,25 @@
import sys
import os
import secrets
import base64
os.chdir('../')
sys.path.append("src/")
from onionrutils import stringvalidators
from onionrutils import basicrequests
def random_tor_generator():
return base64.b32encode(secrets.token_bytes(35)).decode().replace("=", "").lower() + ".onion"
node = input("Enter node to attack. Note that you must legally use your own, and even that might lead to issues")
assert stringvalidators.validate_transport(node)
count = int(input("Attack amount: "))
port = input("Socks:")
for x in range(count):
new = random_tor_generator()
print(f"Introducing {new} to {node}")
basicrequests.do_post_request(
f'http://{node}/announce',
data = {'node': new},
port=port)

21
scripts/block-spammer.py

@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Spam a bunch of Onionr blocks"""
# Please don't run this script on the real Onionr network. You wouldn't do anything but be annoying
print("Please don't run this script on the real Onionr network. You wouldn't do anything but be annoying, and possibly violate law")
import sys
import os
os.chdir('../')
sys.path.append("src/")
import onionrblocks
amount = int(input("Number of blocks:"))
for i in range(amount):
onionrblocks.insert(data=os.urandom(32))
print(i, "done")

2
src/etc/onionrvalues.py

@ -53,7 +53,7 @@ MAX_NEW_PEER_QUEUE = 1000
"""Make announce take a few seconds (on average) to compute to discourage excessive node announcements"""
ANNOUNCE_POW = 6
"""30 days is plenty of time for someone to decide to renew a block"""
DEFAULT_EXPIRE = 2592000
DEFAULT_EXPIRE = 300
# Metadata header section length limits, in bytes
BLOCK_METADATA_LENGTHS = {'meta': 1000, 'sig': 200, 'signer': 200, 'time': 10, 'pow': 1000, 'encryptType': 4, 'expire': 14}

Loading…
Cancel
Save