Created
December 17, 2015 15:49
-
-
Save DonnchaC/13b744a1e30b7d34bc26 to your computer and use it in GitHub Desktop.
A simple script which demonstrates how to retrieve hidden service descriptors via the HSFETCH Tor control port command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import argparse | |
import stem | |
from stem.control import Controller | |
def main(): | |
parser = argparse.ArgumentParser(description="%s fetches a Tor hidden " | |
"service descriptor." % sys.argv[0]) | |
parser.add_argument("-p", "--port", type=int, default=9051, | |
help="Tor controller port") | |
parser.add_argument('onion_address', type=str, help='Onion address') | |
args = parser.parse_args() | |
with Controller.from_port(port=args.port) as controller: | |
controller.authenticate() | |
try: | |
hs_descriptor = controller.get_hidden_service_descriptor(args.onion_address) | |
print(hs_descriptor) | |
except stem.DescriptorUnavailable: | |
print("Descriptor not found, the hidden service may be offline.") | |
return 1 | |
if __name__ == '__main__': | |
sys.exit(main()) |
Unfortunately this only seems to work with TOR v2 addresses.
When using whonix, for v3 addresses, it fails with error stem.ProtocolError: SETEVENTS rejected HS_DESC
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你好,这个代码的运行条件和需要修改的地方是哪些?