This commit is contained in:
bol-van committed 2026-02-21 10:23:25 +03:00
1 parent 4c7a3d08d8
commit 7c12f60e1e
4 files changed
+20 -13

No files matched your search

+8 -7
View File
@@ -729,14 +729,15 @@ function hostfakesplit(ctx, desync)
local midhost local midhost
if desync.arg.midhost then if desync.arg.midhost then
midhost = resolve_pos(data,desync.l7payload,desync.arg.midhost) midhost = resolve_pos(data,desync.l7payload,desync.arg.midhost)
if not midhost then if midhost then
DLOG("hosfakesplit: midhost marker resolved to "..midhost)
if midhost<=pos[1] or midhost>pos[2] then
DLOG("hostfakesplit: midhost is not inside the host range")
midhost = nil
end
else
DLOG("hostfakesplit: cannot resolve midhost marker '"..desync.arg.midhost.."'") DLOG("hostfakesplit: cannot resolve midhost marker '"..desync.arg.midhost.."'")
end end
DLOG("hosfakesplit: midhost marker resolved to "..midhost)
if midhost<=pos[1] or midhost>pos[2] then
DLOG("hostfakesplit: midhost is not inside the host range")
midhost = nil
end
end end
-- if present apply ipfrag only to real host parts. fakes and parts outside of the host must be visible to DPI. -- if present apply ipfrag only to real host parts. fakes and parts outside of the host must be visible to DPI.
if midhost then if midhost then
@@ -942,7 +943,7 @@ function fakeddisorder(ctx, desync)
local opts_orig = {rawsend = rawsend_opts_base(desync), reconstruct = {}, ipfrag = {}, ipid = desync.arg, fooling = {tcp_ts_up = desync.arg.tcp_ts_up}} local opts_orig = {rawsend = rawsend_opts_base(desync), reconstruct = {}, ipfrag = {}, ipid = desync.arg, fooling = {tcp_ts_up = desync.arg.tcp_ts_up}}
local opts_fake = {rawsend = rawsend_opts(desync), reconstruct = reconstruct_opts(desync), ipfrag = {}, ipid = desync.arg, fooling = desync.arg} local opts_fake = {rawsend = rawsend_opts(desync), reconstruct = reconstruct_opts(desync), ipfrag = {}, ipid = desync.arg, fooling = desync.arg}
fakepat = desync.arg.pattern and blob(desync,desync.arg.pattern) or "\x00" local fakepat = desync.arg.pattern and blob(desync,desync.arg.pattern) or "\x00"
-- second fake -- second fake
fake = pattern(fakepat,pos,#data-pos+1) fake = pattern(fakepat,pos,#data-pos+1)
+2 -2
View File
@@ -1,6 +1,6 @@
function pcap_write_header(file) function pcap_write_header(file)
-- big endian, nanoseconds in timestamps, ver 2.4, max packet size - 0x4000 (16384), 0x65 - l3 packets without l2 -- big endian, nanoseconds in timestamps, ver 2.4, max packet size - 0xFFFF (65535), 0x65 - l3 packets without l2
file:write("\xA1\xB2\x3C\x4D\x00\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x65") file:write("\xA1\xB2\x3C\x4D\x00\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00\x00\x65")
end end
function pcap_write_packet(file, raw) function pcap_write_packet(file, raw)
local sec, nsec = clock_gettime(); local sec, nsec = clock_gettime();
+6 -2
View File
@@ -557,12 +557,15 @@ void proto_dissect_l3l4(const uint8_t *data, size_t len, struct dissect *dis, bo
dis->data_pkt = data; dis->data_pkt = data;
dis->len_pkt = len; dis->len_pkt = len;
uint16_t iplen;
if (proto_check_ipv4(data, len) && (no_payload_check || proto_check_ipv4_payload(data, len))) if (proto_check_ipv4(data, len) && (no_payload_check || proto_check_ipv4_payload(data, len)))
{ {
dis->ip = (const struct ip *) data; dis->ip = (const struct ip *) data;
dis->proto = dis->ip->ip_p; dis->proto = dis->ip->ip_p;
p = data; p = data;
dis->len_pkt = len = ntohs(((struct ip*)data)->ip_len); iplen = ntohs(((struct ip*)data)->ip_len);
if (iplen<len) dis->len_pkt = len = iplen;
proto_skip_ipv4(&data, &len, &dis->frag, &dis->frag_off); proto_skip_ipv4(&data, &len, &dis->frag, &dis->frag_off);
dis->len_l3 = data-p; dis->len_l3 = data-p;
} }
@@ -570,7 +573,8 @@ void proto_dissect_l3l4(const uint8_t *data, size_t len, struct dissect *dis, bo
{ {
dis->ip6 = (const struct ip6_hdr *) data; dis->ip6 = (const struct ip6_hdr *) data;
p = data; p = data;
dis->len_pkt = len = ntohs(((struct ip6_hdr*)data)->ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(struct ip6_hdr); iplen = ntohs(((struct ip6_hdr*)data)->ip6_ctlun.ip6_un1.ip6_un1_plen) + sizeof(struct ip6_hdr);
if (iplen<len) dis->len_pkt = len = iplen;
proto_skip_ipv6(&data, &len, &dis->proto, &dis->frag, &dis->frag_off); proto_skip_ipv6(&data, &len, &dis->proto, &dis->frag, &dis->frag_off);
dis->len_l3 = data-p; dis->len_l3 = data-p;
} }
+4 -2
View File
@@ -387,6 +387,8 @@ static void notify_ready(void)
#endif #endif
} }
// extra space for netlink headers
#define NFQ_MAX_RECV_SIZE (RECONSTRUCT_MAX_SIZE+512)
static int nfq_main(void) static int nfq_main(void)
{ {
struct nfq_handle *h = NULL; struct nfq_handle *h = NULL;
@@ -436,7 +438,7 @@ static int nfq_main(void)
goto exok; goto exok;
} }
if (!(buf = malloc(RECONSTRUCT_MAX_SIZE)) || !(mod = malloc(RECONSTRUCT_MAX_SIZE))) if (!(buf = malloc(NFQ_MAX_RECV_SIZE)) || !(mod = malloc(RECONSTRUCT_MAX_SIZE)))
{ {
DLOG_ERR("out of memory\n"); DLOG_ERR("out of memory\n");
goto err; goto err;
@@ -466,7 +468,7 @@ static int nfq_main(void)
do do
{ {
if (bQuit) goto quit; if (bQuit) goto quit;
while ((rd = recv(fd, buf, RECONSTRUCT_MAX_SIZE, 0)) >= 0) while ((rd = recv(fd, buf, NFQ_MAX_RECV_SIZE, 0)) >= 0)
{ {
if (!rd) if (!rd)
{ {