Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple script which demonstrates how to retrieve hidden service descriptors via the HSFETCH Tor control port command
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())
@ws1021

This comment has been minimized.

Copy link

ws1021 commented May 6, 2019

你好,这个代码的运行条件和需要修改的地方是哪些?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.