@ -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-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 "
" --split-any-protocol \t \t \t ; split not only http and https \n "
# if defined(BSD) && !defined(__APPLE__)
# 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
# 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
# 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 "
" --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 "
" --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 "
" --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-http-req " , required_argument , 0 , 0 } , // optidx=23
{ " split-pos " , required_argument , 0 , 0 } , // optidx=24
{ " split-pos " , required_argument , 0 , 0 } , // optidx=24
{ " split-any-protocol " , optional_argument , 0 , 0 } , // optidx=25
{ " split-any-protocol " , optional_argument , 0 , 0 } , // optidx=25
{ " disorder " , n o_argument, 0 , 0 } , // optidx=26
{ " disorder " , optional _argument , 0 , 0 } , // optidx=26
{ " oob " , optional_argument , 0 , 0 } , // optidx=27
{ " oob " , optional_argument , 0 , 0 } , // optidx=27
{ " methodspace " , no_argument , 0 , 0 } , // optidx=28
{ " oob-data " , required_argument , 0 , 0 } , // optidx=28
{ " methodeol " , no_argument , 0 , 0 } , // optidx=29
{ " methodspace " , no_argument , 0 , 0 } , // optidx=29
{ " hosttab " , no_argument , 0 , 0 } , // optidx=30
{ " methodeol " , no_argument , 0 , 0 } , // optidx=30
{ " unixeol " , no_argument , 0 , 0 } , // optidx=31
{ " hosttab " , no_argument , 0 , 0 } , // optidx=31
{ " tlsrec " , required_argument , 0 , 0 } , // optidx=32
{ " unixeol " , no_argument , 0 , 0 } , // optidx=32
{ " tlsrec-pos " , required_argument , 0 , 0 } , // optidx=33
{ " tlsrec " , required_argument , 0 , 0 } , // optidx=33
{ " hostlist " , required_argument , 0 , 0 } , // optidx=34
{ " tlsrec-pos " , required_argument , 0 , 0 } , // optidx=34
{ " hostlist-exclude " , required_argument , 0 , 0 } , // optidx=35
{ " hostlist " , required_argument , 0 , 0 } , // optidx=35
{ " hostlist-auto " , required_argument , 0 , 0 } , // optidx=36
{ " hostlist-exclude " , required_argument , 0 , 0 } , // optidx=36
{ " hostlist-auto-fail-threshold " , required_argument , 0 , 0 } , // optidx=37
{ " hostlist-auto " , required_argument , 0 , 0 } , // optidx=37
{ " hostlist-auto-fail-time " , required_argument , 0 , 0 } , // optidx=38
{ " hostlist-auto-fail-threshold " , required_argument , 0 , 0 } , // optidx=38
{ " hostlist-auto-debug " , required_argument , 0 , 0 } , // optidx=39
{ " hostlist-auto-fail-time " , required_argument , 0 , 0 } , // optidx=39
{ " pidfile " , required_argument , 0 , 0 } , // optidx=40
{ " hostlist-auto-debug " , required_argument , 0 , 0 } , // optidx=40
{ " debug " , optional_argument , 0 , 0 } , // optidx=41
{ " pidfile " , required_argument , 0 , 0 } , // optidx=41
{ " local-rcvbuf " , required_argument , 0 , 0 } , // optidx=42
{ " debug " , optional_argument , 0 , 0 } , // optidx=42
{ " local-sndbuf " , required_argument , 0 , 0 } , // optidx=43
{ " local-rcvbuf " , required_argument , 0 , 0 } , // optidx=43
{ " remote-rcvbuf " , required_argument , 0 , 0 } , // optidx=44
{ " local-sndbuf " , required_argument , 0 , 0 } , // optidx=44
{ " remote-sndbuf " , required_argument , 0 , 0 } , // optidx=45
{ " remote-rcvbuf " , required_argument , 0 , 0 } , // optidx=45
{ " socks " , no_argument , 0 , 0 } , // optidx=46
{ " remote-sndbuf " , required_argument , 0 , 0 } , // optidx=46
{ " no-resolve " , no_argument , 0 , 0 } , // optidx=47
{ " socks " , no_argument , 0 , 0 } , // optidx=47
{ " skip-nodelay " , no_argument , 0 , 0 } , // optidx=48
{ " no-resolve " , no_argument , 0 , 0 } , // optidx=48
{ " tamper-start " , required_argument , 0 , 0 } , // optidx=49
{ " skip-nodelay " , no_argument , 0 , 0 } , // optidx=49
{ " tamper-cutoff " , required_argument , 0 , 0 } , // optidx=50
{ " tamper-start " , required_argument , 0 , 0 } , // optidx=50
{ " tamper-cutoff " , required_argument , 0 , 0 } , // optidx=51
# if defined(BSD) && !defined(__OpenBSD__) && !defined(__APPLE__)
# if defined(BSD) && !defined(__OpenBSD__) && !defined(__APPLE__)
{ " enable-pf " , no_argument , 0 , 0 } , // optidx=51
{ " enable-pf " , no_argument , 0 , 0 } , // optidx=52
# endif
# endif
{ " hostlist-auto-retrans-threshold " , optional_argument , 0 , 0 } , // ignored. for nfqws command line compatibility
{ " hostlist-auto-retrans-threshold " , optional_argument , 0 , 0 } , // ignored. for nfqws command line compatibility
{ NULL , 0 , NULL , 0 }
{ NULL , 0 , NULL , 0 }
@ -507,41 +509,64 @@ void parse_params(int argc, char *argv[])
params . split_any_protocol = true ;
params . split_any_protocol = true ;
break ;
break ;
case 26 : /* disorder */
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 ( ) ;
save_default_ttl ( ) ;
break ;
break ;
case 27 : /* oob */
case 27 : /* oob */
if ( optarg )
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 ) ;
size_t l = strlen ( optarg ) ;
unsigned int bt ;
unsigned int bt ;
if ( l = = 1 ) params . oob_byte = ( uint8_t ) * optarg ;
if ( l = = 1 ) params . oob_byte = ( uint8_t ) * optarg ;
else if ( l ! = 4 | | sscanf ( optarg , " 0x%02X " , & bt ) ! = 1 )
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 ) ;
exit_clean ( 1 ) ;
}
}
else params . oob_byte = ( uint8_t ) bt ;
else params . oob_byte = ( uint8_t ) bt ;
}
}
params . oob = true ;
break ;
break ;
case 28 : /* methodspace */
case 29 : /* methodspace */
params . methodspace = true ;
params . methodspace = true ;
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 29 : /* methodeol */
case 30 : /* methodeol */
params . methodeol = true ;
params . methodeol = true ;
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 30 : /* hosttab */
case 31 : /* hosttab */
params . hosttab = true ;
params . hosttab = true ;
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 31 : /* unixeol */
case 32 : /* unixeol */
params . unixeol = true ;
params . unixeol = true ;
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 32 : /* tlsrec */
case 33 : /* tlsrec */
if ( ! strcmp ( optarg , " sni " ) )
if ( ! strcmp ( optarg , " sni " ) )
params . tlsrec = tlsrec_sni ;
params . tlsrec = tlsrec_sni ;
else
else
@ -551,7 +576,7 @@ void parse_params(int argc, char *argv[])
}
}
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 33 : /* tlsrec-pos */
case 34 : /* tlsrec-pos */
if ( ( params . tlsrec_pos = atoi ( optarg ) ) > 0 )
if ( ( params . tlsrec_pos = atoi ( optarg ) ) > 0 )
params . tlsrec = tlsrec_pos ;
params . tlsrec = tlsrec_pos ;
else
else
@ -561,7 +586,7 @@ void parse_params(int argc, char *argv[])
}
}
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 34 : /* hostlist */
case 35 : /* hostlist */
if ( ! strlist_add ( & params . hostlist_files , optarg ) )
if ( ! strlist_add ( & params . hostlist_files , optarg ) )
{
{
fprintf ( stderr , " strlist_add failed \n " ) ;
fprintf ( stderr , " strlist_add failed \n " ) ;
@ -569,7 +594,7 @@ void parse_params(int argc, char *argv[])
}
}
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 35 : /* hostlist-exclude */
case 36 : /* hostlist-exclude */
if ( ! strlist_add ( & params . hostlist_exclude_files , optarg ) )
if ( ! strlist_add ( & params . hostlist_exclude_files , optarg ) )
{
{
fprintf ( stderr , " strlist_add failed \n " ) ;
fprintf ( stderr , " strlist_add failed \n " ) ;
@ -577,7 +602,7 @@ void parse_params(int argc, char *argv[])
}
}
params . tamper = true ;
params . tamper = true ;
break ;
break ;
case 36 : /* hostlist-auto */
case 37 : /* hostlist-auto */
if ( * params . hostlist_auto_filename )
if ( * params . hostlist_auto_filename )
{
{
fprintf ( stderr , " only one auto hostlist is supported \n " ) ;
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 . hostlist_auto_filename [ sizeof ( params . hostlist_auto_filename ) - 1 ] = ' \0 ' ;
params . tamper = true ; // need to detect blocks and update autohostlist. cannot just slice.
params . tamper = true ; // need to detect blocks and update autohostlist. cannot just slice.
break ;
break ;
case 37 : /* hostlist-auto-fail-threshold */
case 38 : /* hostlist-auto-fail-threshold */
params . hostlist_auto_fail_threshold = ( uint8_t ) atoi ( optarg ) ;
params . hostlist_auto_fail_threshold = ( uint8_t ) atoi ( optarg ) ;
if ( params . hostlist_auto_fail_threshold < 1 | | params . hostlist_auto_fail_threshold > 20 )
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 ) ;
exit_clean ( 1 ) ;
}
}
break ;
break ;
case 38 : /* hostlist-auto-fail-time */
case 39 : /* hostlist-auto-fail-time */
params . hostlist_auto_fail_time = ( uint8_t ) atoi ( optarg ) ;
params . hostlist_auto_fail_time = ( uint8_t ) atoi ( optarg ) ;
if ( params . hostlist_auto_fail_time < 1 )
if ( params . hostlist_auto_fail_time < 1 )
{
{
@ -625,7 +650,7 @@ void parse_params(int argc, char *argv[])
exit_clean ( 1 ) ;
exit_clean ( 1 ) ;
}
}
break ;
break ;
case 39 : /* hostlist-auto-debug */
case 40 : /* hostlist-auto-debug */
{
{
FILE * F = fopen ( optarg , " a+t " ) ;
FILE * F = fopen ( optarg , " a+t " ) ;
if ( ! F )
if ( ! F )
@ -640,35 +665,35 @@ void parse_params(int argc, char *argv[])
params . hostlist_auto_debuglog [ sizeof ( params . hostlist_auto_debuglog ) - 1 ] = ' \0 ' ;
params . hostlist_auto_debuglog [ sizeof ( params . hostlist_auto_debuglog ) - 1 ] = ' \0 ' ;
}
}
break ;
break ;
case 40 : /* pidfile */
case 41 : /* pidfile */
strncpy ( params . pidfile , optarg , sizeof ( params . pidfile ) ) ;
strncpy ( params . pidfile , optarg , sizeof ( params . pidfile ) ) ;
params . pidfile [ sizeof ( params . pidfile ) - 1 ] = ' \0 ' ;
params . pidfile [ sizeof ( params . pidfile ) - 1 ] = ' \0 ' ;
break ;
break ;
case 41 :
case 42 :
params . debug = optarg ? atoi ( optarg ) : 1 ;
params . debug = optarg ? atoi ( optarg ) : 1 ;
break ;
break ;
case 42 : /* local-rcvbuf */
case 43 : /* local-rcvbuf */
params . local_rcvbuf = atoi ( optarg ) / 2 ;
params . local_rcvbuf = atoi ( optarg ) / 2 ;
break ;
break ;
case 43 : /* local-sndbuf */
case 44 : /* local-sndbuf */
params . local_sndbuf = atoi ( optarg ) / 2 ;
params . local_sndbuf = atoi ( optarg ) / 2 ;
break ;
break ;
case 44 : /* remote-rcvbuf */
case 45 : /* remote-rcvbuf */
params . remote_rcvbuf = atoi ( optarg ) / 2 ;
params . remote_rcvbuf = atoi ( optarg ) / 2 ;
break ;
break ;
case 45 : /* remote-sndbuf */
case 46 : /* remote-sndbuf */
params . remote_sndbuf = atoi ( optarg ) / 2 ;
params . remote_sndbuf = atoi ( optarg ) / 2 ;
break ;
break ;
case 46 : /* socks */
case 47 : /* socks */
params . proxy_type = CONN_TYPE_SOCKS ;
params . proxy_type = CONN_TYPE_SOCKS ;
break ;
break ;
case 47 : /* no-resolve */
case 48 : /* no-resolve */
params . no_resolve = true ;
params . no_resolve = true ;
break ;
break ;
case 48 : /* skip-nodelay */
case 49 : /* skip-nodelay */
params . skip_nodelay = true ;
params . skip_nodelay = true ;
break ;
break ;
case 49 : /* tamper-start */
case 50 : /* tamper-start */
{
{
const char * p = optarg ;
const char * p = optarg ;
if ( * p = = ' n ' )
if ( * p = = ' n ' )
@ -681,7 +706,7 @@ void parse_params(int argc, char *argv[])
params . tamper_start = atoi ( p ) ;
params . tamper_start = atoi ( p ) ;
}
}
break ;
break ;
case 50 : /* tamper-cutoff */
case 51 : /* tamper-cutoff */
{
{
const char * p = optarg ;
const char * p = optarg ;
if ( * p = = ' n ' )
if ( * p = = ' n ' )
@ -695,7 +720,7 @@ void parse_params(int argc, char *argv[])
}
}
break ;
break ;
# if defined(BSD) && !defined(__OpenBSD__) && !defined(__APPLE__)
# if defined(BSD) && !defined(__OpenBSD__) && !defined(__APPLE__)
case 51 : /* enable-pf */
case 52 : /* enable-pf */
params . pf_enable = true ;
params . pf_enable = true ;
break ;
break ;
# endif
# endif