2021-03-04 14:30:38 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "darkmagic.h"
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2024-08-20 17:08:40 +03:00
|
|
|
|
|
|
|
#define __FAVOR_BSD
|
2021-03-04 14:30:38 +03:00
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip6.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
#define DPI_DESYNC_FWMARK_DEFAULT 0x40000000
|
|
|
|
#else
|
|
|
|
#define DPI_DESYNC_FWMARK_DEFAULT 512
|
|
|
|
#endif
|
|
|
|
|
2021-03-19 15:47:28 +03:00
|
|
|
#define DPI_DESYNC_MAX_FAKE_LEN 9216
|
2021-03-04 14:30:38 +03:00
|
|
|
|
|
|
|
enum dpi_desync_mode {
|
|
|
|
DESYNC_NONE=0,
|
|
|
|
DESYNC_INVALID,
|
|
|
|
DESYNC_FAKE,
|
2022-04-12 15:52:06 +03:00
|
|
|
DESYNC_FAKE_KNOWN,
|
2021-03-04 14:30:38 +03:00
|
|
|
DESYNC_RST,
|
|
|
|
DESYNC_RSTACK,
|
2021-04-07 12:13:46 +03:00
|
|
|
DESYNC_SYNACK,
|
2024-03-19 13:50:20 +03:00
|
|
|
DESYNC_SYNDATA,
|
2021-03-04 14:30:38 +03:00
|
|
|
DESYNC_DISORDER,
|
|
|
|
DESYNC_DISORDER2,
|
|
|
|
DESYNC_SPLIT,
|
2022-01-03 12:38:18 +03:00
|
|
|
DESYNC_SPLIT2,
|
2022-02-01 20:35:52 +03:00
|
|
|
DESYNC_IPFRAG2,
|
2022-02-05 13:36:03 +03:00
|
|
|
DESYNC_HOPBYHOP,
|
2022-02-05 15:41:46 +03:00
|
|
|
DESYNC_DESTOPT,
|
2022-04-12 15:52:06 +03:00
|
|
|
DESYNC_IPFRAG1,
|
2023-09-07 19:03:37 +03:00
|
|
|
DESYNC_UDPLEN,
|
|
|
|
DESYNC_TAMPER
|
2021-03-04 14:30:38 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *fake_http_request_default;
|
2024-09-14 22:07:46 +03:00
|
|
|
extern const uint8_t fake_tls_clienthello_default[648];
|
|
|
|
void randomize_default_tls_payload(uint8_t *p);
|
2021-03-04 14:30:38 +03:00
|
|
|
|
|
|
|
enum dpi_desync_mode desync_mode_from_string(const char *s);
|
2021-04-07 12:13:46 +03:00
|
|
|
bool desync_valid_zero_stage(enum dpi_desync_mode mode);
|
2021-03-04 14:30:38 +03:00
|
|
|
bool desync_valid_first_stage(enum dpi_desync_mode mode);
|
2022-02-01 20:35:52 +03:00
|
|
|
bool desync_only_first_stage(enum dpi_desync_mode mode);
|
2021-03-04 14:30:38 +03:00
|
|
|
bool desync_valid_second_stage(enum dpi_desync_mode mode);
|
2022-04-12 15:52:06 +03:00
|
|
|
bool desync_valid_second_stage_tcp(enum dpi_desync_mode mode);
|
|
|
|
bool desync_valid_second_stage_udp(enum dpi_desync_mode mode);
|
2021-03-04 14:30:38 +03:00
|
|
|
|
2023-10-13 20:10:46 +03:00
|
|
|
void desync_init(void);
|
2024-04-20 20:59:45 +03:00
|
|
|
uint8_t dpi_desync_packet(uint32_t fwmark, const char *ifout, uint8_t *data_pkt, size_t *len_pkt);
|