parent
94d06b9556
commit
167ec2e5c8
|
@ -5,7 +5,7 @@
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
|
||||||
|
|
||||||
<activity android:name=".Orbot"
|
<activity android:name=".Orbot"
|
||||||
android:theme="@android:style/Theme.NoTitleBar">
|
android:theme="@android:style/Theme.NoTitleBar">
|
||||||
|
@ -33,7 +33,8 @@
|
||||||
<activity android:name=".AppManager" android:label="@string/app_name"/>
|
<activity android:name=".AppManager" android:label="@string/app_name"/>
|
||||||
<activity android:name=".WizardActivity" android:label="@string/app_name"/>
|
<activity android:name=".WizardActivity" android:label="@string/app_name"/>
|
||||||
|
|
||||||
<service android:name=".service.TorService" android:process=":remote">
|
<!-- <service android:name=".service.TorService" android:process=":remote"> -->
|
||||||
|
<service android:name=".service.TorService">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.torproject.android.service.ITorService" />
|
<action android:name="org.torproject.android.service.ITorService" />
|
||||||
<action android:name="org.torproject.android.service.TOR_SERVICE" />
|
<action android:name="org.torproject.android.service.TOR_SERVICE" />
|
||||||
|
|
|
@ -6,7 +6,7 @@ public interface TorServiceConstants {
|
||||||
|
|
||||||
public final static String TAG = "ORBOT";
|
public final static String TAG = "ORBOT";
|
||||||
|
|
||||||
public static boolean LOG_OUTPUT_TO_DEBUG = false;
|
public static boolean LOG_OUTPUT_TO_DEBUG = true;
|
||||||
|
|
||||||
public final static String TOR_APP_USERNAME = "org.torproject.android";
|
public final static String TOR_APP_USERNAME = "org.torproject.android";
|
||||||
|
|
||||||
|
@ -56,6 +56,9 @@ public interface TorServiceConstants {
|
||||||
public final static String IP_LOCALHOST = "127.0.0.1";
|
public final static String IP_LOCALHOST = "127.0.0.1";
|
||||||
public final static int TOR_CONTROL_PORT = 9051;
|
public final static int TOR_CONTROL_PORT = 9051;
|
||||||
public final static int UPDATE_TIMEOUT = 1000;
|
public final static int UPDATE_TIMEOUT = 1000;
|
||||||
|
public final static int TOR_TRANSPROXY_PORT = 9040;
|
||||||
|
public final static int STANDARD_DNS_PORT = 53;
|
||||||
|
public final static int TOR_DNS_PORT = 5400;
|
||||||
|
|
||||||
//path to check Tor against
|
//path to check Tor against
|
||||||
public final static String URL_TOR_CHECK = "https://check.torproject.org";
|
public final static String URL_TOR_CHECK = "https://check.torproject.org";
|
||||||
|
|
|
@ -112,6 +112,8 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
|
|
||||||
public static int purgeIptables(Context context, TorifiedApp[] apps) throws Exception {
|
public static int purgeIptables(Context context, TorifiedApp[] apps) throws Exception {
|
||||||
|
|
||||||
|
//restoreDNSResolvConf(); //not working yet
|
||||||
|
|
||||||
String baseDir = findBaseDir();
|
String baseDir = findBaseDir();
|
||||||
|
|
||||||
final StringBuilder script = new StringBuilder();
|
final StringBuilder script = new StringBuilder();
|
||||||
|
@ -145,11 +147,52 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int redirectDNSResolvConf () throws Exception
|
||||||
|
{
|
||||||
|
StringBuilder script = new StringBuilder();
|
||||||
|
StringBuilder res = new StringBuilder();
|
||||||
|
int code = -1;
|
||||||
|
|
||||||
|
//mv resolv.conf to resolve.conf.bak
|
||||||
|
String cmd = "mv /etc/resolv.conf /etc/resolv.conf.bak";
|
||||||
|
script.append(cmd);
|
||||||
|
|
||||||
|
//create new resolve.conf pointing to localhost/127.0.0.1
|
||||||
|
cmd = "echo \"nameserver 127.0.0.1\" > /etc/resolv.conf";
|
||||||
|
script.append(cmd);
|
||||||
|
|
||||||
|
String[] cmdFlush = {script.toString()};
|
||||||
|
code = TorServiceUtils.doShellCommand(cmdFlush, res, true, true);
|
||||||
|
//String msg = res.toString(); //get stdout from command
|
||||||
|
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int restoreDNSResolvConf () throws Exception
|
||||||
|
{
|
||||||
|
StringBuilder script = new StringBuilder();
|
||||||
|
StringBuilder res = new StringBuilder();
|
||||||
|
int code = -1;
|
||||||
|
|
||||||
|
//mv resolv.conf to resolve.conf.bak
|
||||||
|
String cmd = "mv /etc/resolv.conf.bak /etc/resolv.conf";
|
||||||
|
script.append(cmd);
|
||||||
|
script.append(" || exit\n");
|
||||||
|
|
||||||
|
String[] cmdFlush = {script.toString()};
|
||||||
|
code = TorServiceUtils.doShellCommand(cmdFlush, res, true, true);
|
||||||
|
//String msg = res.toString(); //get stdout from command
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception
|
public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
//android.os.Debug.waitForDebugger();
|
android.os.Debug.waitForDebugger();
|
||||||
|
|
||||||
|
//redirectDNSResolvConf(); //not working yet
|
||||||
|
|
||||||
String baseDir = findBaseDir();
|
String baseDir = findBaseDir();
|
||||||
|
|
||||||
|
@ -210,9 +253,11 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
script.append(" -m tcp --syn");
|
script.append(" -m tcp --syn");
|
||||||
|
|
||||||
if (ipTablesOld)
|
if (ipTablesOld)
|
||||||
script.append(" -j DNAT --to 127.0.0.1:9040");
|
script.append(" -j DNAT --to 127.0.0.1:");
|
||||||
else
|
else
|
||||||
script.append(" -j REDIRECT --to-ports 9040");
|
script.append(" -j REDIRECT --to-ports ");
|
||||||
|
|
||||||
|
script.append(TOR_TRANSPROXY_PORT);
|
||||||
|
|
||||||
script.append(" || exit\n");
|
script.append(" || exit\n");
|
||||||
|
|
||||||
|
@ -221,12 +266,15 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
script.append("iptables -t nat");
|
script.append("iptables -t nat");
|
||||||
script.append(" -A OUTPUT -p udp -m owner --uid-owner ");
|
script.append(" -A OUTPUT -p udp -m owner --uid-owner ");
|
||||||
script.append(apps[i].getUid());
|
script.append(apps[i].getUid());
|
||||||
script.append(" --dport 53"); //drop all UDP packets as Tor won't handle them
|
script.append(" --dport ");
|
||||||
|
script.append(STANDARD_DNS_PORT);
|
||||||
|
|
||||||
if (ipTablesOld)
|
if (ipTablesOld)
|
||||||
script.append(" -j DNAT --to 127.0.0.1:5400");
|
script.append(" -j DNAT --to 127.0.0.1:");
|
||||||
else
|
else
|
||||||
script.append(" -j REDIRECT --to-ports 5400");
|
script.append(" -j REDIRECT --to-ports ");
|
||||||
|
|
||||||
|
script.append(TOR_DNS_PORT);
|
||||||
|
|
||||||
script.append(" || exit\n");
|
script.append(" || exit\n");
|
||||||
|
|
||||||
|
@ -249,7 +297,9 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
script.append(" -A OUTPUT -p tcp");
|
script.append(" -A OUTPUT -p tcp");
|
||||||
script.append(" -m owner --uid-owner ");
|
script.append(" -m owner --uid-owner ");
|
||||||
script.append(apps[i].getUid());
|
script.append(apps[i].getUid());
|
||||||
script.append(" -m tcp --dport 9040 -j ACCEPT");
|
script.append(" -m tcp --dport ");
|
||||||
|
script.append(TOR_TRANSPROXY_PORT);
|
||||||
|
script.append(" -j ACCEPT");
|
||||||
script.append(" || exit\n");
|
script.append(" || exit\n");
|
||||||
|
|
||||||
script.append(baseDir);
|
script.append(baseDir);
|
||||||
|
@ -257,7 +307,9 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
script.append(" -A OUTPUT -p udp");
|
script.append(" -A OUTPUT -p udp");
|
||||||
script.append(" -m owner --uid-owner ");
|
script.append(" -m owner --uid-owner ");
|
||||||
script.append(apps[i].getUid());
|
script.append(apps[i].getUid());
|
||||||
script.append(" -m udp --dport 5400 -j ACCEPT");
|
script.append(" -m udp --dport ");
|
||||||
|
script.append(TOR_DNS_PORT);
|
||||||
|
script.append(" -j ACCEPT");
|
||||||
script.append(" || exit\n");
|
script.append(" || exit\n");
|
||||||
|
|
||||||
script.append(baseDir);
|
script.append(baseDir);
|
||||||
|
|
Loading…
Reference in New Issue