diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index a625aba..3de372e 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -98,10 +98,10 @@ function detect_payload_str(ctx, desync) local data = desync.reasm_data or desync.dis.payload local b = data and string.find(data,desync.arg.pattern,1,true) if b then - DLOG("detect_payload_str: detected '"..desync.arg.payload.."'") + DLOG("detect_payload_str: detected '"..(desync.arg.payload or '?').."'") if desync.arg.payload then desync.l7payload = desync.arg.payload end else - DLOG("detect_payload_str: not detected '"..desync.arg.payload.."'") + DLOG("detect_payload_str: not detected '"..(desync.arg.payload or '?').."'") if desync.arg.undetected then desync.l7payload = desync.arg.undetected end end end @@ -1201,7 +1201,7 @@ function rawsend_dissect_segmented(desync, dis, mss, options) -- stop if failed return false end - discopy.tcp.th_seq = discopy.tcp.th_seq + len + discopy.tcp.th_seq = u32add(discopy.tcp.th_seq, len) pos = pos + len end return true diff --git a/nfq2/darkmagic.c b/nfq2/darkmagic.c index 1528c7e..9ba21ba 100644 --- a/nfq2/darkmagic.c +++ b/nfq2/darkmagic.c @@ -803,8 +803,8 @@ static BOOL RemoveTokenPrivs(void) if (memcmp(&privs->Privileges[k].Luid, &luid_SeChangeNotifyPrivilege, sizeof(LUID))) privs->Privileges[k].Attributes = SE_PRIVILEGE_REMOVED; } + bRes = AdjustTokenPrivileges(hToken, FALSE, privs, dwSize, NULL, NULL); } - bRes = AdjustTokenPrivileges(hToken, FALSE, privs, dwSize, NULL, NULL); free(privs); } } diff --git a/nfq2/desync.c b/nfq2/desync.c index 6357e2c..42081b8 100644 --- a/nfq2/desync.c +++ b/nfq2/desync.c @@ -2003,7 +2003,7 @@ static uint8_t dpi_desync_icmp_packet( // invert direction. they are answering to this packet bReverse = !bReverse; DLOG("found conntrack entry. inverted reverse=%u\n",bReverse); - if (ctrack->dp_search_complete) + if (ctrack->dp_search_complete && ctrack->dp) { // RELATED icmp processed within base connection profile dp = ctrack->dp; diff --git a/nfq2/lua.c b/nfq2/lua.c index 8748c5c..ee8702d 100644 --- a/nfq2/lua.c +++ b/nfq2/lua.c @@ -1905,11 +1905,24 @@ static bool lua_reconstruct_ip6exthdr(lua_State *L, int idx, struct ip6_hdr *ip6 lua_getfield(L,-1, "data"); if (lua_type(L,-1)!=LUA_TSTRING) goto err; if (!(p=(uint8_t*)lua_tolstring(L,-1,&l))) l=0; - if (l<6 || (l+2)>left || (type==IPPROTO_AH ? (l>=1024 || ((l+2) & 3)) : (l>=2048 || ((l+2) & 7)))) goto err; - memcpy(data+2,p,l); - l+=2; + + if (l<6 || (l+2)>left) goto err; + if (type==IPPROTO_AH) + { + if (l>=1024 || ((l+2) & 3)) goto err; + memcpy(data+2,p,l); + l+=2; + data[1] = (l>>2)-2; + } + else + { + if (l>=2048 || ((l+2) & 7)) goto err; + memcpy(data+2,p,l); + l+=2; + data[1] = (l>>3)-1; + } + data[0] = next; // may be overwritten later - data[1] = (type==IPPROTO_AH) ? (l>>2)-2 : (l>>3)-1; if (!preserve_next) *last_proto = type; last_proto = data; // first byte of header holds type left -= l; data += l; filled += l; diff --git a/nfq2/nfqws.c b/nfq2/nfqws.c index df14d7f..bb89d74 100644 --- a/nfq2/nfqws.c +++ b/nfq2/nfqws.c @@ -260,8 +260,8 @@ static int nfq_cb(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg, struct nfq_da uint32_t mark; struct ifreq ifr_in, ifr_out; - ph = nfq_get_msg_packet_hdr(nfa); - id = ph ? ntohl(ph->packet_id) : 0; + if (!(ph = nfq_get_msg_packet_hdr(nfa))) return 0; // should not happen + id = ntohl(ph->packet_id); mark = nfq_get_nfmark(nfa); ilen = nfq_get_payload(nfa, &data); @@ -666,6 +666,7 @@ static int dvt_main(void) if (rd < 0) { DLOG_PERROR("recvfrom"); + if (errno==ENOBUFS) continue; goto exiterr; } else if (rd > 0) diff --git a/nfq2/protocol.c b/nfq2/protocol.c index e0af87c..110b295 100644 --- a/nfq2/protocol.c +++ b/nfq2/protocol.c @@ -565,7 +565,7 @@ bool TLSFindExtLenOffsetInHandshake(const uint8_t *data, size_t len, size_t *off } bool TLSFindExtLen(const uint8_t *data, size_t len, size_t *off) { - if (!TLSFindExtLenOffsetInHandshake(data+5,len-5,off)) + if (len<5 || !TLSFindExtLenOffsetInHandshake(data+5,len-5,off)) return false; *off+=5; return true;