Torpy - a hidden service controller and py module
run torpy from the commandline:
generate a password for accessing tor remotely, and append it to your torrc
% /usr/sbin/tor --hash-password "password"
Oct 23 23:39:44.561 [notice] Tor v0.2.3.22-rc (git-4a0c70a817797420) running on Linux.
Oct 23 23:39:44.561 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Oct 23 23:39:44.564 [notice] This version of OpenSSL has a known-good EVP counter-mode implementation. Using it.
16:1387221FFADC246D60BEAA58274647717AA12A2ACE268F7AF0D5BF271A
% sudo printf "\nCookieAuthentication 0\nHashedControlPassword 16:1387221FFADC246D60BEAA58274647717AA12A2ACE268F7AF0D5BF271A\n" >>/etc/tor/torrcgit submodule init
git submodule update
virtualenv env
source env/bin/activate
pip install pytorctl/ #note the / at the end!
echo 'passphrase="password"' >config.pyusage:
torpy list
torpy status <service>
torpy start <service> <host:port> <serviceport>
torpy stop <service>"or use it from python:
tp=Torpy(passphrase)
# list services
tp.list()
# check if test_service is running
print "running" if tp.status("test_service") else "not running"
# start test_service
tp.start("test_service","localhost:80","80")
# check again
print "running" if tp.status("test_service") else "not running"
# stop service
tp.stop("test_service")
# don't forget to close the control connection
tp.close()warning if you start a new onion service using start, the full path must be readable, writable, and executable (o+rwx) by the user running tor.