Verbosity, debug logs

This commit is contained in:
Vadim Vetrov 2024-08-11 21:43:32 +03:00
parent 9c2d31f51d
commit 7d571e6860
No known key found for this signature in database
GPG Key ID: E8A308689D7A73A5
4 changed files with 67 additions and 50 deletions

60
args.c
View File

@ -99,7 +99,8 @@ static long parse_numeric_option(const char* value) {
void print_version() { void print_version() {
printf("youtubeUnblock\n"); printf("youtubeUnblock\n");
printf("Bypasses youtube detection systems that relies on SNI\n"); printf("Bypasses deep packet inspection systems that relies on SNI\n");
printf("\n");
} }
void print_usage(const char *argv0) { void print_usage(const char *argv0) {
@ -143,9 +144,10 @@ int parse_args(int argc, char *argv[]) {
config.use_gso = 0; config.use_gso = 0;
break; break;
case OPT_SNI_DOMAINS: case OPT_SNI_DOMAINS:
if (strcmp(optarg, "all")) { if (!strcmp(optarg, "all")) {
config.all_domains = 1; config.all_domains = 1;
} }
config.domains_str = optarg; config.domains_str = optarg;
config.domains_strlen = strlen(config.domains_str); config.domains_strlen = strlen(config.domains_str);
@ -274,3 +276,57 @@ error:
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
void print_welcome() {
switch (config.fragmentation_strategy) {
case FRAG_STRAT_TCP:
printf("Using TCP segmentation\n");
break;
case FRAG_STRAT_IP:
printf("Using IP fragmentation\n");
break;
default:
printf("SNI fragmentation is disabled\n");
break;
}
if (config.seg2_delay) {
printf("Some outgoing googlevideo request segments will be delayed for %d ms as of seg2_delay define\n", config.seg2_delay);
}
if (config.fake_sni) {
printf("Fake SNI will be sent before each target client hello\n");
} else {
printf("Fake SNI is disabled\n");
}
if (config.frag_sni_reverse) {
printf("Fragmentation Client Hello will be reversed\n");
}
if (config.frag_sni_faked) {
printf("Fooling packets will be sent near the original Client Hello\n");
}
if (config.fake_sni_seq_len > 1) {
printf("Faking sequence of length %d will be built as fake sni\n", config.fake_sni_seq_len);
}
switch (config.faking_strategy) {
case FAKE_STRAT_TTL:
printf("TTL faking strategy will be used with TTL %d\n", config.faking_ttl);
break;
case FAKE_STRAT_ACK_SEQ:
printf("Ack-Seq faking strategy will be used\n");
break;
}
if (config.use_gso) {
printf("GSO is enabled\n");
}
if (config.all_domains) {
printf("All Client Hello will be targetted by youtubeUnblock!\n");
}
}

3
args.h
View File

@ -5,4 +5,7 @@ void print_version();
void print_usage(const char *argv0); void print_usage(const char *argv0);
int parse_args(int argc, char *argv[]); int parse_args(int argc, char *argv[]);
/* Prints starting messages */
void print_welcome();
#endif /* ARGS_H */ #endif /* ARGS_H */

View File

@ -183,7 +183,7 @@ int process_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
if (vrd.target_sni) { if (vrd.target_sni) {
if (config.verbose) if (config.verbose)
printf("SNI target detected\n"); printf("Target SNI detected: %.*s\n", vrd.sni_len, data + vrd.sni_offset);
uint8_t payload[MAX_PACKET_SIZE]; uint8_t payload[MAX_PACKET_SIZE];
uint32_t payload_len = raw_payload_len; uint32_t payload_len = raw_payload_len;
@ -560,6 +560,9 @@ int tcp4_frag(const __u8 *pkt, __u32 buflen, __u32 payload_offset,
s2_tcph->seq = htonl(ntohl(s2_tcph->seq) + payload_offset); s2_tcph->seq = htonl(ntohl(s2_tcph->seq) + payload_offset);
s1_tcph->window = htons(1);
s2_tcph->window = htons(1);
if (config.verbose) if (config.verbose)
printf("Packet split in portion %u %u\n", s1_plen, s2_plen); printf("Packet split in portion %u %u\n", s1_plen, s2_plen);

View File

@ -454,53 +454,8 @@ int main(int argc, char *argv[]) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
switch (config.fragmentation_strategy) { print_version();
case FRAG_STRAT_TCP: print_welcome();
printf("Using TCP segmentation\n");
break;
case FRAG_STRAT_IP:
printf("Using IP fragmentation\n");
break;
default:
printf("SNI fragmentation is disabled\n");
break;
}
if (config.seg2_delay) {
printf("Some outgoing googlevideo request segments will be delayed for %d ms as of seg2_delay define\n", config.seg2_delay);
}
if (config.fake_sni) {
printf("Fake SNI will be sent before each target client hello\n");
} else {
printf("Fake SNI is disabled\n");
}
if (config.frag_sni_reverse) {
printf("Fragmentation Client Hello will be reversed\n");
}
if (config.frag_sni_faked) {
printf("Fooling packets will be sent near the original Client Hello\n");
}
if (config.fake_sni_seq_len > 1) {
printf("Faking sequence of length %d will be built as fake sni\n", config.fake_sni_seq_len);
}
switch (config.faking_strategy) {
case FAKE_STRAT_TTL:
printf("TTL faking strategy will be used with TTL %d\n", config.faking_ttl);
break;
case FAKE_STRAT_ACK_SEQ:
printf("Ack-Seq faking strategy will be used\n");
break;
}
if (config.use_gso) {
printf("GSO is enabled\n");
}
if (open_raw_socket() < 0) { if (open_raw_socket() < 0) {
perror("Unable to open raw socket"); perror("Unable to open raw socket");