From 518a193bfab70f0e4f0d83a73492d877ea7fee1e Mon Sep 17 00:00:00 2001 From: Connection Refused Date: Wed, 29 Sep 2021 19:28:09 +0800 Subject: [PATCH] [Redirector] Support custom icmp delay --- Redirector/Based.cpp | 1 + Redirector/Based.h | 2 ++ Redirector/IPEventHandler.cpp | 3 +++ Redirector/Redirector.cpp | 10 +++++++--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Redirector/Based.cpp b/Redirector/Based.cpp index f4335234..686fdee5 100644 --- a/Redirector/Based.cpp +++ b/Redirector/Based.cpp @@ -5,6 +5,7 @@ BOOL filterIntranet = FALSE; BOOL filterICMP = TRUE; BOOL filterTCP = TRUE; BOOL filterUDP = TRUE; +DWORD icmping = 0; wstring tgtHost = L"1.1.1.1"; wstring tgtPort = L"1080"; string tgtUsername = ""; diff --git a/Redirector/Based.h b/Redirector/Based.h index b7ab994a..6455805a 100644 --- a/Redirector/Based.h +++ b/Redirector/Based.h @@ -29,6 +29,8 @@ typedef enum _AIO_TYPE { AIO_FILTERTCP, AIO_FILTERUDP, + AIO_ICMPING, + AIO_TGTHOST, AIO_TGTPORT, AIO_TGTUSER, diff --git a/Redirector/IPEventHandler.cpp b/Redirector/IPEventHandler.cpp index b2bc6d81..decc900b 100644 --- a/Redirector/IPEventHandler.cpp +++ b/Redirector/IPEventHandler.cpp @@ -1,5 +1,7 @@ #include "IPEventHandler.h" +extern DWORD icmping; + USHORT IPv4Checksum(PBYTE buffer, ULONG64 size) { UINT32 sum = 0; @@ -76,6 +78,7 @@ void ipSend(const char* buffer, int length, PNF_IP_PACKET_OPTIONS options) data[options->ipHeaderSize + 2] = icmpsum & 0xff; data[options->ipHeaderSize + 3] = (icmpsum >> 8); + Sleep(icmping); printf("[Redirector][IPEventHandler][ipSend] Fake ICMP response for %d.%d.%d.%d\n", data[12], data[13], data[14], data[15]); nf_ipPostReceive((PCHAR)data, length, options); diff --git a/Redirector/Redirector.cpp b/Redirector/Redirector.cpp index 93064c16..e99df9f8 100644 --- a/Redirector/Redirector.cpp +++ b/Redirector/Redirector.cpp @@ -8,6 +8,7 @@ extern BOOL filterIntranet; extern BOOL filterICMP; extern BOOL filterTCP; extern BOOL filterUDP; +extern DWORD icmping; extern wstring tgtHost; extern wstring tgtPort; extern string tgtUsername; @@ -68,9 +69,8 @@ extern "C" { case AIO_FILTERUDP: filterUDP = (wstring(value).find(L"false") == string::npos); break; - case AIO_CLRNAME: - bypassList.clear(); - handleList.clear(); + case AIO_ICMPING: + icmping = atoi(ws2s(value).c_str()); break; case AIO_TGTHOST: tgtHost = wstring(value); @@ -84,6 +84,10 @@ extern "C" { case AIO_TGTPASS: tgtPassword = ws2s(value); break; + case AIO_CLRNAME: + bypassList.clear(); + handleList.clear(); + break; case AIO_BYPNAME: try {