From d1e299250a97448d240f44a542fc04194dfb23e3 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Mon, 1 Oct 2012 00:18:22 +0530 Subject: [PATCH] adds UDP reject for transproxy; thx to patrickbx From a81741afe06ac2309b4306dedbd5a0ebf755b7e1 Mon Sep 17 00:00:00 2001 From: patch --- .../android/service/TorTransProxy.java | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/org/torproject/android/service/TorTransProxy.java b/src/org/torproject/android/service/TorTransProxy.java index 8753097a..1a34c5c8 100644 --- a/src/org/torproject/android/service/TorTransProxy.java +++ b/src/org/torproject/android/service/TorTransProxy.java @@ -309,6 +309,16 @@ public class TorTransProxy implements TorServiceConstants { script.append(" -j REJECT"); script.append(" || exit\n"); + // Reject all other outbound UDP packets + script.append(ipTablesPath); + script.append(" -A OUTPUT"); + script.append(" -t filter"); + script.append(" -m owner --uid-owner "); + script.append(tApp.getUid()); + script.append(" -p udp"); + script.append(" -j REJECT"); + script.append(" || exit\n"); + } } @@ -407,6 +417,16 @@ public class TorTransProxy implements TorServiceConstants { script.append(" -j REJECT"); script.append(" || exit\n"); + // Reject all other outbound TCP packets + script.append(ipTablesPath); + script.append(" -D OUTPUT"); + script.append(" -t filter"); + script.append(" -m owner --uid-owner "); + script.append(tApp.getUid()); + script.append(" -p udp"); + script.append(" -j REJECT"); + script.append(" || exit\n"); + } } @@ -648,7 +668,15 @@ public class TorTransProxy implements TorServiceConstants { script.append(" -p tcp"); script.append(" -j REJECT"); script.append(" || exit\n"); - + + // Reject all other outbound UDP packets + script.append(ipTablesPath); + script.append(" -t filter"); + script.append(" -A OUTPUT"); + script.append(" -p udp"); + script.append(" -j REJECT"); + script.append(" || exit\n"); + String[] cmdAdd = {script.toString()}; code = TorServiceUtils.doShellCommand(cmdAdd, res, runRoot, waitFor); @@ -717,6 +745,14 @@ public class TorTransProxy implements TorServiceConstants { script.append(" -j REJECT"); script.append(" || exit\n"); + // Reject all other outbound TCP packets + script.append(ipTablesPath); + script.append(" -D OUTPUT"); + script.append(" -t filter"); + script.append(" -p udp"); + script.append(" -j REJECT"); + script.append(" || exit\n"); + String[] cmdAdd = {script.toString()}; code = TorServiceUtils.doShellCommand(cmdAdd, res, runRoot, waitFor);