All Projects → PanagiotisDrakatos → T0rlib4Android

PanagiotisDrakatos / T0rlib4Android

Licence: Apache-2.0 license
A minimal android controller library for Tor

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to T0rlib4Android

T0rlib4j
T0rlib4j is a Java controller library for Tor
Stars: ✭ 50 (+100%)
Mutual labels:  tor, tor-network, hidden-services, tor-users
Attacks-on-Tor
Thirteen Years of Tor Attacks
Stars: ✭ 170 (+580%)
Mutual labels:  tor, tor-network, hidden-services
Docker Tor Hiddenservice Nginx
Easily setup a hidden service inside the Tor network
Stars: ✭ 145 (+480%)
Mutual labels:  tor, tor-network
Ansible Relayor
An Ansible Role for Tor Relay Operators
Stars: ✭ 165 (+560%)
Mutual labels:  tor, tor-network
Torghostng
TorghostNG - Make your internet traffic anonymized through Tor network and Privoxy. Rewritten from TorGhost with Python 3
Stars: ✭ 241 (+864%)
Mutual labels:  tor, tor-network
Torpy
Pure python Tor client implementation
Stars: ✭ 104 (+316%)
Mutual labels:  tor, tor-network
Onionbrowser
An open-source, privacy-enhancing web browser for iOS, utilizing the Tor anonymity network
Stars: ✭ 1,702 (+6708%)
Mutual labels:  tor, tor-network
tor-ip-changer
request new identity every X seconds interval using TOR client
Stars: ✭ 233 (+832%)
Mutual labels:  tor, tor-network
Onionite
Explore the Tor network
Stars: ✭ 63 (+152%)
Mutual labels:  tor, tor-network
GhostNET
GhostNET script that will help you be safer on the cyber
Stars: ✭ 45 (+80%)
Mutual labels:  tor, tor-network
OnionHarvester
A small TOR Onion Address harvester for checking if the address is available or not.
Stars: ✭ 71 (+184%)
Mutual labels:  tor, tor-network
Poopak
POOPAK - TOR Hidden Service Crawler
Stars: ✭ 78 (+212%)
Mutual labels:  tor, tor-network
Tortipi
Tor based Raspberry π hotspot
Stars: ✭ 76 (+204%)
Mutual labels:  tor, tor-network
Private Tor Network
Run an isolated instance of a tor network in Docker containers
Stars: ✭ 125 (+400%)
Mutual labels:  tor, tor-network
Tor Router
A SOCKS, HTTP and DNS proxy for distributing traffic across multiple instances of Tor
Stars: ✭ 69 (+176%)
Mutual labels:  tor, tor-network
Online Privacy Test Resource List
Privacy Online Test and Resource Compendium (POTARC) 🕵🏻
Stars: ✭ 185 (+640%)
Mutual labels:  tor, tor-network
tor-rootkit
A Python 3 standalone Windows 10 / Linux Rootkit using Tor.
Stars: ✭ 142 (+468%)
Mutual labels:  tor, hidden-services
Sybilhunter
Hunting for Sybils and anomalies in archived Tor network data.
Stars: ✭ 35 (+40%)
Mutual labels:  tor, tor-network
Deepweb Scappering
Discover hidden deepweb pages
Stars: ✭ 40 (+60%)
Mutual labels:  tor, tor-network
onionfruit
OnionFruit™ Connect - Tor access client with country selection, bridge configuration, pluggable transports and experimental DNS support
Stars: ✭ 150 (+500%)
Mutual labels:  tor, tor-network



T0rlib4Android Implementation

A minimal android controller library for Tor and instant messaging.

                                           Build Status GitHub Issues License GitHub pull requests

Basic Overview

T0rlib4Android is an android controller library for Tor. With it you can use Tor's control protocol to communicate against the Tor process, or build things such as arm. T0rlib4Android latest version is 2.0.1 (released October 12rd, 2017).

In addition, this library simulates and tends to look like a classic messaging app designed for activists, journalists, and anyone else who needs a safe, easy and robust way to communicate via tor network, without being monitored or blocked by their mobile internet service provider. To sum up the main goal is to protect users and their relationships from surveillance by having the ability to transparently torify all of the TCP traffic on your android app.

Why Should i use it?

Well, to begin with, T0rlib4Android have all you need to connect to hiddenservices in order to communicate with 2 or more entities, all in one library. Tor makes it possible for users to hide their locations while offering various kinds of services, such as web publishing or an instant messaging server. Using Tor "rendezvous points," other Tor users can connect to these hidden services, each without knowing the other's network identity. This page describes the technical details of how this rendezvous protocol works.

Start using it right now, you can save more 100 hours of software by writing code. if you you need to use android for your projects to connect to tor network this is the right place to start, for the follownig reasons.

  • It is really easy to use you. The only thing to do is to include the dependency and you are ready to write some sample code to get you started How to Start.
  • The project will try to stay full updated with the latest tor patches tor-win32-0.3.1.7.
  • It is free and open source and is intended to be used by any programmer who wants a messaging app via tor.

How do I use this library?

The only thing to do before you write your code is to add it in your root build.gradle at the end of repositories:

allprojects {
      repositories {
		maven { url 'https://jitpack.io' }
		}
	}

Then go to dependencies in the module of your application and put the following dependency:

dependencies {
        compile 'com.github.PanagiotisDrakatos:T0rlib4Android:v0.2-beta'
}

Android

If you want to run the library from the android studio emulator make sure that you will edit the AVD manager just like the printscreen below. An Android Virtual Device (AVD) is a configuration that defines the characteristics of an Android phone, tablet, Android Wear, or Android TV device that you want to simulate in the Android Emulator. The AVD Manager is an interface you can launch from Android Studio that helps you create and manage AVDs

To open the AVD Manager, do one of the following:

  • Select Tools > Android > AVD Manager.
  • Click AVD Manager icon in the toolbar. From the Your Virtual Devices page, you can perform the following operations on an existing AVD:
  • To edit an AVD, click Edit and make your changes.
  • To delete an AVD, right-click an AVD and select Delete. Or click Menu and select Delete.

This code represent the server side part.To be more specific

  • The HiddenServiceDir directive tells Tor where to look for the Hidden Service Directory containing the private key of the Hidden Service. Each Hidden Service Owns it's own directory. The directory needs to be created and having permissions of the Tor User.
  • The Hostname of your new Hidden Service will be available in the file hostname just created in your Hidden Service Directory
  • The tor directive tells in our Serversocket on which port to listen, to forward to which ip and to which port.
import android.content.Context;


import net.sf.controller.network.AndroidTorRelay;
import net.sf.controller.network.TorServerSocket;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.concurrent.CountDownLatch;

public class ServerSocketViaTor {
    private static final Logger LOG = LoggerFactory.getLogger(ServerSocketViaTor.class);
    private static final int hiddenservicedirport = 80;
    private static final int localport = 2096;
    private static CountDownLatch serverLatch = new CountDownLatch(2);
    private Context ctx;

    public ServerSocketViaTor(Context ctx) {
        this.ctx = ctx;
    }

    public void Init() throws IOException, InterruptedException, ClassNotFoundException, CloneNotSupportedException {
        if (ctx == null) {
            return;
        }
        String fileLocation = "torfiles";
        AndroidTorRelay node = new AndroidTorRelay(ctx, fileLocation);
        TorServerSocket torServerSocket = node.createHiddenService(localport, hiddenservicedirport);

        System.out.println("Hidden Service Binds to   " + torServerSocket.getHostname() + " ");
        System.out.println("Tor Service Listen to RemotePort  " + torServerSocket.getServicePort());
        System.out.println("Tor Service Listen to LocalPort  " + node.getSocksPort());
        ServerSocket ssocks = torServerSocket.getServerSocket();
        Server server = new Server(ssocks);
        new Thread(server).start();

        serverLatch.await();
    }

    private static class Server implements Runnable {
        private final ServerSocket socket;
        private int count = 0;
        private static final DateFormat df = new SimpleDateFormat("K:mm a, z");
        private String Date;

        private Server(ServerSocket socket) {
            this.socket = socket;
        }

        @Override
        public void run() {

            System.out.println("Wating for incoming connections...");
            try {
                while (true) {

                    Socket sock = socket.accept();
                    this.Date =df.format(Calendar.getInstance().getTime());
                    System.out.println("Accepted Client " + (count++) + " at Address - " + sock.getRemoteSocketAddress()
                            + " on port " + sock.getLocalPort() + " at time " + this.Date);
                    ObjectInputStream in = new ObjectInputStream(sock.getInputStream());
                    System.out.println((String) in.readObject());
                    sock.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

        }
    }
}

How do I connect to Tor?

Once you have Tor running and properly configured you have a few ways of connecting to it. The following is one of the most common method for getting a Controller instance, from the highest to lowest level which library supports.

  • Socket Module: You can skip the conveniences of a high level Controller and work directly with the raw components. At T0rlib4j lowest level your connection with Tor is a socks4aSocketConnection-socks5aSocketConnection subclass and for the Server socket TorServerSocket subclass. This provides methods to send, receive, disconnect, and reconnect to Tor.

T0rlib4j offers two interfaces into the Tor network:

  • SSOCKS 4A: proxy 127.0.0.1:9050
  • SSOCKS 5 : proxy 127.0.0.1:9050

Now for the sake of the completeness we will demonstrate how the Tor client behave. Here is some sample code to get you started.

import android.content.Context;
import android.util.Log;

import net.sf.controller.network.AndroidTorRelay;
import net.sf.msopentech.thali.java.toronionproxy.Utilities;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;

public class TorClientSocks4 {
    private Context ctx = null;

    public TorClientSocks4() {
    }

    public TorClientSocks4(Context ctx) {
        
        this.ctx = ctx;
    }

    public void Init() throws IOException, InterruptedException {
        if(ctx==null){
            Log.e("TorTest", "Couldn't start Tor!");
            return;
        }
        String fileLocation = "torfiles";
        // Start the Tor Onion Proxy
        AndroidTorRelay node = new AndroidTorRelay(ctx,fileLocation);
        int hiddenServicePort = 80;
        int localPort = node.getSocksPort();
        String OnionAdress = "bla..bla.onion";
        String localhost="127.0.0.1";

        Socket clientSocket = Utilities.socks4aSocketConnection(OnionAdress, hiddenServicePort, "127.0.0.1", localPort);

        ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());
        out.flush();

        out.writeObject("i am workingg");
        out.flush();
    }
}

Acknowledgements

A huge thanks to thaliproject an open source company. This project started by literally copying their code which handled things in Android and then expanding it to deal with Java. A massive admiration on theese people for the great effort

Another huge thanks to the Guardian folks for both writing JTorCtl and doing the voodoo to get the Tor OP running on Android.

And of course an endless amount of gratitude to the heroes of the Tor project for making this all possible in the first place and for their binaries which we are using for all our supported Java platforms.

FAQ

What is the maturity of the code in this project?

Well the release version is currently 2.0.1 so that should say something. This is an alpha. We have (literally) one test. Obviously we need a heck of a lot more coverage. But we have run that test and it does actually work which means that the Tor OP is being run and is available.

Where does jtorctl-briar.jar come from?

This is a fork of jtorctl with some fixes from Briar. So we got it out of Briar's depot. The plan is that jtorctl is supposed to accept Briar's changes and then we will start to build jtorctl ourselves from the Tor depot directly.

Where did the binaries for the Tor OP come from?

Android

The ARM binary for Android came from the OrBot distribution available at https://guardianproject.info/releases/. I take the latest PIE release qualify APK, unzip it and go to res/raw and then decompress tor.mp3 and go into bin and copy out the tor executable file and put it into android/src/main/assets

Windows

I download the Expert Bundle for Windows from https://www.torproject.org/download/download.html.en and took tor.exe, libeay32.dll, libevent-2-0-5.dll, libgcc_s_sjlj-1.dll and ssleay32.dll from the Tor directory. I then need to zip them all together into a file called tor.zip and stick them into java/src/main/resources/native/windows/x86.

Where did the geoip and geoip6 files come from?

I took them from the Data/Tor directory of the Windows Expert Bundle [Why Should i use it](#Why Should i use it)

Why does the Android code require minSdkVersion 16?!?!?! Why so high?

The issue is the tor executable that I get from Guardian. To run on Lollipop the executable has to be PIE. But PIE support only started with SDK 16. So if I'm going to ship a PIE executable I have to set minSdkVersion to 16. But!!!!! Guardian actually also builds a non-PIE version of the executable.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Support

Please open an issue for support or even more open a pull request.

License

This project is licensed under the Apache License 2.0 - see the Licence.md file for details

Contributing

Please contribute using Github Flow. Create a branch, add commits.

  1. Fork it: git clone https://github.com/PanagiotisDrakatos/T0rlib4Android.git
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request
  6. 😄 😄 😄
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].