mirror of
https://github.com/bol-van/zapret.git
synced 2025-12-31 11:55:55 +03:00
tpws: oob and disorder protocol filters
This commit is contained in:
135
tpws/tpws.c
135
tpws/tpws.c
@@ -171,11 +171,12 @@ static void exithelp(void)
|
||||
" --split-pos=<numeric_offset>\t\t; split at specified pos. split-http-req takes precedence for http.\n"
|
||||
" --split-any-protocol\t\t\t; split not only http and https\n"
|
||||
#if defined(BSD) && !defined(__APPLE__)
|
||||
" --disorder\t\t\t\t; when splitting simulate sending second fragment first (BSD sends entire message instead of first fragment, this is not good)\n"
|
||||
" --disorder[=http|tls]\t\t\t; when splitting simulate sending second fragment first (BSD sends entire message instead of first fragment, this is not good)\n"
|
||||
#else
|
||||
" --disorder\t\t\t\t; when splitting simulate sending second fragment first\n"
|
||||
" --disorder[=http|tls]\t\t\t; when splitting simulate sending second fragment first\n"
|
||||
#endif
|
||||
" --oob[=<char>|0xHEX]\t\t\t; when splitting send out of band byte. default is HEX 0x00.\n"
|
||||
" --oob[=http|tls]\t\t\t; when splitting send out of band byte. default is HEX 0x00.\n"
|
||||
" --oob-data=<char>|0xHEX\t\t; override default 0x00 OOB byte.\n"
|
||||
" --hostcase\t\t\t\t; change Host: => host:\n"
|
||||
" --hostspell\t\t\t\t; exact spelling of \"Host\" header. must be 4 chars. default is \"host\"\n"
|
||||
" --hostdot\t\t\t\t; add \".\" after Host: name\n"
|
||||
@@ -295,33 +296,34 @@ void parse_params(int argc, char *argv[])
|
||||
{ "split-http-req",required_argument,0,0 },// optidx=23
|
||||
{ "split-pos",required_argument,0,0 },// optidx=24
|
||||
{ "split-any-protocol",optional_argument,0,0},// optidx=25
|
||||
{ "disorder",no_argument,0,0 },// optidx=26
|
||||
{ "disorder",optional_argument,0,0 },// optidx=26
|
||||
{ "oob",optional_argument,0,0 },// optidx=27
|
||||
{ "methodspace",no_argument,0,0 },// optidx=28
|
||||
{ "methodeol",no_argument,0,0 },// optidx=29
|
||||
{ "hosttab",no_argument,0,0 },// optidx=30
|
||||
{ "unixeol",no_argument,0,0 },// optidx=31
|
||||
{ "tlsrec",required_argument,0,0 },// optidx=32
|
||||
{ "tlsrec-pos",required_argument,0,0 },// optidx=33
|
||||
{ "hostlist",required_argument,0,0 },// optidx=34
|
||||
{ "hostlist-exclude",required_argument,0,0 },// optidx=35
|
||||
{ "hostlist-auto",required_argument,0,0}, // optidx=36
|
||||
{ "hostlist-auto-fail-threshold",required_argument,0,0}, // optidx=37
|
||||
{ "hostlist-auto-fail-time",required_argument,0,0}, // optidx=38
|
||||
{ "hostlist-auto-debug",required_argument,0,0}, // optidx=39
|
||||
{ "pidfile",required_argument,0,0 },// optidx=40
|
||||
{ "debug",optional_argument,0,0 },// optidx=41
|
||||
{ "local-rcvbuf",required_argument,0,0 },// optidx=42
|
||||
{ "local-sndbuf",required_argument,0,0 },// optidx=43
|
||||
{ "remote-rcvbuf",required_argument,0,0 },// optidx=44
|
||||
{ "remote-sndbuf",required_argument,0,0 },// optidx=45
|
||||
{ "socks",no_argument,0,0 },// optidx=46
|
||||
{ "no-resolve",no_argument,0,0 },// optidx=47
|
||||
{ "skip-nodelay",no_argument,0,0 },// optidx=48
|
||||
{ "tamper-start",required_argument,0,0 },// optidx=49
|
||||
{ "tamper-cutoff",required_argument,0,0 },// optidx=50
|
||||
{ "oob-data",required_argument,0,0 },// optidx=28
|
||||
{ "methodspace",no_argument,0,0 },// optidx=29
|
||||
{ "methodeol",no_argument,0,0 },// optidx=30
|
||||
{ "hosttab",no_argument,0,0 },// optidx=31
|
||||
{ "unixeol",no_argument,0,0 },// optidx=32
|
||||
{ "tlsrec",required_argument,0,0 },// optidx=33
|
||||
{ "tlsrec-pos",required_argument,0,0 },// optidx=34
|
||||
{ "hostlist",required_argument,0,0 },// optidx=35
|
||||
{ "hostlist-exclude",required_argument,0,0 },// optidx=36
|
||||
{ "hostlist-auto",required_argument,0,0}, // optidx=37
|
||||
{ "hostlist-auto-fail-threshold",required_argument,0,0}, // optidx=38
|
||||
{ "hostlist-auto-fail-time",required_argument,0,0}, // optidx=39
|
||||
{ "hostlist-auto-debug",required_argument,0,0}, // optidx=40
|
||||
{ "pidfile",required_argument,0,0 },// optidx=41
|
||||
{ "debug",optional_argument,0,0 },// optidx=42
|
||||
{ "local-rcvbuf",required_argument,0,0 },// optidx=43
|
||||
{ "local-sndbuf",required_argument,0,0 },// optidx=44
|
||||
{ "remote-rcvbuf",required_argument,0,0 },// optidx=45
|
||||
{ "remote-sndbuf",required_argument,0,0 },// optidx=46
|
||||
{ "socks",no_argument,0,0 },// optidx=47
|
||||
{ "no-resolve",no_argument,0,0 },// optidx=48
|
||||
{ "skip-nodelay",no_argument,0,0 },// optidx=49
|
||||
{ "tamper-start",required_argument,0,0 },// optidx=50
|
||||
{ "tamper-cutoff",required_argument,0,0 },// optidx=51
|
||||
#if defined(BSD) && !defined(__OpenBSD__) && !defined(__APPLE__)
|
||||
{ "enable-pf",no_argument,0,0 },// optidx=51
|
||||
{ "enable-pf",no_argument,0,0 },// optidx=52
|
||||
#endif
|
||||
{ "hostlist-auto-retrans-threshold",optional_argument,0,0}, // ignored. for nfqws command line compatibility
|
||||
{ NULL,0,NULL,0 }
|
||||
@@ -507,41 +509,64 @@ void parse_params(int argc, char *argv[])
|
||||
params.split_any_protocol = true;
|
||||
break;
|
||||
case 26: /* disorder */
|
||||
params.disorder = true;
|
||||
if (optarg)
|
||||
{
|
||||
if (!strcmp(optarg,"http")) params.disorder_http=true;
|
||||
else if (!strcmp(optarg,"tls")) params.disorder_tls=true;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Invalid argument for disorder\n");
|
||||
exit_clean(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
params.disorder = true;
|
||||
save_default_ttl();
|
||||
break;
|
||||
case 27: /* oob */
|
||||
if (optarg)
|
||||
{
|
||||
if (!strcmp(optarg,"http")) params.oob_http=true;
|
||||
else if (!strcmp(optarg,"tls")) params.oob_tls=true;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Invalid argument for oob\n");
|
||||
exit_clean(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
params.oob = true;
|
||||
break;
|
||||
case 28: /* oob-data */
|
||||
{
|
||||
size_t l = strlen(optarg);
|
||||
unsigned int bt;
|
||||
if (l==1) params.oob_byte = (uint8_t)*optarg;
|
||||
else if (l!=4 || sscanf(optarg,"0x%02X",&bt)!=1)
|
||||
{
|
||||
fprintf(stderr, "Invalid argument for oob\n");
|
||||
fprintf(stderr, "Invalid argument for oob-data\n");
|
||||
exit_clean(1);
|
||||
}
|
||||
else params.oob_byte = (uint8_t)bt;
|
||||
}
|
||||
params.oob = true;
|
||||
break;
|
||||
case 28: /* methodspace */
|
||||
case 29: /* methodspace */
|
||||
params.methodspace = true;
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 29: /* methodeol */
|
||||
case 30: /* methodeol */
|
||||
params.methodeol = true;
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 30: /* hosttab */
|
||||
case 31: /* hosttab */
|
||||
params.hosttab = true;
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 31: /* unixeol */
|
||||
case 32: /* unixeol */
|
||||
params.unixeol = true;
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 32: /* tlsrec */
|
||||
case 33: /* tlsrec */
|
||||
if (!strcmp(optarg, "sni"))
|
||||
params.tlsrec = tlsrec_sni;
|
||||
else
|
||||
@@ -551,7 +576,7 @@ void parse_params(int argc, char *argv[])
|
||||
}
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 33: /* tlsrec-pos */
|
||||
case 34: /* tlsrec-pos */
|
||||
if ((params.tlsrec_pos = atoi(optarg))>0)
|
||||
params.tlsrec = tlsrec_pos;
|
||||
else
|
||||
@@ -561,7 +586,7 @@ void parse_params(int argc, char *argv[])
|
||||
}
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 34: /* hostlist */
|
||||
case 35: /* hostlist */
|
||||
if (!strlist_add(¶ms.hostlist_files, optarg))
|
||||
{
|
||||
fprintf(stderr, "strlist_add failed\n");
|
||||
@@ -569,7 +594,7 @@ void parse_params(int argc, char *argv[])
|
||||
}
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 35: /* hostlist-exclude */
|
||||
case 36: /* hostlist-exclude */
|
||||
if (!strlist_add(¶ms.hostlist_exclude_files, optarg))
|
||||
{
|
||||
fprintf(stderr, "strlist_add failed\n");
|
||||
@@ -577,7 +602,7 @@ void parse_params(int argc, char *argv[])
|
||||
}
|
||||
params.tamper = true;
|
||||
break;
|
||||
case 36: /* hostlist-auto */
|
||||
case 37: /* hostlist-auto */
|
||||
if (*params.hostlist_auto_filename)
|
||||
{
|
||||
fprintf(stderr, "only one auto hostlist is supported\n");
|
||||
@@ -609,7 +634,7 @@ void parse_params(int argc, char *argv[])
|
||||
params.hostlist_auto_filename[sizeof(params.hostlist_auto_filename) - 1] = '\0';
|
||||
params.tamper = true; // need to detect blocks and update autohostlist. cannot just slice.
|
||||
break;
|
||||
case 37: /* hostlist-auto-fail-threshold */
|
||||
case 38: /* hostlist-auto-fail-threshold */
|
||||
params.hostlist_auto_fail_threshold = (uint8_t)atoi(optarg);
|
||||
if (params.hostlist_auto_fail_threshold<1 || params.hostlist_auto_fail_threshold>20)
|
||||
{
|
||||
@@ -617,7 +642,7 @@ void parse_params(int argc, char *argv[])
|
||||
exit_clean(1);
|
||||
}
|
||||
break;
|
||||
case 38: /* hostlist-auto-fail-time */
|
||||
case 39: /* hostlist-auto-fail-time */
|
||||
params.hostlist_auto_fail_time = (uint8_t)atoi(optarg);
|
||||
if (params.hostlist_auto_fail_time<1)
|
||||
{
|
||||
@@ -625,7 +650,7 @@ void parse_params(int argc, char *argv[])
|
||||
exit_clean(1);
|
||||
}
|
||||
break;
|
||||
case 39: /* hostlist-auto-debug */
|
||||
case 40: /* hostlist-auto-debug */
|
||||
{
|
||||
FILE *F = fopen(optarg,"a+t");
|
||||
if (!F)
|
||||
@@ -640,35 +665,35 @@ void parse_params(int argc, char *argv[])
|
||||
params.hostlist_auto_debuglog[sizeof(params.hostlist_auto_debuglog) - 1] = '\0';
|
||||
}
|
||||
break;
|
||||
case 40: /* pidfile */
|
||||
case 41: /* pidfile */
|
||||
strncpy(params.pidfile,optarg,sizeof(params.pidfile));
|
||||
params.pidfile[sizeof(params.pidfile)-1]='\0';
|
||||
break;
|
||||
case 41:
|
||||
case 42:
|
||||
params.debug = optarg ? atoi(optarg) : 1;
|
||||
break;
|
||||
case 42: /* local-rcvbuf */
|
||||
case 43: /* local-rcvbuf */
|
||||
params.local_rcvbuf = atoi(optarg)/2;
|
||||
break;
|
||||
case 43: /* local-sndbuf */
|
||||
case 44: /* local-sndbuf */
|
||||
params.local_sndbuf = atoi(optarg)/2;
|
||||
break;
|
||||
case 44: /* remote-rcvbuf */
|
||||
case 45: /* remote-rcvbuf */
|
||||
params.remote_rcvbuf = atoi(optarg)/2;
|
||||
break;
|
||||
case 45: /* remote-sndbuf */
|
||||
case 46: /* remote-sndbuf */
|
||||
params.remote_sndbuf = atoi(optarg)/2;
|
||||
break;
|
||||
case 46: /* socks */
|
||||
case 47: /* socks */
|
||||
params.proxy_type = CONN_TYPE_SOCKS;
|
||||
break;
|
||||
case 47: /* no-resolve */
|
||||
case 48: /* no-resolve */
|
||||
params.no_resolve = true;
|
||||
break;
|
||||
case 48: /* skip-nodelay */
|
||||
case 49: /* skip-nodelay */
|
||||
params.skip_nodelay = true;
|
||||
break;
|
||||
case 49: /* tamper-start */
|
||||
case 50: /* tamper-start */
|
||||
{
|
||||
const char *p=optarg;
|
||||
if (*p=='n')
|
||||
@@ -681,7 +706,7 @@ void parse_params(int argc, char *argv[])
|
||||
params.tamper_start = atoi(p);
|
||||
}
|
||||
break;
|
||||
case 50: /* tamper-cutoff */
|
||||
case 51: /* tamper-cutoff */
|
||||
{
|
||||
const char *p=optarg;
|
||||
if (*p=='n')
|
||||
@@ -695,7 +720,7 @@ void parse_params(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
#if defined(BSD) && !defined(__OpenBSD__) && !defined(__APPLE__)
|
||||
case 51: /* enable-pf */
|
||||
case 52: /* enable-pf */
|
||||
params.pf_enable = true;
|
||||
break;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user