DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Integrating Redis With Message Brokers
  • Terraform State File: Key Challenges and Solutions
  • How to Reorganize and Rebuild Indexes in MS SQL?
  • Essential GitHub Enterprise Admin Commands

Trending

  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  • Analyzing Techniques to Provision Access via IDAM Models During Emergency and Disaster Response
  • Distributed Consensus: Paxos vs. Raft and Modern Implementations
  • Using Python Libraries in Java
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. Command Line Tor

Command Line Tor

So Tor's useful for anonymous internet access, for sure. But most of us use it from the browser bundle - how can you use it from the command line or a program?

By 
Christopher Lamb user avatar
Christopher Lamb
·
Updated Apr. 03, 18 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
23.7K Views

Join the DZone community and get the full member experience.

Join For Free

Let's take a look at the command line first. So Tor, in the bundle we all know and love, consists of two things - the browser and the router. The browser is preconfigured to use the Tor router in the installed bundle. When you use Tor from the command line, we don't have that option. We end up needing to, somehow, force the commands we would generally use from the command line to dispatch requests through the Tor router.

To do this, you use Tor, Torify, and, preferentially, Torsocks. So first, you still need to install Tor. You don't need to use the bundle - you can use either brew or apt, or likely any other package manager. You'll want to install Tor and Torsocks. On Ubuntu or a similar Debian system, you get all this for free by installing Tor. If you're on OS X, use brew to install Tor and Torsocks separately - Torsocks isn't included. If you're not using either a Linux or OS X, well, you have other issues you might want to address, but you can fix that temporarily at least by downloading VirtualBox and getting a VM running you can use to do real work.

Now, you do need to configure Tor in order to use it - and this is slightly different depending on the platform you use. On a Mac, copy the torrc.sample file to the root of the Tor distribution - /usr/local/etc/tor, and name it torrc. Then uncomment the controlport line and the Cookieauthentication line. Change the cookieauthentication value to 0 and start Tor (the tor command on the command line is sufficient for this).

Do the same thing on a Linux system, but you don't need to copy the torrc file first - it's in /etc/tor. After you've made these changes, you can restart the service or the system - up to you. On Linuxes, Tor runs as a service.

Now Torify requires that you manually create a new session in order to use Tor. You do this by sending a command to the Tor control port, like this:

$ echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 

Then, you can use Torify to execute a request over Tor:

$ torify curl -v https://slashdot.org

To start a new session, re-echo the authentication command to the local control port.

Now Torify is a bit complex, and it's easy to mess up. Torsocks is harder to use incorrectly, as you don't need to manually create a new session, or manually control the router. With Tor running, you use Torsocks just like you do Torify (e.g. torsocks <your command here>), and it will create the virtual circuit for you prior to executing your command.

So overall, not that bad! Enjoy your anonymous command line.

Tor (network) Command (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Integrating Redis With Message Brokers
  • Terraform State File: Key Challenges and Solutions
  • How to Reorganize and Rebuild Indexes in MS SQL?
  • Essential GitHub Enterprise Admin Commands

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!