diff --git a/binaries/aarch64/tpws b/binaries/aarch64/tpws index c095ca3..a4b10c4 100755 Binary files a/binaries/aarch64/tpws and b/binaries/aarch64/tpws differ diff --git a/binaries/armhf/tpws b/binaries/armhf/tpws index 3576a77..42b80b9 100755 Binary files a/binaries/armhf/tpws and b/binaries/armhf/tpws differ diff --git a/binaries/mips32r1-lsb/tpws b/binaries/mips32r1-lsb/tpws index c24250c..c8c035e 100755 Binary files a/binaries/mips32r1-lsb/tpws and b/binaries/mips32r1-lsb/tpws differ diff --git a/binaries/mips32r1-msb/tpws b/binaries/mips32r1-msb/tpws index d0a4e59..a1259a1 100755 Binary files a/binaries/mips32r1-msb/tpws and b/binaries/mips32r1-msb/tpws differ diff --git a/binaries/mips64r2-msb/tpws b/binaries/mips64r2-msb/tpws index 65bd026..04d1949 100755 Binary files a/binaries/mips64r2-msb/tpws and b/binaries/mips64r2-msb/tpws differ diff --git a/binaries/ppc/tpws b/binaries/ppc/tpws index 0ef2a3e..aada087 100755 Binary files a/binaries/ppc/tpws and b/binaries/ppc/tpws differ diff --git a/binaries/x86/tpws b/binaries/x86/tpws index 9ae993f..2346f50 100755 Binary files a/binaries/x86/tpws and b/binaries/x86/tpws differ diff --git a/binaries/x86_64/tpws b/binaries/x86_64/tpws index 87f1055..b5c284e 100755 Binary files a/binaries/x86_64/tpws and b/binaries/x86_64/tpws differ diff --git a/docs/readme.eng.txt b/docs/readme.eng.txt index 14dc48a..f1950ae 100644 --- a/docs/readme.eng.txt +++ b/docs/readme.eng.txt @@ -170,6 +170,7 @@ tpws is transparent proxy. --daemon ; daemonize --pidfile= ; write pid to file --user= ; drop root privs + --uid=uid[:gid] ; менять uid процесса The manipulation parameters can be combined in any way. There are exceptions: split-pos replaces split-http-req. hostdot and hosttab are mutually exclusive. diff --git a/docs/readme.txt b/docs/readme.txt index 06967de..823cc98 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -157,6 +157,7 @@ tpws - это transparent proxy. --daemon ; демонизировать прогу --pidfile= ; сохранить PID в файл --user= ; менять uid процесса + --uid=uid[:gid] ; менять uid процесса --bind-addr ; на каком адресе слушать. может быть ipv4 или ipv6 адрес. если не указано, то слушает на всех адресах ipv4 и ipv6 ; если указан ipv6 link local, то требуется указать с какого он интерфейса через --bind-iface6 --bind-linklocal=prefer|force ; если prefer, то найти link local от iface6. если не найдено - использовать первый адрес любого типа. @@ -765,6 +766,29 @@ Openwrt является одной из немногих относительн --split-pos - единственный параметр, который работает на не-HTTP трафике, все остальное работать не будет. Попробуйте, может вам повезет. +Android +------- + +Без рута забудьте. +Не стоит ждать, что в стоковом ядре будет NFQUEUE или ipset, зато DNAT есть наверняка. +tpws проверен на эмуляторе - он работает. +В android нет /etc/passwd, потому опция --user не будет работать. Вместо нее можно +пользоваться числовыми user id и опцией --uid. +Напишите шелл скрипт с iptables и tpws, запускайте его средствами вашего рут менеджера. +Скрипты автозапуска лежат тут : +magisk : /data/adb/service.d +supersu : /system/su.d + +Я не проверял не прибивают ли новые андроиды iptables по своей прихоти в процессе работы +или при подключении/отключении wifi, mobile data, ... + +Кто силен в разработке под андроид, думаю будет несложно написать простую програмулину +с выбором опций tpws, которая сможет выбрать tpws нужной архитектуры, запустить его +и добавить iptables. Чтобы была возможность автозапуска (после нее применяем настройки +и сразу exit). И чтобы были кнопки start/stop. +Если кто готов такую програмулину написать - все скажут спасибо. +Тогда любой желающий с рутом сможет парой кликов настроить себе tpws. + Почему стоит вложиться в покупку VPS ------------------------------------ diff --git a/tpws/tpws.c b/tpws/tpws.c index eadaec8..8614374 100644 --- a/tpws/tpws.c +++ b/tpws/tpws.c @@ -548,6 +548,7 @@ void exithelp() " --daemon\t\t\t; daemonize\n" " --pidfile=\t\t; write pid to file\n" " --user=\t\t; drop root privs\n" + " --uid=uid[:gid]\t\t; drop root privs\n" ); exit(1); } @@ -591,19 +592,20 @@ void parse_params(int argc, char *argv[]) { "port",required_argument,0,0 },// optidx=9 { "daemon",no_argument,0,0 },// optidx=10 { "user",required_argument,0,0 },// optidx=11 - { "maxconn",required_argument,0,0 },// optidx=12 - { "hostcase",no_argument,0,0 },// optidx=13 - { "hostspell",required_argument,0,0 },// optidx=14 - { "hostdot",no_argument,0,0 },// optidx=15 - { "hostnospace",no_argument,0,0 },// optidx=16 - { "split-http-req",required_argument,0,0 },// optidx=17 - { "split-pos",required_argument,0,0 },// optidx=18 - { "methodspace",no_argument,0,0 },// optidx=19 - { "methodeol",no_argument,0,0 },// optidx=20 - { "hosttab",no_argument,0,0 },// optidx=21 - { "unixeol",no_argument,0,0 },// optidx=22 - { "hostlist",required_argument,0,0 },// optidx=23 - { "pidfile",required_argument,0,0 },// optidx=24 + { "uid",required_argument,0,0 },// optidx=12 + { "maxconn",required_argument,0,0 },// optidx=13 + { "hostcase",no_argument,0,0 },// optidx=14 + { "hostspell",required_argument,0,0 },// optidx=15 + { "hostdot",no_argument,0,0 },// optidx=16 + { "hostnospace",no_argument,0,0 },// optidx=17 + { "split-http-req",required_argument,0,0 },// optidx=18 + { "split-pos",required_argument,0,0 },// optidx=19 + { "methodspace",no_argument,0,0 },// optidx=20 + { "methodeol",no_argument,0,0 },// optidx=21 + { "hosttab",no_argument,0,0 },// optidx=22 + { "unixeol",no_argument,0,0 },// optidx=23 + { "hostlist",required_argument,0,0 },// optidx=24 + { "pidfile",required_argument,0,0 },// optidx=25 { NULL,0,NULL,0 } }; while ((v = getopt_long_only(argc, argv, "", long_options, &option_index)) != -1) @@ -672,7 +674,15 @@ void parse_params(int argc, char *argv[]) params.gid = pwd->pw_gid; break; } - case 12: /* maxconn */ + case 12: /* uid */ + params.gid=0x7FFFFFFF; // default git. drop gid=0 + if (!sscanf(optarg,"%u:%u",¶ms.uid,¶ms.gid)) + { + fprintf(stderr, "--uid should be : uid[:gid]\n"); + exit_clean(1); + } + break; + case 13: /* maxconn */ params.maxconn = atoi(optarg); if (params.maxconn <= 0) { @@ -680,10 +690,10 @@ void parse_params(int argc, char *argv[]) exit_clean(1); } break; - case 13: /* hostcase */ + case 14: /* hostcase */ params.hostcase = true; break; - case 14: /* hostspell */ + case 15: /* hostspell */ if (strlen(optarg) != 4) { fprintf(stderr, "hostspell must be exactly 4 chars long\n"); @@ -692,13 +702,13 @@ void parse_params(int argc, char *argv[]) params.hostcase = true; memcpy(params.hostspell, optarg, 4); break; - case 15: /* hostdot */ + case 16: /* hostdot */ params.hostdot = true; break; - case 16: /* hostnospace */ + case 17: /* hostnospace */ params.hostnospace = true; break; - case 17: /* split-http-req */ + case 18: /* split-http-req */ if (!strcmp(optarg, "method")) params.split_http_req = split_method; else if (!strcmp(optarg, "host")) @@ -709,7 +719,7 @@ void parse_params(int argc, char *argv[]) exit_clean(1); } break; - case 18: /* split-pos */ + case 19: /* split-pos */ i = atoi(optarg); if (i) params.split_pos = i; @@ -719,25 +729,25 @@ void parse_params(int argc, char *argv[]) exit_clean(1); } break; - case 19: /* methodspace */ + case 20: /* methodspace */ params.methodspace = true; break; - case 20: /* methodeol */ + case 21: /* methodeol */ params.methodeol = true; break; - case 21: /* hosttab */ + case 22: /* hosttab */ params.hosttab = true; break; - case 22: /* unixeol */ + case 23: /* unixeol */ params.unixeol = true; break; - case 23: /* hostlist */ + case 24: /* hostlist */ if (!LoadHostList(¶ms.hostlist, optarg)) exit_clean(1); strncpy(params.hostfile,optarg,sizeof(params.hostfile)); params.hostfile[sizeof(params.hostfile)-1]='\0'; break; - case 24: /* pidfile */ + case 25: /* pidfile */ strncpy(params.pidfile,optarg,sizeof(params.pidfile)); params.pidfile[sizeof(params.pidfile)-1]='\0'; break; @@ -781,7 +791,7 @@ void daemonize() bool droproot() { - if (params.uid) + if (params.uid || params.gid) { if (setgid(params.gid)) { @@ -1001,15 +1011,17 @@ int main(int argc, char *argv[]) { goto exiterr; } - if (!droproot()) - { + if (bind(listen_fd, (struct sockaddr *)&salisten, salisten_len) == -1) { + perror("bind: "); goto exiterr; } - if (bind(listen_fd, (struct sockaddr *)&salisten, salisten_len) == -1) { - perror("bind: "); + if (!droproot()) + { goto exiterr; } + + fprintf(stderr,"Running as UID=%u GID=%u\n",getuid(),getgid()); if (listen(listen_fd, BACKLOG) == -1) { perror("listen: ");