thaliproject / Tor_Onion_Proxy_Library

Provides a JAR and an AAR for embedding the Tor Onion Proxy into a Java or Android Program
Apache License 2.0
174 stars 97 forks source link

targetSdkVersion 29 permission denied #153

Open pingothedoer opened 3 years ago

pingothedoer commented 3 years ago

Hi. Since November is the deadline for all the apps to start using targetSdkVersion 29, This library doesn't work. Here are the logs that i faced when i upgraded my sdk version.

W/System.err: java.io.IOException: Cannot run program "/data/user/0/<app-id>/app_torfiles/tor" (in directory "/data/user/0/<app-id>/app_torfiles"): error=13, Permission denied W/System.err: at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050) W/System.err: at com.msopentech.thali.toronionproxy.OnionProxyManager.installAndStartTorOp(OnionProxyManager.java:366) W/System.err: at com.msopentech.thali.android.toronionproxy.AndroidOnionProxyManager.installAndStartTorOp(AndroidOnionProxyManager.java:66) W/System.err: at com.msopentech.thali.toronionproxy.OnionProxyManager.startWithRepeat(OnionProxyManager.java:106) W/System.err: at <app-id>.shared.tor.TorProxyService.onHandleIntent(TorProxyService.kt:24) W/System.err: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:78) W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107) W/System.err: at android.os.Looper.loop(Looper.java:214) W/System.err: at android.os.HandlerThread.run(HandlerThread.java:67) W/System.err: Caused by: java.io.IOException: error=13, Permission denied W/System.err: at java.lang.UNIXProcess.forkAndExec(Native Method) W/System.err: at java.lang.UNIXProcess.<init>(UNIXProcess.java:133) W/System.err: at java.lang.ProcessImpl.start(ProcessImpl.java:141) W/System.err: at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) W/System.err: ... 8 more

And here is my implementation for TorProxyService

package mypackage.shared.tor

import android.app.IntentService
import android.content.Intent
import com.msopentech.thali.android.toronionproxy.AndroidOnionProxyManager
import com.msopentech.thali.toronionproxy.OnionProxyManager
import mypackage.ObserverUtils
import mypackage.shared.utils.Logger

class TorProxyService : IntentService("TorProxyIntentService") {

    override fun onHandleIntent(p0: Intent?) {

        return try {

            ObserverUtils.torObserver.post(TorStatus.CONNECTING)

            Logger.showDebugLog(TorConstants.TAG, "Starting TOR \uD83D\uDEA7 \uD83D\uDEA7 \uD83D\uDEA7 \uD83D\uDEA7")

            val fileStorageLocation = "torfiles"
            val proxyManager: OnionProxyManager = AndroidOnionProxyManager(applicationContext, fileStorageLocation)
            val totalSecondsPerTorStartup = 4 * 60
            val totalTriesPerTorStartup = 5
            val torStarted = proxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup)

            if (!torStarted) {

                Logger.showDebugLog(TorConstants.TAG, "Couldn't start TOR ❌❌❌❌")
                ObserverUtils.torObserver.post(TorStatus.DISCONNECTED)

            } else {

                while (!proxyManager.isRunning) {
                    Thread.sleep(90)
                }

                TorConstants.TOR_SOCK_PORT = proxyManager.iPv4LocalHostSocksPort
                Logger.showDebugLog(TorConstants.TAG, "TOR Started ✅✅✅✅")
                ObserverUtils.torObserver.post(TorStatus.CONNECTED)

            }
        } catch (e: Exception) {
            e.printStackTrace()
            Logger.showDebugLog(TorConstants.TAG, "Couldn't start TOR ❌❌❌❌")
            ObserverUtils.torObserver.post(TorStatus.DISCONNECTED)
        }

    }

}
05nelsonm commented 3 years ago

Executable files are no longer supported for API 29+ from data/data and the shared native libs must be extracted to the native Dir.

https://github.com/05nelsonm/TOPL-Android-TorBinary

pingothedoer commented 3 years ago

@05nelsonm Thanks, Will the implementation of TOR be same? Just need to replace the dependencies ???

Suryah07 commented 1 year ago

So is there any way to make this library work?